Merge branch 'master' into doOptimize-doProfiling

This commit is contained in:
John Wiegley 2018-11-22 08:57:09 -08:00 committed by GitHub
commit e0669ce3c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 22 deletions

View file

@ -32,6 +32,12 @@ drv = haskellPackages.developPackage {
overrides = with pkgs.haskell.lib; self: super: {
mono-traversable = dontCheck super.mono-traversable;
megaparsec = self.callCabal2nix "megaparsec" (pkgs.fetchFromGitHub {
owner = "mrkkrp";
repo = "megaparsec";
rev = "9fff501f7794c01e2cf4a7a492f1cfef67fab19a";
sha256 = "0a9g6gpc8m9qrvldwn4chs0yqnr4dps93achg1df72lxknrpp0iy";
}) {};
}
//
(if compiler == "ghc802"

View file

@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: bd9c8bad70af6e6bdc23b53988448061d7ab6aaee6054beb9d0f696e717f8a3c
-- hash: 01a6c3bc4e7f71ac6b77c5b00cad1822a2b855928e68f33b68cdb5e549f7cd5d
name: hnix
version: 0.5.2
@ -506,10 +506,11 @@ library
, interpolate
, lens-family-th
, logict
, megaparsec >=6.5 && <7.0
, megaparsec >=7.0 && <7.1
, monadlist
, mtl
, optparse-applicative
, parser-combinators
, prettyprinter
, process
, ref-tf

View file

@ -109,9 +109,10 @@ library:
- interpolate
- lens-family-th
- logict
- megaparsec >= 6.5 && < 7.0
- megaparsec >= 7.0 && < 7.1
- monadlist
- prettyprinter
- parser-combinators
- process
- regex-tdfa
- regex-tdfa-text

View file

@ -51,6 +51,7 @@ import Prelude hiding (readFile)
import Control.Applicative hiding (many, some)
import Control.DeepSeq
import Control.Monad
import Control.Monad.Combinators.Expr
import Data.Char (isAlpha, isDigit, isSpace)
import Data.Data (Data(..))
import Data.Foldable (concat)
@ -74,7 +75,6 @@ import Nix.Strings
import Text.Megaparsec
import Text.Megaparsec.Char
import qualified Text.Megaparsec.Char.Lexer as L
import Text.Megaparsec.Expr
infixl 3 <+>
(<+>) :: MonadPlus m => m a -> m a -> m a
@ -284,9 +284,9 @@ nixString' = lexeme (doubleQuoted <+> indented <?> "string")
<+> Plain . pack <$> some plainChar
where
plainChar =
notFollowedBy (end <+> void (char '$') <+> escStart) *> anyChar
notFollowedBy (end <+> void (char '$') <+> escStart) *> anySingle
escapeCode = msum [ c <$ char e | (c,e) <- escapeCodes ] <+> anyChar
escapeCode = msum [ c <$ char e | (c,e) <- escapeCodes ] <+> anySingle
-- | Gets all of the arguments for a function.
argExpr :: Parser (Params NExprLoc)
@ -338,11 +338,11 @@ nixBinders = (inherit <+> namedVar) `endBy` semi where
-- We can't use 'reserved' here because it would consume the whitespace
-- after the keyword, which is not exactly the semantics of C++ Nix.
try $ string "inherit" *> lookAhead (void (satisfy reservedEnd))
p <- getPosition
p <- getSourcePos
x <- whiteSpace *> optional scope
Inherit x <$> many keyName <*> pure p <?> "inherited binding"
namedVar = do
p <- getPosition
p <- getSourcePos
NamedVar <$> (annotated <$> nixSelector)
<*> (equals *> nixToplevelForm)
<*> pure p
@ -444,12 +444,12 @@ data Result a = Success a | Failure (Doc Void) deriving (Show, Functor)
parseFromFileEx :: MonadFile m => Parser a -> FilePath -> m (Result a)
parseFromFileEx p path = do
txt <- decodeUtf8 <$> readFile path
return $ either (Failure . pretty . parseErrorPretty' txt) Success
return $ either (Failure . pretty . errorBundlePretty) Success
$ parse p path txt
parseFromText :: Parser a -> Text -> Result a
parseFromText p txt =
either (Failure . pretty . parseErrorPretty' txt) Success $
either (Failure . pretty . errorBundlePretty) Success $
parse p "<string>" txt
{- Parser.Operators -}
@ -468,9 +468,9 @@ data NOperatorDef
annotateLocation :: Parser a -> Parser (Ann SrcSpan a)
annotateLocation p = do
begin <- getPosition
begin <- getSourcePos
res <- p
end <- getPosition
end <- getSourcePos
pure $ Ann (SrcSpan begin end) res
annotateLocation1 :: Parser (NExprF NExprLoc) -> Parser NExprLoc

View file

@ -65,15 +65,11 @@ instance MonadFile IO where
doesDirectoryExist = S.doesDirectoryExist
getSymbolicLinkStatus = S.getSymbolicLinkStatus
posAndMsg :: SourcePos -> Doc a-> ParseError t Void
posAndMsg beg msg =
FancyError (beg :| [])
posAndMsg :: SourcePos -> Doc a -> ParseError s Void
posAndMsg (SourcePos _ lineNo _) msg =
FancyError (unPos lineNo)
(Set.fromList [ErrorFail (show msg) :: ErrorFancy Void])
renderLocation :: MonadFile m => SrcSpan -> Doc a -> m (Doc a)
renderLocation (SrcSpan beg@(SourcePos "<string>" _ _) _) msg =
return $ pretty $ init $ parseErrorPretty @Char (posAndMsg beg msg)
renderLocation (SrcSpan beg@(SourcePos path _ _) _) msg = do
contents <- Nix.Render.readFile path
return $ pretty $ init $ parseErrorPretty' contents (posAndMsg beg msg)
renderLocation :: Monad m => SrcSpan -> Doc a -> m (Doc a)
renderLocation (SrcSpan beg@(SourcePos _ _ _) _) msg =
return $ pretty $ init $ parseErrorPretty @String (posAndMsg beg msg)