{-# LANGUAGE TypeFamilies, FlexibleContexts, TypeOperators #-}
-- Infamous paradise benchmark
module Paradise
where
import Data.Generics.IG.Representable
import Company
class Increase a where
increase :: Float -> a -> a
instance Increase Unit where
increase _ _ = Unit
instance Increase Char where
increase _ x = x
instance (Increase a, Increase b) => Increase (a :+: b) where
increase k (Inl x) = Inl (increase k x)
increase k (Inr y) = Inr (increase k y)
instance (Increase a, Increase b) => Increase (a :*: b) where
increase k (x :*: y) = (increase k x) :*: (increase k y)
dft_increase :: (Representable a, Increase (Repr a)) => Float -> a -> a
dft_increase k = fromRepr . increase k . toRepr
instance (Increase a) => Increase [a] where
increase = dft_increase
instance Increase Company where
increase = dft_increase
instance Increase Dept where
increase = dft_increase
instance Increase CUnit where
increase = dft_increase
instance Increase Employee where
increase = dft_increase
instance Increase Person where
increase = dft_increase
instance Increase Salary where
increase k = fromRepr . (* (1 + k)) . toRepr