dhall 1.8.0 → 1.8.1
raw patch · 9 files changed
+119/−100 lines, 9 filesdep ~prettyprinterPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: prettyprinter
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- Prelude/List/concatMap +1/−1
- Prelude/List/map +1/−1
- dhall.cabal +4/−3
- dhall/Main.hs +33/−15
- src/Dhall/Core.hs +1/−1
- src/Dhall/Import.hs +4/−2
- src/Dhall/Tutorial.hs +70/−76
- src/Dhall/TypeCheck.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,7 @@+1.8.1++* + 1.8.0 * BREAKING CHANGE TO LANGUAGE: Add support for import integrity checks
Prelude/List/concatMap view
@@ -1,5 +1,5 @@ {--Tranform a list by applying a function to each element and flattening the+Transform a list by applying a function to each element and flattening the results Examples:
Prelude/List/map view
@@ -1,5 +1,5 @@ {--Tranform a list by applying a function to each element+Transform a list by applying a function to each element Examples:
dhall.cabal view
@@ -1,5 +1,5 @@ Name: dhall-Version: 1.8.0+Version: 1.8.1 Cabal-Version: >=1.8.0.2 Build-Type: Simple Tested-With: GHC == 8.0.1@@ -8,7 +8,7 @@ Copyright: 2017 Gabriel Gonzalez Author: Gabriel Gonzalez Maintainer: Gabriel439@gmail.com-Bug-Reports: https://github.com/Gabriel439/Haskell-Dhall-Library/issues+Bug-Reports: https://github.com/dhall-lang/dhall-haskell/issues Synopsis: A configuration language guaranteed to terminate Description: Dhall is an explicitly typed configuration language that is not Turing@@ -86,7 +86,7 @@ Source-Repository head Type: git- Location: https://github.com/Gabriel439/Haskell-Dhall-Library+ Location: https://github.com/dhall-lang/dhall-haskell Library Hs-Source-Dirs: src@@ -131,6 +131,7 @@ base >= 4 && < 5 , dhall , optparse-generic >= 1.1.1 && < 1.3,+ prettyprinter , trifecta >= 1.6 && < 1.8, text >= 0.11.1.0 && < 1.3 GHC-Options: -Wall
dhall/Main.hs view
@@ -8,14 +8,13 @@ import Control.Exception (SomeException) import Control.Monad (when)-import Data.Monoid (mempty)+import Data.Monoid (mempty, (<>)) import Data.Version (showVersion)-import Dhall.Core (pretty, normalize)+import Dhall.Core (normalize) import Dhall.Import (Imported(..), load)-import Dhall.Parser (Src, exprFromText)+import Dhall.Parser (Src, exprAndHeaderFromText) import Dhall.TypeCheck (DetailedTypeError(..), TypeError) import Options.Generic (Generic, ParseRecord, type (<?>)(..))-import System.IO (stderr) import System.Exit (exitFailure, exitSuccess) import Text.Trifecta.Delta (Delta(..)) @@ -23,6 +22,9 @@ import qualified Control.Exception import qualified Data.Text.Lazy.IO+import qualified Data.Text.Prettyprint.Doc as Pretty+import qualified Data.Text.Prettyprint.Doc.Render.Text as Pretty+import qualified Dhall.Core import qualified Dhall.TypeCheck import qualified Options.Generic import qualified System.IO@@ -30,16 +32,23 @@ data Options = Options { explain :: Bool <?> "Explain error messages in more detail" , version :: Bool <?> "Display version and exit"+ , pretty :: Bool <?> "Format output" } deriving (Generic) instance ParseRecord Options +opts :: Pretty.LayoutOptions+opts =+ Pretty.defaultLayoutOptions+ { Pretty.layoutPageWidth = Pretty.AvailablePerLine 80 1.0 }+ main :: IO () main = do options <- Options.Generic.getRecord "Compiler for the Dhall language" when (unHelpful (version options)) $ do putStrLn (showVersion Meta.version) exitSuccess+ let handle = Control.Exception.handle handler2 . Control.Exception.handle handler1@@ -47,39 +56,48 @@ where handler0 e = do let _ = e :: TypeError Src- System.IO.hPutStrLn stderr ""+ System.IO.hPutStrLn System.IO.stderr "" if unHelpful (explain options) then Control.Exception.throwIO (DetailedTypeError e) else do- Data.Text.Lazy.IO.hPutStrLn stderr "\ESC[2mUse \"dhall --explain\" for detailed errors\ESC[0m"+ Data.Text.Lazy.IO.hPutStrLn System.IO.stderr "\ESC[2mUse \"dhall --explain\" for detailed errors\ESC[0m" Control.Exception.throwIO e handler1 (Imported ps e) = do let _ = e :: TypeError Src- System.IO.hPutStrLn stderr ""+ System.IO.hPutStrLn System.IO.stderr "" if unHelpful (explain options) then Control.Exception.throwIO (Imported ps (DetailedTypeError e)) else do- Data.Text.Lazy.IO.hPutStrLn stderr "\ESC[2mUse \"dhall --explain\" for detailed errors\ESC[0m"+ Data.Text.Lazy.IO.hPutStrLn System.IO.stderr "\ESC[2mUse \"dhall --explain\" for detailed errors\ESC[0m" Control.Exception.throwIO (Imported ps e) handler2 e = do let _ = e :: SomeException- System.IO.hPrint stderr e+ System.IO.hPrint System.IO.stderr e System.Exit.exitFailure handle (do inText <- Data.Text.Lazy.IO.getContents - expr <- case exprFromText (Directed "(stdin)" 0 0 0 0) inText of- Left err -> Control.Exception.throwIO err- Right expr -> return expr+ (header, expr) <- case exprAndHeaderFromText (Directed "(stdin)" 0 0 0 0) inText of+ Left err -> Control.Exception.throwIO err+ Right x -> return x + let render h e =+ if unHelpful (pretty options)+ then do+ let doc = Pretty.pretty header <> Pretty.pretty e+ Pretty.renderIO h (Pretty.layoutSmart opts doc)+ Data.Text.Lazy.IO.hPutStrLn h ""+ else do+ Data.Text.Lazy.IO.hPutStrLn h (Dhall.Core.pretty e)+ expr' <- load expr typeExpr <- case Dhall.TypeCheck.typeOf expr' of Left err -> Control.Exception.throwIO err Right typeExpr -> return typeExpr- Data.Text.Lazy.IO.hPutStrLn stderr (pretty (normalize typeExpr))- Data.Text.Lazy.IO.hPutStrLn stderr mempty- Data.Text.Lazy.IO.putStrLn (pretty (normalize expr')) )+ render System.IO.stderr (normalize typeExpr)+ Data.Text.Lazy.IO.hPutStrLn System.IO.stderr mempty+ render System.IO.stdout (normalize expr') )
src/Dhall/Core.hs view
@@ -2385,7 +2385,7 @@ , "You didn't do anything wrong, but if you would like to see this problem fixed " , "then you should report the bug at: " , " "- , "https://github.com/Gabriel439/Haskell-Dhall-Library/issues "+ , "https://github.com/dhall-lang/dhall-haskell/issues " , " " , "Please include the following text in your bug report: " , " "
src/Dhall/Import.hs view
@@ -165,6 +165,7 @@ import qualified Data.List as List import qualified Data.Map.Strict as Map import qualified Data.Text.Encoding+import qualified Data.Text.IO import qualified Data.Text.Lazy as Text import qualified Data.Text.Lazy.Builder as Builder import qualified Data.Text.Lazy.Encoding@@ -514,7 +515,7 @@ , "You didn't do anything wrong, but if you would like to see this problem fixed " , "then you should report the bug at: " , " "- , "https://github.com/Gabriel439/Haskell-Dhall-Library/issues "+ , "https://github.com/dhall-lang/dhall-haskell/issues " , " " , "Please include the following text in your bug report: " , " "@@ -607,7 +608,8 @@ Success expr -> do return expr RawText -> do- text <- Filesystem.readTextFile path+ let pathString = Filesystem.Path.CurrentOS.encodeString path+ text <- Data.Text.IO.readFile pathString return (TextLit (build text)) URL url headerPath -> do request <- HTTP.parseUrlThrow (Text.unpack url)
src/Dhall/Tutorial.hs view
@@ -1311,8 +1311,8 @@ -- complex example: -- -- > $ dhall--- > let List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map--- > in λ(f : Integer → Integer) → List/map Integer Integer f [1, 2, 3]+-- > let Prelude/List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map+-- > in λ(f : Integer → Integer) → Prelude/List/map Integer Integer f [1, 2, 3] -- > <Ctrl-D> -- > ∀(f : Integer → Integer) → List Integer -- > @@ -1611,49 +1611,43 @@ -- > <Ctrl-D> -- > List (List (List Integer)) -- > --- > ( [ ( [ ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > ]--- > : List (List Integer)--- > )--- > , ( [ ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > ]--- > : List (List Integer)--- > )--- > , ( [ ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > ]--- > : List (List Integer)--- > )--- > , ( [ ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > ]--- > : List (List Integer)--- > )--- > , ( [ ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > , ([ 1, 1, 1, 1, 1 ] : List Integer)--- > ]--- > : List (List Integer)--- > )--- > ]--- > : List (List (List Integer))--- > )+-- > [ [ [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > ]+-- > : List (List Integer)+-- > , [ [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > ]+-- > : List (List Integer)+-- > , [ [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > ]+-- > : List (List Integer)+-- > , [ [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > ]+-- > : List (List Integer)+-- > , [ [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > , [ 1, 1, 1, 1, 1 ] : List Integer+-- > ]+-- > : List (List Integer)+-- > ]+-- > : List (List (List Integer)) -- -- You can also use the formatter to modify files in place using the -- @--inplace@ flag:@@ -2276,9 +2270,9 @@ -- -- Rules: ----- > let List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat+-- > let Prelude/List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat -- >--- > List/fold a (List/concat a xss) b c+-- > List/fold a (Prelude/List/concat a xss) b c -- > = List/fold (List a) xss b (λ(x : List a) → List/fold a x b c) -- > -- > List/fold a ([] : List a) b c n = n@@ -2345,18 +2339,18 @@ -- -- Rules: ----- > let Optional/head = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/Optional/head--- > let List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat--- > let List/concatMap = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concatMap--- > let List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map+-- > let Prelude/Optional/head = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/Optional/head+-- > let Prelude/List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat+-- > let Prelude/List/concatMap = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concatMap+-- > let Prelude/List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map -- > --- > List/head a (List/concat a xss) =--- > Optional/head a (List/map (List a) (Optional a) (List/head a) xss)+-- > List/head a (Prelude/List/concat a xss) =+-- > Prelude/Optional/head a (Prelude/List/map (List a) (Optional a) (List/head a) xss) -- > -- > List/head a ([x] : List a) = [x] : Optional a -- > --- > List/head b (List/concatMap a b f m)--- > = Optional/concatMap a b (λ(x : a) → List/head b (f x)) (List/head a m)+-- > List/head b (Prelude/List/concatMap a b f m)+-- > = Prelude/Optional/concatMap a b (λ(x : a) → List/head b (f x)) (List/head a m) -- $listLast --@@ -2376,18 +2370,18 @@ -- -- Rules: ----- > let Optional/last = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/Optional/last--- > let List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat--- > let List/concatMap = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concatMap--- > let List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map+-- > let Prelude/Optional/last = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/Optional/last+-- > let Prelude/List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat+-- > let Prelude/List/concatMap = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concatMap+-- > let Prelude/List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map -- > --- > List/last a (List/concat a xss) =--- > Optional/last a (List/map (List a) (Optional a) (List/last a) xss)+-- > List/last a (Prelude/List/concat a xss) =+-- > Prelude/Optional/last a (Prelude/List/map (List a) (Optional a) (List/last a) xss) -- > -- > List/last a ([x] : List a) = [x] : Optional a -- > --- > List/last b (List/concatMap a b f m)--- > = Optional/concatMap a b (λ(x : a) → List/last b (f x)) (List/last a m)+-- > List/last b (Prelude/List/concatMap a b f m)+-- > = Prelude/Optional/concatMap a b (λ(x : a) → List/last b (f x)) (List/last a m) -- $listIndexed --@@ -2407,12 +2401,12 @@ -- -- Rules: ----- > let List/shifted = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/shifted--- > let List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat--- > let List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map+-- > let Prelude/List/shifted = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/shifted+-- > let Prelude/List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat+-- > let Prelude/List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map -- > --- > List/indexed a (List/concat a xss) =--- > List/shifted a (List/map (List a) (List { index : Natural, value : a }) (List/indexed a) xss)+-- > List/indexed a (Prelude/List/concat a xss) =+-- > Prelude/List/shifted a (Prelude/List/map (List a) (List { index : Natural, value : a }) (List/indexed a) xss) -- $listReverse --@@ -2432,17 +2426,17 @@ -- -- Rules: ----- > let List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map--- > let List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat--- > let List/concatMap = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concatMap+-- > let Prelude/List/map = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map+-- > let Prelude/List/concat = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concat+-- > let Prelude/List/concatMap = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/concatMap -- > --- > List/reverse a (List/concat a xss)--- > = List/concat a (List/reverse (List a) (List/map (List a) (List a) (List/reverse a) xss))+-- > List/reverse a (Prelude/List/concat a xss)+-- > = Prelude/List/concat a (List/reverse (List a) (Prelude/List/map (List a) (List a) (List/reverse a) xss)) -- > -- > List/reverse a ([x] : List a) = [x] : List a -- >--- > List/reverse b (List/concatMap a b f xs)--- > = List/concatMap a b (λ(x : a) → List/reverse b (f x)) (List/reverse a xs)+-- > List/reverse b (Prelude/List/concatMap a b f xs)+-- > = Prelude/List/concatMap a b (λ(x : a) → List/reverse b (f x)) (List/reverse a xs) -- > -- > List/reverse a ([x, y] : List a) = [y, x] : List a @@ -2662,7 +2656,7 @@ -- author, import, and program configuration files. If you run into any issues -- you can report them at: ----- <https://github.com/Gabriel439/Haskell-Dhall-Library/issues>+-- <https://github.com/dhall-lang/dhall-haskell/issues> -- -- You can also request features, support, or documentation improvements on the -- above issue tracker.
src/Dhall/TypeCheck.hs view
@@ -738,7 +738,7 @@ prettyTypeMessage :: TypeMessage s -> ErrorMessages prettyTypeMessage (UnboundVariable _) = ErrorMessages {..} -- We do not need to print variable name here. For the discussion see:- -- https://github.com/Gabriel439/Haskell-Dhall-Library/pull/116+ -- https://github.com/dhall-lang/dhall-haskell/pull/116 where short = "Unbound variable"