> For example all functions with Int -> Int are type equivalent
> However,
> 
> data D a b = MkD a b

All objects D Int Int are type equivalent.  I'm not sure what
your question means, otherwise.

If you define 

data Function a b = F (a -> b)

apply:: Function a b -> a -> b
apply (F f) a = f a

you add an extra level of constructor, but you can still use
anything of type Function Int Int where Function Int Int is
required:

square:: Function Int Int
square = F (\ a -> a*a)

sqare_root:: Function Int Int
square_root = F (\ a -> round (sqrt (fromIntegral a)))

E&OE -- it's about my bedtime.


-- 
J�n Fairbairn                                 [EMAIL PROTECTED]
31 Chalmers Road                                         [EMAIL PROTECTED]
Cambridge CB1 3SZ            +44 1223 570179 (after 14:00 only, please!)


_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to