Merged and upload to CPM. Thanks for the fix.
Michael Hanus (c2361eea) at 18 Jul 15:02
Add Reader and Writer monads
Michael Hanus (14806eb2) at 18 Jul 15:02
Add Reader and Writer monads
Fredrik Wieczerkowski (d25c0a39) at 18 Jul 14:57
While evaluating
Control.Monad.Trans.State> evalState ((\x -> (x ++ " world")) <$> get) "hello"
"hello world"
works correctly, evaluating
Control.Monad.Trans.State> evalState (pure (\x -> (x ++ " world")) <*> get) "hello"
currently causes the program to loop (due to an infinite recursion between the default definition of (<*>)
and liftA2
). This branch fixes this oversight by adding the corresponding (<*>)
implementation to the Applicative
instance of StateT
.
Michael Hanus (ed2a9f00) at 18 Jul 14:57
Merge branch 'missing-state-application' into 'master'
... and 1 more commit
Fredrik Wieczerkowski (7763f73f) at 18 Jul 14:55
Michael Hanus (fdc517d5) at 18 Jul 14:55
Merge branch 'reader-writer' into 'master'
... and 8 more commits
This branch adds the well-known ReaderT
and WriterT
monad transformers for expressing computations with an environment and an appendable output, respectively. The corresponding specializations to Identity
, Reader
and Writer
, are provided as well.
@mh Any chance to get this reviewed/merged?
This bug subtly causes programs using the state monad's <*>
and liftA2
to loop (while consuming more and more memory until the OOM killer jumps in).
While evaluating
Control.Monad.Trans.State> evalState ((\x -> (x ++ " world")) <$> get) "hello"
"hello world"
works correctly, evaluating
Control.Monad.Trans.State> evalState (pure (\x -> (x ++ " world")) <*> get) "hello"
currently causes the program to loop (due to an infinite recursion between the default definition of (<*>)
and liftA2
). This branch fixes this oversight by adding the corresponding (<*>)
implementation to the Applicative
instance of StateT
.
Fredrik Wieczerkowski (d25c0a39) at 07 Mar 06:20
Add missing (<*>) operator for StateT
Strangely, KiCS2 seems to throw an error when evaluating runWriter (do { tell ["hello"]; tell ["world"]; return () }) :: ((), [String])
in the REPL:
.curry/kics2-3.0.0/Curry_Curry_Main_Goal.hs:33:3: error:
Not in scope:
‘Data.Functor.Curry_Identity.d_OP_uscore_inst_hash_Prelude_dot_Monad_hash_Data_dot_Functor_dot_Identity_dot_Identity’
No module named ‘Data.Functor.Curry_Identity’ is imported.
|
33 | Data.Functor.Curry_Identity.d_OP_uscore_inst_hash_Prelude_dot_Monad_hash_Data_dot_Functor_dot_Identity_dot_Identity
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Since PAKCS handles this expression correctly, I assume this is a KiCS2 bug.
This branch adds the well-known ReaderT
and WriterT
monad transformers for expressing computations with an environment and an appendable output, respectively. The corresponding specializations to Identity
, Reader
and Writer
, are provided as well.
Fredrik Wieczerkowski (7763f73f) at 07 Mar 06:06
Add utility functions for WriterT
... and 7 more commits