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

Christopher Done chrisdone at gmail.com
Thu Feb 19 13:08:39 UTC 2015

On 19 February 2015 at 13:43, Oliver Charles <ollie at ocharles.org.uk> wrote:
> This has actually reminded me of another point. Tuples are one form of
> construction in Haskell that is somewhat special - but another is using
> record syntax. I wonder if it would be possible to use idiom brackets
> there to lift the record constructor too:
>   (| T { a = x, b = y } |)
> This would desugar into (something like)
>   (\a b -> T {..}) <$> x <*> y

Yeah, this would nicely handle: (1) being explicit about naming when
you want to be, (2) order of effects.

> In this case, we've "lifted" the original syntax into the idiom
> brackets, so I think it's only natural that we're able to lift tuple
> construction into these brackets too. My preference would be that
>   (| (g x y, h (g x y) |)

There's a wee bit of contention with (| foo |) which is supposed to be
"pure foo", AIUI. I saw elsewhere someone suggest:

(| g x y, h x y |)

But that doesn't help with a way to involve records.


On an unrelated note but the same topic, "applicative
comprehensions" could be fun:

(| f a b |)


(| f a b | a <- x, b <- y |)


(| T{..} | a <- x, b <- y |)

More information about the Haskell-Cafe mailing list