Skip to content

Fix: Add missing (<*>) implementation for StateT

Fredrik Wieczerkowski requested to merge missing-state-application into master

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.

Merge request reports