Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ComonadStore instances for EnvT and TracedT #107

Merged
merged 1 commit into from
Apr 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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