What is your favourite Haskell "aha" moment?

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

Re: Investing in languages

Stefan Monnier
> but functional programming is harder.

There's no doubt that languages like Haskell go through extra efforts to
make it *harder* to write incorrect code, and along the way they also
make it harder to write code at all.

So maybe it will take your guy a week to get the code written in
Haskell, whereas a couple days were sufficient in Java.  But that's
without counting the subsequent month during which the Java code will
have to be debugged before it actually works ;-)

IIRC it was Bob Harper who said a good programming language should be
hard to write (but easy to read, of course)?


        Stefan

_______________________________________________
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: What is your favourite Haskell "aha" moment?

Neil Mayhew
In reply to this post by Haskell - Haskell-Cafe mailing list
I came to Haskell from C++, and I was used to the idea of parametric types and functions from C++ templates.

However, what I really liked about Haskell's way of doing these was that, due to type inference, not only is there a lot less ceremony involved, but code is generic (parametric) *by default*, and thus much more reusable, although you still have the option of tightening it up by adding a type annotation (eg for performance reasons). For a while, I was writing all my C++ code as templates, but this ended up being a pain.

Also, traditionally C++ has not allowed you to place any constraints on template arguments (type parameters) whereas Haskell's type classes are a very elegant way of doing it. (C++ now has concepts, but I haven't taken the time yet to see how they compare with type classes.)

I was also used to function overloading, which is somewhat similar to type inference, in that the compiler will pick an implementation based on the types of a function's arguments. This is similar to Haskell picking an implementation from among type class instances. However, what blew me away is that Haskell can overload based on *return type* as well as argument types. I haven't seen any other production-ready language that can do this. A great example of how this is useful is the regex library, where you can select from among widely varying styles of regex matching result simply by type inference, ie without needing any type annotation.

There were a *lot* of other things I found amazing, but others have covered many of these already. Also, languages are borrowing from each other at a rapid rate these days (eg Rust traits are equivalent to type classes) so it's hard to find a "killer feature" in Haskell any more (except laziness, perhaps). I think it's more the well-balanced combination of all the features that makes Haskell so pleasant to work in, and it's hard to demonstrate all of these in a single example.

My own favourite "gem" is this code for computing all primes, based on code in a paper[1] by Doug McIlroy:

primes = sieve [2..] where sieve (p : ns) = p : sieve [n | n <- ns, n `mod` p /= 0]

I think care must be exercised, when using examples like this one, to avoid giving the impression that Haskell is a "toy" language. However, what I find interesting about this example is that all other sieve implementations I've seen work on a fixed size of sieve up front, and if you later change your mind about how many primes you want, eg because you're expanding a hash table and want a bigger prime for the size, you typically have to start the sieve from scratch again.

[1]: http://www.cs.dartmouth.edu/~doug/sieve/sieve.pdf

_______________________________________________
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: What is your favourite Haskell "aha" moment?

Haskell - Haskell-Cafe mailing list

Also, languages are borrowing from each other at a rapid rate these days (eg Rust traits are equivalent to type classes) so it's hard to find a "killer feature" in Haskell any more

 

That’s true, and to be celebrated!

 

One thing that stands our for me is the ability to abstract over type constructors:

            f :: forall (m :: * -> *) (a :: *). Monad m => a -> m a

 

That ability is what has given rise to a stunningly huge collection of abstractions: not just Monad, but Functor, Applicative, Traversable, Foldable, etc etc etc.   Really a lot.  It opens up a new way to think about the world.  But only made possible by that one feature.   (Plus type classes of course.)

 

Do any statically typed languages other than Haskell and Scala do this?

 

Simon

 

From: Haskell-Cafe <[hidden email]> On Behalf Of Neil Mayhew
Sent: 11 July 2018 17:12
To: Haskell Cafe <[hidden email]>
Subject: Re: [Haskell-cafe] What is your favourite Haskell "aha" moment?

 

I came to Haskell from C++, and I was used to the idea of parametric types and functions from C++ templates.

However, what I really liked about Haskell's way of doing these was that, due to type inference, not only is there a lot less ceremony involved, but code is generic (parametric) *by default*, and thus much more reusable, although you still have the option of tightening it up by adding a type annotation (eg for performance reasons). For a while, I was writing all my C++ code as templates, but this ended up being a pain.

Also, traditionally C++ has not allowed you to place any constraints on template arguments (type parameters) whereas Haskell's type classes are a very elegant way of doing it. (C++ now has concepts, but I haven't taken the time yet to see how they compare with type classes.)

I was also used to function overloading, which is somewhat similar to type inference, in that the compiler will pick an implementation based on the types of a function's arguments. This is similar to Haskell picking an implementation from among type class instances. However, what blew me away is that Haskell can overload based on *return type* as well as argument types. I haven't seen any other production-ready language that can do this. A great example of how this is useful is the regex library, where you can select from among widely varying styles of regex matching result simply by type inference, ie without needing any type annotation.

There were a *lot* of other things I found amazing, but others have covered many of these already. Also, languages are borrowing from each other at a rapid rate these days (eg Rust traits are equivalent to type classes) so it's hard to find a "killer feature" in Haskell any more (except laziness, perhaps). I think it's more the well-balanced combination of all the features that makes Haskell so pleasant to work in, and it's hard to demonstrate all of these in a single example.

My own favourite "gem" is this code for computing all primes, based on code in a paper[1] by Doug McIlroy:

primes = sieve [2..] where sieve (p : ns) = p : sieve [n | n <- ns, n `mod` p /= 0]

I think care must be exercised, when using examples like this one, to avoid giving the impression that Haskell is a "toy" language. However, what I find interesting about this example is that all other sieve implementations I've seen work on a fixed size of sieve up front, and if you later change your mind about how many primes you want, eg because you're expanding a hash table and want a bigger prime for the size, you typically have to start the sieve from scratch again.

[1]: http://www.cs.dartmouth.edu/~doug/sieve/sieve.pdf


_______________________________________________
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: What is your favourite Haskell "aha" moment?

Vanessa McHale

Idris allows such abstractions in much the same way Haskell does. ATS allows monads via template (see e.g. https://github.com/githwxi/ATS-Postiats/blob/e83a467485857d568e20512b486ee52b4b4da97a/libats/ML/DATS/SHARE/monad.hats) but they're kind of broken in practice in that you can have only instance per executable/library (!)


On 07/11/2018 11:24 AM, Simon Peyton Jones via Haskell-Cafe wrote:

Also, languages are borrowing from each other at a rapid rate these days (eg Rust traits are equivalent to type classes) so it's hard to find a "killer feature" in Haskell any more

 

That’s true, and to be celebrated!

 

One thing that stands our for me is the ability to abstract over type constructors:

            f :: forall (m :: * -> *) (a :: *). Monad m => a -> m a

 

That ability is what has given rise to a stunningly huge collection of abstractions: not just Monad, but Functor, Applicative, Traversable, Foldable, etc etc etc.   Really a lot.  It opens up a new way to think about the world.  But only made possible by that one feature.   (Plus type classes of course.)

 

Do any statically typed languages other than Haskell and Scala do this?

 

Simon

 

From: Haskell-Cafe [hidden email] On Behalf Of Neil Mayhew
Sent: 11 July 2018 17:12
To: Haskell Cafe [hidden email]
Subject: Re: [Haskell-cafe] What is your favourite Haskell "aha" moment?

 

I came to Haskell from C++, and I was used to the idea of parametric types and functions from C++ templates.

However, what I really liked about Haskell's way of doing these was that, due to type inference, not only is there a lot less ceremony involved, but code is generic (parametric) *by default*, and thus much more reusable, although you still have the option of tightening it up by adding a type annotation (eg for performance reasons). For a while, I was writing all my C++ code as templates, but this ended up being a pain.

Also, traditionally C++ has not allowed you to place any constraints on template arguments (type parameters) whereas Haskell's type classes are a very elegant way of doing it. (C++ now has concepts, but I haven't taken the time yet to see how they compare with type classes.)

I was also used to function overloading, which is somewhat similar to type inference, in that the compiler will pick an implementation based on the types of a function's arguments. This is similar to Haskell picking an implementation from among type class instances. However, what blew me away is that Haskell can overload based on *return type* as well as argument types. I haven't seen any other production-ready language that can do this. A great example of how this is useful is the regex library, where you can select from among widely varying styles of regex matching result simply by type inference, ie without needing any type annotation.

There were a *lot* of other things I found amazing, but others have covered many of these already. Also, languages are borrowing from each other at a rapid rate these days (eg Rust traits are equivalent to type classes) so it's hard to find a "killer feature" in Haskell any more (except laziness, perhaps). I think it's more the well-balanced combination of all the features that makes Haskell so pleasant to work in, and it's hard to demonstrate all of these in a single example.

My own favourite "gem" is this code for computing all primes, based on code in a paper[1] by Doug McIlroy:

primes = sieve [2..] where sieve (p : ns) = p : sieve [n | n <- ns, n `mod` p /= 0]

I think care must be exercised, when using examples like this one, to avoid giving the impression that Haskell is a "toy" language. However, what I find interesting about this example is that all other sieve implementations I've seen work on a fixed size of sieve up front, and if you later change your mind about how many primes you want, eg because you're expanding a hash table and want a bigger prime for the size, you typically have to start the sieve from scratch again.

[1]: http://www.cs.dartmouth.edu/~doug/sieve/sieve.pdf



_______________________________________________
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.

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: What is your favourite Haskell "aha" moment?

David Feuer
In reply to this post by Haskell - Haskell-Cafe mailing list
Haskell is the only language I know of with typeclass coherence.

On Wed, Jul 11, 2018, 12:25 PM Simon Peyton Jones via Haskell-Cafe <[hidden email]> wrote:

Also, languages are borrowing from each other at a rapid rate these days (eg Rust traits are equivalent to type classes) so it's hard to find a "killer feature" in Haskell any more

 

That’s true, and to be celebrated!

 

One thing that stands our for me is the ability to abstract over type constructors:

            f :: forall (m :: * -> *) (a :: *). Monad m => a -> m a

 

That ability is what has given rise to a stunningly huge collection of abstractions: not just Monad, but Functor, Applicative, Traversable, Foldable, etc etc etc.   Really a lot.  It opens up a new way to think about the world.  But only made possible by that one feature.   (Plus type classes of course.)

 

Do any statically typed languages other than Haskell and Scala do this?

 

Simon

 

From: Haskell-Cafe <[hidden email]> On Behalf Of Neil Mayhew
Sent: 11 July 2018 17:12
To: Haskell Cafe <[hidden email]>
Subject: Re: [Haskell-cafe] What is your favourite Haskell "aha" moment?

 

I came to Haskell from C++, and I was used to the idea of parametric types and functions from C++ templates.

However, what I really liked about Haskell's way of doing these was that, due to type inference, not only is there a lot less ceremony involved, but code is generic (parametric) *by default*, and thus much more reusable, although you still have the option of tightening it up by adding a type annotation (eg for performance reasons). For a while, I was writing all my C++ code as templates, but this ended up being a pain.

Also, traditionally C++ has not allowed you to place any constraints on template arguments (type parameters) whereas Haskell's type classes are a very elegant way of doing it. (C++ now has concepts, but I haven't taken the time yet to see how they compare with type classes.)

I was also used to function overloading, which is somewhat similar to type inference, in that the compiler will pick an implementation based on the types of a function's arguments. This is similar to Haskell picking an implementation from among type class instances. However, what blew me away is that Haskell can overload based on *return type* as well as argument types. I haven't seen any other production-ready language that can do this. A great example of how this is useful is the regex library, where you can select from among widely varying styles of regex matching result simply by type inference, ie without needing any type annotation.

There were a *lot* of other things I found amazing, but others have covered many of these already. Also, languages are borrowing from each other at a rapid rate these days (eg Rust traits are equivalent to type classes) so it's hard to find a "killer feature" in Haskell any more (except laziness, perhaps). I think it's more the well-balanced combination of all the features that makes Haskell so pleasant to work in, and it's hard to demonstrate all of these in a single example.

My own favourite "gem" is this code for computing all primes, based on code in a paper[1] by Doug McIlroy:

primes = sieve [2..] where sieve (p : ns) = p : sieve [n | n <- ns, n `mod` p /= 0]

I think care must be exercised, when using examples like this one, to avoid giving the impression that Haskell is a "toy" language. However, what I find interesting about this example is that all other sieve implementations I've seen work on a fixed size of sieve up front, and if you later change your mind about how many primes you want, eg because you're expanding a hash table and want a bigger prime for the size, you typically have to start the sieve from scratch again.

[1]: http://www.cs.dartmouth.edu/~doug/sieve/sieve.pdf

_______________________________________________
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: What is your favourite Haskell "aha" moment?

Henrik Nilsson-2
In reply to this post by Vanessa McHale
Hi,

On 07/11/2018 02:46 PM, Vanessa McHale wrote:
> #2: enumerate all strings on an alphabet (this uses laziness!)
>
>
> allStrings :: [a] -> [[a]] allStrings = sequence <=< (inits . repeat)
>

Neat!

I find the following alternative appealing too, as it in essence
just states a recursive equation that says what it means for
a list to be a list of all strings over the given alphabet:

allStrings alphabet = xss
     where xss = [] : [ x : xs | xs <- xss, x <- alphabet ]

(Admittedly, one has to be careful with the ordering of the generators,
or the order in which the strings are enumerated becomes less useful.)

This capability of declaratively stating an equation that characterises
the sought answer is another perspective on why techniques like
dynamic programming is such a great fit for lazy languages, as
pointed out by Jake.

One of my favourite examples is finding a minimal length triangulation
of a polygon where an elegant solution is obtained by just
transliterating the defining equations from a classic textbook on data
structures and algorithms (Aho, Hopcroft, Ullman 1983).

Attribute grammar evaluation is another great application of laziness
in a similar vein.

Best,

/Henrik




This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please contact the sender and delete the email and
attachment.

Any views or opinions expressed by the author of this email do not
necessarily reflect the views of the University of Nottingham. Email
communications with the University of Nottingham may be monitored
where permitted by law.




_______________________________________________
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: Investing in languages

Chris Smith-31
In reply to this post by Stefan Monnier
I think it's important to keep in mind that the correct trade-off for one situation is not the correct trade-off for another.  This is a great example!  On one side of the spectrum, you've got situations where Idris or Agda are good fits, where it's critically important to know that code is correct, even at the expense of significant complexity or time.  But there is another side of that spectrum.  It's probably best characterized by education: there are no users, bugs that aren't found don't matter at all, and even when you know for sure that something is wrong, it would be great if you can let it fail and *watch* it go wrong; stopping someone who's learning to tell them they got something wrong before they understand WHY is bad teaching.

I've been working for years now on using (a variant of) Haskell in early education, as young as 10 to 11 years old.  Looking at this experience, I agree whole-heartedly that regardless of what's best in a professional setting, there's still something about Haskell that's far more difficult to learn than Python and Java.  It's not about the incidental complexity of the language, which can usually be avoided.  It's about the way everything just looks so easy once it's written, but new programmers struggle mightily to figure out how to get started in writing it.  People don't understand how to build things compositionally.

As an aside: I know it's popular among the functional programming world to hypothesize that this is because people have used imperative languages first.  I can tell you, though, that the hypothesis is wrong.  I spend a good bit of my time teaching students with no previous programming experience in any language.  They also struggle with it, but they understand imperative programming intuitively.  Mathematics teachers also know this, and it's why they so often fall back to teaching step-by-step processes instead of talking about subexpressions having meaning.  Think about how you learned the "order of operations", which obviously should be understood as a question of parsing and identifying subexpressions, but is always taught as "you multiply before you add" because that's what gets correct answers on exams.

Incidentally, realizing this makes me more determined to teach Haskell and compositional thinking at a younger age.  It might not be easy, but you don't get far in mathematics without grasping the idea of building up abstract objects through composition.  This shift from thinking about "how to get it done" to thinking about "what it means" is a huge step toward understanding the world around us, and should be pretty far up on the priority list.  So I'm not badmouthing Haskell here.  I'm just saying we should realize that there's a very real sense in which it is legitimately HARDER to understand.  No use being in denial about that.

On Wed, Jul 11, 2018 at 11:10 AM Stefan Monnier <[hidden email]> wrote:
> but functional programming is harder.

There's no doubt that languages like Haskell go through extra efforts to
make it *harder* to write incorrect code, and along the way they also
make it harder to write code at all.

So maybe it will take your guy a week to get the code written in
Haskell, whereas a couple days were sufficient in Java.  But that's
without counting the subsequent month during which the Java code will
have to be debugged before it actually works ;-)

IIRC it was Bob Harper who said a good programming language should be
hard to write (but easy to read, of course)?


        Stefan

_______________________________________________
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: What is your favourite Haskell "aha" moment?

S. Doaitse Swierstra
In reply to this post by Haskell - Haskell-Cafe mailing list
[Shameless promotion]

I once wrote a parser combinator library. Something everyone does once in his life ;-}

Then I realised that I could run parsers in an interleaved way, and wrote the package uu-interleaved”. In remarkably few lines of code this can turn a parser combinator library in a a library that can run parsers in an interleavedway . If you look at the code in:


this boils down to writing a few instances for a new data type. Although the code is intricate it is very short, and the types guided me get the code correct. Without te types I would have spent ages in getting things to work.

The I realised that by adding just a few extra lines of code this could be turned in a package for writing code for dealing with command line arguments in a very broad sense: repeating arguments, dealing with missing obligatory arguments, optional arguments and parsing the arguments according to what they stand for and reporting errors in the command line in a systematic way 

