6
votes

I'm new to Haskell and playing around 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 => [m a] -> m [a]
*Main> let res1 = (sequence stateProcessors)
*Main> :t res1
res1 :: StateT GoldenCrossState Identity [String]

From the type signature of sequence, I expected res1 to have type State GoldenCrossState [String]. Why doesn't it?

1

1 Answers

10
votes

It does. State s a is a type synonym for StateT s Identity a, as you can read in Haddock.