[Haskell-beginners] How to think in Haskell

Russ Abbott russ.abbott at gmail.com
Sat Dec 18 17:58:38 CET 2010


It seems to me that among the basic concepts to focus on when learning
Haskell are Currying (or partial evaluation), functional composition as a
way to produce another function (and not just as an evaluation strategy),
and passing functions are arguments.

In all three one has to think in terms of functions being values that are
created dynamically and passed around.

A good way to practice is to focus on writing point-free code and to use the
$ syntax notation as much as possible. $ is nice in that it is the apply
function. Thinking of it in those terms helps build intuition since (again)
its first argument is a function that is passed to it.

A nice thing about these concepts is that they all exist and can be played
with at the code level. They can all be explored at the level of the
operational semantics of the language--i.e., how it works when you write
code. Virtually no theory is required to learn or use them.
*
-- Russ*
*
*
On Sat, Dec 18, 2010 at 3:00 AM, <beginners-request at haskell.org> wrote:

> Send Beginners mailing list submissions to
>        beginners at haskell.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://www.haskell.org/mailman/listinfo/beginners
> or, via email, send a message with subject or body 'help' to
>        beginners-request at haskell.org
>
> You can reach the person managing the list at
>        beginners-owner at haskell.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Beginners digest..."
>
>
> Today's Topics:
>
>   1. Re:  How to think in Haskell (David Virebayre)
>   2.  How to think in Haskell (Jun HU) (Sean Charles)
>   3. Re:  How to think in Haskell (Jun HU) (Gregg Reynolds)
>   4. Re:  How to think in Haskell (Ertugrul Soeylemez)
>   5.  Computational Linguistic (Luca Ciciriello)
>   6. Re:  Computational Linguistic (SOLVED) (Luca Ciciriello)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 17 Dec 2010 13:10:45 +0100
> From: David Virebayre <dav.vire+haskell at gmail.com<dav.vire%2Bhaskell at gmail.com>
> >
> Subject: Re: [Haskell-beginners] How to think in Haskell
> To: Brent Yorgey <byorgey at seas.upenn.edu>
> Cc: beginners at haskell.org
> Message-ID:
>        <AANLkTik3yaYtdOJ5ZOtxwj8xn5m7CjGrjL32RD80_0+Z at mail.gmail.com<AANLkTik3yaYtdOJ5ZOtxwj8xn5m7CjGrjL32RD80_0%2BZ at mail.gmail.com>
> >
> Content-Type: text/plain; charset=UTF-8
>
> 2010/12/16 Brent Yorgey <byorgey at seas.upenn.edu>:
> > On Thu, Dec 16, 2010 at 04:41:24PM +0100, Luca Ciciriello wrote:
> >> Hi, here my path (in correct order) I followed to learn to think
> functionally:
>
> >> 1) Curry-Howard Isomorphism
> >> 2) Type Theory & Functional Programming
> >> 3) The Hindley-Milner Type inference algorithm
> >> 4) Basic Category Theory
> >> 5) Notions of computation and monads
> >> 6) Denotational semantics
> >> 7) Monads for functional programming
> >> 8) Theorems for free.
> >> 9) A History of Haskell: Being Lazy With Class
>
> > These are all wonderful topics. ?But I strongly disagree with the
> > notion that one must understand all of these before even starting a
> > Haskell tutorial (!), or even that one must understand all of these to
> > be able to "think functionally" in some sense.
>
> ... aaaaand I'm going to agree with Brent here.
>
> It took me a while to have many things "click", but I found it hard to
> thoroughly read many papers. The mathematical notation which I'm not
> familiar with often is a problem to stay focused.
>
> What helped for me was reading tutorials and practice. Reading about
> people's problems on Caf?, and reading the replies. Re-reading several
> times a tutorial, weeks apart. I wish I had Real world haskell was I
> was starting, but I have it now and I'm glad I do.
>
> I can't claim I understand more than Haskell 98, but it's more than
> enough for a start.
>
> David.
>
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 17 Dec 2010 14:44:09 +0000
> From: Sean Charles <sean at objitsu.com>
> Subject: [Haskell-beginners] How to think in Haskell (Jun HU)
> To: beginners at haskell.org
> Message-ID: <1292597049.3903.18.camel at sean-desktop>
> Content-Type: text/plain; charset="UTF-8"
>
> I learned Smalltalk in 1999, then I found LISP because Alan Kay said it
> was the most awesome language ever invented. That got me hooked into
> using s-expressions for everything!
>
> Then I found Erlang and that was just brilliant, although I still missed
> the s-expression format of LISP.
>
> Then, about seven months ago I decided to try Haskell, I bought the Real
> World Haskell book and I've been trying to get better every day I can.
>
> I've been a software develoepr for aobut twenty-six years, from assembly
> language on chips and DEC/VAX right through to today and without doubt
> Haskell has been my single most frustrating learning experience ever.
>
> And that my friends is a compliment to Haskell!  :)
>
> I am *not* a mathematician, I did 'A'-level maths and physics and
> computers back when Clive Sinclair was a force to be reckoned with.
> To be told I have to read a big list of stuff with titles that would
> make people think I was speaking in tongues doesn't cut it for me. For
> my day job I *have* to cut PHP/Drupal, so I applied learning Haskell and
> made myself some tools that generate Drupal code!
>
> Make it relevant to what you do everyday, that way it will carry more
> meaning for you, why spend hours head-scratching over some fancy pants
> monadic kung-fu lesson when you can as easily learn to read a file and
> process each line, do something with it and then create a new file.
>
> First rule of optimisation: Don't do it. It was how I felt learning LISP
> too, there are so many functions to do things, which is the 'right' one?
> Make it work first then you can step back and say, "Can I do this more
> succinctly using more advanced language features?"
>
> Don't try to learn it all at once, it's depressing! I know!
>
>
> BIG HELP: The single biggest thing that helped me was to download the
> PDF slide-notes and watch both parts of Simon Peyton Jones talks, all
> available here:
> http://notes-on-haskell.blogspot.com/2007/08/more-spj.html
>
> It was when I realises that, unlike C++ for example, where there is an
> implicit 'this' pointer stuffed in the stack, in Haskell programs there
> is an implicit pointer to the type information being passed around which
> made lots of things click for me like "How does it know?" LOL
>
> Haskell is the classic elephant sandwich; a formidable task, but
> everytime I understand something new it feels great!
>
> Best of luck!
> :)
> Sean Charles
>
>
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 17 Dec 2010 09:18:42 -0600
> From: Gregg Reynolds <dev at mobileink.com>
> Subject: Re: [Haskell-beginners] How to think in Haskell (Jun HU)
> To: sean at objitsu.com
> Cc: beginners at haskell.org
> Message-ID:
>        <AANLkTimXZj__z2uzJB-T9tH0f-ftkcAUVCMb-nuFc3QQ at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> On Fri, Dec 17, 2010 at 8:44 AM, Sean Charles <sean at objitsu.com> wrote:
>
> >
> > I've been a software develoepr for aobut twenty-six years, from assembly
> > language on chips and DEC/VAX right through to today and without doubt
> > Haskell has been my single most frustrating learning experience ever.
> >
> > And that my friends is a compliment to Haskell!  :)
> >
> > Don't try to learn it all at once, it's depressing! I know!
> >
>
> I took my first crack at Haskell 5+ years ago, was befuddled by the term
> "constructor" and left completely in the dark by monads. So I moved on to
> other things.  It took me about three tries and a lot of research into
> various corners of computer science (I was a liberal arts major) to reach
> the point where I understood the terminology and began to grasp the big
> picture.  Fortunately there's a lot more information available for
> beginners
> now.
>
> Even though the likelihood of me ever getting paid to program in Haskell is
> nil, what I've gained from studying it vastly outweighs the considerable
> effort I put into it.  I thought I was learning another programming
> language; in fact, I was learning to think about computation, logic, and
> mathematics in ways that were completely new and very enlightening to me.
>  To really really understand it all, you have to delve into lambda calculus
> most obviously, but also intuitionistic mathematics and logic, proof
> theory,
> category theory, and various other fascinating topics.  In 100 or even 10
> years such stuff will form part of a basic educational program, but at the
> moment it's like a secret world of magical beasts.  The down side is
> there's
> nobody to talk to about it (except via mailing lists) since almost nobody
> outside of specialists even knows this world exists.
>
>
> >
> > BIG HELP: The single biggest thing that helped me was to download the
> > PDF slide-notes and watch both parts of Simon Peyton Jones talks, all
> > available here:
> > http://notes-on-haskell.blogspot.com/2007/08/more-spj.html
>
>
> His book "Implementation of Functional
> Languages<
> http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/index.htm
> >"
> is also very helpful, even if you have no interest in actually implementing
> functional languages.  It (and various other pubs) has proven very helpful
> in deciphering some of the arcane bits of terminology that often pop up in
> discussions of Haskell and FP, such as boxing, bottom, "weak head normal
> form", etc.  You can skim the gory details and still get a lot out of it.
>  Plus, I just found the tutorial
> version<
> http://research.microsoft.com/en-us/um/people/simonpj/papers/pj-lester-book/
> >
> .
>
> -Gregg
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://www.haskell.org/pipermail/beginners/attachments/20101217/910b3832/attachment-0001.htm
> >
>
> ------------------------------
>
> Message: 4
> Date: Sat, 18 Dec 2010 08:00:16 +0100
> From: Ertugrul Soeylemez <es at ertes.de>
> Subject: Re: [Haskell-beginners] How to think in Haskell
> To: beginners at haskell.org
> Message-ID: <20101218080016.103692e0 at tritium.streitmacht.eu>
> Content-Type: text/plain; charset=US-ASCII
>
> Jun HU <junhufr at gmail.com> wrote:
>
> > My first language is C, and I've strong intention in learning a pure
> > functional programming language. My very first question is how to
> > think in the functional programming way, anyone has some ideas.
> > Really appreciate....
>
> Well, programming is about building a house.  Using the imperative
> procedural paradigm (C) you express how to build the house (what do you
> need to do to reach the goal?), much like in a recipe.  Using the
> declarative functional paradigm (Haskell) you express what the house is,
> much like in a scheme or specification.
>
> Haskell is about as functional as a programming language can get by
> concept, because with the equals sign (=) you write actual equations.
> In most other languages the equals sign expresses assignment, not
> equation.
>
>
> Greets,
> Ertugrul
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
>
>
>
>
>
> ------------------------------
>
> Message: 5
> Date: Sat, 18 Dec 2010 11:32:38 +0100
> From: Luca Ciciriello <luca_ciciriello at hotmail.com>
> Subject: [Haskell-beginners] Computational Linguistic
> To: beginners at haskell.org
> Message-ID: <BLU0-SMTP16246E38E0F3B9CA892E1B39A170 at phx.gbl>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi All.
> It's my impression or all "items" about computational linguistic are been
> ripped away from Hackage?
>
> Luca.
>
>
> ------------------------------
>
> Message: 6
> Date: Sat, 18 Dec 2010 11:34:52 +0100
> From: Luca Ciciriello <luca_ciciriello at hotmail.com>
> Subject: Re: [Haskell-beginners] Computational Linguistic (SOLVED)
> To: Luca Ciciriello <luca_ciciriello at hotmail.com>
> Cc: beginners at haskell.org
> Message-ID: <BLU0-SMTP144B35C877E3BE11E4E4E179A170 at phx.gbl>
> Content-Type: text/plain; charset="us-ascii"
>
> Ok, my fault. I was searching in wrong place.
>
> Luca.
>
> On Dec 18, 2010, at 11:32 AM, Luca Ciciriello wrote:
>
> > Hi All.
> > It's my impression or all "items" about computational linguistic are been
> ripped away from Hackage?
> >
> > Luca.
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> >
>
>
>
>
> ------------------------------
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
> End of Beginners Digest, Vol 30, Issue 35
> *****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20101218/c85338a1/attachment-0001.htm>


More information about the Beginners mailing list