IOMutable与MutableIO文件

Fed*_*tti 4 frege

我正在尝试加载文件.

我有:

wf :: STMutable a File
wf = File.new "worlds/seed_77.world"

data PickleSerialization = pure native com.github.lands.PickleSerialization where
native loadWorld com.github.lands.PickleSerialization.loadWorld :: MutableIO File -> IO World throws IOException, IncorrectFileException
Run Code Online (Sandbox Code Playgroud)

如果我尝试做:

PickleSerialization.loadWorld wf
Run Code Online (Sandbox Code Playgroud)

我收到这个错误,这对我来说似乎很混乱:

[ERROR: 4]: type error in  expression wf
type is   IOMutable File
used as   MutableIO File
Run Code Online (Sandbox Code Playgroud)

Mar*_*amy 5

wf返回生成文件的操作.loadWorld接受文件,而不是动作.我认为这应该有效:wf >>= loadWorld.

MutableIO File表示可变文件,而是IOMutable返回可变文件的操作.IOMutable定义为(取自来源):

--- This is an abbreviation for @ST RealWorld (Mutable RealWorld d)@ type IOMutable d = IO (MutableIO d)

同样STMutable被定义为,

--- The type of 'ST' actions that return a mutable value of type _d_ --- This is an abbreviation for @ST s (Mutable s d)@ type STMutable s d = ST s (Mutable s d)