-
Notifications
You must be signed in to change notification settings - Fork 18
Expose notNull so that a _NotNull prism can be made.
#8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Data/Lens.purs
Outdated
|
|
||
| import Data.Lens (prism') | ||
| import Data.Nullable (Nullable, notNull, toMaybe) | ||
| import Data.Profunctor.Choice (class Choice) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this need to go into bower.json?
src/Data/Lens.purs
Outdated
| import Data.Profunctor.Choice (class Choice) | ||
|
|
||
| _NotNull :: forall p a. (Choice p) => p a a -> p (Nullable a) (Nullable a) | ||
| _NotNull = prism' notNull toMaybe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about making this an Iso between Nullable and Maybe. Then you can reuse _Just, and you don't need to export notNull, which I think has a slightly confusing name.
|
Quite right about the bower dependency. I've never used Iso so I'll look into that. |
|
Bump |
|
Is this the kind of thing you were thinking? The Prism can be defined separately in terms of |
|
Sorry I'm not following, if |
Yes please. Something like import Data.Profunctor
isoToMaybe :: forall p a b. Profunctor p => p (Nullable a) (Nullable b) -> p (Maybe a) (Maybe b)
isoToMaybe = dimap toNullable toMaybe By using |
|
Since this is now a bit different from the proposal, I'll close it and make an issue instead. Thanks anyway! |
I was trying to construct a prism for Nullable JS data and exposing
notNullseemed the most straightforward way to get the right type. This also give future users a prism to use.