Commit 674934e1 authored by Ning Wang's avatar Ning Wang

Merge pull request #31 from bgamari/master

Add Functor, Foldable, Traversable instances for maps
parents 218c2726 dccbc3aa
{-# LANGUAGE CPP, TypeFamilies #-}
{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
#if __GLASGOW_HASKELL__ >= 701
{-# LANGUAGE Safe #-}
#endif
......@@ -17,6 +18,10 @@ where
import Compiler.Hoopl.Collections
import Compiler.Hoopl.Unique
#if !MIN_VERSION_base(4,8,0)
import Data.Traversable (Traversable)
import Data.Foldable (Foldable)
#endif
-----------------------------------------------------------------------------
-- Label
......@@ -64,7 +69,8 @@ instance IsSet LabelSet where
-----------------------------------------------------------------------------
-- LabelMap
newtype LabelMap v = LM (UniqueMap v) deriving (Eq, Ord, Show)
newtype LabelMap v = LM (UniqueMap v)
deriving (Eq, Ord, Show, Functor, Foldable, Traversable)
instance IsMap LabelMap where
type KeyOf LabelMap = Label
......
{-# LANGUAGE CPP, TypeFamilies #-}
{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
#if __GLASGOW_HASKELL__ >= 709
{-# LANGUAGE Safe #-}
#elif __GLASGOW_HASKELL__ >= 701
......@@ -26,6 +27,10 @@ import qualified Data.IntSet as S
import Control.Applicative as AP
import Control.Monad (ap,liftM)
#if !MIN_VERSION_base(4,8,0)
import Data.Traversable (Traversable)
import Data.Foldable (Foldable)
#endif
-----------------------------------------------------------------------------
-- Unique
......@@ -69,7 +74,8 @@ instance IsSet UniqueSet where
-----------------------------------------------------------------------------
-- UniqueMap
newtype UniqueMap v = UM (M.IntMap v) deriving (Eq, Ord, Show)
newtype UniqueMap v = UM (M.IntMap v)
deriving (Eq, Ord, Show, Functor, Foldable, Traversable)
instance IsMap UniqueMap where
type KeyOf UniqueMap = Unique
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment