71
71
> $ export BAZ='λ(x : Bool) → x == False'
72
72
> $ dhall <<< "{ foo = env:FOO , bar = env:BAR , baz = env:BAZ }"
73
73
> { bar : Text, baz : ∀(x : Bool) → Bool, foo : Integer }
74
- >
74
+ >
75
75
> { bar = "Hi", baz = λ(x : Bool) → x == False, foo = 1 }
76
76
77
77
If you wish to import the raw contents of a path as @Text@ then add
78
78
@as Text@ to the end of the import:
79
79
80
80
> $ dhall <<< "http://example.com as Text"
81
81
> Text
82
- >
82
+ >
83
83
> "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta
84
84
> charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html
85
- > ; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
85
+ > ; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
86
86
> initial-scale=1\" />\n <style type=\"text/css\">\n body {\n backgro
87
87
> und-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-famil
88
- > y: \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n
88
+ > y: \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n
89
89
> }\n div {\n width: 600px;\n margin: 5em auto;\n paddi
90
90
> ng: 50px;\n background-color: #fff;\n border-radius: 1em;\n }\n
91
91
> a:link, a:visited {\n color: #38488f;\n text-decoration: none;
92
92
> \n }\n @media (max-width: 700px) {\n body {\n background
93
93
> -color: #fff;\n }\n div {\n width: auto;\n m
94
- > argin: 0 auto;\n border-radius: 0;\n padding: 1em;\n
94
+ > argin: 0 auto;\n border-radius: 0;\n padding: 1em;\n
95
95
> }\n }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</
96
96
> h1>\n <p>This domain is established to be used for illustrative examples in d
97
97
> ocuments. You may use this\n domain in examples without prior coordination or
@@ -124,6 +124,7 @@ import Control.Monad (join)
124
124
import Control.Monad.Catch (throwM , MonadCatch (catch ))
125
125
import Control.Monad.IO.Class (MonadIO (.. ))
126
126
import Control.Monad.Trans.State.Strict (StateT )
127
+ import Crypto.Hash (SHA256 )
127
128
import Data.ByteString.Lazy (ByteString )
128
129
import Data.CaseInsensitive (CI )
129
130
import Data.Map (Map )
@@ -160,9 +161,9 @@ import Text.Trifecta (Result(..))
160
161
import Text.Trifecta.Delta (Delta (.. ))
161
162
162
163
import qualified Control.Monad.Trans.State.Strict as State
163
- import qualified Crypto.Hash.SHA256
164
+ import qualified Crypto.Hash
165
+ import qualified Data.ByteArray
164
166
import qualified Data.ByteString
165
- import qualified Data.ByteString.Base16
166
167
import qualified Data.ByteString.Char8
167
168
import qualified Data.ByteString.Lazy
168
169
import qualified Data.CaseInsensitive
@@ -534,8 +535,8 @@ instance Exception InternalError
534
535
535
536
-- | Exception thrown when an integrity check fails
536
537
data HashMismatch = HashMismatch
537
- { expectedHash :: Data.ByteString. ByteString
538
- , actualHash :: Data.ByteString. ByteString
538
+ { expectedHash :: Crypto.Hash. Digest SHA256
539
+ , actualHash :: Crypto.Hash. Digest SHA256
539
540
} deriving (Typeable )
540
541
541
542
instance Exception HashMismatch
@@ -547,14 +548,11 @@ instance Show HashMismatch where
547
548
<> " \n "
548
549
<> " Expected hash:\n "
549
550
<> " \n "
550
- <> " ↳ " <> toString expectedHash <> " \n "
551
+ <> " ↳ " <> show expectedHash <> " \n "
551
552
<> " \n "
552
553
<> " Actual hash:\n "
553
554
<> " \n "
554
- <> " ↳ " <> toString actualHash <> " \n "
555
- where
556
- toString =
557
- Data.ByteString.Char8. unpack . Data.ByteString.Base16. encode
555
+ <> " ↳ " <> show actualHash <> " \n "
558
556
559
557
parseFromFileEx
560
558
:: Text.Trifecta. Parser a
@@ -849,8 +847,8 @@ load :: Expr Src Path -> IO (Expr Src X)
849
847
load = loadWithContext Dhall.Context. empty
850
848
851
849
-- | Hash a fully resolved expression
852
- hashExpression :: Expr s X -> Data.ByteString. ByteString
853
- hashExpression expr = Crypto.Hash.SHA256. hashlazy actualBytes
850
+ hashExpression :: Expr s X -> ( Crypto.Hash. Digest SHA256 )
851
+ hashExpression expr = Crypto.Hash. hashlazy actualBytes
854
852
where
855
853
text = Dhall.Core. pretty (Dhall.Core. normalize expr)
856
854
actualBytes = Data.Text.Lazy.Encoding. encodeUtf8 text
@@ -866,7 +864,7 @@ hashExpressionToCode expr = "sha256:" <> lazyText
866
864
where
867
865
bytes = hashExpression expr
868
866
869
- bytes16 = Data.ByteString.Base16. encode bytes
867
+ bytes16 = Data.ByteArray. convert bytes
870
868
871
869
-- Notes that `decodeUtf8` is partial, but the base16-encoded bytestring
872
870
-- should always successfully decode
0 commit comments