Haskell's sequence function returns a slightly different type than expected

I am new to Haskell and play with some code . I was confused by the following GHCI session:

*Main> :l golden_cross_sample.hs *Main> :t stateProcessors stateProcessors :: [State GoldenCrossState String] *Main> :t sequence sequence :: Monad m => [ma] -> m [a] *Main> let res1 = (sequence stateProcessors) *Main> :t res1 res1 :: StateT GoldenCrossState Identity [String] 

From a signature of type sequence I expected res1 to be of type State GoldenCrossState [String] . Why is this not so?

+6
source share
1 answer

This is true. State sa is a synonym for StateT s Identity a , as you can read in Haddock .

+10
source

Source: https://habr.com/ru/post/972471/


All Articles