[Haskell-cafe] ANNOUNCE slot-lambda
vogt.adam at gmail.com
Mon Apr 7 20:28:40 UTC 2014
Maybe haskell-src-exts will follow ghc-7.8 and accept _ in expressions
as ghc-7.8 does (http://www.haskell.org/haskellwiki/GHC/TypedHoles).
Ideally there could be something like camlp4 for haskell, but as far
as I know there isn't such a thing.
On Mon, Apr 7, 2014 at 12:02 PM, ducis <ducis_cn at 126.com> wrote:
> It lets your write lambdas with 'slots' without inventing names for the
> [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.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe