简体   繁体   English

Haskell 状态 Monad 语法

[英]Haskell State Monad Syntax

What is the Syntax to test this code sample in haskell?在haskell中测试此代码示例的语法是什么?

type Estate1 x = ([Int], Map x Int)

pop :: State (Estate1 Int) Int
pop = do
  (liste,key) <- get
  return ((Map.!) key 1)
runState pop ([1,2,3], Map.singleton 1 42)
              ^^^^^^^^^^^^^^^^^^
                 initial state

Try it in ghci, you'll see what it returns.在 ghci 中尝试一下,您会看到它返回的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM