Skip to content

Commit

Permalink
#167 rename (prec -> prev) & (dupe -> dup) (#185)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Cmdv authored and vrom911 committed Sep 13, 2019
1 parent a6e670f commit 50ed105
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion hlint/hlint.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/Relude/Extra/Enum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Relude.Extra.Enum
( universe
, inverseMap
, next
, prec
, prev
, safeToEnum
) where

Expand Down Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions src/Relude/Extra/Tuple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Contains utility functions for working with tuples.
-}

module Relude.Extra.Tuple
( dupe
( dup
, mapToFst
, mapToSnd
, mapBoth
Expand All @@ -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.
Expand Down

0 comments on commit 50ed105

Please sign in to comment.