Merge branch 'pending'

This commit is contained in:
John Wiegley 2019-03-09 11:39:19 -08:00
commit 07e6a5a381
No known key found for this signature in database
GPG key ID: C144D8F4F19FE630
5 changed files with 66 additions and 23 deletions

View file

@ -15,8 +15,8 @@ env:
- secure: "dm6I+M4+V+C7QMTpcSADdKPE633SvmToXZrTbZ7miNDGmMN+/SfHeN2ybi1+PW6oViMlbPN/7J/aEfiGjSJI8vLk72Y4uCWGmpSb8TXZLu6+whnxtZzzW8+z4tsM4048QJg7CF3N/25U8thRFgs3DqUub1Sf3nG9LrNWdz6ZcDQ="
matrix:
- GHCVERSION=ghc844 STRICT=false TRACING=false
- GHCVERSION=ghc844 STRICT=false TRACING=true
- GHCVERSION=ghc863 STRICT=false TRACING=false
- GHCVERSION=ghc863 STRICT=false TRACING=true
# - GHCVERSION=ghcjs
#
# matrix:

View file

@ -1,4 +1,4 @@
{ compiler ? "ghc844"
{ compiler ? "ghc863"
, doBenchmark ? false
, doTracing ? false
@ -6,8 +6,10 @@
, doProfiling ? false # enables profiling support in GHC
, doStrict ? false
, rev ? "3f3f6021593070330091a4a2bc785f6761bbb3c1"
, sha256 ? "1a7vvxxz8phff51vwsrdlsq5i70ig5hxvvb7lkm2lgwizgvpa6gv"
, withHoogle ? false
, rev ? "120eab94e0981758a1c928ff81229cd802053158"
, sha256 ? "0qk6k8gxx5xlkyg05dljywj5wx5fvrc3dzp4v2h6ab83b7zwg813"
, pkgs ?
if builtins.compareVersions builtins.nixVersion "2.0" < 0
@ -31,23 +33,27 @@ drv = haskellPackages.developPackage {
overrides = with pkgs.haskell.lib; self: super: {
mono-traversable = dontCheck super.mono-traversable;
megaparsec = super.megaparsec_7_0_4;
};
these = doJailbreak super.these;
} //
(if withHoogle then {
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
ghcWithPackages = self.ghc.withPackages;
} else {});
source-overrides = {};
modifier = drv: pkgs.haskell.lib.overrideCabal drv (attrs: {
buildTools = (attrs.buildTools or []) ++ [
pkgs.haskell.packages.${compiler}.cabal-install
haskellPackages.cabal-install
];
enableLibraryProfiling = doProfiling;
enableExecutableProfiling = doProfiling;
testHaskellDepends = attrs.testHaskellDepends ++
[ pkgs.nix
pkgs.haskell.packages.ghc844.criterion
];
testHaskellDepends = attrs.testHaskellDepends ++ [
pkgs.nix
haskellPackages.criterion
];
inherit doBenchmark;
@ -56,9 +62,7 @@ drv = haskellPackages.developPackage {
++ pkgs.stdenv.lib.optional doOptimize "--flags=optimize"
++ pkgs.stdenv.lib.optional doStrict "--ghc-options=-Werror";
passthru = {
nixpkgs = pkgs;
};
passthru = { nixpkgs = pkgs; };
});
inherit returnShellEnv;

View file

@ -548,9 +548,9 @@ library
build-depends:
lens-family >=1.2.2
, lens-family-core >=1.2.2
if impl(ghc < 8.4.0) && !flag(profiling)
build-depends:
ghc-datasize
-- if impl(ghc < 8.4.0) && !flag(profiling)
-- build-depends:
-- ghc-datasize
if impl(ghcjs)
build-depends:
hashable >=1.2.4 && <1.3

View file

@ -7,6 +7,7 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
module Nix.Render where
@ -16,13 +17,16 @@ import Control.Monad.Trans
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Text.Prettyprint.Doc
import Data.Void
import Debug.Trace
import Nix.Expr.Types.Annotated
import qualified System.Posix.Files as S
import qualified System.Directory as S
import qualified System.Posix.Files as S
import Text.Megaparsec.Error
import Text.Megaparsec.Pos (SourcePos(..))
import Text.Megaparsec.Pos
class Monad m => MonadFile m where
readFile :: FilePath -> m ByteString
@ -69,6 +73,39 @@ posAndMsg (SourcePos _ lineNo _) msg =
FancyError (unPos lineNo)
(Set.fromList [ErrorFail (show msg) :: ErrorFancy Void])
renderLocation :: Monad m => SrcSpan -> Doc a -> m (Doc a)
renderLocation (SrcSpan beg@(SourcePos _ _ _) _) msg =
return $ pretty $ init $ parseErrorPretty @String (posAndMsg beg msg)
renderLocation :: MonadFile m => SrcSpan -> Doc a -> m (Doc a)
renderLocation (SrcSpan (SourcePos file begLine begCol)
(SourcePos file' endLine endCol)) msg
| file /= "<string>" && file == file' = do
exist <- doesFileExist file
if exist
then do
txt <- sourceContext file begLine begCol endLine endCol msg
return $ vsep
[ "In file " <> errorContext file begLine begCol endLine endCol <> ":"
, txt
]
else return msg
renderLocation (SrcSpan beg end) msg =
fail $ "Don't know how to render range from " ++ show beg ++ " to " ++ show end
++ " for error: " ++ show msg
errorContext :: FilePath -> Pos -> Pos -> Pos -> Pos -> Doc a
errorContext path bl bc _el _ec =
pretty path <> ":" <> pretty (unPos bl) <> ":" <> pretty (unPos bc)
sourceContext :: MonadFile m => FilePath -> Pos -> Pos -> Pos -> Pos -> Doc a -> m (Doc a)
sourceContext path (unPos -> begLine) (unPos -> begCol)
(unPos -> endLine) (unPos -> endCol) msg = do
traceM $ "Taking lines from " ++ path
traceM $ "begLine = " ++ show begLine
traceM $ "begCol = " ++ show begCol
traceM $ "endLine = " ++ show endLine
traceM $ "endCol = " ++ show endCol
traceM $ "msg = " ++ show msg
ls <- take (endLine - begLine)
. drop (pred begLine)
. T.lines
. T.decodeUtf8
<$> readFile path
pure $ vsep $ map pretty ls

View file

@ -16,6 +16,8 @@
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Nix.Thunk where
import Control.Exception hiding (catch)