Surprisingly the  the code of this package is probably less that what an ordinary program spends on processing it's command line arguments, while providing much larger security.

 [End of shameless promotion]

If your audience consists of experienced programmers they must have been spending quite some time on code that is no longer necessary when using such a package.

 Doaitse







Op 11 jul. 2018, om 14:10  heeft Simon Peyton Jones via Haskell-Cafe <[hidden email]> het volgende geschreven:

Friends

In a few weeks I’m giving a talk to a bunch of genomics folk at the Sanger Institute about Haskell.   They do lots of programming, but they aren’t computer scientists.

I can tell them plenty about Haskell, but I’m ill-equipped to answer the main question in their minds: why should I even care about Haskell?  I’m too much of a biased witness.

So I thought I’d ask you for help.  War stories perhaps – how using Haskell worked (or didn’t) for you.  But rather than talk generalities, I’d love to illustrate with copious examples of beautiful code. 

  • Can you identify a few lines of Haskell that best characterise what you think makes Haskell distinctively worth caring about?   Something that gave you an “aha” moment, or that feeling of joy when you truly make sense of something for the first time.

The challenge is, of course, that this audience will know no Haskell, so muttering about Cartesian Closed Categories isn’t going to do it for them.  I need examples that I can present in 5 minutes, without needing a long setup.

To take a very basic example, consider Quicksort using list comprehensions, compared with its equivalent in C.  It’s so short, so obviously right, whereas doing the right thing with in-place update in C notoriously prone to fencepost errors etc.  But it also makes much less good use of memory, and is likely to run slower.  I think I can do that in 5 minutes.

Another thing that I think comes over easily is the ability to abstract: generalising sum and product to fold by abstracting out a functional argument; generalising at the type level by polymorphism, including polymorphism over higher-kinded type constructors.   Maybe 8 minutes.

But you will have more and better ideas, and (crucially) ideas that are more credibly grounded in the day to day reality of writing programs that get work done.

Pointers to your favourite blog posts would be another avenue.  (I love the Haskell Weekly News.)

Finally, I know that some of you use Haskell specifically for genomics work, and maybe some of your insights would be particularly relevant for the Sanger audience.

Thank you!  Perhaps your responses on this thread (if any) may be helpful to more than just me.

Simon

_______________________________________________
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.

