From 50ed105815b705856598f4489914402dd6343668 Mon Sep 17 00:00:00 2001 From: Vincent Orr Date: Fri, 13 Sep 2019 08:35:38 +0100 Subject: [PATCH] #167 rename (prec -> prev) & (dupe -> dup) (#185) * Rename `prec` to `prev` in Relude.Extra.Enum * rename `dupe` to `dup` in Relude.Extra.Tuple * add CHANGELOG and rename in prec in .hlint.yaml * remove prec/prec from hlint * regenerate .hlint.yaml * stray word in Changelog --- .hlint.yaml | 4 ++-- CHANGELOG.md | 2 ++ CONTRIBUTING.md | 10 +++++----- hlint/hlint.dhall | 2 +- src/Relude/Extra/Enum.hs | 12 ++++++------ src/Relude/Extra/Tuple.hs | 12 ++++++------ 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index a9d3b5c3..4e5396d8 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -3045,8 +3045,8 @@ - hint: lhs: pred note: '`pred` from `Prelude` is a pure function but it may throw exception. Consider - using `prec` from `Relude.Extra.Enum` instead.' - rhs: prec + using `prev` from `Relude.Extra.Enum` instead.' + rhs: prev - hint: lhs: toEnum note: '`toEnum` from `Prelude` is a pure function but it may throw exception. diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b31ee7e..e758afcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The changelog is available [on GitHub][2]. ## Unreleased: 0.6.0.0 +* [#167](https://github.com/kowainik/relude/issues/167): + Rename functions `prec`/`prev`, `dupe`/`dup`. * [#155](https://github.com/kowainik/relude/issues/155): Implement `Relude.Extra.Foldable` module. * Re-export `GHC.Float.atan2`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 086a5103..00922fd0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,25 +19,25 @@ to tell about your intention to work on something under the corresponding issue, so everyone is aware that you're on it. If there's no such issue — simply create a new one! -To get started with the Pull Request implementation you should first +To get started with the Pull Request implementation you should first [fork](../../fork), then clone the repo: git clone git@github.com:your-username/project-name.git -Make your changes and consider the following checklist to go through +Make your changes and consider the following checklist to go through before submitting your pull request. ### :white_check_mark: Check list - [ ] New/fixed features work as expected (Bonus points for the new tests). - [ ] There are no warnings during compilation. - [ ] `hlint .` output is: _No Hints_ (see [`hlint`][hlint] tool docs). -- [ ] The code is formatted with the [`stylish-haskell`][stylish-tool] tool +- [ ] The code is formatted with the [`stylish-haskell`][stylish-tool] tool using [stylish-haskell.yaml][stylish] file in the repository. -- [ ] The code style of the files you changed is preserved (for more specific +- [ ] The code style of the files you changed is preserved (for more specific details on our style guide check [this document][style-guide]). - [ ] Commit messages are in the proper format. Start the first line of the commit with the issue number in square parentheses. - + **_Example:_** `[#42] Upgrade upper bounds of 'base'` After all above is done commit and push to your fork. diff --git a/hlint/hlint.dhall b/hlint/hlint.dhall index 07f70aac..e773a5d1 100644 --- a/hlint/hlint.dhall +++ b/hlint/hlint.dhall @@ -901,7 +901,7 @@ in [ Rule.Arguments { arguments = -- Enum , hintNote "[minBound .. maxBound]" "universe" "Use `universe` from `Relude.Extra.Enum`" , hintNote "succ" "next" "`succ` from `Prelude` is a pure function but it may throw exception. Consider using `next` from `Relude.Extra.Enum` instead." - , hintNote "pred" "prec" "`pred` from `Prelude` is a pure function but it may throw exception. Consider using `prec` from `Relude.Extra.Enum` instead." + , hintNote "pred" "prev" "`pred` from `Prelude` is a pure function but it may throw exception. Consider using `prev` from `Relude.Extra.Enum` instead." , hintNote "toEnum" "safeToEnum" "`toEnum` from `Prelude` is a pure function but it may throw exception. Consider using `safeToEnum` from `Relude.Extra.Enum` instead." -- Tuple diff --git a/src/Relude/Extra/Enum.hs b/src/Relude/Extra/Enum.hs index c70dc0b0..152a4443 100644 --- a/src/Relude/Extra/Enum.hs +++ b/src/Relude/Extra/Enum.hs @@ -13,7 +13,7 @@ module Relude.Extra.Enum ( universe , inverseMap , next - , prec + , prev , safeToEnum ) where @@ -81,18 +81,18 @@ next e {- | Like 'pred', but doesn't fail on 'minBound'. Instead it returns 'maxBound'. ->>> prec False +>>> prev False True ->>> prec True +>>> prev True False >>> pred False *** Exception: Prelude.Enum.Bool.pred: bad argument -} -prec :: (Eq a, Bounded a, Enum a) => a -> a -prec e +prev :: (Eq a, Bounded a, Enum a) => a -> a +prev e | e == minBound = maxBound | otherwise = pred e -{-# INLINE prec #-} +{-# INLINE prev #-} {- | Returns 'Nothing' if given 'Int' outside range. diff --git a/src/Relude/Extra/Tuple.hs b/src/Relude/Extra/Tuple.hs index bacc2c96..7850f8e6 100644 --- a/src/Relude/Extra/Tuple.hs +++ b/src/Relude/Extra/Tuple.hs @@ -9,7 +9,7 @@ Contains utility functions for working with tuples. -} module Relude.Extra.Tuple - ( dupe + ( dup , mapToFst , mapToSnd , mapBoth @@ -23,14 +23,14 @@ import Relude {- | Creates a tuple by pairing something with itself. ->>> dupe "foo" +>>> dup "foo" ("foo","foo") ->>> dupe () +>>> dup () ((),()) -} -dupe :: a -> (a, a) -dupe a = (a, a) -{-# INLINE dupe #-} +dup :: a -> (a, a) +dup a = (a, a) +{-# INLINE dup #-} {- | Apply a function, with the result in the fst slot, and the value in the other.