How does the ST monad work?

后端 未结 2 1971
长情又很酷
长情又很酷 2020-12-02 06:05

I understand that the ST monad is something like a little brother of IO, which in turn is the state monad with added RealWorld magic. I can picture states and I

2条回答
  •  醉话见心
    2020-12-02 06:33

    The s is just a hack that makes the type system stop you doing things which would be unsafe. It doesn't "do" anything at run-time; it just makes the type checker reject programs that do dubious things. (It is a so-called phantom type, a thing with only exists in the type checker's head, and doesn't affect anything at run-time.)

提交回复
热议问题