[Haskell-cafe] Idiom Brackets for GHC (first full proposal)

43 views
Skip to first unread message

Oliver Charles

unread,
Feb 26, 2015, 4:04:14 PM2/26/15
to haskel...@haskell.org
Hi all,

A few days ago I made a post here to gauge interest in adding idiom
brackets to GHC. Response was a bit more mixed than I was hoping, but no
one seemed to drastically against the idea, so I've moved forward with a
more detailed proposal.

You can find the full proposal here:

https://ocharles.org.uk/IdiomBrackets.html

A particular difference in my proposal from existing solutions comes
from my desire to lift almost *all* expressions - with the original
syntax - into idiom brackets. This means normal function application and
tuples, but also case expressions, let bindings, record construction,
record update, infix notation, and so on.

At first I was skeptical about this, but I am finding uses for this more
and more. I really like how it lets me use the interesting data (that
is, whatever is "under" the applicative functor) where it's most
relevant - rather than having to build a function and thread that value
back through. Examples of this can be seen in my proposal.

To prove its use, I've been working with this Template Haskell
expression:

https://ocharles.org.uk/IdiomExp.hs

It *almost* does exactly what I want, the only problem is I can't get
Template Haskell to give me a difference between

$(i [| const True False |])

and

$(i [| (const True) False |])

which I was planning to be significant.

The proposal has mostly grown into my own personal notebook, so I'm
happy to clarify anything that is vague/contradictory/confusing.

Look forward to hearing your thoughts!

-- Ollie
_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Roman Cheplyaka

unread,
Feb 26, 2015, 6:28:24 PM2/26/15
to Oliver Charles, haskel...@haskell.org
I'm starting to like this. Except the weird difference between spaces on
different levels that you point out, i.e.

[| const True False |]

vs

[| (const True) False |]

Oliver Charles

unread,
Feb 27, 2015, 2:58:56 AM2/27/15
to Roman Cheplyaka, Haskell Cafe

So you would argue that these should desugar to the same thing? I'm on the fence - on the one hand its nice to be able to leave a few 'pure's out, but on the other those parenthesis have no syntactic meaning before, so it's questionable why they suddenly do inside idiom brackets.

I can live with needing a few more 'pure's though.

- Ollie

Roman Cheplyaka

unread,
Feb 27, 2015, 5:09:38 AM2/27/15
to Oliver Charles, Haskell Cafe
On 27/02/15 09:58, Oliver Charles wrote:
> So you would argue that these should desugar to the same thing?

I guess I'm talking more generally here. On the one hand, I find this
practical and convenient. On the other hand, it (almost by design)
breaks our usual intuition of how the space works.

E.g. in most other cases id x is the same as x, but inside idiom
brackets they mean x and pure x, respectively.

I don't have a specific suggestion, just a concern.


> I'm on
> the fence - on the one hand its nice to be able to leave a few 'pure's
> out, but on the other those parenthesis have no syntactic meaning
> before, so it's questionable why they suddenly do inside idiom brackets.
>
> I can live with needing a few more 'pure's though.
>
> - Ollie
>
> On 26 Feb 2015 23:28, "Roman Cheplyaka" <ro...@ro-che.info
> > Haskel...@haskell.org <mailto:Haskel...@haskell.org>
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Reply all
Reply to author
Forward
0 new messages