[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] Template Haskell - substitution in pattern in a lamb

Subject: Re: [Haskell-cafe] Template Haskell - substitution in pattern in a lambda
From: Antoine Latter
Date: Sun, 3 Jan 2010 20:41:13 -0600
On Sun, Jan 3, 2010 at 8:30 PM, Patrick Caldon <[email protected]> wrote:
>
> I'm trying to write some template haskell which will transform:
>
> $(buildCP 0) Âinto \(SimpleM d1 d2 d3) (SimpleM _ _ _) -> (SimpleM d1 d2 d3)
> $(buildCP 1) Âinto \(SimpleM _ d2 d3) (SimpleM d1 _ _) -> (SimpleM d1 d2 d3)
> $(buildCP 1) Âinto \(SimpleM d1 _ d3) (SimpleM _ d2 _) -> (SimpleM d1 d2 d3)
> and so on.
>
> Ultimately I want to generalize this to more variables.
>
> I can't seem to get anything to substitute for the pattern variables in a
> lambda. ÂIs there a straightforward way of doing this?
>

Hello,

It looks like you want to construct expressions with the LamE
constructor, which is declared like so:

LamE [Pat] Exp

For the Pat, you would use eiter VarP or WildP for variable binding
patterns or wild-card patterns.

Or am I missing something?

Antoine
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>