Ticket #4338: Foo.hs

File Foo.hs, 467 bytes (added by illissius, 3 years ago)
Line 
1{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleContexts #-}
2
3class (There a ~ b, BackAgain b ~ a) => Foo a b where
4    type There a
5    type BackAgain b
6    there :: a -> b
7    back :: b -> a
8    tickle :: b -> b
9
10instance Foo Char Int where
11    type There Char = Int
12    type BackAgain Int = Char
13    there = fromEnum
14    back = toEnum
15    tickle = (+1)
16
17--test :: (Foo a b) => a -> a
18test = back . tickle . there
19
20--main :: IO ()
21main = print $ test 'F'