Skip to content
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

Switch to relude; clean-up; some String -> Text migration work #890

Merged
merged 6 commits into from
Mar 21, 2021
Merged
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
5 changes: 3 additions & 2 deletions .github/workflows/Optional-Nix-dev-env-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ jobs:


build20:
name: "GHC 8.10, strict quality build, SDist, Optimizations, Benchmark, Haddock, Completions"
# name: "GHC 8.10, strict quality build, SDist, Optimizations, Benchmark, Haddock, Completions"
name: "GHC 8.10, SDist, Optimizations, Benchmark, Haddock, Completions"
runs-on: ubuntu-latest
continue-on-error: true
steps:
Expand All @@ -104,7 +105,7 @@ jobs:
env:
compiler: "ghc8103"
buildFromSdist: "true"
buildStrictly: "true"
buildStrictly: "false"
linkWithGold: "true"
doHaddock: "true"
doHyperlinkSource: "true"
Expand Down
32 changes: 30 additions & 2 deletions hnix.cabal
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cabal-version: 2.2
name: hnix
version: 0.12.0.1
synopsis: Haskell implementation of the Nix language
Expand All @@ -7,10 +8,9 @@ homepage: https://github.com/haskell-nix/hnix#readme
bug-reports: https://github.com/haskell-nix/hnix/issues
author: John Wiegley
maintainer: [email protected]
license: BSD3
license: BSD-3-Clause
license-file: License
build-type: Simple
cabal-version: >= 1.10
data-dir: data/
data-files:
nix/corepkgs/buildenv.nix
Expand Down Expand Up @@ -393,6 +393,10 @@ library
Paths_hnix
hs-source-dirs:
src
mixins:
base hiding (Prelude)
, relude
, relude (Relude as Prelude)
ghc-options: -Wall -fprint-potential-instances
build-depends:
aeson >= 1.4.2 && < 1.6
Expand Down Expand Up @@ -432,6 +436,7 @@ library
, process >= 1.6.3 && < 1.7
, ref-tf >= 0.4.0 && <= 0.4.0.2
, regex-tdfa >= 1.2.3 && < 1.4
, relude
, scientific >= 0.3.6 && < 0.4
, semialign >= 1 && < 1.2
, semialign-indexed >= 1 && < 1.2
Expand All @@ -448,6 +453,8 @@ library
, unordered-containers >= 0.2.9 && < 0.3
, vector >= 0.12.0 && < 0.13
, xml >= 1.3.14 && < 1.4
default-extensions:
OverloadedStrings
if flag(optimize)
default-extensions:
ApplicativeDo
Expand Down Expand Up @@ -491,13 +498,20 @@ executable hnix
, pretty-show
, prettyprinter
, ref-tf
, relude
, repline >= 0.4.0.0 && < 0.5
, serialise
, template-haskell
, text
, time
, transformers
, unordered-containers
mixins:
base hiding (Prelude)
, relude
, relude (Relude as Prelude)
default-extensions:
OverloadedStrings
if flag(optimize)
default-extensions:
ApplicativeDo
Expand All @@ -522,6 +536,10 @@ test-suite hnix-tests
ReduceExprTests
TestCommon
Paths_hnix
mixins:
base hiding (Prelude)
, relude
, relude (Relude as Prelude)
hs-source-dirs:
tests
ghc-options: -Wall -threaded
Expand All @@ -546,6 +564,7 @@ test-suite hnix-tests
, pretty-show
, prettyprinter
, process
, relude
, split
, tasty
, tasty-hedgehog
Expand All @@ -558,6 +577,8 @@ test-suite hnix-tests
, transformers
, unix
, unordered-containers
default-extensions:
OverloadedStrings
if flag(optimize)
default-extensions:
ApplicativeDo
Expand All @@ -574,6 +595,10 @@ benchmark hnix-benchmarks
Paths_hnix
hs-source-dirs:
benchmarks
mixins:
base hiding (Prelude)
, relude
, relude (Relude as Prelude)
ghc-options: -Wall
build-depends:
base
Expand All @@ -588,12 +613,15 @@ benchmark hnix-benchmarks
, hnix
, mtl
, optparse-applicative
, relude
, serialise
, template-haskell
, text
, time
, transformers
, unordered-containers
default-extensions:
OverloadedStrings
if flag(optimize)
default-extensions:
ApplicativeDo
Expand Down
12 changes: 5 additions & 7 deletions main/Main.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
Expand All @@ -10,17 +9,18 @@

