[Haskell-beginners] coding style: instead of let, return?

Obscaenvs obscaenvs at gmail.com
Sat Jul 13 08:56:31 CEST 2013


Just a style question:

What's the community's verdict when it comes to using `return` to bind
names instead of `let`? E.g. if instead of
`
  let p1 <- mkName "p1"
  a <- newName "a"
`
, we use
`
  p1 <- return $ mkName "p1"
  a <- newName "a"
`.

I have seen this a couple of times in other people's code now, and I am
ambivalent about it: `let` states intention better, and refrains from
redundancy, but when you know why the writer behind the code is using
the `return`-variant, it's somewhat easier on the eyes (at least when
some actions in do-notation follow).

In my opinion, `let` *is* the better alternative, but there is code in
the wild[1] that uses the `return`-variant, so I wanted to gauge the
community's opinion on the matter.

[1] http://monads.haskell.cz/html/statemonad.html

--
fredrik






More information about the Beginners mailing list