|
|
|
|
|
by gizmo686
2005 days ago
|
|
Linear types don't help here. The complaint is that with lazyIO, even if your code does the write before closing the file, the actual order the operations occur in could change, to put the close first. If you look at the lazyIO documentation, you will see: >Although this module calls unsafeInterleaveIO for you, it cannot take the responsibility from you. Using this module is still as unsafe as calling unsafeInterleaveIO manually. Thus we recommend to wrap the lazy I/O monad into a custom newtype with a restricted set of operations which is considered safe for interleaving I/O actions. https://hackage.haskell.org/package/lazyio-0.1.0.4/docs/Syst... TLDR, don't use lazy IO. |
|