[Haskell-beginners] turning a value into an expression
Deniz Dogan
deniz.a.m.dogan at gmail.com
Mon Nov 9 17:48:38 EST 2009
2009/11/9 John Moore <john.moore54 at gmail.com>:
> Hi,
> How do I turn a value into an expression
> I want to do for e.g. 8 - 1 turn it into (subtract (Val8) (Val1)
>
> Any ideas
>
> J
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
import Prelude hiding ((-))
data Val a = Val a
deriving Show
data Expr a b = Subtract a b
deriving Show
(-) :: Num a => a -> a -> Expr (Val a) (Val a)
x - y = Subtract (Val x) (Val y)
> 4 - 3
Subtract (Val 4) (Val 3)
--
Deniz Dogan
More information about the Beginners
mailing list