Skip to content

Updates related to psc-0.10 #5

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

Merged
merged 6 commits into from
Oct 27, 2016
Merged

Updates related to psc-0.10 #5

merged 6 commits into from
Oct 27, 2016

Conversation

zudov
Copy link
Contributor

@zudov zudov commented Oct 17, 2016

No description provided.

@@ -27,15 +28,11 @@ toArray :: FormURLEncoded -> Array (Tuple String (Maybe String))
toArray (FormURLEncoded a) = a
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be replaced with a Newtype instance now.

Copy link
Contributor Author

@zudov zudov Oct 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 [...] vs serialize (wrap [ ... ] :: MyNewType) where serialize :: Serializable a => a -> String.

zudov added 2 commits October 18, 2016 23:26
Since we expose the newtype internals through the `Newtype` instance it
makes sense to expose the constructor too.
@zudov zudov merged commit 1f75bde into master Oct 27, 2016
@zudov zudov deleted the psc-0.10 branch October 27, 2016 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants