1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# OPTIONS_GHC -fno-warn-orphans #-}
6 module Hcompta.Lib.Consable where
8 -- import Control.Applicative (Const(..))
9 import Data.Function (id)
10 -- import Data.Functor.Compose (Compose(..))
11 import Data.Monoid (Monoid(..))
12 import Data.Ord (Ord(..))
13 import qualified Data.Map.Strict as Map
14 import Data.Map.Strict (Map)
16 class Consable x m where
19 instance Consable x () where
21 instance Consable x [x] where
24 instance (Monoid v, Ord k) => Consable (k, v) (Map k v) where
25 mcons (k, v) = Map.insertWith mappend k v
28 instance Monoid (f (g x)) => Monoid ((Compose f g) x) where
29 mempty = Compose mempty
30 mappend (Compose x) (Compose y) = Compose (mappend x y)