ParseYourOptions.pdf (372K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: What is your favourite Haskell "aha" moment?

Scott Fleischman
In reply to this post by Haskell - Haskell-Cafe mailing list
We make extensive use of Servant for our web services at Plow Technologies. It is my favorite example of the success of using types (even relatively fancy types) to help with a common problem (creating web sites with web services) and reduce boilerplate.

I like the examples in the tutorial.

Scott Fleischman


On Wed, Jul 11, 2018 at 5:10 AM, Simon Peyton Jones via Haskell-Cafe <[hidden email]> wrote:

Friends

In a few weeks I’m giving a talk to a bunch of genomics folk at the Sanger Institute about Haskell.   They do lots of programming, but they aren’t computer scientists.

I can tell them plenty about Haskell, but I’m ill-equipped to answer the main question in their minds: why should I even care about Haskell?  I’m too much of a biased witness.

So I thought I’d ask you for help.  War stories perhaps – how using Haskell worked (or didn’t) for you.  But rather than talk generalities, I’d love to illustrate with copious examples of beautiful code.

  • Can you identify a few lines of Haskell that best characterise what you think makes Haskell distinctively worth caring about?   Something that gave you an “aha” moment, or that feeling of joy when you truly make sense of something for the first time.

The challenge is, of course, that this audience will know no Haskell, so muttering about Cartesian Closed Categories isn’t going to do it for them.  I need examples that I can present in 5 minutes, without needing a long setup.

To take a very basic example, consider Quicksort using list comprehensions, compared with its equivalent in C.  It’s so short, so obviously right, whereas doing the right thing with in-place update in C notoriously prone to fencepost errors etc.  But it also makes much less good use of memory, and is likely to run slower.  I think I can do that in 5 minutes.

Another thing that I think comes over easily is the ability to abstract: generalising sum and product to fold by abstracting out a functional argument; generalising at the type level by polymorphism, including polymorphism over higher-kinded type constructors.   Maybe 8 minutes.

But you will have more and better ideas, and (crucially) ideas that are more credibly grounded in the day to day reality of writing programs that get work done.

Pointers to your favourite blog posts would be another avenue.  (I love the Haskell Weekly News.)

Finally, I know that some of you use Haskell specifically for genomics work, and maybe some of your insights would be particularly relevant for the Sanger audience.

Thank you!  Perhaps your responses on this thread (if any) may be helpful to more than just me.

Simon


_______________________________________________
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: What is your favourite Haskell "aha" moment?

Chris Smith-31
I feel like the one theme that's been missing in all of this is the interaction between equational reasoning and rewrite rules.  Examples of fusing operations on Text or ByteString were pretty impressive to me.  The ideas may be incorporated into other languages, but I believe Haskell is pretty unique, at least versus mainstream languages, in doing the fusion in the optimizer where there's still opportunity for the results to be inlined and further optimized.

I don't have a complete example off the top of my head.

On Wed, Jul 11, 2018 at 3:31 PM Scott Fleischman <[hidden email]> wrote:
We make extensive use of Servant for our web services at Plow Technologies. It is my favorite example of the success of using types (even relatively fancy types) to help with a common problem (creating web sites with web services) and reduce boilerplate.

I like the examples in the tutorial.

Scott Fleischman


On Wed, Jul 11, 2018 at 5:10 AM, Simon Peyton Jones via Haskell-Cafe <[hidden email]> wrote:

Friends

In a few weeks I’m giving a talk to a bunch of genomics folk at the Sanger Institute about Haskell.   They do lots of programming, but they aren’t computer scientists.

I can tell them plenty about Haskell, but I’m ill-equipped to answer the main question in their minds: why should I even care about Haskell?  I’m too much of a biased witness.

So I thought I’d ask you for help.  War stories perhaps – how using Haskell worked (or didn’t) for you.  But rather than talk generalities, I’d love to illustrate with copious examples of beautiful code.

  • Can you identify a few lines of Haskell that best characterise what you think makes Haskell distinctively worth caring about?   Something that gave you an “aha” moment, or that feeling of joy when you truly make sense of something for the first time.

The challenge is, of course, that this audience will know no Haskell, so muttering about Cartesian Closed Categories isn’t going to do it for them.  I need examples that I can present in 5 minutes, without needing a long setup.

To take a very basic example, consider Quicksort using list comprehensions, compared with its equivalent in C.  It’s so short, so obviously right, whereas doing the right thing with in-place update in C notoriously prone to fencepost errors etc.  But it also makes much less good use of memory, and is likely to run slower.  I think I can do that in 5 minutes.

Another thing that I think comes over easily is the ability to abstract: generalising sum and product to fold by abstracting out a functional argument; generalising at the type level by polymorphism, including polymorphism over higher-kinded type constructors.   Maybe 8 minutes.

But you will have more and better ideas, and (crucially) ideas that are more credibly grounded in the day to day reality of writing programs that get work done.

Pointers to your favourite blog posts would be another avenue.  (I love the Haskell Weekly News.)

Finally, I know that some of you use Haskell specifically for genomics work, and maybe some of your insights would be particularly relevant for the Sanger audience.

Thank you!  Perhaps your responses on this thread (if any) may be helpful to more than just me.

Simon


_______________________________________________
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.
Reply | Threaded
Open this post in threaded view
|

Re: What is your favourite Haskell "aha" moment?

Jeffrey Brown
"Blow your mind" on the Haskell Wiki[1] is a collection of short bits of awesome code.


On Wed, Jul 11, 2018 at 2:40 PM Chris Smith <[hidden email]> wrote:
I feel like the one theme that's been missing in all of this is the interaction between equational reasoning and rewrite rules.  Examples of fusing operations on Text or ByteString were pretty impressive to me.  The ideas may be incorporated into other languages, but I believe Haskell is pretty unique, at least versus mainstream languages, in doing the fusion in the optimizer where there's still opportunity for the results to be inlined and further optimized.

I don't have a complete example off the top of my head.

On Wed, Jul 11, 2018 at 3:31 PM Scott Fleischman <[hidden email]> wrote:
We make extensive use of Servant for our web services at Plow Technologies. It is my favorite example of the success of using types (even relatively fancy types) to help with a common problem (creating web sites with web services) and reduce boilerplate.

I like the examples in the tutorial.

Scott Fleischman


On Wed, Jul 11, 2018 at 5:10 AM, Simon Peyton Jones via Haskell-Cafe <[hidden email]> wrote:

Friends

In a few weeks I’m giving a talk to a bunch of genomics folk at the Sanger Institute about Haskell.   They do lots of programming, but they aren’t computer scientists.

I can tell them plenty about Haskell, but I’m ill-equipped to answer the main question in their minds: why should I even care about Haskell?  I’m too much of a biased witness.

So I thought I’d ask you for help.  War stories perhaps – how using Haskell worked (or didn’t) for you.  But rather than talk generalities, I’d love to illustrate with copious examples of beautiful code.

  • Can you identify a few lines of Haskell that best characterise what you think makes Haskell distinctively worth caring about?   Something that gave you an “aha” moment, or that feeling of joy when you truly make sense of something for the first time.

The challenge is, of course, that this audience will know no Haskell, so muttering about Cartesian Closed Categories isn’t going to do it for them.  I need examples that I can present in 5 minutes, without needing a long setup.

To take a very basic example, consider Quicksort using list comprehensions, compared with its equivalent in C.  It’s so short, so obviously right, whereas doing the right thing with in-place update in C notoriously prone to fencepost errors etc.  But it also makes much less good use of memory, and is likely to run slower.  I think I can do that in 5 minutes.

Another thing that I think comes over easily is the ability to abstract: generalising sum and product to fold by abstracting out a functional argument; generalising at the type level by polymorphism, including polymorphism over higher-kinded type constructors.   Maybe 8 minutes.

But you will have more and better ideas, and (crucially) ideas that are more credibly grounded in the day to day reality of writing programs that get work done.

Pointers to your favourite blog posts would be another avenue.  (I love the Haskell Weekly News.)

Finally, I know that some of you use Haskell specifically for genomics work, and maybe some of your insights would be particularly relevant for the Sanger audience.

Thank you!  Perhaps your responses on this thread (if any) may be helpful to more than just me.

Simon


_______________________________________________
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.


--
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: What is your favourite Haskell "aha" moment?

Theodore Lief Gannon
Gabriel Gonzalez's "Haskell for Everyone" blog is a wellspring of great candidates. This one came up in another thread yesterday, as an example of what you can get from treating IO actions as data: http://www.haskellforall.com/2018/02/the-wizard-monoid.html

On Wed, Jul 11, 2018, 12:51 PM Jeffrey Brown <[hidden email]> wrote:
"Blow your mind" on the Haskell Wiki[1] is a collection of short bits of awesome code.


On Wed, Jul 11, 2018 at 2:40 PM Chris Smith <[hidden email]> wrote:
I feel like the one theme that's been missing in all of this is the interaction between equational reasoning and rewrite rules.  Examples of fusing operations on Text or ByteString were pretty impressive to me.  The ideas may be incorporated into other languages, but I believe Haskell is pretty unique, at least versus mainstream languages, in doing the fusion in the optimizer where there's still opportunity for the results to be inlined and further optimized.

I don't have a complete example off the top of my head.

On Wed, Jul 11, 2018 at 3:31 PM Scott Fleischman <[hidden email]> wrote:
We make extensive use of Servant for our web services at Plow Technologies. It is my favorite example of the success of using types (even relatively fancy types) to help with a common problem (creating web sites with web services) and reduce boilerplate.

I like the examples in the tutorial.

Scott Fleischman


On Wed, Jul 11, 2018 at 5:10 AM, Simon Peyton Jones via Haskell-Cafe <[hidden email]> wrote:

Friends

In a few weeks I’m giving a talk to a bunch of genomics folk at the Sanger Institute about Haskell.   They do lots of programming, but they aren’t computer scientists.

I can tell them plenty about Haskell, but I’m ill-equipped to answer the main question in their minds: why should I even care about Haskell?  I’m too much of a biased witness.

So I thought I’d ask you for help.  War stories perhaps – how using Haskell worked (or didn’t) for you.  But rather than talk generalities, I’d love to illustrate with copious examples of beautiful code.

  • Can you identify a few lines of Haskell that best characterise what you think makes Haskell distinctively worth caring about?   Something that gave you an “aha” moment, or that feeling of joy when you truly make sense of something for the first time.

The challenge is, of course, that this audience will know no Haskell, so muttering about Cartesian Closed Categories isn’t going to do it for them.  I need examples that I can present in 5 minutes, without needing a long setup.

To take a very basic example, consider Quicksort using list comprehensions, compared with its equivalent in C.  It’s so short, so obviously right, whereas doing the right thing with in-place update in C notoriously prone to fencepost errors etc.  But it also makes much less good use of memory, and is likely to run slower.  I think I can do that in 5 minutes.

Another thing that I think comes over easily is the ability to abstract: generalising sum and product to fold by abstracting out a functional argument; generalising at the type level by polymorphism, including polymorphism over higher-kinded type constructors.   Maybe 8 minutes.

But you will have more and better ideas, and (crucially) ideas that are more credibly grounded in the day to day reality of writing programs that get work done.

Pointers to your favourite blog posts would be another avenue.  (I love the Haskell Weekly News.)

Finally, I know that some of you use Haskell specifically for genomics work, and maybe some of your insights would be particularly relevant for the Sanger audience.

Thank you!  Perhaps your responses on this thread (if any) may be helpful to more than just me.

Simon


_______________________________________________
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.


--
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.

_______________________________________________
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: What is your favourite Haskell "aha" moment?

John Wiegley-2
In reply to this post by Stefan Monnier
>>>>> "SM" == Stefan Monnier <[hidden email]> writes:

SM> I don't much like the monad solution for side-effects, but if those guys
SM> might have some knowledge of the horror of concurrent programming with
SM> locks, the STM system would be a good candidate.

I would vote for STM too, especially when using retry within a logical block
to indicate "try again when things might make more sense". When dealing with
multiple variables, and queues that you're popping values from, that is a
truly hard thing to say with traditional concurrent programming.

--
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2
_______________________________________________
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: What is your favourite Haskell "aha" moment?

Conal Elliott
In reply to this post by Vanessa McHale
The fact that you can define the IO monad in Haskell was quite a revelation.

But it's *not* a fact. It's a lie. And one of the most devious sort, since the source code appears to agree. The purported definition couldn't possibly explain concurrency.

On Wed, Jul 11, 2018 at 7:21 AM, Vanessa McHale <[hidden email]> wrote:

I find it quite elegant! The fact that you can define the IO monad in Haskell was quite a revelation. And it's especially nice when paired with a demonstration of C FFI (where you might *need* to sequence side effects such as freeing a value after it has been read).

newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))

On 07/11/2018 09:14 AM, Stefan Monnier wrote:
In a few weeks I'm giving a talk to a bunch of genomics folk at the Sanger
Institute<https://www.sanger.ac.uk/> about Haskell.   They do lots of
programming, but they aren't computer scientists.
I can tell them plenty about Haskell, but I'm ill-equipped to answer the
main question in their minds: why should I even care about Haskell?  I'm too
much of a biased witness.
I don't much like the monad solution for side-effects, but if those guys
might have some knowledge of the horror of concurrent programming with
locks, the STM system would be a good candidate.


        Stefan

_______________________________________________
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.

--



Vanessa McHale
Functional Compiler Engineer | Chicago, IL

Website: www.iohk.io
Twitter: @vamchale
PGP Key ID: 4209B7B5

Input
          Output

Twitter Github LinkedIn


This e-mail and any file transmitted with it are confidential and intended solely for the use of the recipient(s) to whom it is addressed. Dissemination, distribution, and/or copying of the transmission by anyone other than the intended recipient(s) is prohibited. If you have received this transmission in error please notify IOHK immediately and delete it from your system. E-mail transmissions cannot be guaranteed to be secure or error free. We do not accept liability for any loss, damage, or error arising from this transmission

_______________________________________________
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: What is your favourite Haskell "aha" moment?

David Feuer
The purported definition also mixes very badly with strictness analysis. For IO, m >>= f should be *lazy* in f (e.g., print 3 >> undefined should print 3 before throwing an exception) but the purported definition would suggest it's *strict* (print 3 >> undefined is equivalent to undefined).

On Wed, Jul 11, 2018, 6:20 PM Conal Elliott <[hidden email]> wrote:
The fact that you can define the IO monad in Haskell was quite a revelation.

But it's *not* a fact. It's a lie. And one of the most devious sort, since the source code appears to agree. The purported definition couldn't possibly explain concurrency.

On Wed, Jul 11, 2018 at 7:21 AM, Vanessa McHale <[hidden email]> wrote:

I find it quite elegant! The fact that you can define the IO monad in Haskell was quite a revelation. And it's especially nice when paired with a demonstration of C FFI (where you might *need* to sequence side effects such as freeing a value after it has been read).

newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))

On 07/11/2018 09:14 AM, Stefan Monnier wrote:
In a few weeks I'm giving a talk to a bunch of genomics folk at the Sanger
Institute<https://www.sanger.ac.uk/> about Haskell.   They do lots of
programming, but they aren't computer scientists.
I can tell them plenty about Haskell, but I'm ill-equipped to answer the
main question in their minds: why should I even care about Haskell?  I'm too
much of a biased witness.
I don't much like the monad solution for side-effects, but if those guys
might have some knowledge of the horror of concurrent programming with
locks, the STM system would be a good candidate.


        Stefan

