Conversation
paf31
reviewed
Oct 17, 2016
| @@ -27,15 +28,11 @@ toArray :: FormURLEncoded -> Array (Tuple String (Maybe String)) | |||
| toArray (FormURLEncoded a) = a | |||
There was a problem hiding this comment.
These could be replaced with a Newtype instance now.
Contributor
Author
There was a problem hiding this comment.
I think we should add a Newtype instance, but still have monophonic functions.
I think Newtype is very nice with it's higher-order combinators (e.g. over MyNewType f vs MyNewtype <<< f <<< runNewType), and possibility for abstracting over newtypes (e.g. StrMap with polymorphic functions forall key. Newtype key String).
However for simple construction/deconstruction I think I'll often be preferring plain functions:
- they make mistakes more wrong looking, in order to construct/deconstruct a type you have to somehow mention it's name, either directly in a function name (
runNewtype) or through qualified import (MyNewType.fromArray). - they are more interference-friendly
(serialize $ MyNewType.fromArray [...]vsserialize (wrap [ ... ] :: MyNewType)whereserialize :: Serializable a => a -> String.
Since we expose the newtype internals through the `Newtype` instance it makes sense to expose the constructor too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.