Re:Tricks I wish I knew when I learned TypeScript
by knuthsat on Tuesday October 12, 2021 @02:35PM
(#28843333)
Does rust have Mut annotations on functions?
I mean, when you look at a problem that monads solve with types is that every function has an “annotation “ of what it uses (IO or mutable state). Similar how async in JS allows await, a state annotation would allow put get or IO annotation any of the IO capabilities.
Of course monads are much more but Mut does not look like it pollutes everything with Mut, including function definitions and results
Re:Tricks I wish I knew when I learned TypeScript
by lalaithion on Tuesday October 12, 2021 @04:33PM
(#28844730)
No, it does not.
Re:Tricks I wish I knew when I learned TypeScript
by whimsicalism on Tuesday October 12, 2021 @02:38PM
(#28843377)
Effects systems in Scala
I think it’s only really Haskell (and perhaps languages like Idris) that’s super strict on side effects.
In Rust it’s a simple mut annotation, and perhaps a mutex (and you’ll want that in C too of course) if you’re working across threads.