{"action":"created","issue":{"url":"https://api.github.com/repos/gcanti/fp-ts/issues/512","repository_url":"https://api.github.com/repos/gcanti/fp-ts","labels_url":"https://api.github.com/repos/gcanti/fp-ts/issues/512/labels{/name}","comments_url":"https://api.github.com/repos/gcanti/fp-ts/issues/512/comments","events_url":"https://api.github.com/repos/gcanti/fp-ts/issues/512/events","html_url":"https://github.com/gcanti/fp-ts/issues/512","id":336992181,"node_id":"MDU6SXNzdWUzMzY5OTIxODE=","number":512,"title":"Suggestion: Sortable typeclass","user":{"login":"raveclassic","id":1743568,"node_id":"MDQ6VXNlcjE3NDM1Njg=","avatar_url":"https://avatars2.githubusercontent.com/u/1743568?v=4","gravatar_id":"","url":"https://api.github.com/users/raveclassic","html_url":"https://github.com/raveclassic","followers_url":"https://api.github.com/users/raveclassic/followers","following_url":"https://api.github.com/users/raveclassic/following{/other_user}","gists_url":"https://api.github.com/users/raveclassic/gists{/gist_id}","starred_url":"https://api.github.com/users/raveclassic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raveclassic/subscriptions","organizations_url":"https://api.github.com/users/raveclassic/orgs","repos_url":"https://api.github.com/users/raveclassic/repos","events_url":"https://api.github.com/users/raveclassic/events{/privacy}","received_events_url":"https://api.github.com/users/raveclassic/received_events","type":"User","site_admin":false},"labels":[{"id":561258626,"node_id":"MDU6TGFiZWw1NjEyNTg2MjY=","url":"https://api.github.com/repos/gcanti/fp-ts/labels/discussion","name":"discussion","color":"fef2c0","default":false},{"id":643650994,"node_id":"MDU6TGFiZWw2NDM2NTA5OTQ=","url":"https://api.github.com/repos/gcanti/fp-ts/labels/suggestion","name":"suggestion","color":"006b75","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-06-29T13:07:46Z","updated_at":"2018-07-02T14:06:08Z","closed_at":null,"author_association":"COLLABORATOR","body":"I'd like to suggest to introduce new typeclass `Sortable` to describe structures that can be sorted using some `Ord`. Obvious candidates are `Array`, `NonEmptyArray`, `BinaryTree` (not existent in fp-ts), `StrMap` (?).\r\n\r\nSuch typeclass would make possible generalization of `span`, `takeWhile`, `dropWhile`, `group` and others.\r\nExample:\r\n```typescript\r\nexport interface Sortable<F> {\r\n  sort: <A>(O: Ord<A>) => (fa: HKT<F, A>) => HKT<F, A>\r\n}\r\n\r\nfunction span<F>(\r\n  F: Filterable<F> & Sortable<F>\r\n): <A>(ord: Ord<A>) => (fa: HKT<F, A>, p: Predicate<A>) => Separated<HKT<F, A>, HKT<F, A>> {\r\n  return O => {\r\n    const sort = F.sort(O)\r\n    return (fa, p) => {\r\n      const sorted = sort(fa)\r\n      let collectLeft = true\r\n      return F.partition(sorted, a => {\r\n        if (collectLeft) {\r\n          if (p(a)) {\r\n            return false\r\n          }\r\n          collectLeft = true\r\n        }\r\n        return true\r\n      })\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nWhat do you think? I think this would be very handy but it should be carefully thought out.\r\n"},"comment":{"url":"https://api.github.com/repos/gcanti/fp-ts/issues/comments/401816670","html_url":"https://github.com/gcanti/fp-ts/issues/512#issuecomment-401816670","issue_url":"https://api.github.com/repos/gcanti/fp-ts/issues/512","id":401816670,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTgxNjY3MA==","user":{"login":"raveclassic","id":1743568,"node_id":"MDQ6VXNlcjE3NDM1Njg=","avatar_url":"https://avatars2.githubusercontent.com/u/1743568?v=4","gravatar_id":"","url":"https://api.github.com/users/raveclassic","html_url":"https://github.com/raveclassic","followers_url":"https://api.github.com/users/raveclassic/followers","following_url":"https://api.github.com/users/raveclassic/following{/other_user}","gists_url":"https://api.github.com/users/raveclassic/gists{/gist_id}","starred_url":"https://api.github.com/users/raveclassic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raveclassic/subscriptions","organizations_url":"https://api.github.com/users/raveclassic/orgs","repos_url":"https://api.github.com/users/raveclassic/repos","events_url":"https://api.github.com/users/raveclassic/events{/privacy}","received_events_url":"https://api.github.com/users/raveclassic/received_events","type":"User","site_admin":false},"created_at":"2018-07-02T14:06:08Z","updated_at":"2018-07-02T14:06:08Z","author_association":"COLLABORATOR","body":"Well changing `span` signature to accept `Filterable<F> & Foldable<F>` would help so that helpers in https://github.com/gcanti/fp-ts/pull/510 could be defined. @gcanti What do you think?"}}
{"actor":{"display_login":"raveclassic"}}