Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Control.Applicative
- import Control.Monad.State.Lazy as Lazy
- import Control.Monad.State.Strict as Strict
- import Data.List
- type LazyState = Lazy.State Int
- type LazyStateIO = Lazy.StateT Int IO
- type StrictState = Strict.State Int
- type StrictStateIO = Strict.StateT Int IO
- -- (1) exhausts the stack
- main1 = do
- let x = Strict.evalState (head <$> mapM return [1..]) 0
- print x
- -- (2) exhausts the stack
- main2 = do
- x <- Strict.evalStateT (head <$> mapM return [1..]) 0
- print x
- -- (3) works ok (constant size)
- main = do
- let x = Lazy.evalState (head <$> mapM return [1..]) 0
- print x
- -- (4) exhausts the stack
- main4 = do
- x <- Lazy.evalStateT (head <$> mapM return [1..]) 0
- print x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement