File tree Expand file tree Collapse file tree
core/src/Streamly/Internal/Data/ParserK Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,39 @@ import qualified Streamly.Internal.Data.MutArray.Generic as GenArr
6262import qualified Streamly.Internal.Data.Array.Generic as GenArr
6363import qualified Streamly.Internal.Data.Parser.Type as ParserD
6464
65+ -------------------------------------------------------------------------------
66+ -- Developer Notes
67+ -------------------------------------------------------------------------------
68+
69+ -- MonadReader cannot be implemented using continuations for ParserK
70+ --
71+ -- "local" (and hence "MonadReader") cannot be implemented for ParserK because
72+ -- there is no way to override all continuations.
73+ --
74+ -- We can implement `MonadReader` for ParserK via ParserD:
75+ --
76+ -- @
77+ -- instance (Show r, MonadReader r m) => MonadReader r (Parser a m) where
78+ -- {-# INLINE ask #-}
79+ -- ask = Parser.fromEffect ask
80+ -- {-# INLINE local #-}
81+ -- local f (Parser step initial extract) =
82+ -- Parser
83+ -- ((local f .) . step)
84+ -- (local f initial)
85+ -- (local f . extract)
86+ --
87+ -- instance (Show r, MonadReader r m) => MonadReader r (ParserK a m) where
88+ -- {-# INLINE ask #-}
89+ -- ask = ParserK.fromEffect ask
90+ -- {-# INLINE local #-}
91+ -- local f parser = ParserK.adapt $ local f $ ParserK.toParser parser
92+ -- @
93+
94+ -------------------------------------------------------------------------------
95+ -- Types
96+ -------------------------------------------------------------------------------
97+
6598-- Note: We cannot use an Array directly as input because we need to identify
6699-- the end of input case using None. We cannot do that using nil Array as nil
67100-- Arrays can be encountered in normal input as well.
You can’t perform that action at this time.
0 commit comments