Skip to content

Commit

Permalink
[#460] Use relude-0.7.0.0 (#462)
Browse files Browse the repository at this point in the history
* [#460] Use relude-0.7.0.0

Resolves #460

* Fix stack, update HLint rules
  • Loading branch information
vrom911 authored May 21, 2020
1 parent 73da3ae commit ff247ad
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ matrix:

install:
# HLint
- curl https://raw.githubusercontent.com/kowainik/relude/v0.6.0.0/.hlint.yaml -o .hlint-relude.yaml
- curl https://raw.githubusercontent.com/kowainik/relude/v0.7.0.0/.hlint.yaml -o .hlint-relude.yaml
- curl -sSL https://raw.github.com/ndmitchell/neil/master/misc/travis.sh | sh -s -- hlint -h .hlint-relude.yaml summoner-cli/src/ summoner-cli/test/ summoner-cli/app/ summoner-tui/src/ summoner-tui/app/

# install stack and build project
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ The changelog is available [on GitHub][2].

* [#459](https://github.com/kowainik/summoner/issues/459):
Bump up `tomland` version to `1.3.0.0`.
* [#460](https://github.com/kowainik/summoner/issues/460):
Bump up `relude` version to `0.7.0.0`.
Remove `Summoner.Template.Mempty` as `memptyIfFalse` is imported from
`Relude`.
* [#455](https://github.com/kowainik/summoner/issues/455):
Allow `validation-selective` version `0.1.0.0`.
* [#452](https://github.com/kowainik/summoner/issues/452):
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ extra-deps:
- colourista-0.1.0.0
- generic-data-0.8.0.0
- hspec-hedgehog-0.0.1.1
- relude-0.7.0.0
- tomland-1.3.0.0
- validation-selective-0.1.0.0
8 changes: 5 additions & 3 deletions summoner-cli/src/Summoner/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ module Summoner.Project

import Colourista (bold, errorMessage, formattedMessage, green, infoMessage, skipMessage,
successMessage, warningMessage)
import Data.List.NonEmpty ((<|))
import NeatInterpolation (text)
import Relude.Extra.Enum (universe)
import Relude.Extra.Enum (universe, universeNonEmpty)
import Shellmet (($?))
import System.Directory (findExecutable, setCurrentDirectory)

Expand All @@ -38,10 +39,11 @@ import Summoner.Question (YesNoPrompt (..), checkUniqueName, choose, doesExistPr
import Summoner.Settings (Settings (..))
import Summoner.Source (fetchSources)
import Summoner.Template (createProjectTemplate)
import Summoner.Template.Mempty (memptyIfFalse)
import Summoner.Text (intercalateMap, moduleNameValid, packageNameValid, packageToModule)
import Summoner.Tree (showBoldTree, traverseTree)

import qualified Data.List.NonEmpty as NE


-- | Generate the project.
generateProject
Expand Down Expand Up @@ -76,7 +78,7 @@ generateProjectInteractive connectMode projectName ConfigP{..} = do
putText licenseText
settingsLicenseName <- if isOffline connectMode
then NONE <$ infoMessage "'NONE' license is used in offline mode"
else choose parseLicenseName "License: " $ ordNub (cLicense : universe)
else choose parseLicenseName "License: " $ NE.nub (cLicense <| universeNonEmpty)

-- License creation
settingsYear <- currentYear
Expand Down
16 changes: 8 additions & 8 deletions summoner-cli/src/Summoner/Question.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import System.IO (hFlush)
import Summoner.Text (headToUpper, intercalateMap)

import qualified Data.Text as T
import qualified Relude.Unsafe as Unsafe


{- HLINT ignore "Redundant multi-way if" -}
Expand Down Expand Up @@ -130,22 +129,23 @@ printQuestion question (def:rest) = do
choose :: Show a
=> (Text -> Maybe a) -- ^ Parse function
-> Text -- ^ Question text.
-> [a] -- ^ List of available options.
-> NonEmpty a -- ^ List of available options.
-> IO a -- ^ The chosen option.
choose parser question choices = do
let showChoices = map show choices
let showChoices = map show $ toList choices
printQuestion question showChoices
answer <- prompt
if T.null answer
then pure (Unsafe.head choices)
then pure (head choices)
else whenNothing (parser answer)
(errorMessage "This wasn't a valid choice." >> choose parser question choices)

-- | Like 'choose' but the possible answer are 'Y' or 'N'.
chooseYesNo :: YesNoPrompt -- ^ Target and Prompt
-> IO a -- ^ action for 'Y' answer
-> IO a -- ^ action for 'N' answer
-> IO a
chooseYesNo
:: YesNoPrompt -- ^ Target and Prompt
-> IO a -- ^ action for 'Y' answer
-> IO a -- ^ action for 'N' answer
-> IO a
chooseYesNo p@YesNoPrompt {..} yesDo noDo = do
printQuestion yesNoPrompt ["y", "n"]
answer <- yesOrNo <$> prompt
Expand Down
1 change: 0 additions & 1 deletion summoner-cli/src/Summoner/Template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Summoner.Template.Cabal (cabalFile)
import Summoner.Template.Doc (docFiles)
import Summoner.Template.GitHub (gitHubFiles)
import Summoner.Template.Haskell (haskellFiles)
import Summoner.Template.Mempty (memptyIfFalse)
import Summoner.Template.Stack (stackFiles)
import Summoner.Tree (TreeFs (..), insertTree)

Expand Down
1 change: 0 additions & 1 deletion summoner-cli/src/Summoner/Template/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Summoner.Default (defaultCabal)
import Summoner.GhcVer (cabalBaseVersions, showGhcVer)
import Summoner.License (LicenseName (..))
import Summoner.Settings (Settings (..))
import Summoner.Template.Mempty (memptyIfFalse)
import Summoner.Text (endLine, intercalateMap, packageToModule)
import Summoner.Tree (TreeFs (..))

Expand Down
1 change: 0 additions & 1 deletion summoner-cli/src/Summoner/Template/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import NeatInterpolation (text)
import Summoner.Default (defaultCabal, defaultGHC)
import Summoner.GhcVer (GhcVer (..), oldGhcs, showGhcVer)
import Summoner.Settings (Settings (..))
import Summoner.Template.Mempty (memptyIfFalse)
import Summoner.Text (endLine, intercalateMap, tconcatMap)
import Summoner.Tree (TreeFs (..))

Expand Down
18 changes: 0 additions & 18 deletions summoner-cli/src/Summoner/Template/Mempty.hs

This file was deleted.

4 changes: 1 addition & 3 deletions summoner-cli/summoner.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ source-repository head

common common-options
build-depends: base >= 4.11 && < 4.14
, relude ^>= 0.6.0.0
, relude ^>= 0.7.0.0

mixins: base hiding (Prelude)
, relude (Relude as Prelude
, Relude.Extra.Enum
, Relude.Unsafe
)

ghc-options: -Wall
Expand Down Expand Up @@ -129,7 +128,6 @@ library
Summoner.Template.Doc
Summoner.Template.GitHub
Summoner.Template.Haskell
Summoner.Template.Mempty
Summoner.Template.Script
Summoner.Template.Stack
Summoner.Text
Expand Down
2 changes: 1 addition & 1 deletion summoner-tui/summoner-tui.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ source-repository head

common common-options
build-depends: base >= 4.11 && < 4.14
, relude ^>= 0.6.0.0
, relude ^>= 0.7.0.0

mixins: base hiding (Prelude)
, relude (Relude as Prelude
Expand Down

0 comments on commit ff247ad

Please sign in to comment.