
2 Oct
2016
2 Oct
'16
11:57 a.m.
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