]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Data.hs
Gather into Writeable instances.
[comptalang.git] / lib / Hcompta / Data.hs
1 {-# LANGUAGE ConstraintKinds #-}
2 module Hcompta.Data where
3
4 import Data.Tuple (fst, snd)
5
6 -- * Class 'Has'
7 type Has ty a = (Get ty a, Set ty a)
8
9 -- ** Class 'Get'
10 class Get ty a where
11 get :: a -> ty
12 instance Get a (a, b) where get = fst
13 instance Get b (a, b) where get = snd
14
15 -- ** Class 'Set'
16 class Set ty a where
17 set :: ty -> a -> a
18 instance Set a (a, b) where set a (_, b) = (a, b)
19 instance Set b (a, b) where set b (a, _) = (a, b)
20
21 -- * Class 'Iso'
22 type Iso ty a = (To ty a, To a ty)
23
24 -- ** Class 'To'
25 class To ty a where
26 to :: a -> ty
27 {-
28 instance To a a where
29 to = id
30 -}