[Haskell-beginners] Problems with lifting code
Imants Cekusins
imantc at gmail.com
Sun Oct 2 15:57:54 UTC 2016
this works:
{-# LANGUAGE MultiParamTypeClasses,FlexibleInstances #-}
module Lift where
newtype MyNumbers a = MyNum a deriving Show
class Numbers a where
sqr :: a -> a
class Lifts b a where
lift0 :: a -> b a
lift1 :: (a -> a) -> b a -> b a
instance Lifts MyNumbers a where
lift0 x = MyNum x
lift1 o (MyNum x) = MyNum (o x)
instance Numbers Float where
sqr x = x * x
instance Numbers (MyNumbers Float) where
sqr x = lift1 sqr x
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161002/3b4fe4f7/attachment.html>
More information about the Beginners
mailing list