Nice clean code example?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Nice clean code example?

hanjoosten
I'd like to showoff some nice Haskell code to a CTO with no experience with FP. I promised to send him a small piece of Haskell so he could get an idea. The code should be easy to read, without obscure looking operators (so sorry, no lens, arrows stuff like that), optionally even do something interesting. 
Who has the nicest example laying around? 

(and yes, I need it by yesterday ;-)  )

Thanks!

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Nice clean code example?

Francesco Ariis
On Fri, Jun 30, 2017 at 08:33:29PM +0200, Han Joosten wrote:
> I'd like to showoff some nice Haskell code to a CTO with no experience with
> FP. I promised to send him a small piece of Haskell so he could get an
> idea. The code should be easy to read, without obscure looking operators
> (so sorry, no lens, arrows stuff like that), optionally even do something
> interesting.
> Who has the nicest example laying around?

Some ideas:

- a wrongly typed piece of code: then show him a) how ghc(i) pinpoints
the problem part and is very clear in its demands ("I wanted this, you
gave me this") and b) how malleable the type system is.

- a declarative graph made with diagrams (with a graphical result
displayed)

- parsec (even if you go with applicative style, the code is very readable)
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Nice clean code example?

Bram Neijt
I have no idea what you consider clean. I have some ugly code that
shows off some Haskell features:

https://github.com/BigDataRepublic/hanon/blob/master/src/Mapper.hs

I think it shows off:
- Introducing types to create a language
- Explicit IO, allowing for clear contract exposure to the user of the library?
- defaultHighlighters is a subset of defaultInputPaths through a
simple map allowing for easily exposing constrained subsets of code
(not data)??

if I would force myself to continue, the number of question marks
would just increase, so I'll stop here.

Best of luck!

Bram



On Fri, Jun 30, 2017 at 9:08 PM, Francesco Ariis <[hidden email]> wrote:

> On Fri, Jun 30, 2017 at 08:33:29PM +0200, Han Joosten wrote:
>> I'd like to showoff some nice Haskell code to a CTO with no experience with
>> FP. I promised to send him a small piece of Haskell so he could get an
>> idea. The code should be easy to read, without obscure looking operators
>> (so sorry, no lens, arrows stuff like that), optionally even do something
>> interesting.
>> Who has the nicest example laying around?
>
> Some ideas:
>
> - a wrongly typed piece of code: then show him a) how ghc(i) pinpoints
> the problem part and is very clear in its demands ("I wanted this, you
> gave me this") and b) how malleable the type system is.
>
> - a declarative graph made with diagrams (with a graphical result
> displayed)
>
> - parsec (even if you go with applicative style, the code is very readable)
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Nice clean code example?

Jeffrey Brown
Jake Brownson wrote a game of tic-tac-toe in 160 lines[1] that I thought was beautiful. I forked it to make it a little more readable[2].


On Fri, Jun 30, 2017 at 1:46 PM, Bram Neijt <[hidden email]> wrote:
I have no idea what you consider clean. I have some ugly code that
shows off some Haskell features:

https://github.com/BigDataRepublic/hanon/blob/master/src/Mapper.hs

I think it shows off:
- Introducing types to create a language
- Explicit IO, allowing for clear contract exposure to the user of the library?
- defaultHighlighters is a subset of defaultInputPaths through a
simple map allowing for easily exposing constrained subsets of code
(not data)??

if I would force myself to continue, the number of question marks
would just increase, so I'll stop here.

Best of luck!

Bram



On Fri, Jun 30, 2017 at 9:08 PM, Francesco Ariis <[hidden email]> wrote:
> On Fri, Jun 30, 2017 at 08:33:29PM +0200, Han Joosten wrote:
>> I'd like to showoff some nice Haskell code to a CTO with no experience with
>> FP. I promised to send him a small piece of Haskell so he could get an
>> idea. The code should be easy to read, without obscure looking operators
>> (so sorry, no lens, arrows stuff like that), optionally even do something
>> interesting.
>> Who has the nicest example laying around?
>
> Some ideas:
>
> - a wrongly typed piece of code: then show him a) how ghc(i) pinpoints
> the problem part and is very clear in its demands ("I wanted this, you
> gave me this") and b) how malleable the type system is.
>
> - a declarative graph made with diagrams (with a graphical result
> displayed)
>
> - parsec (even if you go with applicative style, the code is very readable)
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.



--
Jeff Brown | Jeffrey Benjamin Brown
Website   |   Facebook   |   LinkedIn(spammy, so I often miss messages here)   |   Github   

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Nice clean code example?

Chris Wong-2
In reply to this post by hanjoosten
How about Hackagebot?


It involves a lot of concurrency, networking, and data structure manipulation -- all areas Haskell excels in.

It avoids using advanced features as well (except maybe pattern synonyms, but those aren't visible in the code that uses them)

Here are some numbers: its sibling Cargobot boasts 3+ months continuous uptime, with memory usage never going beyond 12 MB. It has never crashed. I expect Hackagebot to have similar metrics.

On Jul 1, 2017 06:34, "Han Joosten" <[hidden email]> wrote:
I'd like to showoff some nice Haskell code to a CTO with no experience with FP. I promised to send him a small piece of Haskell so he could get an idea. The code should be easy to read, without obscure looking operators (so sorry, no lens, arrows stuff like that), optionally even do something interesting. 
Who has the nicest example laying around? 

(and yes, I need it by yesterday ;-)  )

Thanks!

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Nice clean code example?

Will Yager
In reply to this post by hanjoosten
I wrote this specifically to be easy to read despite using some cool features (green threads, STM, etc.): 


Will


On Jul 1, 2017, at 1:33 AM, Han Joosten <[hidden email]> wrote:

I'd like to showoff some nice Haskell code to a CTO with no experience with FP. I promised to send him a small piece of Haskell so he could get an idea. The code should be easy to read, without obscure looking operators (so sorry, no lens, arrows stuff like that), optionally even do something interesting. 
Who has the nicest example laying around? 

(and yes, I need it by yesterday ;-)  )

