On 5/8/12 8:24 PM, Sebastien Zany wrote:
Hmm, I don't understand how that would work.
Using one of the fundep versions:
class (Functor f) = Fixpoint f x | ... where
fix :: f x - x
unfix :: x - f x
We'd define instances like the following:
data List a = Nil | Cons a
Hmm, I don't understand how that would work.
I wish I could define something like this:
class (Functor f) = Fixpoint f x | x - f where
fix :: x - Fix f
instance (Functor f) = Fixpoint f (forall a. f a) where
fix = id
instance (Functor f, Fixpoint f x) = Fixpoint f (f x) where
fix
Er, sorry – fix = id should be fix = Fix.
On Tue, May 8, 2012 at 5:24 PM, Sebastien Zany
sebast...@chaoticresearch.com wrote:
Hmm, I don't understand how that would work.
I wish I could define something like this:
class (Functor f) = Fixpoint f x | x - f where
fix :: x - Fix f
Thanks Wren!
When I try
fix term
ghci complains of an ambiguous type variable.
I have to specify
term :: (Expr (Expr (Expr (Fix Expr
for it to work.
Is there a way around this?
On Sun, May 6, 2012 at 4:04 PM, wren ng thornton w...@freegeek.org wrote:
On 5/6/12 8:59 AM, Sebastien Zany
To slightly alter the question, is there a way to define a class
class (Functor f) = Fixpoint f x where
...
so that I can define something with a type signature that looks like
something :: (Fixpoint f x) = ... x ...
which will accept any
argument :: F (F (F ... (F a) ... ))
in place
On 5/7/12 8:55 PM, Sebastien Zany wrote:
To slightly alter the question, is there a way to define a class
class (Functor f) = Fixpoint f x where
...
You can just do that (with MPTCs enabled). Though the usability will be
much better if you use fundeps or associated types in order to
Hi,
Suppose I have the following types:
data Expr expr = Lit Nat | Add (expr, expr)
newtype Fix f = Fix {unFix :: f (Fix f)}
I can construct a sample term:
term :: Expr (Expr (Expr expr))
term = Add (Lit 1, Add (Lit 2, Lit 3))
But isn't quite what I need. What I really need is:
term' ::
Hi,
In these cases is good to define smart constructors, e.g.:
data E e = Lit Int | Add e e
data Fix f = Fix {unFix :: f (Fix f)}
type Expr = Fix E
lit :: Int - Expr
lit = Fix . Lit
add :: Expr - Expr - Expr
add e1 e2 = Fix (Add e1 e2)
term :: Expr
term = add (lit 1) (add (lit 2)
Sorry, I think I misunderstood your question, if I understand correctly
you want some function to convert nested Expr to Fix'ed Exprs.
You can do that with a typeclass, but you have to provide the Fix'ed
type at the bottom:
--
{-# LANGUAGE
On 5/6/12 8:59 AM, Sebastien Zany wrote:
Hi,
Suppose I have the following types:
data Expr expr = Lit Nat | Add (expr, expr)
newtype Fix f = Fix {unFix :: f (Fix f)}
I can construct a sample term:
term :: Expr (Expr (Expr expr))
term = Add (Lit 1, Add (Lit 2, Lit 3))
But isn't quite
10 matches
Mail list logo