[Haskell-cafe] Let's teach GHC idiom brackets!
Oliver Charles
ollie at ocharles.org.uk
Thu Feb 19 12:43:57 UTC 2015
Christopher Done <chrisdone at gmail.com> writes:
> Although, I'm pretty sure this use of tuples is inconsistent with
> what's in the Applicatives paper. It'd be:
>
> [| (,) (g x y) (h (g x y))) |]
>
> [| id f (g x y) (h [| (,) (g x y)) |] |]
>
> I think that's the legit way to write it. The transformation is pretty trivial.
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
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) |)
Does the expected thing, where my expectation is (following on from my
point about record syntax) would be:
(\a b -> (a, b)) <$> g x y <*> h (g x y)
-- Ollie
More information about the Haskell-Cafe
mailing list