モナド定義側関数

が適当に命名した名前
pop :: State Stack String
のようなモナドを生成する側の関数のこと
以下のようなコードの pop
, push
, stackMainp
hsimport Control.Monad.State
type Stack = [Int]
pop :: State Stack Int
pop = state $ \(x : xs) -> (x, xs) -- (x, xs)は(Int, Stack)
push :: Int -> State Stack ()
push a = state $ \xs -> ((), a : xs)
stackMainp :: State Stack Int
stackMainp = do
push 3
pop
pop
main = do
print $ runState stackMainp [11, 12, 13, 14, 15]
こうした関数を定義する際に気にすることを見る
hsstackMainp :: State Stack Int
stackMainp = do
-- ここを実装するときに何を意識するか