[Haskell-cafe] Let's teach GHC idiom brackets!

Erik Hesselink hesselink at gmail.com
Thu Feb 19 10:37:30 UTC 2015


On Thu, Feb 19, 2015 at 10:56 AM, Oliver Charles <ollie at ocharles.org.uk> wrote:
> A slightly more complicated example is
>
> youngPeople = proc () -> do
>   row@(_, age, _) <- personQuery -< ()
>   restrict -< age .<= 18
>   returnA -< row
>
> could become
>
>   (| fst (second (lmap age restrict) . (| dup personQuery |)) |)
>     where dup a = (a,a)

OT: you might be able to make this clearer with `where_` [1] which we
defined in our opaleye utility package [2]. It feels much more natural
to me than restrict, and works much better with composition outside of
arrow notation.

Erik

[1] https://github.com/silkapp/silk-opaleye/blob/c3a324e277d730eafa9c455e1a33e67b15283cb3/src/Silk/Opaleye.hs#L170
[2] https://github.com/silkapp/silk-opaleye


More information about the Haskell-Cafe mailing list