News for hackers. Stuff that matters.
Re:Ask HN: What are some cool but obscure data structures yo... by epolanski on Friday July 22, 2022 @09:36AM (#32191735)
Referential transparency is a property of expressions, not type classes. Referential transparency is nowhere in the definition of a monad because a monad is obviously not an expression but a type class.

It is definitely true that Promise is a data type that _could_ admit a monad instance. It has:

- a data type M a which is Promise a

- a function pure with the signature a => M a, which is x => Promise.resolve(x)

- a bind function with the signature M a => a => M b => M b which is essentialy `then`

But a monad requires three properties to hold true: Right identity, Left identity and associativity. Right identity holds for every function `f: a => M b`, but left identity and associativity do not hold.

Re:Ask HN: What are some cool but obscure data structures yo... by brewmarche on Friday July 22, 2022 @05:07PM (#32197129)
Maybe comonads fit better