Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to haddocks #2396

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dhall/src/Dhall/Pretty/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,8 @@ layoutOpts =
Pretty.defaultLayoutOptions
{ Pretty.layoutPageWidth = Pretty.AvailablePerLine 80 1.0 }

{-| Convert an expression representing a temporal value to `Text`, if possible
{-| Convert an expression representing a temporal value to `Data.Text.Text`, if
possible

This is used by downstream integrations (e.g. `dhall-json` for treating
temporal values as strings
Expand Down
18 changes: 3 additions & 15 deletions dhall/src/Dhall/Tutorial.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,7 @@ import Dhall
-- $substitutions
--
-- Substitutions are another way to extend the language.
--
-- Suppose we have the following Haskell datatype:
--
-- > data Result = Failure Integer | Success String
Expand All @@ -1985,22 +1986,9 @@ import Dhall
-- Right now it is quite easy to keep these two definitions (the one in Haskell source and the one in the Dhall file) synchronized:
-- If we implement a new feature in the Haskell source we update the corresponding type in the Dhall file.
-- But what happens if our application is growing and our Result type contains e.g. 10 unions with possible types embedded in it?
-- Maintaining the code will get tedious. Luckily we can extract the correct Dhall type from the Haskell definition:
--
-- > resultDecoder :: Dhall.Decoder Result
-- > resultDecoder = Dhall.auto
-- >
-- > resultType :: Expr Src Void
-- > resultType = maximum $ Dhall.expected resultDecoder
-- >
-- > resultTypeString :: String
-- > resultTypeString = show $ pretty resultType
--
-- Now we just have to inject that type into the Dhall code and we are done. One common way to do that is to wrap the import of example.dhall in a let expression:
--
-- > Dhall.input (Dhall.auto :: Dhall.Decoder Result) ("let Result = " <> Data.Text.pack resultTypeString <> " in ./example.dhall")
--
-- Now we can omit the definition of Result in our example.dhall file. While this will work perfectly Dhall provides a cleaner solution for our \"injection problem\":
-- We can override the interpreter's @evaluateSettings@ with a custom set of
-- substitutions, like this:
--
-- > {-# LANGUAGE OverloadedStrings #-}
-- >
Expand Down