Polish source code

This commit is contained in:
Gabriel Gonzalez 2017-02-05 11:23:31 -08:00
parent df892060aa
commit cad5c8af20
3 changed files with 17 additions and 12 deletions

View File

@ -370,8 +370,7 @@ instance Bifunctor Expr where
second = fmap
instance IsString (Expr s a)
where
instance IsString (Expr s a) where
fromString str = Var (fromString str)
{- There is a one-to-one correspondence between the builders in this section
@ -683,7 +682,8 @@ buildAlternativeType :: Buildable a => (Text, Expr s a) -> Builder
buildAlternativeType (a, b) = buildLabel a <> " : " <> buildExprA b
-- | Builder corresponding to the @unionLit@ parser in "Dhall.Parser"
buildUnionLit :: Buildable a => Text -> Expr s a -> Map Text (Expr s a) -> Builder
buildUnionLit
:: Buildable a => Text -> Expr s a -> Map Text (Expr s a) -> Builder
buildUnionLit a b c
| Data.Map.null c =
"< "
@ -1466,12 +1466,15 @@ isNormalized e = case shift 0 "_" e of -- `shift` is a hack to delete `Note`
Note _ e' -> isNormalized e'
Embed _ -> True
_ERROR :: Data.Text.Text
_ERROR = "\ESC[1;31mError\ESC[0m"
{-| Utility function used to throw internal errors that should never happen
(in theory) but that are not enforced by the type system
-}
internalError :: Data.Text.Text -> forall b . b
internalError text = error (Data.Text.unpack [NeatInterpolation.text|
Error: Compiler bug
$_ERROR: Compiler bug
Explanation: This error message means that there is a bug in the Dhall compiler.
You didn't do anything wrong, but if you would like to see this problem fixed

View File

@ -95,7 +95,8 @@ import Dhall.Core (Expr, Path(..))
import Dhall.Parser (Parser(..), ParseError(..), Src)
import Dhall.TypeCheck (X(..))
#if MIN_VERSION_http_client(0,5,0)
import Network.HTTP.Client (HttpException(..), HttpExceptionContent(..), Manager)
import Network.HTTP.Client
(HttpException(..), HttpExceptionContent(..), Manager)
#else
import Network.HTTP.Client (HttpException(..), Manager)
#endif
@ -182,9 +183,11 @@ instance Exception e => Exception (Imported e)
instance Show e => Show (Imported e) where
show (Imported paths e) =
(case paths of [] -> ""; _ -> "\n")
++ unlines (map (\(n, path) -> take (2 * n) (repeat ' ') ++ "" ++ builderToString (build path)) paths')
++ unlines (map indent paths')
++ show e
where
indent (n, path) =
take (2 * n) (repeat ' ') ++ "" ++ builderToString (build path)
-- Canonicalize all paths
paths' = zip [0..] (drop 1 (reverse (canonicalizeAll paths)))
@ -294,7 +297,7 @@ needManager = do
if you navigate to any downstream relative paths
* Removing spurious @.@s and @..@s from the path
Also, there are way too many `reverse`s in the URL-handling cod For now I
Also, there are way too many `reverse`s in the URL-handling code For now I
don't mind, but if were to really do this correctly we'd store the URLs as
`Text` for O(1) access to the end of the string. The only reason we use
`String` at all is for consistency with the @http-client@ library.
@ -368,10 +371,9 @@ exprFromFile :: FilePath -> IO (Expr Src Path)
exprFromFile path = do
let string = Filesystem.Path.CurrentOS.encodeString path
-- Unfortunately, GHC throws an `InappropriateType`
-- exception when trying to read a directory, but does not
-- export the exception, so I must resort to a more
-- heavy-handed `catch`
-- Unfortunately, GHC throws an `InappropriateType` exception when trying to
-- to read a directory, but does not export the exception, so I must resort
-- to a more heavy-handed `catch`
let handler :: IOException -> IO (Result (Expr Src Path))
handler e = do
let string' = Filesystem.Path.CurrentOS.encodeString (path </> "@")

View File

@ -777,7 +777,7 @@ exprFromText delta text = case result of
parser = unParser (do
Text.Parser.Token.whiteSpace
r <- exprA import_
r <- expr
Text.Parser.Combinators.eof
return r )