Ticket #4338: Bar.hs

File Bar.hs, 344 bytes (added by illissius, 3 years ago)
Line 
1{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
2
3class Bar a b | a -> b, b -> a where
4    there :: a -> b
5    back :: b -> a
6    tickle :: b -> b
7
8instance Bar Char Int where
9    there = fromEnum
10    back = toEnum
11    tickle = (+1)
12
13test :: (Bar a b) => a -> a
14test = back . tickle . there
15
16main :: IO ()
17main = print $ test 'F'