Thanks!
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Nice clean code example?

hanjoosten
Thanks everyone for the awsome examples. I really enjoy the deversity of them. This tops my expectations 8-)

2017-07-01 3:43 GMT+02:00 Will Yager <[hidden email]>:
I wrote this specifically to be easy to read despite using some cool features (green threads, STM, etc.): 


Will


On Jul 1, 2017, at 1:33 AM, Han Joosten <[hidden email]> wrote:

I'd like to showoff some nice Haskell code to a CTO with no experience with FP. I promised to send him a small piece of Haskell so he could get an idea. The code should be easy to read, without obscure looking operators (so sorry, no lens, arrows stuff like that), optionally even do something interesting. 
Who has the nicest example laying around? 

(and yes, I need it by yesterday ;-)  )

Thanks!
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Nice clean code example?

Imants Cekusins
This online book shows clear working examples in a variety of contexts :

http://book.realworldhaskell.org/read

Visitor is literally 2 clicks away from code examples in areas of interest to them.



On 1 July 2017 at 13:08, Han Joosten <[hidden email]> wrote:
Thanks everyone for the awsome examples. I really enjoy the deversity of them. This tops my expectations 8-)

2017-07-01 3:43 GMT+02:00 Will Yager <[hidden email]>:
I wrote this specifically to be easy to read despite using some cool features (green threads, STM, etc.): 


Will


On Jul 1, 2017, at 1:33 AM, Han Joosten <[hidden email]> wrote:

I'd like to showoff some nice Haskell code to a CTO with no experience with FP. I promised to send him a small piece of Haskell so he could get an idea. The code should be easy to read, without obscure looking operators (so sorry, no lens, arrows stuff like that), optionally even do something interesting. 
Who has the nicest example laying around? 

(and yes, I need it by yesterday ;-)  )

Thanks!
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.