{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Hcompta.Lib.Consable where -- import Control.Applicative (Const(..)) import Data.Function (id) -- import Data.Functor.Compose (Compose(..)) import Data.Monoid (Monoid(..)) import Data.Ord (Ord(..)) import qualified Data.Map.Strict as Map import Data.Map.Strict (Map) class Consable x m where mcons :: x -> m -> m instance Consable x () where mcons _x = id instance Consable x [x] where mcons = (:) instance (Monoid v, Ord k) => Consable (k, v) (Map k v) where mcons (k, v) = Map.insertWith mappend k v {- instance Monoid (f (g x)) => Monoid ((Compose f g) x) where mempty = Compose mempty mappend (Compose x) (Compose y) = Compose (mappend x y) -}