News for hackers. Stuff that matters.
Re:GHC 9.0, supporting linear types by vsskanth on Wednesday December 30, 2020 @02:23PM (#25585009)
How can linear types be used for something like doing a bunch of calculations on a DataFrame of unknown size ? ex: filter rows based on certain conditions, compute some averages, and then plot certain columns etc.

Its hard to find real world use examples and learn about linear types when I search online. If anyone has links, that would help.

Re:GHC 9.0, supporting linear types by jose_zap on Wednesday December 30, 2020 @03:15PM (#25585554)
Some real world examples with links:

- A safe streaming library where effects are guaranteed to only be performed once: https://www.tweag.io/blog/2018-06-21-linear-streams/

- Efficient zero-copy network communication: https://www.tweag.io/blog/2017-08-24-linear-types-packed-dat...

- Safe manual memory management and prompt resource release: https://www.tweag.io/blog/2020-02-06-safe-inline-java/

- Explicit API design to guide developers on what function to call next when implementing a protocol like TCP: https://www.tweag.io/blog/2017-08-03-linear-typestates/

- Add correctness proofs to already existing algorithm implementations like merge sort: https://www.tweag.io/blog/2018-03-08-linear-sort/

Re:GHC 9.0, supporting linear types by vsskanth on Wednesday December 30, 2020 @04:43PM (#25586525)
Thank you!
Re:GHC 9.0, supporting linear types by whateveracct on Wednesday December 30, 2020 @03:02PM (#25585403)
They'd mostly be used for creating a pure API around any mutability under the hood

But we already had ST for that, so the real advantage of LTs over ST is you can type-safely "freeze" and "thaw" your mutable structure without copying.

The mutable array example in the Linear Haskell paper is a simple comparison to what you're asking for.

Re:GHC 9.0, supporting linear types by taktoa on Thursday December 31, 2020 @11:48AM (#25594280)
It's not "linear" as in linear algebra (well, it is technically, but only in the abstruse sense that the category of the vector spaces and linear maps is a model of linear logic).