Skip to content

Derive newtype instances where possible #166

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ New features:
Bugfixes:

Other improvements:
- Derive `newtype` instances where possible (#166 by @mhmdanas)
- Redefine `Data.String.NonEmpty.CodeUnits.fromFoldable1` in terms of `singleton` (#168 by @postsolar)

## [v6.0.1](https://github.com/purescript/purescript-strings/releases/tag/v6.0.1) - 2022-08-16
Expand Down
4 changes: 2 additions & 2 deletions src/Data/String/CodePoints.purs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import Data.Unfoldable (unfoldr)
-- | Unicode code points.
newtype CodePoint = CodePoint Int

derive instance eqCodePoint :: Eq CodePoint
derive instance ordCodePoint :: Ord CodePoint
derive newtype instance eqCodePoint :: Eq CodePoint
derive newtype instance ordCodePoint :: Ord CodePoint

instance showCodePoint :: Show CodePoint where
show (CodePoint i) = "(CodePoint 0x" <> toUpper (toStringAs hexadecimal i) <> ")"
Expand Down
8 changes: 4 additions & 4 deletions src/Data/String/Pattern.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import Data.Newtype (class Newtype)
-- |
newtype Pattern = Pattern String

derive instance eqPattern :: Eq Pattern
derive instance ordPattern :: Ord Pattern
derive newtype instance eqPattern :: Eq Pattern
derive newtype instance ordPattern :: Ord Pattern
derive instance newtypePattern :: Newtype Pattern _

instance showPattern :: Show Pattern where
Expand All @@ -25,8 +25,8 @@ instance showPattern :: Show Pattern where
-- | A newtype used in cases to specify a replacement for a pattern.
newtype Replacement = Replacement String

derive instance eqReplacement :: Eq Replacement
derive instance ordReplacement :: Ord Replacement
derive newtype instance eqReplacement :: Eq Replacement
derive newtype instance ordReplacement :: Ord Replacement
derive instance newtypeReplacement :: Newtype Replacement _

instance showReplacement :: Show Replacement where
Expand Down