From b28c0987244622411cdd5e6d438782b0ce7da4ee Mon Sep 17 00:00:00 2001 From: colin-passiv Date: Fri, 6 Apr 2018 14:54:53 +0100 Subject: [PATCH] add ComonadStore instances for EnvT and TracedT --- src/Control/Comonad/Store/Class.purs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Control/Comonad/Store/Class.purs b/src/Control/Comonad/Store/Class.purs index 2c4f0009..ae620033 100644 --- a/src/Control/Comonad/Store/Class.purs +++ b/src/Control/Comonad/Store/Class.purs @@ -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`. @@ -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