标题非常具有自我描述性,但有一部分引起了我的注意:
newtype IO a = IO ()
Run Code Online (Sandbox Code Playgroud)
剥离newtype,我们得到:
State# RealWorld -> (# State# RealWorld, a #)
Run Code Online (Sandbox Code Playgroud)
我不知道是什么意思State#.我们可以这样替换它State:
State RealWorld -> (State RealWorld, a)
Run Code Online (Sandbox Code Playgroud)
那可以这样表达吗?
State (State RealWorld) a
Run Code Online (Sandbox Code Playgroud)
这个特殊的结构引起了我的注意
我从概念上知道
type IO a = RealWorld -> (a, RealWorld)
Run Code Online (Sandbox Code Playgroud)
@ R.MartinhoFernandes告诉我,我实际上可以考虑实现ST RealWorld a,但我只是好奇为什么特定的GHC版本就像它一样.