Haskell with only one typeclass
http://okmij.org/ftp/Haskell/Haskell1/Class2.hs
http://okmij.org/ftp/Haskell/types.html#Haskell1
How to make ad hoc overloading less ad hoc while defining no type classes. Haskell1' -- the extension of Haskell1 with functional dependencies, and bounded-polymorphic higher-rank types
- data ERROR a
- strMsg :: forall a. C (ERROR a) (String -> a) => String -> a
- data ThrowError m a
- throwError :: forall e m a b t1 t2. (C (ThrowError m a) (e -> m a), C (RET m a) t1, C (BIND m a b) t2) => e -> m a
- data CatchError m a
- catchError :: forall e m a. C (CatchError m a) (m a -> (e -> m a) -> m a) => m a -> (e -> m a) -> m a
- data FC1 a b c
- fc1 :: forall a b c. C (FC1 a b c) (a -> b -> c) => a -> b -> c
- data FC2 a b c
- fc2 :: forall a b c. C (FC2 a b c) (a -> b -> c) => a -> b -> c
- data FC3 a b c
- fc3 :: forall a b c. C (FC3 a b c) (a -> b -> c) => a -> b -> c
- data FromList e
- fromList :: forall e array. C (FromList e) (Int -> [e] -> array) => Int -> [e] -> array
- data Index e
- indexA :: forall e array. C (Index e) (array -> Int -> e) => array -> Int -> e
- data NUM a = NUM {}
- data CLS a
- (+$$) :: forall a. C (CLS (NUM a)) (NUM a) => a -> a -> a
- (*$$) :: forall a. C (CLS (NUM a)) (NUM a) => a -> a -> a
- nshw :: forall a. C (CLS (NUM a)) (NUM a) => a -> String
- nfromI :: forall a. C (CLS (NUM a)) (NUM a) => Integer -> a
- data PACK = forall a . C (CLS (NUM a)) (NUM a) => PACK a
- class TypeCast a b | a -> b, b -> a where
- typeCast :: a -> b
- class TypeCast' t a b | t a -> b, t b -> a where
- typeCast' :: t -> a -> b
- class TypeCast'' t a b | t a -> b, t b -> a where
- typeCast'' :: t -> a -> b
Documentation
Some functional dependencies: implementing Monad Error As it turns out, some functional dependencies are expressible already in Haskell1. The example is MonadError, which in Haskell' has the form
data ThrowError m a Source
C (ThrowError (Either e) a) (e -> Either e a) |
throwError :: forall e m a b t1 t2. (C (ThrowError m a) (e -> m a), C (RET m a) t1, C (BIND m a b) t2) => e -> m aSource
data CatchError m a Source
catchError :: forall e m a. C (CatchError m a) (m a -> (e -> m a) -> m a) => m a -> (e -> m a) -> m aSource
class TypeCast' t a b | t a -> b, t b -> a whereSource
TypeCast'' t a b => TypeCast' t a b |
class TypeCast'' t a b | t a -> b, t b -> a whereSource
typeCast'' :: t -> a -> bSource
TypeCast'' () a a |