_______________________________________________
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.

--



Vanessa McHale
Functional Compiler Engineer | Chicago, IL

Website: www.iohk.io
Twitter: @vamchale
PGP Key ID: 4209B7B5

Input
          Output

Twitter Github LinkedIn


This e-mail and any file transmitted with it are confidential and intended solely for the use of the recipient(s) to whom it is addressed. Dissemination, distribution, and/or copying of the transmission by anyone other than the intended recipient(s) is prohibited. If you have received this transmission in error please notify IOHK immediately and delete it from your system. E-mail transmissions cannot be guaranteed to be secure or error free. We do not accept liability for any loss, damage, or error arising from this transmission

_______________________________________________
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.
Reply | Threaded
Open this post in threaded view
|

Re: Investing in languages (Was: What is your favourite Haskell "aha" moment?)

Tony Morris-4
In reply to this post by Bryan Richter-2

https://github.com/functionaljava/functionaljava/blob/6ac5f9547dbb1f0ca3777be6b366f256e9943194/core/src/main/java/fj/data/List.java#L452

This function was written over 15 years ago. I disagree with this reasoning that though a lot of programmers are unwilling to make the investment to learn (true), that this has consequences for the use of Haskell (not true). Those same programmers have barely learned Java and yet Java is pervasive through our industry. I learned this (nobody knows Java) when I was working on implementing the JVM and I asked myself, "if I am to implement this Java thing, does anyone out there actually know it?" I quickly learned that the answer is no. In fact, I wrote a test back then (~2003), subtitled, "but do you even know the basics of Java?" and the best score to this day on that test is 4/10 (twice). I wrote that test to debunk the common protest, "but where will I hire Java programmers?!" The correct answer is nowhere, they do not exist.

Sorry for the diversion.


On 07/12/2018 12:03 AM, Bryan Richter wrote:
cartProdN :: [[a]] -> [[a]] cartProdN = sequence

This also made me realize of two things:
0. Haskell will never be mainstream, because there are not a lot of programmers out there who are willing to do the investment required for learning the necessary concepts to understand and write code like the one shown above.


_______________________________________________
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.

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: What is your favourite Haskell "aha" moment?

Jay Sulzberger
In reply to this post by Haskell - Haskell-Cafe mailing list

On Wed, 11 Jul 2018, Simon Peyton Jones <[hidden email]>
via Haskell-Cafe wrote:

> Friends
>
> In a few weeks I'm giving a talk to a bunch of genomics folk at
> the Sanger Institute<https://www.sanger.ac.uk/> about Haskell.
> They do lots of programming, but they aren't computer
> scientists.
>
> I can tell them plenty about Haskell, but I'm ill-equipped to
> answer the main question in their minds: why should I even care
> about Haskell?  I'm too much of a biased witness.

The compiler enforces comments.  The type system is the mechanism
of this enforceement.

oo--JS.


>
> So I thought I'd ask you for help.  War stories perhaps - how using Haskell worked (or didn't) for you.  But rather than talk generalities, I'd love to illustrate with copious examples of beautiful code.
>
>  *   Can you identify a few lines of Haskell that best characterise what you think makes Haskell distinctively worth caring about?   Something that gave you an "aha" moment, or that feeling of joy when you truly make sense of something for the first time.
> The challenge is, of course, that this audience will know no Haskell, so muttering about Cartesian Closed Categories isn't going to do it for them.  I need examples that I can present in 5 minutes, without needing a long setup.
> To take a very basic example, consider Quicksort using list comprehensions, compared with its equivalent in C.  It's so short, so obviously right, whereas doing the right thing with in-place update in C notoriously prone to fencepost errors etc.  But it also makes much less good use of memory, and is likely to run slower.  I think I can do that in 5 minutes.
> Another thing that I think comes over easily is the ability to abstract: generalising sum and product to fold by abstracting out a functional argument; generalising at the type level by polymorphism, including polymorphism over higher-kinded type constructors.   Maybe 8 minutes.
> But you will have more and better ideas, and (crucially) ideas that are more credibly grounded in the day to day reality of writing programs that get work done.
> Pointers to your favourite blog posts would be another avenue.  (I love the Haskell Weekly News.)
> Finally, I know that some of you use Haskell specifically for genomics work, and maybe some of your insights would be particularly relevant for the Sanger audience.
> Thank you!  Perhaps your responses on this thread (if any) may be helpful to more than just me.
> Simon
>
_______________________________________________
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: What is your favourite Haskell "aha" moment?

Vanessa McHale
In reply to this post by Conal Elliott

I'm not sure I follow. Do you mean that IO is not a monad because equivalence of values cannot be defined? Or is it something deeper?

On 07/11/2018 05:19 PM, Conal Elliott wrote:
The fact that you can define the IO monad in Haskell was quite a revelation.

But it's *not* a fact. It's a lie. And one of the most devious sort, since the source code appears to agree. The purported definition couldn't possibly explain concurrency.

On Wed, Jul 11, 2018 at 7:21 AM, Vanessa McHale <[hidden email]> wrote:

I find it quite elegant! The fact that you can define the IO monad in Haskell was quite a revelation. And it's especially nice when paired with a demonstration of C FFI (where you might *need* to sequence side effects such as freeing a value after it has been read).

newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))

On 07/11/2018 09:14 AM, Stefan Monnier wrote:
In a few weeks I'm giving a talk to a bunch of genomics folk at the Sanger
Institute<https://www.sanger.ac.uk/> about Haskell.   They do lots of
programming, but they aren't computer scientists.
I can tell them plenty about Haskell, but I'm ill-equipped to answer the
main question in their minds: why should I even care about Haskell?  I'm too
much of a biased witness.
I don't much like the monad solution for side-effects, but if those guys
might have some knowledge of the horror of concurrent programming with
locks, the STM system would be a good candidate.


        Stefan

