News for hackers. Stuff that matters.
Re:Understanding Memory Fragmentation in Haskell by siraben on Saturday August 22, 2020 @02:22AM (#24242106)
Having written Haskell for over a year now for personal projects, understanding the memory model can be one of the hardest aspects of Haskell, which can make it frustrating to write allocation-free code (although some techniques like deforestation are done by the compiler to eliminate intermediate structures entirely).

Linear types being added in GHC 8.12 would be a big deal because it would allow programmers to be able to write allocation-free code that can use mutable data structures with a pure API (as opposed to the ST state monad), much like how Rust solves this with the ownership system.

Re:Understanding Memory Fragmentation in Haskell by platz on Saturday August 22, 2020 @02:56AM (#24242272)
I don't understand how ghc linear types allows allocation-free code. GHC'ss linear types don't give you uniqueness types in the same way rust does
Re:Understanding Memory Fragmentation in Haskell by zetalemur on Saturday August 22, 2020 @08:05AM (#24243563)
> GHC'ss linear types don't give you uniqueness types in the same way rust does

Why, though?

Is it because GHC's linear types are a superset of Rust's linear types? I guess that could rule out some features the compiler is able to prove (or not).

Re:Understanding Memory Fragmentation in Haskell by platz on Saturday August 22, 2020 @11:11AM (#24244637)
GHC models linearity differently. Rust puts linearity on the types, GHC puts linearity on the arrows. https://i.imgur.com/s0Mxhcr_d.webp?maxwidth=640&shape=thumb&...
Re:Understanding Memory Fragmentation in Haskell by senorsmile on Saturday August 22, 2020 @01:10PM (#24245533)
Is Idris 2's linearity the same as Haskell's in this respect?
Re:Understanding Memory Fragmentation in Haskell by platz on Saturday August 22, 2020 @01:14PM (#24245566)
yes
Re:Understanding Memory Fragmentation in Haskell by whateveracct on Saturday August 22, 2020 @01:50PM (#24245808)
You can use them to write much safer off-heap memory management APIs in userspace. But GHC can't do anything for free, no.