How do I declare Maybe of a mutable type in an non-pure native function in Frege? -


the native-gen tool generates native declaration showopendialog method in javafx.stage.filechooser so

data filechooser = mutable native javafx.stage.filechooser  native showopendialog :: filechooser -> window -> io file 

compiling leads message

non pure native type file must mutableio     file in io actions. 

now setting

native showopendialog :: filechooser -> window -> mutableio file 

leads to

filechooser.showopendialog has illegal     return type method not pure, perhaps st s (mutableio     file) work 

but following advice leads first error message again.

the compiler accepts iomutable file return type, makes sense since io action returns mutable type.

if possible, compiler error message should adapted avoid frustration on user side.

however, in special situation, file can null , core type not file maybe file. using iomutable (maybe file) leads rather surprising message

the type mutableio (maybe file) illegal,     maybe file must native type. 

any advice on how declare type?

the code generated native-gen wrong because file has been declared io in native-gen file defined stateful (not io) native type can seen here.

iomutable defined type iomutable d = io (mutableio d). case, mutable native type (mutableio d) can null following should work:

data filechooser = mutable native javafx.stage.filechooser   native showopendialog :: filechooser -> window -> io (maybe (mutableio file)) 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -