Conversation
joneshf
left a comment
There was a problem hiding this comment.
Wooo!!! Had a quick question about naming.
| @@ -0,0 +1,10 @@ | |||
| let Applicative = ./../Applicative/Type | |||
There was a problem hiding this comment.
Should this (and the other similar expressions) be suffixed with Optional instead of Maybe: i.e. apOptional?
There was a problem hiding this comment.
You are completely right. Was looking at the Haskell stuff 🙈
sellout
left a comment
There was a problem hiding this comment.
This looks great. I don’t have much opinion on the repetition stuff at the moment. But I think you need to merge in master to grab the circle config and get a green build.
|
@sellout I don't think that's the CI issue.
Looks like we don't have credits for this? |
| in λ(f : Type → Type) | ||
| → { mapOptional : | ||
| ∀(a : Type) → ∀(b : Type) → (a → Optional b) → f a → f b | ||
| , mapEither : |
There was a problem hiding this comment.
What's the motivation behind removing mapEither? If it's about having one function to implement, we can derive mapOptional from mapEither, but we cannot derive mapEither from mapOptional. In that sense, it seems better to keep mapEither and have mapOptional be a derived function. Is there a different reason to remove mapEither?
There was a problem hiding this comment.
I was wrong, you did derive mapEither! Forget I said anything.
There was a problem hiding this comment.
We can derive mapEither from mapOptional it's here :) The motivation was that mapOptional is the canonical function when thinking about this class in terms of categories: Compactable f === KleisliFunctor Optional f where kmap :: (a -> m b) -> f a -> f b is specialised to (a -> Optional b) -> f a -> f b i.e. mapOptional 🎉!
This will make future integration with catewaul easier :)
There was a problem hiding this comment.
Heh! I wrote my response before I saw the next comment 😄
|
Ah, well the previous failure was due to no CI config. This new one seems … wrong. This is an OSS project, I thought those wouldn’t require “credits”? |
|
Yeh I've no idea, should we ask ops? |
| @@ -0,0 +1,49 @@ | |||
| {- | |||
|
|
|||
| mapEither maps a function to Either over the `f` and `separate`s `Left`s from `Right`s. | |||
There was a problem hiding this comment.
This says mapEither, but the file is separate. I would change this comment to say something like “This expression maps …” to make it less likely to get out of sync.
| ``` | ||
| let E = constructors (./Either/Type Natural Natural) | ||
|
|
||
| in ./Compactable/mapEither |
There was a problem hiding this comment.
Same here. Obviously harder to avoid the name. I guess we need like dhall-doctest now, right 😁
| @@ -0,0 +1,31 @@ | |||
| {- | |||
| mapOptional : (a -> Optional b) -> Either m a -> Either m b | |||
There was a problem hiding this comment.
I don’t think this is useful documentation, especially since this is a type class instance.
There was a problem hiding this comment.
Thanks for catching, I actually just put it there to help me implement it 😅
|
|
||
| in let E = constructors (Either Text Natural) | ||
|
|
||
| in ./Either/flipEither Text Natural (E.Left "ohno") |
There was a problem hiding this comment.
Should probably just rename this to flip. Also, it’s probably type-classable, like Bifunctor-ish?
There was a problem hiding this comment.
There was a problem hiding this comment.
I've leave it for now though and just rename to flip
There was a problem hiding this comment.
Actually, Either isn't an instance. Need to keep looking :)
There was a problem hiding this comment.
| {- | ||
|
|
||
| Compactable serves as an abstraction over filtering and partitioning, using two functions | ||
| compact and separate, respectively. |
There was a problem hiding this comment.
This makes it sound like the type class still has multiple methods. I would rewrite this to discuss mapOptional instead, and then move the other comments to the respective expressions.
| @@ -0,0 +1,30 @@ | |||
| {- | |||
| apEither maps an `f` of functions to Eithers over the `f a` and `separate`s `Left`s from `Right`s. | |||
There was a problem hiding this comment.
Get rid of apEither in the comment here.
| @@ -0,0 +1,31 @@ | |||
| {- | |||
|
|
|||
| apOptional maps a `f` of functions to Optionals over the `f` and `compact`s away the `None` values. | |||
There was a problem hiding this comment.
Get rid of “apOptional” here.
| @@ -0,0 +1,44 @@ | |||
| {- | |||
|
|
|||
| bindEither binds to a `f` of Optional over the `f a` and `separate`s `Left`s and `Right`s. | |||
There was a problem hiding this comment.
Same, etc. for other files.
| @@ -0,0 +1,23 @@ | |||
| {- | |||
|
|
|||
| mapOptional maps a function to Optionals over the `f` and `compact`s away the `None` values. | |||
There was a problem hiding this comment.
This claims to be mapOptional, but isn’t.
|
Ah crap … apparently I left a ton of comments on an old commit sigh. |
|
I guess like two of my comments are still valid 🤷🏼♂️ |
Fixes #54 cc @joneshf
Notes:
map,ap,bind,traversefunctions. @sellout you probably have some tricks here 😛