{-# LANGUAGE ConstraintKinds #-} module Hcompta.Data where import Data.Tuple (fst, snd) -- * Class 'Has' type Has ty a = (Get ty a, Set ty a) -- ** Class 'Get' class Get ty a where get :: a -> ty instance Get a (a, b) where get = fst instance Get b (a, b) where get = snd -- ** Class 'Set' class Set ty a where set :: ty -> a -> a instance Set a (a, b) where set a (_, b) = (a, b) instance Set b (a, b) where set b (a, _) = (a, b) -- * Class 'Iso' type Iso ty a = (To ty a, To a ty) -- ** Class 'To' class To ty a where to :: a -> ty {- instance To a a where to = id -}