]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Lib/Consable.hs
Ajout : Calculus.Lambda.Omega.Explicit.
[comptalang.git] / lib / Hcompta / Lib / Consable.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE MultiParamTypeClasses #-}
4 {-# OPTIONS_GHC -fno-warn-orphans #-}
5
6 module Hcompta.Lib.Consable where
7
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)
14 import Prelude (id)
15
16 class Consable x m where
17 mcons :: x -> m -> m
18
19 instance Consable x () where
20 mcons _x = id
21 instance Consable x [x] where
22 mcons = (:)
23
24 instance (Monoid v, Ord k) => Consable (k, v) (Map k v) where
25 mcons (k, v) = Map.insertWith mappend k v
26
27 {-
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)
31 -}