{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, GeneralizedNewtypeDeriving #-}
module MinHS.Env ( Env(..)
import qualified Data.Map as M
Copyright By PowCoder代写 加微信 powcoder
import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
import Data.Monoid
import Prelude hiding (lookup)
import Data.Semigroup
newtype Env e = Env (M.Map String e) deriving (Functor, Foldable, Traversable, Show, Eq, Semigroup, Monoid)
empty :: Env e
empty = Env M.empty
lookup :: Env e -> String -> Maybe e
lookup (Env env) var = M.lookup var env
add :: Env e -> (String, e) -> Env e
add (Env env) (key,elt) = Env (M.insert key elt env)
addAll :: Env e -> [(String,e)] -> Env e
addAll (Env env) pairs = Env $ foldr (\(k,e) g -> M.insert k e g) env pairs
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com