[Haskell-cafe] [Haskell] Rank-N types with (.) composition
Tyson Whitehead
twhitehead at gmail.com
Wed Feb 11 15:06:35 UTC 2015
On 11/02/15 04:39 AM, Simon Peyton Jones wrote:
> ($) has its own *typing rule*; it does not have a special type. It's very ad hoc, but ($) is used so much to decrease parens that (e1 $ e2) is almost special syntax!
I do like the idea of being able to end a function application with a
lambda, let, if, case, or do without having to use $ though. Would
something like the following grammar rules be problematic for parsing?
infixexp→ lexp qop infixexp
| - infixexp
| [fexp] lexp (*)
| aexp (*)
lexp → \ apat1 … apatn -> exp
| let decls in exp
| if exp [;] then exp [;] else exp
| case exp of { alts }
| do { stmts }
(*)
fexp → [fexp] aexp
aexp → qvar
| gcon
| literal
| ( exp )
| ( exp1 , … , expk )
| [ exp1 , … , expk ]
| [ exp1 [, exp2] .. [exp3] ]
| [ exp | qual1 , … , qualn ]
| ( infixexp qop )
| ( qop⟨-⟩ infixexp )
| qcon { fbind1 , … , fbindn }
| aexp⟨qcon⟩ { fbind1 , … , fbindn }
https://www.haskell.org/onlinereport/haskell2010/haskellch3.html
were I've added (*) to where I have added or removed lines (basically
I've moved function application from lexp to infixexp in order to allow
the last exp in a function application to be an lexp).
> At the moment the *only* robust way to pass a polymorphic function to a polymorphic function (here, you are passing Wrap to (.)) is to wrap it in a newtype, much as Wrap does.
Good to know.
Thanks! -Tyson
More information about the Haskell-Cafe
mailing list