{"action":"created","issue":{"url":"https://api.github.com/repos/purescript/purescript-foldable-traversable/issues/44","repository_url":"https://api.github.com/repos/purescript/purescript-foldable-traversable","labels_url":"https://api.github.com/repos/purescript/purescript-foldable-traversable/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/purescript/purescript-foldable-traversable/issues/44/comments","events_url":"https://api.github.com/repos/purescript/purescript-foldable-traversable/issues/44/events","html_url":"https://github.com/purescript/purescript-foldable-traversable/issues/44","id":131933459,"number":44,"title":"Generic filter/etc","user":{"login":"AppShipIt","id":48431,"avatar_url":"https://avatars.githubusercontent.com/u/48431?v=3","gravatar_id":"","url":"https://api.github.com/users/AppShipIt","html_url":"https://github.com/AppShipIt","followers_url":"https://api.github.com/users/AppShipIt/followers","following_url":"https://api.github.com/users/AppShipIt/following{/other_user}","gists_url":"https://api.github.com/users/AppShipIt/gists{/gist_id}","starred_url":"https://api.github.com/users/AppShipIt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AppShipIt/subscriptions","organizations_url":"https://api.github.com/users/AppShipIt/orgs","repos_url":"https://api.github.com/users/AppShipIt/repos","events_url":"https://api.github.com/users/AppShipIt/events{/privacy}","received_events_url":"https://api.github.com/users/AppShipIt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-07T04:10:21Z","updated_at":"2016-02-07T16:25:45Z","closed_at":null,"body":"The collection packages are monomorphic for functions like (but not limited to) `filter` with a couple pain points:\r\n\r\n1. They're inconvenient to use in conjunction without aliasing (e.g. `List` vs `Array`) also noted by @aspidites in tfausak/purescript-batteries#1.\r\n2. They're inconvenient to change out collection types to compare relative performance (thus encouraging `Array` use). The primary reason is type signatures must include the specialized type instead of class.\r\n\r\nI implemented a [naive approach](http://try.purescript.org/?gist=d94ccab2e99d4d052897) (technically for `partition`) using a `Cons`-able class. @michaelficarra took the [same approach](https://github.com/michaelficarra/purescript-filterable) except with `empty` (called `zero`) instead of `singleton`. I considered that but wanted to support nonempty types. @tfausak noted (or I incorrectly inferred) `Cons`-able looks strikingly like [Clojure's `seq`](http://clojure.org/reference/sequences) and @Gabriel439 pointed to his [`Foldl` in Haskell](https://hackage.haskell.org/package/foldl-1.1.5/docs/Control-Foldl.html) for inspiration.\r\n\r\n@jdegoes suggested an [`Unfoldable`](https://pursuit.purescript.org/packages/purescript-unfoldable/0.4.1) (“refoldable”) `Foldable` along with @joneshf commenting on purescript/purescript-monoid#6 but I encountered [issues trying it](https://twitter.com/AppShipIt/status/694717112204525568). Hardy also recommended [`Witherable` in Haskell](https://hackage.haskell.org/package/witherable-0.1.3.2/docs/Data-Witherable.html) (compelling to me) and implemented a [lens-based `Cons`](https://github.com/joneshf/purescript-cons) himself.\r\n\r\n@paf31 believes the answer lies in [profunctor-lenses](https://pursuit.purescript.org/packages/purescript-profunctor-lenses/0.4.0) with examples from Hardy again in purescript/purescript#607. [On IRC](http://chrisdone.com:10001/browse/purescript?id=92973&timestamp=1430514034) with @garyb he postulated the following potential issues with a type class solution:\r\n\r\n1. Degraded performance because type class instances are currently never inlined (even when safe to do so).\r\n2. More complex type signatures because of type class constraints. I'll add to that occasionally ambiguous inference and less friendly type errors but those are also true of this package.\r\n\r\nCC:\r\n- purescript/purescript#1075\r\n- @bodil\r\n- @drboolean"},"comment":{"url":"https://api.github.com/repos/purescript/purescript-foldable-traversable/issues/comments/181042412","html_url":"https://github.com/purescript/purescript-foldable-traversable/issues/44#issuecomment-181042412","issue_url":"https://api.github.com/repos/purescript/purescript-foldable-traversable/issues/44","id":181042412,"user":{"login":"AppShipIt","id":48431,"avatar_url":"https://avatars.githubusercontent.com/u/48431?v=3","gravatar_id":"","url":"https://api.github.com/users/AppShipIt","html_url":"https://github.com/AppShipIt","followers_url":"https://api.github.com/users/AppShipIt/followers","following_url":"https://api.github.com/users/AppShipIt/following{/other_user}","gists_url":"https://api.github.com/users/AppShipIt/gists{/gist_id}","starred_url":"https://api.github.com/users/AppShipIt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AppShipIt/subscriptions","organizations_url":"https://api.github.com/users/AppShipIt/orgs","repos_url":"https://api.github.com/users/AppShipIt/repos","events_url":"https://api.github.com/users/AppShipIt/events{/privacy}","received_events_url":"https://api.github.com/users/AppShipIt/received_events","type":"User","site_admin":false},"created_at":"2016-02-07T16:25:45Z","updated_at":"2016-02-07T16:25:45Z","body":"Thanks so much for your input! It looks like a strong contender. Regarding laws I also read about their [pertinence to transducers](https://oleksandrmanzyuk.wordpress.com)."}}