TypeFamilies - Intro

Run Settings
LanguageHaskell
Language Version
Run Command
{-# LANGUAGE TypeFamilies, MultiParamTypeClasses #-} -- Generalised Num class class GNum a b where type SumTy a b :: * (+>) :: a -> b -> SumTy a b instance GNum Int Int where type SumTy Int Int = Int x +> y = x + y instance GNum Int Float where type SumTy Int Float = Float x +> y = fromIntegral x + y instance GNum Float Int where type SumTy Float Int = Float x +> y = x + fromIntegral y main = do print $ (1 :: Int) +> (5 :: Int) print $ (1 :: Int) +> (4.2 :: Float) print $ (1.24 :: Float) +> (2 :: Int) -- http://research.microsoft.com/en-us/um/people/simonpj/papers/assoc-types/fun-with-type-funs/FunWithTypeFuns-Apr09.pdf
Editor Settings
Theme
Key bindings
Full width
Lines