purescript / purescript-lists

Linked Lists
BSD 3-Clause "New" or "Revised" License
57 stars 51 forks source link

ZipList is Bind #219

Open worldmaker18349276 opened 1 month ago

worldmaker18349276 commented 1 month ago

https://github.com/purescript/purescript-lists/blob/b113451e5b41cad87d669a3165f955c71cd863e2/src/Data/List/ZipList.purs#L57-L66

ZipList is Bind, in which join is just diagonal. It's also Monad and MonadPlus.

Example: https://try.purescript.org/?gist=4888527a78d71d12df75fa628acd4719

worldmaker18349276 commented 1 month ago

by the way,

fix-sized array is Bind: https://github.com/sigma-andex/purescript-fast-vect/blob/209c35d9b616370dc2bb7efaa4c1d2ac4fd394bf/src/Data/FastVect/FastVect.purs#L75

ZipArray (finite nonempty array using zip longest strategy) is Bind: https://gist.github.com/ajnsit/b2aebc5f70d1192122bde7bf5f18592a#file-ziparray-purs-L100

Map is Bind: https://github.com/purescript/purescript-ordered-collections/blob/b9c8ec72b53ee56d6cb6dc962d5ad7ea4708b438/src/Data/Map/Internal.purs#L164