[Haskell-cafe] Proposal: Non-recursive let

Andreas Abel andreas.abel at ifi.lmu.de
Wed Jul 10 23:55:04 CEST 2013


On 10.07.13 9:31 PM, Carter Schonwald wrote:
> theres a very simple way to do non recursive let already! do notation in
> the identity monad. I use it quite a lot lately.

Yeah, the hack

   x <- return $ e

instead of

   let x = e

has been discussed already.

If you put everything into the Identity monad, you lose if-then-else and 
direct use of case, instead of

   case me of {branches }

you need to write

    e <- me; case e of { branches }

This gets a bit better with the new \case, if you can afford to only 
compile on the newest ghc.

   me >>= \case { branches }


> On Wed, Jul 10, 2013 at 1:49 PM, Ertugrul Söylemez <es at ertes.de
> <mailto:es at ertes.de>> wrote:
>
>     "Ezra e. k. Cooper" <ezra at ezrakilty.net <mailto:ezra at ezrakilty.net>>
>     wrote:
>
>      > As starter suggestions for the keyword or syntax, I submit:
>      >
>      >   let new x = expr in body   -- Not the old x!
>
>     It's not the old x in either case (recursive and non-recursive).
>
>
>      >   let shadowing x = expr in body
>      >
>      >   shadow x = expr in body
>
>     It's shadowing in either case.
>
>
>      >   let x =! expr in body  -- The explosive bang gives an imperative
>      >   flavor.
>
>     (=!) is a valid operator name.
>
>
>      > Other suggestions would be welcome.
>
>     My suggestion:  Don't add a non-recursive let.  See my other post about
>     general recursion and totality checking.
>
>
>     Greets,
>     Ertugrul
>
>     --
>     Not to be or to be and (not to be or to be and (not to be or to be and
>     (not to be or to be and ... that is the list monad.
>

-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.abel at ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/



More information about the Haskell-Cafe mailing list