module Main where

import Nix.Utils
import Control.Comonad ( extract )
import qualified Control.DeepSeq as Deep
import qualified Control.Exception as Exc
import Control.Monad
import GHC.Err ( errorWithoutStackTrace )
import Control.Monad.Catch
import System.IO ( hPutStrLn, getContents )
import Control.Monad.Free
import Control.Monad.IO.Class
import qualified Data.HashMap.Lazy as M
import qualified Data.Map as Map
import Data.List ( sortOn )
import Data.Maybe ( fromJust )
import qualified Data.String as String
import Data.Time
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
Expand All @@ -34,15 +34,13 @@ import Nix.Standard
import Nix.Thunk.Basic
import qualified Nix.Type.Env as Env
import qualified Nix.Type.Infer as HM
import Nix.Utils
import Nix.Var
import Nix.Value.Monad
import Options.Applicative hiding ( ParserResult(..) )
import Prettyprinter hiding ( list )
import Prettyprinter.Render.Text
import qualified Repl
import System.FilePath
import System.IO
import qualified Text.Show.Pretty as PS

main :: IO ()
Expand All @@ -67,7 +65,7 @@ main = do
)
(\ x ->
-- We can start use Text as in the base case, requires changing FilePath -> Text
traverse_ (processFile opts) . lines =<< liftIO
traverse_ (processFile opts) . String.lines =<< liftIO
(case x of
"-" -> getContents -- get user input
_path -> readFile _path
Expand Down
14 changes: 5 additions & 9 deletions main/Repl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
Expand All @@ -32,16 +31,13 @@ import qualified Data.Maybe as Maybe
import qualified Data.HashMap.Lazy
import Data.Char ( isSpace )
import Data.List ( dropWhileEnd )
import Data.Text ( Text )
import qualified Data.String as String
import qualified Data.Text as Text
import qualified Data.Text.IO as Text.IO
import Data.Version ( showVersion )
import Paths_hnix ( version )

import Control.Monad.Catch
import Control.Monad.Identity
import Control.Monad.Reader
import Control.Monad.State.Strict

import Prettyprinter ( Doc
, space
Expand Down Expand Up @@ -116,11 +112,11 @@ main' iniVal =
(\case
((prefix:command) : xs) | prefix == commandPrefix ->
do
let arguments = unwords xs
let arguments = String.unwords xs
optMatcher command options arguments
x -> cmd $ unwords x
x -> cmd $ String.unwords x
)
(words . Text.unpack <$> Text.lines f)
(String.words . Text.unpack <$> Text.lines f)

handleMissing e
| Error.isDoesNotExistError e = pure ""
Expand Down Expand Up @@ -338,7 +334,7 @@ quit _ = liftIO Exit.exitSuccess

-- | @:set@ command
setConfig :: (MonadNix e t f m, MonadIO m) => String -> Repl e t f m ()
setConfig args = case words args of
setConfig args = case String.words args of
[] -> liftIO $ putStrLn "No option to set specified"
(x:_xs) ->
case filter ((==x) . helpSetOptionName) helpSetOptions of
Expand Down
9 changes: 2 additions & 7 deletions src/Nix.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}

Expand Down Expand Up @@ -28,12 +27,8 @@ module Nix
)
where

import Control.Applicative ( Alternative )
import Control.Arrow ( second )
import Control.Monad.Reader ( MonadIO
, asks
, (<=<)
)
import Relude.Unsafe ( (!!) )
import GHC.Err ( errorWithoutStackTrace )
import Data.Fix ( Fix )
import qualified Data.HashMap.Lazy as M
import qualified Data.Text as Text
Expand Down
10 changes: 2 additions & 8 deletions src/Nix/Atoms.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}

module Nix.Atoms where

#ifdef MIN_VERSION_serialise
import Codec.Serialise ( Serialise )
#endif

import Control.DeepSeq ( NFData )
import Data.Data ( Typeable
, Data)
import Data.Data ( Data)
import Data.Fixed ( mod' )
import Data.Hashable ( Hashable )
import Data.Text ( Text
, pack
import Data.Text ( pack
)
import GHC.Generics ( Generic )
import Data.Binary ( Binary )
import Data.Aeson.Types ( FromJSON
, ToJSON
Expand Down
Loading