[Haskell-cafe] MPTC and type classes issue (polymorphic '+')

Joel Reymont joelr1 at gmail.com
Sat Apr 7 09:51:23 EDT 2007


On Apr 7, 2007, at 2:01 PM, Pepe Iborra wrote:

> So what I would do is to create a thin wrapper:
>
> >i = id :: Integer -> Integer
>
> and write:
>
> > input2 = [ InputDecs [ inp "emaLength" TyNumber ((i 20) + (i  
> 40)) ] ]

I do it like this and it does save typing. It's not bad so I'll stick  
to it for now:

id = VarIdent

d = Double
i = Int
b = Bool
s = Str

d' = NumExpr . d
i' = NumExpr . i
b' = CondExpr . b
s' = StrExpr . s

n = NumExpr

(+) a b = NumExpr (NumOp Plus a b)

This is much less verbose than my OCaml version anyway.

--
http://wagerlabs.com/







More information about the Haskell-Cafe mailing list