1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# OPTIONS_GHC -fno-warn-orphans #-}
6 module Hcompta.Lib.Consable where
8 -- import Data.Functor.Compose (Compose(..))
9 -- import Control.Applicative (Const(..))
10 import Data.Monoid (Monoid(..))
11 import Data.Ord (Ord(..))
12 import qualified Data.Map.Strict as Map
13 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)