tweag / linear-base

Standard library for linear types in Haskell.
MIT License
336 stars 37 forks source link

Yet another Applicative? #350

Open treeowl opened 3 years ago

treeowl commented 3 years ago

[] and Data.Sequence seem almost the opposite of data Applicative: pure is linear, but liftA2 is not. Are there other types like this?

aspiwack commented 3 years ago

They're data monads. (that's return :: a %1 -> M a; (>>=) :: M a %1 -> (a %-> M b) -> M b (note the one unrestricted arrow in (>>=)).

I don't think that the unrestricted liftA2 can be deduced from the data monad structure. But many data monads are also monads in Hask, therefore have this unrestricted liftA2.

The problem with seeing them as applicatives as you suggest is that I can't really see a way to relate pure and liftA2 that I can see.