Get the latest tech news

Violating memory safety with Haskell's value restriction


Violating memory safety with Haskell's value restriction

IO can create mutable references so we need to prevent it from generalizing them and that’s why the monadic interface imposes something resembling the value restriction. Using this constructor directly can be unsafe, since the illusion of purely modifying the real world (and IO ’s sequencing guarantees) only apply if the State# RealWorld tokens are passed around linearly, i.e. are never duplicated or dropped. Contrary to popular belief, unwrapping the IO constructor is deeply unsafe and can violate memory safety, even if State# tokens are never duplicated or dropped.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Haskell

Haskell

Photo of Memory Safety

Memory Safety

Photo of value restriction

value restriction

Related news:

News photo

Silly job interview questions in Haskell

News photo

Packed Data Support in Haskell

News photo

Test Spies in Haskell