_______________________________________________
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.

--



Vanessa McHale
Functional Compiler Engineer | Chicago, IL

Website: www.iohk.io
Twitter: @vamchale
PGP Key ID: 4209B7B5

Input Output

Twitter Github LinkedIn


This e-mail and any file transmitted with it are confidential and intended solely for the use of the recipient(s) to whom it is addressed. Dissemination, distribution, and/or copying of the transmission by anyone other than the intended recipient(s) is prohibited. If you have received this transmission in error please notify IOHK immediately and delete it from your system. E-mail transmissions cannot be guaranteed to be secure or error free. We do not accept liability for any loss, damage, or error arising from this transmission

_______________________________________________
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.

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: What is your favourite Haskell "aha" moment?

Brandon Allbery
In the presence of concurrency, IO requires runtime support and can't be simply defined in Haskell proper.

On Wed, Jul 11, 2018 at 9:59 PM Vanessa McHale <[hidden email]> wrote:

I'm not sure I follow. Do you mean that IO is not a monad because equivalence of values cannot be defined? Or is it something deeper?

On 07/11/2018 05:19 PM, Conal Elliott wrote:
The fact that you can define the IO monad in Haskell was quite a revelation.

But it's *not* a fact. It's a lie. And one of the most devious sort, since the source code appears to agree. The purported definition couldn't possibly explain concurrency.

On Wed, Jul 11, 2018 at 7:21 AM, Vanessa McHale <[hidden email]> wrote:

I find it quite elegant! The fact that you can define the IO monad in Haskell was quite a revelation. And it's especially nice when paired with a demonstration of C FFI (where you might *need* to sequence side effects such as freeing a value after it has been read).

newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))

On 07/11/2018 09:14 AM, Stefan Monnier wrote:
In a few weeks I'm giving a talk to a bunch of genomics folk at the Sanger
Institute<https://www.sanger.ac.uk/> about Haskell.   They do lots of
programming, but they aren't computer scientists.
I can tell them plenty about Haskell, but I'm ill-equipped to answer the
main question in their minds: why should I even care about Haskell?  I'm too
much of a biased witness.
I don't much like the monad solution for side-effects, but if those guys
might have some knowledge of the horror of concurrent programming with
locks, the STM system would be a good candidate.


        Stefan

_______________________________________________
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.

--



Vanessa McHale
Functional Compiler Engineer | Chicago, IL

Website: www.iohk.io
Twitter: @vamchale
PGP Key ID: 4209B7B5

Input Output

Twitter Github LinkedIn


This e-mail and any file transmitted with it are confidential and intended solely for the use of the recipient(s) to whom it is addressed. Dissemination, distribution, and/or copying of the transmission by anyone other than the intended recipient(s) is prohibited. If you have received this transmission in error please notify IOHK immediately and delete it from your system. E-mail transmissions cannot be guaranteed to be secure or error free. We do not accept liability for any loss, damage, or error arising from this transmission

_______________________________________________
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.


--
brandon s allbery kf8nh                               sine nomine associates
[hidden email]                                  [hidden email]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
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: What is your favourite Haskell "aha" moment?

Conal Elliott
Concurrency *can* be defined in Haskell proper (the denotative subset), but not compatibly with that "source code" and probably not at all with the current particulars of IO. With the source code in question, even the "real world" cannot evolve concurrently with program execution, let alone different threads with an IO computation.

On Wed, Jul 11, 2018 at 7:03 PM, Brandon Allbery <[hidden email]> wrote:
In the presence of concurrency, IO requires runtime support and can't be simply defined in Haskell proper.

On Wed, Jul 11, 2018 at 9:59 PM Vanessa McHale <[hidden email]> wrote:

I'm not sure I follow. Do you mean that IO is not a monad because equivalence of values cannot be defined? Or is it something deeper?

On 07/11/2018 05:19 PM, Conal Elliott wrote:
The fact that you can define the IO monad in Haskell was quite a revelation.

But it's *not* a fact. It's a lie. And one of the most devious sort, since the source code appears to agree. The purported definition couldn't possibly explain concurrency.

On Wed, Jul 11, 2018 at 7:21 AM, Vanessa McHale <[hidden email]> wrote:

I find it quite elegant! The fact that you can define the IO monad in Haskell was quite a revelation. And it's especially nice when paired with a demonstration of C FFI (where you might *need* to sequence side effects such as freeing a value after it has been read).

newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))

On 07/11/2018 09:14 AM, Stefan Monnier wrote:
In a few weeks I'm giving a talk to a bunch of genomics folk at the Sanger
Institute<https://www.sanger.ac.uk/> about Haskell.   They do lots of
programming, but they aren't computer scientists.
I can tell them plenty about Haskell, but I'm ill-equipped to answer the
main question in their minds: why should I even care about Haskell?  I'm too
much of a biased witness.
I don't much like the monad solution for side-effects, but if those guys
might have some knowledge of the horror of concurrent programming with
locks, the STM system would be a good candidate.


        Stefan

_______________________________________________
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.

--



Vanessa McHale
Functional Compiler Engineer | Chicago, IL

Website: www.iohk.io
Twitter: @vamchale
PGP Key ID: 4209B7B5

Input Output

Twitter Github LinkedIn


This e-mail and any file transmitted with it are confidential and intended solely for the use of the recipient(s) to whom it is addressed. Dissemination, distribution, and/or copying of the transmission by anyone other than the intended recipient(s) is prohibited. If you have received this transmission in error please notify IOHK immediately and delete it from your system. E-mail transmissions cannot be guaranteed to be secure or error free. We do not accept liability for any loss, damage, or error arising from this transmission

_______________________________________________
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.


--
brandon s allbery kf8nh                               sine nomine associates
[hidden email]                                  [hidden email]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net


_______________________________________________
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.
123456