[Haskell-cafe] ANNOUNCE slot-lambda

ducis ducis_cn at 126.com
Mon Apr 7 16:02:08 UTC 2014


It lets your write lambdas with 'slots' without inventing names for the parameters.

[s| ı + ı |]  =  \x y -> x+y

The unicode character ı(305) representing a 'slot' can be input in vim with the digraph 'i.' . 
Use _ı to refer to the immediate left ı, and _0, _1, _2, ... to refer to the 1st, 2nd, 3rd, ... arguments respectively. 
[s| ı : ı : _ı : ı : _ı : _ı : _0 : [] |] 'a' 'b' 'c'
=  (\x y z -> x:y:y:z:z:z:x:[]) 'a' 'b' 'c'
=  "abbccca"
I originally intended using '_' to represent the 'slots' but that doesn't parse as legal haskell. 
Actually I wonder how to achieve that without rolling my own haskell parser or forking haskell-src-exts.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140408/fa6ac19f/attachment.html>

More information about the Haskell-Cafe mailing list