Skip to content

Commit

Permalink
add ComonadStore instances for EnvT and TracedT
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-passiv committed Apr 6, 2018
1 parent be1de05 commit b28c098
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Control/Comonad/Store/Class.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ module Control.Comonad.Store.Class where
import Prelude

import Control.Comonad (class Comonad, extract)
import Control.Comonad.Env.Trans (EnvT)
import Control.Comonad.Store.Trans (StoreT(..))
import Control.Comonad.Traced.Trans (TracedT)
import Control.Comonad.Trans.Class (lower)
import Control.Extend (duplicate)

import Data.Tuple (Tuple(..))
import Data.Monoid (class Monoid)

-- | The `ComonadStore` type class represents those monads which support local position information via
-- | `pos` and `peek`.
Expand Down Expand Up @@ -52,3 +56,11 @@ seeks f = peeks f <<< duplicate
instance comonadStoreStoreT :: Comonad w => ComonadStore s (StoreT s w) where
pos (StoreT (Tuple f s)) = s
peek s (StoreT (Tuple f _)) = extract f s

instance comonadStoreEnvT :: ComonadStore s w => ComonadStore s (EnvT e w) where
pos = pos <<< lower
peek s = peek s <<< lower

instance comonadStoreTracedT :: (ComonadStore s w, Monoid m) => ComonadStore s (TracedT m w) where
pos = pos <<< lower
peek s = peek s <<< lower

0 comments on commit b28c098

Please sign in to comment.