Name: Anonymous 2010-05-28 14:55
I've never had to use them.
both :: Arrow a => a b c -> a (b, b) (c, c)
both = join (***)
instance Num Char where
fromInteger = chr . fromInteger
(+) = ((chr . flip mod (ord maxBound + 1) . uncurry (+)) .) . curry (both ord)
(*) = ((chr . flip mod (ord maxBound + 1) . uncurry (*)) .) . curry (both ord)
(-) = ((chr . flip mod (ord maxBound + 1) . uncurry (-)) .) . curry (both ord)
negate = chr . (ord maxBound + 1 -) . ord
abs = id
signum = chr . signum . ord
instance Real Char where
toRational = toRational . ord
instance Integral Char where
quotRem = ((both chr . uncurry quotRem) .) . curry (both ord)
toInteger = toInteger . ord