diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -147,3 +147,103 @@
 > stack install dhall --stack-yaml=stack-dhall.yaml
 > __bin/dhall format --inplace package.dhall
 ```
+
+## Restrictions
+
+Using hpack's [conditionals](https://github.com/sol/hpack#conditionals) in
+a list in `package.dhall` can cause an error because lists in Dhall must have
+elements of the same type;
+
+From stack's `package.yaml`;
+```
+executables:
+  stack:
+    main: Main.hs
+    source-dirs: src/main
+    generated-other-modules:
+    - Build_stack
+    - Paths_stack
+    ghc-options:
+    - -threaded
+    - -rtsopts
+    dependencies:
+    - stack
+    when:
+    - condition: flag(static)
+      ld-options:
+      - -static
+      - -pthread
+    - condition: ! '!(flag(disable-git-info))'
+      cpp-options: -DUSE_GIT_INFO
+      dependencies:
+      - githash
+      - optparse-simple
+    - condition: flag(hide-dependency-versions)
+      cpp-options: -DHIDE_DEP_VERSIONS
+    - condition: flag(supported-build)
+      cpp-options: -DSUPPORTED_BUILD
+```
+
+This can be represented in `package.dhall` as;
+```
+, executables =
+    { stack =
+        { main =
+            "Main.hs"
+        , source-dirs =
+            [ "src/main" ]
+        , generated-other-modules =
+            [ "Build_stack", "Paths_stack" ]
+        , ghc-options =
+            [ "-threaded", "-rtsopts" ]
+        , dependencies =
+            [ "stack" ]
+        , when =
+            [ { condition =
+                  "flag(static)"
+              , cpp-options =
+                  [] : List Text
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [ "-static", "-pthread" ]
+              }
+            , { condition =
+                  "!(flag(disable-git-info))"
+              , cpp-options =
+                  [ "-DUSE_GIT_INFO" ]
+              , dependencies =
+                  [ "githash", "optparse-simple" ]
+              , ld-options =
+                  [] : List Text
+              }
+            , { condition =
+                  "flag(hide-dependency-versions)"
+              , cpp-options =
+                  [ "-DHIDE_DEP_VERSIONS" ]
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [] : List Text
+              }
+            , { condition =
+                  "flag(supported-build)"
+              , cpp-options =
+                  [ "-DSUPPORTED_BUILD" ]
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [] : List Text
+              }
+            ]
+        }
+    }
+```
+
+### Continuous Integration
+
+With haskell-ci tooling installed, generate the `.travis.yml` setup with;
+```
+> make-travis-yml --output=.travis.yml --config=cabal.haskell-ci hpack-dhall.cabal
+*INFO* Generating Travis-CI config for testing for GHC versions: 8.4.3 8.4.4 8.6.1
+```
diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,10 @@
 The [latest version](https://github.com/blockscope/hpack-dhall/blob/master/changelog.md) of this changelog.
 
+## 0.5.0 - Sorted Fields Pretty Printing
+* Sort fields when pretty printing JSON and YAML.
+* Add real world golden tests, using stack and hpack packages.
+
+## 0.4.0 - Split Executables
 * Add licence and copyright.
 * Rename hpack-dhall to dhall-hpack-cabal.
 * Add dhall-hpack-* executables for showing dhall, json and yaml.
diff --git a/exe/dhall-hpack-cabal/CabalMain.hs b/exe/dhall-hpack-cabal/CabalMain.hs
--- a/exe/dhall-hpack-cabal/CabalMain.hs
+++ b/exe/dhall-hpack-cabal/CabalMain.hs
@@ -38,7 +38,7 @@
         <> O.header "Hpack's dhalling"
         <> O.progDesc "Write the .cabal for a .dhall package description, resolving imports."
     where
-        parser = asum $
+        parser = asum
             [ NumericVersion <$ parseNumericVersion
             , Version <$ parseVersion
             , Run <$> parseOptions
@@ -56,11 +56,11 @@
             putStrLn $ "dhall-hpack-cabal-" ++ showVersion version
             putStrLn $ "hpack-" ++ showVersion H.version
 
-        Run (Options {..}) -> do
+        Run Options{..} -> do
             opts <- H.getOptions pkgFile $
                 mconcat
-                    [ if force then [ "--force" ] else []
-                    , if quiet then [ "--silent" ] else []
+                    [ [ "--force" | force ]
+                    , [ "--silent" | quiet ]
                     ]
             case opts of
                 Just (verbose, options) ->
diff --git a/exe/dhall-hpack-dhall/DhallMain.hs b/exe/dhall-hpack-dhall/DhallMain.hs
--- a/exe/dhall-hpack-dhall/DhallMain.hs
+++ b/exe/dhall-hpack-dhall/DhallMain.hs
@@ -20,7 +20,7 @@
         <> O.header "Hpack as Dhall"
         <> O.progDesc "Show a package description expression with imports resolved."
     where
-        parser = asum $
+        parser = asum
             [ NumericVersion <$ parseNumericVersion
             , Version <$ parseVersion
             , Run <$> parseOptions
@@ -38,7 +38,7 @@
             putStrLn $ "dhall-hpack-dhall-" ++ showVersion version
             putStrLn $ "hpack-" ++ showVersion H.version
 
-        Run (Options {..}) -> do
+        Run Options{..} -> do
             s <- showDhall pkgFile
             putStrLn s
             return ()
diff --git a/exe/dhall-hpack-json/JsonMain.hs b/exe/dhall-hpack-json/JsonMain.hs
--- a/exe/dhall-hpack-json/JsonMain.hs
+++ b/exe/dhall-hpack-json/JsonMain.hs
@@ -20,7 +20,7 @@
         <> O.header "Hpack as JSON"
         <> O.progDesc "Show a package description as JSON."
     where
-        parser = asum $
+        parser = asum
             [ NumericVersion <$ parseNumericVersion
             , Version <$ parseVersion
             , Run <$> parseOptions
@@ -38,7 +38,7 @@
             putStrLn $ "dhall-hpack-json-" ++ showVersion version
             putStrLn $ "hpack-" ++ showVersion H.version
 
-        Run (Options {..}) -> do
-            s <- showJson pkgFile
+        Run Options{..} -> do
+            s <- showJson Nothing pkgFile
             putStrLn s
             return ()
diff --git a/exe/dhall-hpack-yaml/YamlMain.hs b/exe/dhall-hpack-yaml/YamlMain.hs
--- a/exe/dhall-hpack-yaml/YamlMain.hs
+++ b/exe/dhall-hpack-yaml/YamlMain.hs
@@ -20,7 +20,7 @@
         <> O.header "Hpack as YAML"
         <> O.progDesc "Show a package description as YAML."
     where
-        parser = asum $
+        parser = asum
             [ NumericVersion <$ parseNumericVersion
             , Version <$ parseVersion
             , Run <$> parseOptions
@@ -38,7 +38,7 @@
             putStrLn $ "dhall-hpack-yaml-" ++ showVersion version
             putStrLn $ "hpack-" ++ showVersion H.version
 
-        Run (Options {..}) -> do
-            s <- showYaml pkgFile
+        Run Options{..} -> do
+            s <- showYaml Nothing pkgFile
             putStrLn s
             return ()
diff --git a/exe/options/Options.hs b/exe/options/Options.hs
--- a/exe/options/Options.hs
+++ b/exe/options/Options.hs
@@ -15,7 +15,7 @@
 import Hpack.Dhall (packageConfig)
 import Options.Applicative
 
-data Options = Options {pkgFile :: FilePath}
+newtype Options = Options {pkgFile :: FilePath}
 
 parseOptions :: Parser Options
 parseOptions = helper <*> do
diff --git a/hpack-dhall.cabal b/hpack-dhall.cabal
--- a/hpack-dhall.cabal
+++ b/hpack-dhall.cabal
@@ -4,10 +4,10 @@
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: 64cfd0522c69d9cf130736447533067efeee2a454d47b7ede022b171105fa273
+-- hash: 056b2248186a5860a9315055d3cbf8c57994ff2621e5f5941f214397c7ca26d9
 
 name:           hpack-dhall
-version:        0.4.0
+version:        0.5.0
 synopsis:       hpack's dhalling
 description:    Work with hpack's top-level
                 <https://github.com/sol/hpack#top-level-fields fields> in a Dhall
@@ -30,32 +30,73 @@
     package.dhall
     changelog.md
     README.md
-    test/golden/hpack-dhall-cabal/empty-inferred/package.dhall
-    test/golden/hpack-dhall-cabal/empty-package.dhall
-    test/golden/hpack-dhall-cabal/import-local/package.dhall
-    test/golden/hpack-dhall-cabal/import-relative/package.dhall
-    test/golden/hpack-dhall-cabal/import-local/name.dhl
-    test/golden/hpack-dhall-cabal/import-relative.dhl
-    test/golden/hpack-dhall-cabal/empty-inferred/empty-inferred.cabal
-    test/golden/hpack-dhall-cabal/empty-package.cabal
-    test/golden/hpack-dhall-cabal/import-local/import-local.cabal
-    test/golden/hpack-dhall-cabal/import-relative/import-relative.cabal
-    test/golden/hpack-dhall-cabal/empty-inferred/package.json
-    test/golden/hpack-dhall-cabal/empty-package.json
-    test/golden/hpack-dhall-cabal/import-local/package.json
-    test/golden/hpack-dhall-cabal/import-relative/package.json
-    test/golden/hpack-dhall-cabal/empty-inferred/package.yaml
-    test/golden/hpack-dhall-cabal/empty-package.yaml
-    test/golden/hpack-dhall-cabal/import-local/package.yaml
-    test/golden/hpack-dhall-cabal/import-relative/package.yaml
-    test/golden/hpack-dhall-cabal/empty-inferred/empty-inferred.cabal.golden
-    test/golden/hpack-dhall-cabal/empty-inferred/package.dhall.golden
-    test/golden/hpack-dhall-cabal/empty-package.cabal.golden
-    test/golden/hpack-dhall-cabal/empty-package.dhall.golden
-    test/golden/hpack-dhall-cabal/import-local/import-local.cabal.golden
-    test/golden/hpack-dhall-cabal/import-local/package.dhall.golden
-    test/golden/hpack-dhall-cabal/import-relative/import-relative.cabal.golden
-    test/golden/hpack-dhall-cabal/import-relative/package.dhall.golden
+    test/golden/test-files/key/empty-inferred/package.dhall
+    test/golden/test-files/key/empty-package.dhall
+    test/golden/test-files/key/import-local/package.dhall
+    test/golden/test-files/key/import-relative/package.dhall
+    test/golden/test-files/key/when-dependencies.dhall
+    test/golden/test-files/real-world/hpack/hpack.dhall
+    test/golden/test-files/real-world/stack/stack.dhall
+    test/golden/test-files/key/import-local/name.dhl
+    test/golden/test-files/key/import-relative.dhl
+    test/golden/test-files/key/empty-inferred/empty-inferred.cabal
+    test/golden/test-files/key/empty-inferred/package.yaml.cabal
+    test/golden/test-files/key/empty-package.cabal
+    test/golden/test-files/key/empty-package.yaml.cabal
+    test/golden/test-files/key/import-local/import-local.cabal
+    test/golden/test-files/key/import-local/package.yaml.cabal
+    test/golden/test-files/key/import-relative/import-relative.cabal
+    test/golden/test-files/key/import-relative/package.yaml.cabal
+    test/golden/test-files/key/when-dependencies.cabal
+    test/golden/test-files/key/when-dependencies.yaml.cabal
+    test/golden/test-files/real-world/hpack/hpack.cabal
+    test/golden/test-files/real-world/hpack/hpack.yaml.cabal
+    test/golden/test-files/real-world/stack/stack.cabal
+    test/golden/test-files/real-world/stack/stack.yaml.cabal
+    test/golden/test-files/key/empty-inferred/package.json
+    test/golden/test-files/key/empty-package.json
+    test/golden/test-files/key/import-local/package.json
+    test/golden/test-files/key/import-relative/package.json
+    test/golden/test-files/key/when-dependencies.json
+    test/golden/test-files/real-world/hpack/hpack.json
+    test/golden/test-files/real-world/stack/stack.json
+    test/golden/test-files/key/empty-inferred/package.yaml
+    test/golden/test-files/key/empty-package.yaml
+    test/golden/test-files/key/import-local/package.yaml
+    test/golden/test-files/key/import-relative/package.yaml
+    test/golden/test-files/key/when-dependencies.yaml
+    test/golden/test-files/real-world/hpack/hpack.yaml
+    test/golden/test-files/real-world/hpack/package.yaml
+    test/golden/test-files/real-world/stack/package.yaml
+    test/golden/test-files/real-world/stack/stack.yaml
+    test/golden/test-files/key/empty-inferred/empty-inferred.cabal.golden
+    test/golden/test-files/key/empty-inferred/package.dhall.golden
+    test/golden/test-files/key/empty-inferred/package.json.golden
+    test/golden/test-files/key/empty-inferred/package.yaml.golden
+    test/golden/test-files/key/empty-package.cabal.golden
+    test/golden/test-files/key/empty-package.dhall.golden
+    test/golden/test-files/key/empty-package.json.golden
+    test/golden/test-files/key/empty-package.yaml.golden
+    test/golden/test-files/key/import-local/import-local.cabal.golden
+    test/golden/test-files/key/import-local/package.dhall.golden
+    test/golden/test-files/key/import-local/package.json.golden
+    test/golden/test-files/key/import-local/package.yaml.golden
+    test/golden/test-files/key/import-relative/import-relative.cabal.golden
+    test/golden/test-files/key/import-relative/package.dhall.golden
+    test/golden/test-files/key/import-relative/package.json.golden
+    test/golden/test-files/key/import-relative/package.yaml.golden
+    test/golden/test-files/key/when-dependencies.cabal.golden
+    test/golden/test-files/key/when-dependencies.dhall.golden
+    test/golden/test-files/key/when-dependencies.json.golden
+    test/golden/test-files/key/when-dependencies.yaml.golden
+    test/golden/test-files/real-world/hpack/hpack.cabal.golden
+    test/golden/test-files/real-world/hpack/hpack.dhall.golden
+    test/golden/test-files/real-world/hpack/hpack.json.golden
+    test/golden/test-files/real-world/hpack/hpack.yaml.golden
+    test/golden/test-files/real-world/stack/stack.cabal.golden
+    test/golden/test-files/real-world/stack/stack.dhall.golden
+    test/golden/test-files/real-world/stack/stack.json.golden
+    test/golden/test-files/real-world/stack/stack.yaml.golden
 
 source-repository head
   type: git
@@ -64,6 +105,7 @@
 library
   exposed-modules:
       Hpack.Dhall
+      Hpack.Fields
   other-modules:
       Paths_hpack_dhall
   hs-source-dirs:
@@ -90,6 +132,7 @@
   main-is: CabalMain.hs
   other-modules:
       Hpack.Dhall
+      Hpack.Fields
       Options
       Paths_hpack_dhall
   hs-source-dirs:
@@ -106,6 +149,7 @@
     , dhall-json >=1.2.4
     , filepath
     , hpack >=0.31.0
+    , hpack-dhall
     , megaparsec >=7.0.1
     , microlens
     , optparse-applicative
@@ -119,6 +163,7 @@
   main-is: DhallMain.hs
   other-modules:
       Hpack.Dhall
+      Hpack.Fields
       Options
       Paths_hpack_dhall
   hs-source-dirs:
@@ -135,6 +180,7 @@
     , dhall-json >=1.2.4
     , filepath
     , hpack >=0.31.0
+    , hpack-dhall
     , megaparsec >=7.0.1
     , microlens
     , optparse-applicative
@@ -148,6 +194,7 @@
   main-is: JsonMain.hs
   other-modules:
       Hpack.Dhall
+      Hpack.Fields
       Options
       Paths_hpack_dhall
   hs-source-dirs:
@@ -164,6 +211,7 @@
     , dhall-json >=1.2.4
     , filepath
     , hpack >=0.31.0
+    , hpack-dhall
     , megaparsec >=7.0.1
     , microlens
     , optparse-applicative
@@ -177,6 +225,7 @@
   main-is: YamlMain.hs
   other-modules:
       Hpack.Dhall
+      Hpack.Fields
       Options
       Paths_hpack_dhall
   hs-source-dirs:
@@ -193,6 +242,7 @@
     , dhall-json >=1.2.4
     , filepath
     , hpack >=0.31.0
+    , hpack-dhall
     , megaparsec >=7.0.1
     , microlens
     , optparse-applicative
@@ -207,12 +257,11 @@
   main-is: Golden.hs
   other-modules:
       Hpack.Dhall
-      Hpack.Dhall
+      Hpack.Fields
       Paths_hpack_dhall
   hs-source-dirs:
       library
-      library
-      test/golden
+      test/golden/src
   ghc-options: -Wall
   build-depends:
       Cabal
@@ -223,6 +272,7 @@
     , bytestring
     , dhall >=1.18.0
     , dhall-json >=1.2.4
+    , directory
     , filepath
     , hpack >=0.31.0
     , megaparsec >=7.0.1
diff --git a/library/Hpack/Dhall.hs b/library/Hpack/Dhall.hs
--- a/library/Hpack/Dhall.hs
+++ b/library/Hpack/Dhall.hs
@@ -5,7 +5,7 @@
 Copyright:
     © 2018 Phil de Joux
     © 2018 Block Scope Limited
-License: BSD3 
+License: BSD3
 Maintainer: Phil de Joux <phil.dejoux@blockscope.com>
 Stability: experimental
 Instead of working with <https://github.com/sol/hpack#readme hpack> in
@@ -21,6 +21,7 @@
     , packageConfig
     ) where
 
+import Data.Maybe (fromMaybe)
 import Data.Function ((&))
 import Lens.Micro ((^.), set)
 import System.FilePath (takeDirectory)
@@ -30,7 +31,6 @@
 import qualified Control.Monad.Trans.State.Strict as State
 import Data.Bifunctor (first)
 import Data.Aeson (ToJSON, Value)
-import Data.Aeson.Encode.Pretty (encodePretty)
 import qualified Data.ByteString.Lazy as BSL (toStrict)
 import Data.Text.Encoding (decodeUtf8)
 import qualified Data.Text as T (Text, unpack)
@@ -45,16 +45,22 @@
 import Dhall.TypeCheck (X, typeOf)
 import Dhall.JSON (dhallToJSON)
 import Dhall.Pretty (prettyExpr, layoutOpts)
-import Data.Yaml (encode)
 import qualified Data.Text.Prettyprint.Doc as PP
 import qualified Data.Text.Prettyprint.Doc.Render.Text as PP
+import qualified Data.Yaml.Pretty as Y
+import qualified Data.Aeson.Encode.Pretty as A
+import Hpack.Fields (cmp)
 
 -- SEE: http://onoffswitch.net/adventures-pretty-printing-json-haskell/
-getJson :: ToJSON a => a -> String
-getJson = T.unpack . decodeUtf8 . BSL.toStrict . encodePretty
+getJson :: ToJSON a => (Text -> Text -> Ordering) -> a -> String
+getJson cmp' =
+    let cfg = A.defConfig {A.confCompare = cmp'}
+    in T.unpack . decodeUtf8 . BSL.toStrict . A.encodePretty' cfg
 
-getYaml :: ToJSON a => a -> String
-getYaml = T.unpack . decodeUtf8 . Data.Yaml.encode
+getYaml :: ToJSON a => (Text -> Text -> Ordering) -> a -> String
+getYaml cmp' =
+    let cfg = Y.setConfCompare cmp' Y.defConfig
+    in T.unpack . decodeUtf8 . Y.encodePretty cfg
 
 -- | The default package file name is @package.dhall@.
 packageConfig :: FilePath
@@ -62,19 +68,29 @@
 
 -- | Pretty prints JSON for the package description.
 showJson
-    :: FilePath -- ^ Path to a @.dhall@ file
+    :: Maybe (Text -> Text -> Ordering)
+    -- ^ An ordering of JSON fields.
+    -> FilePath
+    -- ^ Path to a @.dhall@ file
     -> IO String
-showJson file = do
-    Right (_, v) <- fileToJson file
-    return $ getJson v
+showJson fieldOrdering file = do
+    x <- fileToJson file
+    return $ case x of
+        Left err -> err
+        Right (_, v) -> getJson (fromMaybe cmp fieldOrdering) v
 
 -- | Pretty prints YAML for the package description.
 showYaml
-    :: FilePath -- ^ Path to a @.dhall@ file
+    :: Maybe (Text -> Text -> Ordering)
+    -- ^ An ordering of YAML fields.
+    -> FilePath
+    -- ^ Path to a @.dhall@ file
     -> IO String
-showYaml file = do
-    Right (_, v) <- fileToJson file
-    return $ getYaml v
+showYaml fieldOrdering file = do
+    x <- fileToJson file
+    return $ case x of
+        Left err -> err
+        Right (_, v) -> getYaml (fromMaybe cmp fieldOrdering) v
 
 -- | Pretty prints the package description Dhall expression, resolving imports
 -- relative to the location of the @.dhall@ file.
@@ -116,12 +132,7 @@
 check :: InputSettings -> Text -> IO (Expr Src X)
 check settings text = do
     expr <- either throwIO return $ exprFromText mempty text
-
-    x <- State.evalStateT
-            (loadWith expr)
-            (emptyStatus $ settings ^. rootDirectory)
-
-    return x
+    State.evalStateT (loadWith expr) (emptyStatus $ settings ^. rootDirectory)
 
 -- SEE: https://github.com/mstksg/hakyll-dhall
 renderDhall :: (PP.Pretty a, Eq a) => Expr Src a -> T.Text
diff --git a/library/Hpack/Fields.hs b/library/Hpack/Fields.hs
new file mode 100644
--- /dev/null
+++ b/library/Hpack/Fields.hs
@@ -0,0 +1,180 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE MultiWayIf #-}
+{-# OPTIONS_HADDOCK ignore-exports #-}
+
+module Hpack.Fields (cmp) where
+
+import Data.Maybe (fromMaybe)
+import Data.List (elemIndex)
+import Data.String (IsString())
+import Control.Applicative (liftA2)
+import Data.Foldable (asum)
+
+-- | A default field ordering comparison.
+cmp :: (Ord a, IsString a) => a -> a -> Ordering
+cmp a b =
+    fromMaybe fallback
+    . asum
+    $ [ liftA2 compare (elemIndex a xs) (elemIndex b xs) | xs <- fields ]
+    where
+        -- NOTE: There can be short form conditions with no then or else. In
+        -- that case always put condition before the other field name.
+        fallback =
+            if | a == "condition" -> LT
+               | b == "condition" -> GT
+               | elem a topLevelFields -> LT
+               | elem b topLevelFields -> GT
+               | otherwise -> a `compare` b
+
+        fields =
+            [ topLevelFields
+            , libraryFields ++ commonFields
+            , runnableFields ++ commonFields
+            , flagFields
+            , conditionalFields
+            , defaultsFields
+            ]
+
+-- | All <https://github.com/sol/hpack#top-level-fields top-level> fields combined.
+topLevelFields :: (Ord a, IsString a) => [a]
+topLevelFields =
+    headerFields
+    ++ repoFields
+    ++ packageFields
+    ++ commonFields
+    ++ stanzasFields
+
+-- | The header subset of
+-- <https://github.com/sol/hpack#top-level-fields top-level> fields.
+headerFields :: (Ord a, IsString a) => [a]
+headerFields =
+    [ "spec-version"
+    , "name"
+    , "version"
+    , "synopsis"
+    , "description"
+    , "category"
+    , "stability"
+    , "homepage"
+    , "bug-reports"
+    , "author"
+    , "maintainer"
+    , "copyright"
+    , "license"
+    , "license-file"
+    , "license-files"
+    , "tested-with"
+    , "build-type"
+    ]
+
+-- | The package subset of
+-- <https://github.com/sol/hpack#top-level-fields top-level> fields.
+packageFields :: (Ord a, IsString a) => [a]
+packageFields =
+    [ "extra-source-files"
+    , "extra-doc-files"
+    , "data-files"
+    , "data-dir"
+    ]
+
+-- | The source repository subset of
+-- <https://github.com/sol/hpack#top-level-fields top-level> fields.
+repoFields :: (Ord a, IsString a) => [a]
+repoFields =
+    [ "github"
+    , "git"
+    ]
+
+-- | The stanzas subset of
+-- <https://github.com/sol/hpack#top-level-fields top-level> fields.
+stanzasFields :: (Ord a, IsString a) => [a]
+stanzasFields =
+    [ "custom-setup"
+    , "flags"
+    , "library"
+    , "internal-libraries"
+    , "executables"
+    , "executable"
+    , "tests"
+    , "benchmarks"
+    , "defaults"
+    ]
+
+-- | The <https://github.com/sol/hpack#common-fields common> fields.
+commonFields :: (Ord a, IsString a) => [a]
+commonFields =
+    [ "buildable"
+    , "source-dirs"
+    , "default-extensions"
+    , "other-extensions"
+    , "ghc-options"
+    , "ghc-prof-options"
+    , "ghcjs-options"
+    , "cpp-options"
+    , "cc-options"
+    , "c-sources"
+    , "cxx-options"
+    , "cxx-sources"
+    , "js-sources"
+    , "extra-lib-dirs"
+    , "extra-libraries"
+    , "include-dirs"
+    , "install-includes"
+    , "frameworks"
+    , "extra-framework-dirs"
+    , "ld-options"
+    , "dependencies"
+    , "pkg-config-depends"
+    , "build-tools"
+    , "system-build-tools"
+    , "when" -- conditional
+    ]
+
+
+-- | The <https://github.com/sol/hpack#library-fields library> fields.
+libraryFields :: (Ord a, IsString a) => [a]
+libraryFields =
+    [ "exposed"
+    , "exposed-modules"
+    , "generated-exposed-modules"
+    , "other-modules"
+    , "generated-other-modules"
+    , "reexported-modules"
+    , "signatures"
+    ]
+
+-- | The <https://github.com/sol/hpack#executable-fields executable>,
+-- <https://github.com/sol/hpack#test-fields test> and
+-- <https://github.com/sol/hpack#benchmark-fields benchmark> fields are all the
+-- same.
+runnableFields :: (Ord a, IsString a) => [a]
+runnableFields =
+    [ "main"
+    , "other-modules"
+    , "generated-other-modules"
+    ]
+
+-- | The <https://github.com/sol/hpack#flags flag> fields.
+flagFields :: (Ord a, IsString a) => [a]
+flagFields =
+    [ "description"
+    , "manual"
+    , "default"
+    ]
+
+-- | The <https://github.com/sol/hpack#-conditionals conditional> fields.
+conditionalFields :: (Ord a, IsString a) => [a]
+conditionalFields =
+    [ "condition"
+    , "then"
+    , "else"
+    ]
+
+-- | The <https://github.com/sol/hpack#defaults defaults> fields.
+defaultsFields :: (Ord a, IsString a) => [a]
+defaultsFields =
+    [ "github"
+    , "ref"
+    , "path"
+    , "local"
+    ]
diff --git a/package.dhall b/package.dhall
--- a/package.dhall
+++ b/package.dhall
@@ -5,22 +5,22 @@
           , "dhall-json >= 1.2.4"
           , "hpack >= 0.31.0"
           , "transformers"
-          , "aeson"
           , "text"
           , "microlens"
           , "filepath"
-          , "aeson-pretty"
           , "bytestring"
           , "prettyprinter"
+          , "aeson"
+          , "aeson-pretty"
           , "yaml"
           ]
 
-in  let exe-deps = deps # [ "optparse-applicative" ]
+in  let exe-deps = [ "hpack-dhall", "optparse-applicative" ]
 
 in  { name =
         "hpack-dhall"
     , version =
-        "0.4.0"
+        "0.5.0"
     , maintainer =
         "Phil de Joux <phil.dejoux@blockscope.com>"
     , copyright =
@@ -66,7 +66,7 @@
     , source-dirs =
         "library"
     , library =
-        { exposed-modules = "Hpack.Dhall" }
+        { exposed-modules = [ "Hpack.Dhall", "Hpack.Fields" ] }
     , executables =
         { dhall-hpack-cabal =
             { main =
@@ -102,30 +102,32 @@
             }
         }
     , tests =
-        { golden =
-            { main =
-                "Golden.hs"
-            , source-dirs =
-                [ "library", "test/golden" ]
-            , dependencies =
-                [ "base"
-                , "Cabal"
-                , "Diff"
-                , "dhall"
-                , "filepath"
-                , "microlens"
-                , "prettyprinter"
-                , "tasty"
-                , "tasty-golden"
-                , "text"
-                , "megaparsec >= 7.0.1"
-                , "dhall >= 1.18.0"
-                , "dhall-json >= 1.2.4"
-                , "hpack >= 0.31.0"
-                , "transformers"
-                , "aeson"
-                , "utf8-string"
-                ]
-            }
-        }
+          ./default-tests.dhall
+        ⫽ { golden =
+              { main =
+                  "Golden.hs"
+              , source-dirs =
+                  [ "test/golden/src" ]
+              , dependencies =
+                  [ "base"
+                  , "Cabal"
+                  , "Diff"
+                  , "dhall"
+                  , "filepath"
+                  , "microlens"
+                  , "prettyprinter"
+                  , "tasty"
+                  , "tasty-golden"
+                  , "text"
+                  , "megaparsec >= 7.0.1"
+                  , "dhall >= 1.18.0"
+                  , "dhall-json >= 1.2.4"
+                  , "hpack >= 0.31.0"
+                  , "transformers"
+                  , "aeson"
+                  , "utf8-string"
+                  , "directory"
+                  ]
+              }
+          }
     }
diff --git a/test/golden/Golden.hs b/test/golden/Golden.hs
deleted file mode 100644
--- a/test/golden/Golden.hs
+++ /dev/null
@@ -1,95 +0,0 @@
-{-# LANGUAGE MultiWayIf #-}
-
-module Main (main) where
-
-import System.FilePath
-    ( (</>), (<.>), (-<.>)
-    , takeBaseName, replaceExtension
-    , takeDirectory, splitDirectories, joinPath
-    )
-import Test.Tasty (defaultMain, TestTree, testGroup)
-import Test.Tasty.Golden (findByExtension)
-import Test.Tasty.Golden (goldenVsFile, goldenVsString)
-
-import Hpack (Verbose(..), Options(..), hpack, defaultOptions, setDecode)
-import Hpack.Config (DecodeOptions(..))
-import Hpack.Dhall (fileToJson, showDhall, showJson, showYaml)
-import Data.ByteString.Lazy.UTF8 (fromString)
-
-main :: IO ()
-main =
-    defaultMain =<< goldenTests
-
-goldenTests :: IO TestTree
-goldenTests = do
-    dhallFiles <- findByExtension [".dhall"] "test/golden/hpack-dhall-cabal/"
-    return $ testGroup "golden tests"
-        [ testGroup ".dhall to .cabal"
-            [ goldenVsFile
-                (testName dhallFile)
-                (cabalFile <.> ".golden")
-                cabalFile
-                (writeCabal dhallFile)
-            | dhallFile <- dhallFiles
-            , let cabalFile = cabalFilePath dhallFile
-            ]
-        , testGroup ".dhall to dhall"
-            [ goldenVsString
-                (testName dhallFile)
-                (dhallFile <.> ".golden")
-                (fmap fromString . showDhall $ dhallFile)
-            | dhallFile <- dhallFiles
-            ]
-        , testGroup ".dhall to json"
-            [ goldenVsString
-                (testName dhallFile)
-                (dhallFile -<.> ".json")
-                (fmap fromString . showJson $ dhallFile)
-            | dhallFile <- dhallFiles
-            ]
-        , testGroup ".dhall to yaml"
-            [ goldenVsString
-                (testName dhallFile)
-                (dhallFile -<.> ".yaml")
-                (fmap fromString . showYaml $ dhallFile)
-            | dhallFile <- dhallFiles
-            ]
-        ]
-
-testName :: FilePath -> FilePath
-testName p =
-    if | fName == dName -> fName
-       | fName == "package" -> dName
-       | dName == "hpack-dhall-cabal" -> fName
-       | otherwise -> dName </> fName
-    where
-        dName =
-            joinPath
-            . take 1
-            . reverse
-            . splitDirectories
-            . takeDirectory
-            $ p
-
-        fName = takeBaseName p
-
-writeCabal :: FilePath -> IO ()
-writeCabal dhallFile =
-    hpack NoVerbose (setDecode fileToJson options)
-    where
-        d = optionsDecodeOptions defaultOptions
-        d' = d {decodeOptionsTarget = dhallFile}
-        options = defaultOptions {optionsDecodeOptions = d'}
-
-cabalFilePath :: FilePath -> FilePath
-cabalFilePath p
-    | takeBaseName p == "package" =
-        case reverse . splitDirectories $ ds of
-            d : ds' -> joinPath (reverse ds') </> d </> d <.> ".cabal"
-            _ -> replaceExtension p ".cabal"
-
-    | otherwise =
-        replaceExtension p ".cabal"
-
-    where
-        ds = takeDirectory p
diff --git a/test/golden/hpack-dhall-cabal/empty-inferred/empty-inferred.cabal b/test/golden/hpack-dhall-cabal/empty-inferred/empty-inferred.cabal
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-inferred/empty-inferred.cabal
+++ /dev/null
@@ -1,11 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from package.dhall by hpack version 0.31.0.
---
--- see: https://github.com/sol/hpack
---
--- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53
-
-name:           empty-inferred
-version:        0.0.0
-build-type:     Simple
diff --git a/test/golden/hpack-dhall-cabal/empty-inferred/empty-inferred.cabal.golden b/test/golden/hpack-dhall-cabal/empty-inferred/empty-inferred.cabal.golden
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-inferred/empty-inferred.cabal.golden
+++ /dev/null
@@ -1,11 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from package.dhall by hpack version 0.31.0.
---
--- see: https://github.com/sol/hpack
---
--- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53
-
-name:           empty-inferred
-version:        0.0.0
-build-type:     Simple
diff --git a/test/golden/hpack-dhall-cabal/empty-inferred/package.dhall b/test/golden/hpack-dhall-cabal/empty-inferred/package.dhall
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-inferred/package.dhall
+++ /dev/null
@@ -1,1 +0,0 @@
-{=}
diff --git a/test/golden/hpack-dhall-cabal/empty-inferred/package.dhall.golden b/test/golden/hpack-dhall-cabal/empty-inferred/package.dhall.golden
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-inferred/package.dhall.golden
+++ /dev/null
@@ -1,1 +0,0 @@
-{=}
diff --git a/test/golden/hpack-dhall-cabal/empty-inferred/package.json b/test/golden/hpack-dhall-cabal/empty-inferred/package.json
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-inferred/package.json
+++ /dev/null
@@ -1,1 +0,0 @@
-{}
diff --git a/test/golden/hpack-dhall-cabal/empty-inferred/package.yaml b/test/golden/hpack-dhall-cabal/empty-inferred/package.yaml
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-inferred/package.yaml
+++ /dev/null
@@ -1,1 +0,0 @@
-{}
diff --git a/test/golden/hpack-dhall-cabal/empty-package.cabal b/test/golden/hpack-dhall-cabal/empty-package.cabal
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-package.cabal
+++ /dev/null
@@ -1,11 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from empty-package.dhall by hpack version 0.31.0.
---
--- see: https://github.com/sol/hpack
---
--- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04
-
-name:           empty-package
-version:        0.0.0
-build-type:     Simple
diff --git a/test/golden/hpack-dhall-cabal/empty-package.cabal.golden b/test/golden/hpack-dhall-cabal/empty-package.cabal.golden
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-package.cabal.golden
+++ /dev/null
@@ -1,11 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from empty-package.dhall by hpack version 0.31.0.
---
--- see: https://github.com/sol/hpack
---
--- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04
-
-name:           empty-package
-version:        0.0.0
-build-type:     Simple
diff --git a/test/golden/hpack-dhall-cabal/empty-package.dhall b/test/golden/hpack-dhall-cabal/empty-package.dhall
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-package.dhall
+++ /dev/null
@@ -1,1 +0,0 @@
-{ name = "empty-package" }
diff --git a/test/golden/hpack-dhall-cabal/empty-package.dhall.golden b/test/golden/hpack-dhall-cabal/empty-package.dhall.golden
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-package.dhall.golden
+++ /dev/null
@@ -1,1 +0,0 @@
-{ name = "empty-package" }
diff --git a/test/golden/hpack-dhall-cabal/empty-package.json b/test/golden/hpack-dhall-cabal/empty-package.json
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-    "name": "empty-package"
-}
diff --git a/test/golden/hpack-dhall-cabal/empty-package.yaml b/test/golden/hpack-dhall-cabal/empty-package.yaml
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/empty-package.yaml
+++ /dev/null
@@ -1,1 +0,0 @@
-name: empty-package
diff --git a/test/golden/hpack-dhall-cabal/import-local/import-local.cabal b/test/golden/hpack-dhall-cabal/import-local/import-local.cabal
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-local/import-local.cabal
+++ /dev/null
@@ -1,11 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from package.dhall by hpack version 0.31.0.
---
--- see: https://github.com/sol/hpack
---
--- hash: fb3f09267f149cb49eb030ac951c27be9964aa0d51e91460e5b2d59ee1a5082f
-
-name:           import-local
-version:        0.0.0
-build-type:     Simple
diff --git a/test/golden/hpack-dhall-cabal/import-local/import-local.cabal.golden b/test/golden/hpack-dhall-cabal/import-local/import-local.cabal.golden
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-local/import-local.cabal.golden
+++ /dev/null
@@ -1,11 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from package.dhall by hpack version 0.31.0.
---
--- see: https://github.com/sol/hpack
---
--- hash: fb3f09267f149cb49eb030ac951c27be9964aa0d51e91460e5b2d59ee1a5082f
-
-name:           import-local
-version:        0.0.0
-build-type:     Simple
diff --git a/test/golden/hpack-dhall-cabal/import-local/name.dhl b/test/golden/hpack-dhall-cabal/import-local/name.dhl
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-local/name.dhl
+++ /dev/null
@@ -1,1 +0,0 @@
-{ name = "import-local" }
diff --git a/test/golden/hpack-dhall-cabal/import-local/package.dhall b/test/golden/hpack-dhall-cabal/import-local/package.dhall
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-local/package.dhall
+++ /dev/null
@@ -1,1 +0,0 @@
-./name.dhl ⫽ {=}
diff --git a/test/golden/hpack-dhall-cabal/import-local/package.dhall.golden b/test/golden/hpack-dhall-cabal/import-local/package.dhall.golden
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-local/package.dhall.golden
+++ /dev/null
@@ -1,1 +0,0 @@
-{ name = "import-local" } ⫽ {=}
diff --git a/test/golden/hpack-dhall-cabal/import-local/package.json b/test/golden/hpack-dhall-cabal/import-local/package.json
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-local/package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-    "name": "import-local"
-}
diff --git a/test/golden/hpack-dhall-cabal/import-local/package.yaml b/test/golden/hpack-dhall-cabal/import-local/package.yaml
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-local/package.yaml
+++ /dev/null
@@ -1,1 +0,0 @@
-name: import-local
diff --git a/test/golden/hpack-dhall-cabal/import-relative.dhl b/test/golden/hpack-dhall-cabal/import-relative.dhl
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-relative.dhl
+++ /dev/null
@@ -1,1 +0,0 @@
-{ name = "import-relative" }
diff --git a/test/golden/hpack-dhall-cabal/import-relative/import-relative.cabal b/test/golden/hpack-dhall-cabal/import-relative/import-relative.cabal
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-relative/import-relative.cabal
+++ /dev/null
@@ -1,11 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from package.dhall by hpack version 0.31.0.
---
--- see: https://github.com/sol/hpack
---
--- hash: 989056d21c3910e06ec15967716df134a39f43c561858afff828d22802a22005
-
-name:           import-relative
-version:        0.0.0
-build-type:     Simple
diff --git a/test/golden/hpack-dhall-cabal/import-relative/import-relative.cabal.golden b/test/golden/hpack-dhall-cabal/import-relative/import-relative.cabal.golden
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-relative/import-relative.cabal.golden
+++ /dev/null
@@ -1,11 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from package.dhall by hpack version 0.31.0.
---
--- see: https://github.com/sol/hpack
---
--- hash: 989056d21c3910e06ec15967716df134a39f43c561858afff828d22802a22005
-
-name:           import-relative
-version:        0.0.0
-build-type:     Simple
diff --git a/test/golden/hpack-dhall-cabal/import-relative/package.dhall b/test/golden/hpack-dhall-cabal/import-relative/package.dhall
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-relative/package.dhall
+++ /dev/null
@@ -1,1 +0,0 @@
-../import-relative.dhl ⫽ {=}
diff --git a/test/golden/hpack-dhall-cabal/import-relative/package.dhall.golden b/test/golden/hpack-dhall-cabal/import-relative/package.dhall.golden
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-relative/package.dhall.golden
+++ /dev/null
@@ -1,1 +0,0 @@
-{ name = "import-relative" } ⫽ {=}
diff --git a/test/golden/hpack-dhall-cabal/import-relative/package.json b/test/golden/hpack-dhall-cabal/import-relative/package.json
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-relative/package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-    "name": "import-relative"
-}
diff --git a/test/golden/hpack-dhall-cabal/import-relative/package.yaml b/test/golden/hpack-dhall-cabal/import-relative/package.yaml
deleted file mode 100644
--- a/test/golden/hpack-dhall-cabal/import-relative/package.yaml
+++ /dev/null
@@ -1,1 +0,0 @@
-name: import-relative
diff --git a/test/golden/src/Golden.hs b/test/golden/src/Golden.hs
new file mode 100644
--- /dev/null
+++ b/test/golden/src/Golden.hs
@@ -0,0 +1,145 @@
+{-# LANGUAGE MultiWayIf #-}
+
+module Main (main) where
+
+import System.FilePath
+    ( (</>), (<.>), (-<.>)
+    , takeBaseName, replaceExtension
+    , takeDirectory, splitDirectories, joinPath
+    )
+import System.Directory (renameFile)
+import Test.Tasty (defaultMain, TestTree, testGroup)
+import Test.Tasty.Golden (findByExtension)
+import Test.Tasty.Golden (goldenVsFile, goldenVsString)
+
+import Hpack (Verbose(..), Options(..), hpack, defaultOptions, setDecode)
+import Hpack.Config (DecodeOptions(..))
+import Hpack.Dhall (fileToJson, showDhall, showJson, showYaml)
+import Data.ByteString.Lazy.UTF8 (fromString)
+
+main :: IO ()
+main =
+    defaultMain =<< goldenTests
+
+goldenTests :: IO TestTree
+goldenTests = do
+    ks <- findByExtension [".dhall"] "test/golden/test-files/key"
+    rs <- findByExtension [".dhall"] "test/golden/test-files/real-world"
+    g1 <- goldenTestSet "archetypes" ks
+    g2 <- goldenTestSet "real-world examples" rs
+    return $ testGroup "golden tests" [g1 , g2]
+
+goldenTestSet :: String -> [FilePath] -> IO TestTree
+goldenTestSet title dhallFiles = do
+    return $ testGroup title 
+        [ testGroup ".dhall to .cabal"
+            [ goldenVsFile
+                (testName dhallFile)
+                (cabalFile <.> ".golden")
+                cabalFile
+                (writeDhallCabal dhallFile)
+            | dhallFile <- dhallFiles
+            , let cabalFile = cabalFilePath dhallFile
+            ]
+        , testGroup ".dhall to dhall"
+            [ goldenVsString
+                (testName dhallFile)
+                (dhallFile <.> ".golden")
+                (fmap fromString . showDhall $ dhallFile)
+            | dhallFile <- dhallFiles
+            ]
+        , testGroup ".dhall to json"
+            [ goldenVsFile
+                (testName dhallFile)
+                (dhallFile -<.> ".json.golden")
+                jsonFile
+                (writeJson dhallFile jsonFile)
+            | dhallFile <- dhallFiles
+            , let jsonFile = dhallFile -<.> ".json"
+            ]
+        , testGroup ".dhall to yaml"
+            [ goldenVsFile
+                (testName dhallFile)
+                (dhallFile -<.> ".yaml.golden")
+                yamlFile
+                (writeYaml dhallFile yamlFile)
+            | dhallFile <- dhallFiles
+            , let yamlFile = dhallFile -<.> ".yaml"
+            ]
+        , testGroup ".yaml to .cabal"
+            [ goldenVsFile
+                (testName dhallFile)
+                (cabalFile <.> ".golden")
+                cabalFile
+                (writeYamlCabal yamlFile cabalFile yamlCabalFile)
+            | dhallFile <- dhallFiles
+            , let yamlFile = dhallFile -<.> ".yaml"
+            , let cabalFile = cabalFilePath dhallFile
+            , let yamlCabalFile = yamlFile <.> ".cabal"
+            ]
+        ]
+
+testName :: FilePath -> FilePath
+testName p =
+    if | fName == dName -> fName
+       | fName == "package" -> dName
+       | dName == "key" -> fName
+       | dName == "real-world" -> fName
+       | otherwise -> dName </> fName
+    where
+        dName =
+            joinPath
+            . take 1
+            . reverse
+            . splitDirectories
+            . takeDirectory
+            $ p
+
+        fName = takeBaseName p
+
+writeDhallCabal :: FilePath -> IO ()
+writeDhallCabal dhallFile =
+    hpack NoVerbose (setDecode fileToJson options)
+    where
+        d = optionsDecodeOptions defaultOptions
+        d' = d {decodeOptionsTarget = dhallFile}
+        options = defaultOptions {optionsDecodeOptions = d'}
+
+writeYamlCabal :: FilePath -> FilePath -> FilePath -> IO ()
+writeYamlCabal yamlFile cabalFile yamlCabalFile = do
+        renameFile cabalFile tmp
+        hpack NoVerbose options
+        renameFile cabalFile yamlCabalFile
+        renameFile tmp cabalFile
+    where
+        tmp = cabalFile <.> ".TMP"
+
+        d = optionsDecodeOptions defaultOptions
+        d' = d {decodeOptionsTarget = yamlFile}
+        options =
+            defaultOptions
+                { optionsDecodeOptions = d'
+                }
+
+writeJson :: FilePath -> FilePath -> IO ()
+writeJson dhallFile jsonFile = do
+    s <- showJson Nothing dhallFile
+    writeFile jsonFile s
+
+writeYaml :: FilePath -> FilePath -> IO ()
+writeYaml dhallFile yamlFile = do
+    s <- showYaml Nothing dhallFile
+    writeFile yamlFile s
+
+cabalFilePath :: FilePath -> FilePath
+cabalFilePath p
+    | takeBaseName p == "package" =
+        case reverse . splitDirectories $ ds of
+            d : ds' -> joinPath (reverse ds') </> d </> d <.> ".cabal"
+            _ -> replaceExtension p ".cabal"
+
+    | otherwise =
+        replaceExtension p ".cabal"
+
+    where
+        ds = takeDirectory p
diff --git a/test/golden/test-files/key/empty-inferred/empty-inferred.cabal b/test/golden/test-files/key/empty-inferred/empty-inferred.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/empty-inferred.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53
+
+name:           empty-inferred
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/empty-inferred/empty-inferred.cabal.golden b/test/golden/test-files/key/empty-inferred/empty-inferred.cabal.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/empty-inferred.cabal.golden
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53
+
+name:           empty-inferred
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/empty-inferred/package.dhall b/test/golden/test-files/key/empty-inferred/package.dhall
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/package.dhall
@@ -0,0 +1,1 @@
+{=}
diff --git a/test/golden/test-files/key/empty-inferred/package.dhall.golden b/test/golden/test-files/key/empty-inferred/package.dhall.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/package.dhall.golden
@@ -0,0 +1,1 @@
+{=}
diff --git a/test/golden/test-files/key/empty-inferred/package.json b/test/golden/test-files/key/empty-inferred/package.json
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/package.json
@@ -0,0 +1,1 @@
+{}
diff --git a/test/golden/test-files/key/empty-inferred/package.json.golden b/test/golden/test-files/key/empty-inferred/package.json.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/package.json.golden
@@ -0,0 +1,1 @@
+{}
diff --git a/test/golden/test-files/key/empty-inferred/package.yaml b/test/golden/test-files/key/empty-inferred/package.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/package.yaml
@@ -0,0 +1,1 @@
+{}
diff --git a/test/golden/test-files/key/empty-inferred/package.yaml.cabal b/test/golden/test-files/key/empty-inferred/package.yaml.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/package.yaml.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.yaml by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53
+
+name:           empty-inferred
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/empty-inferred/package.yaml.golden b/test/golden/test-files/key/empty-inferred/package.yaml.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-inferred/package.yaml.golden
@@ -0,0 +1,1 @@
+{}
diff --git a/test/golden/test-files/key/empty-package.cabal b/test/golden/test-files/key/empty-package.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from empty-package.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04
+
+name:           empty-package
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/empty-package.cabal.golden b/test/golden/test-files/key/empty-package.cabal.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.cabal.golden
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from empty-package.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04
+
+name:           empty-package
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/empty-package.dhall b/test/golden/test-files/key/empty-package.dhall
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.dhall
@@ -0,0 +1,1 @@
+{ name = "empty-package" }
diff --git a/test/golden/test-files/key/empty-package.dhall.golden b/test/golden/test-files/key/empty-package.dhall.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.dhall.golden
@@ -0,0 +1,1 @@
+{ name = "empty-package" }
diff --git a/test/golden/test-files/key/empty-package.json b/test/golden/test-files/key/empty-package.json
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.json
@@ -0,0 +1,3 @@
+{
+    "name": "empty-package"
+}
diff --git a/test/golden/test-files/key/empty-package.json.golden b/test/golden/test-files/key/empty-package.json.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.json.golden
@@ -0,0 +1,3 @@
+{
+    "name": "empty-package"
+}
diff --git a/test/golden/test-files/key/empty-package.yaml b/test/golden/test-files/key/empty-package.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.yaml
@@ -0,0 +1,1 @@
+name: empty-package
diff --git a/test/golden/test-files/key/empty-package.yaml.cabal b/test/golden/test-files/key/empty-package.yaml.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.yaml.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from empty-package.yaml by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04
+
+name:           empty-package
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/empty-package.yaml.golden b/test/golden/test-files/key/empty-package.yaml.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/empty-package.yaml.golden
@@ -0,0 +1,1 @@
+name: empty-package
diff --git a/test/golden/test-files/key/import-local/import-local.cabal b/test/golden/test-files/key/import-local/import-local.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/import-local.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: fb3f09267f149cb49eb030ac951c27be9964aa0d51e91460e5b2d59ee1a5082f
+
+name:           import-local
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/import-local/import-local.cabal.golden b/test/golden/test-files/key/import-local/import-local.cabal.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/import-local.cabal.golden
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: fb3f09267f149cb49eb030ac951c27be9964aa0d51e91460e5b2d59ee1a5082f
+
+name:           import-local
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/import-local/name.dhl b/test/golden/test-files/key/import-local/name.dhl
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/name.dhl
@@ -0,0 +1,1 @@
+{ name = "import-local" }
diff --git a/test/golden/test-files/key/import-local/package.dhall b/test/golden/test-files/key/import-local/package.dhall
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/package.dhall
@@ -0,0 +1,1 @@
+./name.dhl ⫽ {=}
diff --git a/test/golden/test-files/key/import-local/package.dhall.golden b/test/golden/test-files/key/import-local/package.dhall.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/package.dhall.golden
@@ -0,0 +1,1 @@
+{ name = "import-local" } ⫽ {=}
diff --git a/test/golden/test-files/key/import-local/package.json b/test/golden/test-files/key/import-local/package.json
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/package.json
@@ -0,0 +1,3 @@
+{
+    "name": "import-local"
+}
diff --git a/test/golden/test-files/key/import-local/package.json.golden b/test/golden/test-files/key/import-local/package.json.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/package.json.golden
@@ -0,0 +1,3 @@
+{
+    "name": "import-local"
+}
diff --git a/test/golden/test-files/key/import-local/package.yaml b/test/golden/test-files/key/import-local/package.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/package.yaml
@@ -0,0 +1,1 @@
+name: import-local
diff --git a/test/golden/test-files/key/import-local/package.yaml.cabal b/test/golden/test-files/key/import-local/package.yaml.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/package.yaml.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.yaml by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: fb3f09267f149cb49eb030ac951c27be9964aa0d51e91460e5b2d59ee1a5082f
+
+name:           import-local
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/import-local/package.yaml.golden b/test/golden/test-files/key/import-local/package.yaml.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-local/package.yaml.golden
@@ -0,0 +1,1 @@
+name: import-local
diff --git a/test/golden/test-files/key/import-relative.dhl b/test/golden/test-files/key/import-relative.dhl
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative.dhl
@@ -0,0 +1,1 @@
+{ name = "import-relative" }
diff --git a/test/golden/test-files/key/import-relative/import-relative.cabal b/test/golden/test-files/key/import-relative/import-relative.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/import-relative.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 989056d21c3910e06ec15967716df134a39f43c561858afff828d22802a22005
+
+name:           import-relative
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/import-relative/import-relative.cabal.golden b/test/golden/test-files/key/import-relative/import-relative.cabal.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/import-relative.cabal.golden
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 989056d21c3910e06ec15967716df134a39f43c561858afff828d22802a22005
+
+name:           import-relative
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/import-relative/package.dhall b/test/golden/test-files/key/import-relative/package.dhall
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/package.dhall
@@ -0,0 +1,1 @@
+../import-relative.dhl ⫽ {=}
diff --git a/test/golden/test-files/key/import-relative/package.dhall.golden b/test/golden/test-files/key/import-relative/package.dhall.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/package.dhall.golden
@@ -0,0 +1,1 @@
+{ name = "import-relative" } ⫽ {=}
diff --git a/test/golden/test-files/key/import-relative/package.json b/test/golden/test-files/key/import-relative/package.json
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/package.json
@@ -0,0 +1,3 @@
+{
+    "name": "import-relative"
+}
diff --git a/test/golden/test-files/key/import-relative/package.json.golden b/test/golden/test-files/key/import-relative/package.json.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/package.json.golden
@@ -0,0 +1,3 @@
+{
+    "name": "import-relative"
+}
diff --git a/test/golden/test-files/key/import-relative/package.yaml b/test/golden/test-files/key/import-relative/package.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/package.yaml
@@ -0,0 +1,1 @@
+name: import-relative
diff --git a/test/golden/test-files/key/import-relative/package.yaml.cabal b/test/golden/test-files/key/import-relative/package.yaml.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/package.yaml.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.yaml by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 989056d21c3910e06ec15967716df134a39f43c561858afff828d22802a22005
+
+name:           import-relative
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/import-relative/package.yaml.golden b/test/golden/test-files/key/import-relative/package.yaml.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/import-relative/package.yaml.golden
@@ -0,0 +1,1 @@
+name: import-relative
diff --git a/test/golden/test-files/key/when-dependencies.cabal b/test/golden/test-files/key/when-dependencies.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from when-dependencies.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: a1d315a919b697e7986a0c149715373427427e43104f82f05f394a439793907f
+
+name:           when-dependencies
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/when-dependencies.cabal.golden b/test/golden/test-files/key/when-dependencies.cabal.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.cabal.golden
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from when-dependencies.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: a1d315a919b697e7986a0c149715373427427e43104f82f05f394a439793907f
+
+name:           when-dependencies
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/when-dependencies.dhall b/test/golden/test-files/key/when-dependencies.dhall
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.dhall
@@ -0,0 +1,13 @@
+    let deps = [ "base == 4.*" ]
+
+in  { name =
+        "when-dependencies"
+    , when =
+        { condition =
+            "impl(ghc < 8.2.2)"
+        , `then` =
+            { dependencies = deps # [ "yaml" ] }
+        , `else` =
+            { dependencies = deps # [ "yaml-pretty-extras" ] }
+        }
+    }
diff --git a/test/golden/test-files/key/when-dependencies.dhall.golden b/test/golden/test-files/key/when-dependencies.dhall.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.dhall.golden
@@ -0,0 +1,13 @@
+    let deps = [ "base == 4.*" ]
+
+in  { name =
+        "when-dependencies"
+    , when =
+        { condition =
+            "impl(ghc < 8.2.2)"
+        , `then` =
+            { dependencies = deps # [ "yaml" ] }
+        , `else` =
+            { dependencies = deps # [ "yaml-pretty-extras" ] }
+        }
+    }
diff --git a/test/golden/test-files/key/when-dependencies.json b/test/golden/test-files/key/when-dependencies.json
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.json
@@ -0,0 +1,18 @@
+{
+    "name": "when-dependencies",
+    "when": {
+        "condition": "impl(ghc < 8.2.2)",
+        "then": {
+            "dependencies": [
+                "base == 4.*",
+                "yaml"
+            ]
+        },
+        "else": {
+            "dependencies": [
+                "base == 4.*",
+                "yaml-pretty-extras"
+            ]
+        }
+    }
+}
diff --git a/test/golden/test-files/key/when-dependencies.json.golden b/test/golden/test-files/key/when-dependencies.json.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.json.golden
@@ -0,0 +1,18 @@
+{
+    "name": "when-dependencies",
+    "when": {
+        "condition": "impl(ghc < 8.2.2)",
+        "then": {
+            "dependencies": [
+                "base == 4.*",
+                "yaml"
+            ]
+        },
+        "else": {
+            "dependencies": [
+                "base == 4.*",
+                "yaml-pretty-extras"
+            ]
+        }
+    }
+}
diff --git a/test/golden/test-files/key/when-dependencies.yaml b/test/golden/test-files/key/when-dependencies.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.yaml
@@ -0,0 +1,11 @@
+name: when-dependencies
+when:
+  condition: impl(ghc < 8.2.2)
+  then:
+    dependencies:
+    - base == 4.*
+    - yaml
+  else:
+    dependencies:
+    - base == 4.*
+    - yaml-pretty-extras
diff --git a/test/golden/test-files/key/when-dependencies.yaml.cabal b/test/golden/test-files/key/when-dependencies.yaml.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.yaml.cabal
@@ -0,0 +1,11 @@
+cabal-version: 1.12
+
+-- This file has been generated from when-dependencies.yaml by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: a1d315a919b697e7986a0c149715373427427e43104f82f05f394a439793907f
+
+name:           when-dependencies
+version:        0.0.0
+build-type:     Simple
diff --git a/test/golden/test-files/key/when-dependencies.yaml.golden b/test/golden/test-files/key/when-dependencies.yaml.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/key/when-dependencies.yaml.golden
@@ -0,0 +1,11 @@
+name: when-dependencies
+when:
+  condition: impl(ghc < 8.2.2)
+  then:
+    dependencies:
+    - base == 4.*
+    - yaml
+  else:
+    dependencies:
+    - base == 4.*
+    - yaml-pretty-extras
diff --git a/test/golden/test-files/real-world/hpack/hpack.cabal b/test/golden/test-files/real-world/hpack/hpack.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.cabal
@@ -0,0 +1,136 @@
+cabal-version: 1.12
+
+-- This file has been generated from hpack.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 6233d5bc3d8cc3400d64ab30856182d4a593d9245bfdd5096e1287213cc3ae31
+
+name:           hpack
+version:        0.31.1
+synopsis:       A modern format for Haskell packages
+description:    See README at <https://github.com/sol/hpack#readme>
+category:       Development
+homepage:       https://github.com/sol/hpack#readme
+bug-reports:    https://github.com/sol/hpack/issues
+maintainer:     Simon Hengel <sol@typeful.net>
+build-type:     Simple
+extra-source-files:
+    CHANGELOG.md
+
+source-repository head
+  type: git
+  location: https://github.com/sol/hpack
+
+library
+  exposed-modules:
+      Hpack
+      Hpack.Config
+      Hpack.Render
+      Hpack.Yaml
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      src
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , pretty
+    , scientific
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
+
+executable hpack
+  main-is: Main.hs
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      driver
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , hpack
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , pretty
+    , scientific
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
+
+test-suite spec
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      test
+      src
+  ghc-options: -Wall
+  cpp-options: -DTEST
+  build-tool-depends:
+      hspec-discover:hspec-discover
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , HUnit >=1.6.0.0
+    , QuickCheck
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , hspec ==2.*
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , interpolate
+    , mockery >=0.3
+    , pretty
+    , scientific
+    , template-haskell
+    , temporary
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
diff --git a/test/golden/test-files/real-world/hpack/hpack.cabal.golden b/test/golden/test-files/real-world/hpack/hpack.cabal.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.cabal.golden
@@ -0,0 +1,136 @@
+cabal-version: 1.12
+
+-- This file has been generated from hpack.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 6233d5bc3d8cc3400d64ab30856182d4a593d9245bfdd5096e1287213cc3ae31
+
+name:           hpack
+version:        0.31.1
+synopsis:       A modern format for Haskell packages
+description:    See README at <https://github.com/sol/hpack#readme>
+category:       Development
+homepage:       https://github.com/sol/hpack#readme
+bug-reports:    https://github.com/sol/hpack/issues
+maintainer:     Simon Hengel <sol@typeful.net>
+build-type:     Simple
+extra-source-files:
+    CHANGELOG.md
+
+source-repository head
+  type: git
+  location: https://github.com/sol/hpack
+
+library
+  exposed-modules:
+      Hpack
+      Hpack.Config
+      Hpack.Render
+      Hpack.Yaml
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      src
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , pretty
+    , scientific
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
+
+executable hpack
+  main-is: Main.hs
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      driver
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , hpack
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , pretty
+    , scientific
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
+
+test-suite spec
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      test
+      src
+  ghc-options: -Wall
+  cpp-options: -DTEST
+  build-tool-depends:
+      hspec-discover:hspec-discover
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , HUnit >=1.6.0.0
+    , QuickCheck
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , hspec ==2.*
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , interpolate
+    , mockery >=0.3
+    , pretty
+    , scientific
+    , template-haskell
+    , temporary
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
diff --git a/test/golden/test-files/real-world/hpack/hpack.dhall b/test/golden/test-files/real-world/hpack/hpack.dhall
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.dhall
@@ -0,0 +1,72 @@
+{ name =
+    "hpack"
+, version =
+    "0.31.1"
+, synopsis =
+    "A modern format for Haskell packages"
+, description =
+    "See README at <https://github.com/sol/hpack#readme>"
+, maintainer =
+    "Simon Hengel <sol@typeful.net>"
+, github =
+    "sol/hpack"
+, category =
+    "Development"
+, extra-source-files =
+    [ "CHANGELOG.md" ]
+, ghc-options =
+    "-Wall"
+, dependencies =
+    [ "base >= 4.9 && < 5"
+    , "bytestring"
+    , "deepseq"
+    , "directory"
+    , "filepath"
+    , "Glob >= 0.9.0"
+    , "text"
+    , "containers"
+    , "unordered-containers"
+    , "yaml >= 0.10.0"
+    , "aeson >= 1.2.1.0"
+    , "scientific"
+    , "Cabal >= 2.2"
+    , "pretty"
+    , "bifunctors"
+    , "cryptonite"
+    , "transformers"
+    , "http-types"
+    , "http-client"
+    , "http-client-tls"
+    , "vector"
+    , "infer-license >= 0.2.0 && < 0.3"
+    ]
+, library =
+    { source-dirs =
+        "src"
+    , exposed-modules =
+        [ "Hpack", "Hpack.Config", "Hpack.Render", "Hpack.Yaml" ]
+    }
+, executable =
+    { main = "Main.hs", source-dirs = "driver", dependencies = [ "hpack" ] }
+, tests =
+    { spec =
+        { cpp-options =
+            "-DTEST"
+        , main =
+            "Spec.hs"
+        , source-dirs =
+            [ "test", "src" ]
+        , dependencies =
+            [ "hspec == 2.*"
+            , "QuickCheck"
+            , "temporary"
+            , "mockery >= 0.3"
+            , "interpolate"
+            , "template-haskell"
+            , "HUnit >= 1.6.0.0"
+            ]
+        , build-tools =
+            "hspec-discover"
+        }
+    }
+}
diff --git a/test/golden/test-files/real-world/hpack/hpack.dhall.golden b/test/golden/test-files/real-world/hpack/hpack.dhall.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.dhall.golden
@@ -0,0 +1,72 @@
+{ name =
+    "hpack"
+, version =
+    "0.31.1"
+, synopsis =
+    "A modern format for Haskell packages"
+, description =
+    "See README at <https://github.com/sol/hpack#readme>"
+, maintainer =
+    "Simon Hengel <sol@typeful.net>"
+, github =
+    "sol/hpack"
+, category =
+    "Development"
+, extra-source-files =
+    [ "CHANGELOG.md" ]
+, ghc-options =
+    "-Wall"
+, dependencies =
+    [ "base >= 4.9 && < 5"
+    , "bytestring"
+    , "deepseq"
+    , "directory"
+    , "filepath"
+    , "Glob >= 0.9.0"
+    , "text"
+    , "containers"
+    , "unordered-containers"
+    , "yaml >= 0.10.0"
+    , "aeson >= 1.2.1.0"
+    , "scientific"
+    , "Cabal >= 2.2"
+    , "pretty"
+    , "bifunctors"
+    , "cryptonite"
+    , "transformers"
+    , "http-types"
+    , "http-client"
+    , "http-client-tls"
+    , "vector"
+    , "infer-license >= 0.2.0 && < 0.3"
+    ]
+, library =
+    { source-dirs =
+        "src"
+    , exposed-modules =
+        [ "Hpack", "Hpack.Config", "Hpack.Render", "Hpack.Yaml" ]
+    }
+, executable =
+    { main = "Main.hs", source-dirs = "driver", dependencies = [ "hpack" ] }
+, tests =
+    { spec =
+        { cpp-options =
+            "-DTEST"
+        , main =
+            "Spec.hs"
+        , source-dirs =
+            [ "test", "src" ]
+        , dependencies =
+            [ "hspec == 2.*"
+            , "QuickCheck"
+            , "temporary"
+            , "mockery >= 0.3"
+            , "interpolate"
+            , "template-haskell"
+            , "HUnit >= 1.6.0.0"
+            ]
+        , build-tools =
+            "hspec-discover"
+        }
+    }
+}
diff --git a/test/golden/test-files/real-world/hpack/hpack.json b/test/golden/test-files/real-world/hpack/hpack.json
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.json
@@ -0,0 +1,73 @@
+{
+    "name": "hpack",
+    "version": "0.31.1",
+    "synopsis": "A modern format for Haskell packages",
+    "description": "See README at <https://github.com/sol/hpack#readme>",
+    "category": "Development",
+    "maintainer": "Simon Hengel <sol@typeful.net>",
+    "github": "sol/hpack",
+    "extra-source-files": [
+        "CHANGELOG.md"
+    ],
+    "ghc-options": "-Wall",
+    "dependencies": [
+        "base >= 4.9 && < 5",
+        "bytestring",
+        "deepseq",
+        "directory",
+        "filepath",
+        "Glob >= 0.9.0",
+        "text",
+        "containers",
+        "unordered-containers",
+        "yaml >= 0.10.0",
+        "aeson >= 1.2.1.0",
+        "scientific",
+        "Cabal >= 2.2",
+        "pretty",
+        "bifunctors",
+        "cryptonite",
+        "transformers",
+        "http-types",
+        "http-client",
+        "http-client-tls",
+        "vector",
+        "infer-license >= 0.2.0 && < 0.3"
+    ],
+    "library": {
+        "exposed-modules": [
+            "Hpack",
+            "Hpack.Config",
+            "Hpack.Render",
+            "Hpack.Yaml"
+        ],
+        "source-dirs": "src"
+    },
+    "executable": {
+        "main": "Main.hs",
+        "source-dirs": "driver",
+        "dependencies": [
+            "hpack"
+        ]
+    },
+    "tests": {
+        "spec": {
+            "main": "Spec.hs",
+            "source-dirs": [
+                "test",
+                "src"
+            ],
+            "cpp-options": "-DTEST",
+            "dependencies": [
+                "hspec == 2.*",
+                "QuickCheck",
+                "temporary",
+                "mockery >= 0.3",
+                "interpolate",
+                "template-haskell",
+                "HUnit >= 1.6.0.0"
+            ],
+            "build-tools": "hspec-discover"
+        }
+    }
+}
diff --git a/test/golden/test-files/real-world/hpack/hpack.json.golden b/test/golden/test-files/real-world/hpack/hpack.json.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.json.golden
@@ -0,0 +1,73 @@
+{
+    "name": "hpack",
+    "version": "0.31.1",
+    "synopsis": "A modern format for Haskell packages",
+    "description": "See README at <https://github.com/sol/hpack#readme>",
+    "category": "Development",
+    "maintainer": "Simon Hengel <sol@typeful.net>",
+    "github": "sol/hpack",
+    "extra-source-files": [
+        "CHANGELOG.md"
+    ],
+    "ghc-options": "-Wall",
+    "dependencies": [
+        "base >= 4.9 && < 5",
+        "bytestring",
+        "deepseq",
+        "directory",
+        "filepath",
+        "Glob >= 0.9.0",
+        "text",
+        "containers",
+        "unordered-containers",
+        "yaml >= 0.10.0",
+        "aeson >= 1.2.1.0",
+        "scientific",
+        "Cabal >= 2.2",
+        "pretty",
+        "bifunctors",
+        "cryptonite",
+        "transformers",
+        "http-types",
+        "http-client",
+        "http-client-tls",
+        "vector",
+        "infer-license >= 0.2.0 && < 0.3"
+    ],
+    "library": {
+        "exposed-modules": [
+            "Hpack",
+            "Hpack.Config",
+            "Hpack.Render",
+            "Hpack.Yaml"
+        ],
+        "source-dirs": "src"
+    },
+    "executable": {
+        "main": "Main.hs",
+        "source-dirs": "driver",
+        "dependencies": [
+            "hpack"
+        ]
+    },
+    "tests": {
+        "spec": {
+            "main": "Spec.hs",
+            "source-dirs": [
+                "test",
+                "src"
+            ],
+            "cpp-options": "-DTEST",
+            "dependencies": [
+                "hspec == 2.*",
+                "QuickCheck",
+                "temporary",
+                "mockery >= 0.3",
+                "interpolate",
+                "template-haskell",
+                "HUnit >= 1.6.0.0"
+            ],
+            "build-tools": "hspec-discover"
+        }
+    }
+}
diff --git a/test/golden/test-files/real-world/hpack/hpack.yaml b/test/golden/test-files/real-world/hpack/hpack.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.yaml
@@ -0,0 +1,61 @@
+name: hpack
+version: 0.31.1
+synopsis: A modern format for Haskell packages
+description: See README at <https://github.com/sol/hpack#readme>
+category: Development
+maintainer: Simon Hengel <sol@typeful.net>
+github: sol/hpack
+extra-source-files:
+- CHANGELOG.md
+ghc-options: -Wall
+dependencies:
+- base >= 4.9 && < 5
+- bytestring
+- deepseq
+- directory
+- filepath
+- Glob >= 0.9.0
+- text
+- containers
+- unordered-containers
+- yaml >= 0.10.0
+- aeson >= 1.2.1.0
+- scientific
+- Cabal >= 2.2
+- pretty
+- bifunctors
+- cryptonite
+- transformers
+- http-types
+- http-client
+- http-client-tls
+- vector
+- infer-license >= 0.2.0 && < 0.3
+library:
+  exposed-modules:
+  - Hpack
+  - Hpack.Config
+  - Hpack.Render
+  - Hpack.Yaml
+  source-dirs: src
+executable:
+  main: Main.hs
+  source-dirs: driver
+  dependencies:
+  - hpack
+tests:
+  spec:
+    main: Spec.hs
+    source-dirs:
+    - test
+    - src
+    cpp-options: -DTEST
+    dependencies:
+    - hspec == 2.*
+    - QuickCheck
+    - temporary
+    - mockery >= 0.3
+    - interpolate
+    - template-haskell
+    - HUnit >= 1.6.0.0
+    build-tools: hspec-discover
diff --git a/test/golden/test-files/real-world/hpack/hpack.yaml.cabal b/test/golden/test-files/real-world/hpack/hpack.yaml.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.yaml.cabal
@@ -0,0 +1,136 @@
+cabal-version: 1.12
+
+-- This file has been generated from hpack.yaml by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 6233d5bc3d8cc3400d64ab30856182d4a593d9245bfdd5096e1287213cc3ae31
+
+name:           hpack
+version:        0.31.1
+synopsis:       A modern format for Haskell packages
+description:    See README at <https://github.com/sol/hpack#readme>
+category:       Development
+homepage:       https://github.com/sol/hpack#readme
+bug-reports:    https://github.com/sol/hpack/issues
+maintainer:     Simon Hengel <sol@typeful.net>
+build-type:     Simple
+extra-source-files:
+    CHANGELOG.md
+
+source-repository head
+  type: git
+  location: https://github.com/sol/hpack
+
+library
+  exposed-modules:
+      Hpack
+      Hpack.Config
+      Hpack.Render
+      Hpack.Yaml
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      src
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , pretty
+    , scientific
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
+
+executable hpack
+  main-is: Main.hs
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      driver
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , hpack
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , pretty
+    , scientific
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
+
+test-suite spec
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  other-modules:
+      Paths_hpack
+  hs-source-dirs:
+      test
+      src
+  ghc-options: -Wall
+  cpp-options: -DTEST
+  build-tool-depends:
+      hspec-discover:hspec-discover
+  build-depends:
+      Cabal >=2.2
+    , Glob >=0.9.0
+    , HUnit >=1.6.0.0
+    , QuickCheck
+    , aeson >=1.2.1.0
+    , base >=4.9 && <5
+    , bifunctors
+    , bytestring
+    , containers
+    , cryptonite
+    , deepseq
+    , directory
+    , filepath
+    , hspec ==2.*
+    , http-client
+    , http-client-tls
+    , http-types
+    , infer-license >=0.2.0 && <0.3
+    , interpolate
+    , mockery >=0.3
+    , pretty
+    , scientific
+    , template-haskell
+    , temporary
+    , text
+    , transformers
+    , unordered-containers
+    , vector
+    , yaml >=0.10.0
+  default-language: Haskell2010
diff --git a/test/golden/test-files/real-world/hpack/hpack.yaml.golden b/test/golden/test-files/real-world/hpack/hpack.yaml.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/hpack.yaml.golden
@@ -0,0 +1,61 @@
+name: hpack
+version: 0.31.1
+synopsis: A modern format for Haskell packages
+description: See README at <https://github.com/sol/hpack#readme>
+category: Development
+maintainer: Simon Hengel <sol@typeful.net>
+github: sol/hpack
+extra-source-files:
+- CHANGELOG.md
+ghc-options: -Wall
+dependencies:
+- base >= 4.9 && < 5
+- bytestring
+- deepseq
+- directory
+- filepath
+- Glob >= 0.9.0
+- text
+- containers
+- unordered-containers
+- yaml >= 0.10.0
+- aeson >= 1.2.1.0
+- scientific
+- Cabal >= 2.2
+- pretty
+- bifunctors
+- cryptonite
+- transformers
+- http-types
+- http-client
+- http-client-tls
+- vector
+- infer-license >= 0.2.0 && < 0.3
+library:
+  exposed-modules:
+  - Hpack
+  - Hpack.Config
+  - Hpack.Render
+  - Hpack.Yaml
+  source-dirs: src
+executable:
+  main: Main.hs
+  source-dirs: driver
+  dependencies:
+  - hpack
+tests:
+  spec:
+    main: Spec.hs
+    source-dirs:
+    - test
+    - src
+    cpp-options: -DTEST
+    dependencies:
+    - hspec == 2.*
+    - QuickCheck
+    - temporary
+    - mockery >= 0.3
+    - interpolate
+    - template-haskell
+    - HUnit >= 1.6.0.0
+    build-tools: hspec-discover
diff --git a/test/golden/test-files/real-world/hpack/package.yaml b/test/golden/test-files/real-world/hpack/package.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/hpack/package.yaml
@@ -0,0 +1,66 @@
+name: hpack
+version: 0.31.1
+synopsis: A modern format for Haskell packages
+description: See README at <https://github.com/sol/hpack#readme>
+maintainer: Simon Hengel <sol@typeful.net>
+github: sol/hpack
+category: Development
+extra-source-files:
+  - CHANGELOG.md
+
+ghc-options: -Wall
+
+dependencies:
+  - base >= 4.9 && < 5
+  - bytestring
+  - deepseq
+  - directory
+  - filepath
+  - Glob >= 0.9.0
+  - text
+  - containers
+  - unordered-containers
+  - yaml >= 0.10.0
+  - aeson >= 1.2.1.0
+  - scientific
+  - Cabal >= 2.2
+  - pretty
+  - bifunctors
+  - cryptonite
+  - transformers
+  - http-types
+  - http-client
+  - http-client-tls
+  - vector
+  - infer-license >= 0.2.0 && < 0.3
+
+library:
+  source-dirs: src
+  exposed-modules:
+    - Hpack
+    - Hpack.Config
+    - Hpack.Render
+    - Hpack.Yaml
+
+executable:
+  main: Main.hs
+  source-dirs: driver
+  dependencies:
+    - hpack
+
+tests:
+  spec:
+    cpp-options: -DTEST
+    main: Spec.hs
+    source-dirs:
+      - test
+      - src
+    dependencies:
+      - hspec == 2.*
+      - QuickCheck
+      - temporary
+      - mockery >= 0.3
+      - interpolate
+      - template-haskell
+      - HUnit >= 1.6.0.0
+    build-tools: hspec-discover
diff --git a/test/golden/test-files/real-world/stack/package.yaml b/test/golden/test-files/real-world/stack/package.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/package.yaml
@@ -0,0 +1,341 @@
+name: stack
+version: '1.10.0'
+synopsis: The Haskell Tool Stack
+description: ! 'Please see the README.md for usage information, and
+  the wiki on Github for more details.  Also, note that
+  the API for the library is not currently stable, and may
+  change significantly, even between minor releases. It is
+  currently only intended for use by the executable.'
+category: Development
+author: Commercial Haskell SIG
+maintainer: manny@fpcomplete.com
+license: BSD3
+github: commercialhaskell/stack
+homepage: http://haskellstack.org
+custom-setup:
+  dependencies:
+  - base >=4.10 && < 5
+  - Cabal >= 2.4
+  - filepath
+extra-source-files:
+# note: leaving out 'package.yaml' because it causes confusion with hackage metadata revisions
+- CONTRIBUTING.md
+- ChangeLog.md
+- README.md
+- doc/*.md
+- src/setup-shim/StackSetupShim.hs
+- stack.yaml
+- test/package-dump/ghc-7.10.txt
+- test/package-dump/ghc-7.8.4-osx.txt
+- test/package-dump/ghc-7.8.txt
+ghc-options:
+- -Wall
+- -fwarn-tabs
+- -fwarn-incomplete-uni-patterns
+- -fwarn-incomplete-record-updates
+- -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739)
+dependencies:
+- Cabal >= 2.4
+- aeson
+- annotated-wl-pprint
+- ansi-terminal >= 0.8.1
+- array
+- async
+- attoparsec
+- base >=4.10 && < 5
+- base64-bytestring
+- bytestring
+- colour
+- conduit
+- conduit-extra
+- containers
+- cryptonite
+- cryptonite-conduit
+- deepseq
+- directory
+- echo
+- exceptions
+- extra
+- file-embed
+- filelock
+- filepath
+- fsnotify
+- generic-deriving
+- hackage-security
+- hashable
+- hpack
+- hpc
+- http-client
+- http-client-tls
+- http-conduit
+- http-types
+- memory
+- microlens
+- mintty
+# TODO remove dep when persistent drops monad-logger
+- monad-logger
+- mono-traversable
+- mtl
+- mustache
+- neat-interpolation
+- network-uri
+- open-browser
+- optparse-applicative
+- pantry
+- path
+- path-io
+- persistent
+- persistent-sqlite
+- persistent-template
+- pretty
+- primitive
+- process
+- project-template
+- regex-applicative-text
+- resourcet
+- retry >= 0.7
+- rio
+- semigroups
+- split
+- stm
+- store-core # FIXME remove
+- streaming-commons
+- tar
+- template-haskell
+- temporary
+- text
+- text-metrics
+- th-reify-many
+- time
+- tls
+- transformers
+- typed-process
+- unicode-transforms
+- unix-compat
+- unliftio >= 0.2.8.0
+- unordered-containers
+- vector
+- yaml
+- zip-archive
+- zlib
+when:
+- condition: os(windows)
+  then:
+    cpp-options: -DWINDOWS
+    dependencies:
+    - Win32
+  else:
+    build-tools:
+    - hsc2hs
+    dependencies:
+    - unix
+library:
+  source-dirs: src/
+  ghc-options:
+  - -fwarn-identities
+  generated-exposed-modules:
+  - Paths_stack
+  exposed-modules:
+  - Control.Concurrent.Execute
+  - Data.Attoparsec.Args
+  - Data.Attoparsec.Combinators
+  - Data.Attoparsec.Interpreter
+  - Data.Monoid.Map
+  - Network.HTTP.Download
+  - Network.HTTP.Download.Verified
+  - Network.HTTP.StackClient
+  - Options.Applicative.Args
+  - Options.Applicative.Builder.Extra
+  - Options.Applicative.Complicated
+  - Path.CheckInstall
+  - Path.Extra
+  - Path.Find
+  - Stack.Build
+  - Stack.Build.Cache
+  - Stack.Build.ConstructPlan
+  - Stack.Build.Execute
+  - Stack.Build.Haddock
+  - Stack.Build.Installed
+  - Stack.Build.Source
+  - Stack.Build.Target
+  - Stack.BuildPlan
+  - Stack.Clean
+  - Stack.Config
+  - Stack.Config.Build
+  - Stack.Config.Urls
+  - Stack.Config.Docker
+  - Stack.Config.Nix
+  - Stack.ConfigCmd
+  - Stack.Constants
+  - Stack.Constants.Config
+  - Stack.Coverage
+  - Stack.DefaultColorWhen
+  - Stack.DefaultStyles
+  - Stack.Docker
+  - Stack.Docker.GlobalDB
+  - Stack.Dot
+  - Stack.FileWatch
+  - Stack.Freeze
+  - Stack.GhcPkg
+  - Stack.Ghci
+  - Stack.Ghci.Script
+  - Stack.Hoogle
+  - Stack.IDE
+  - Stack.Image
+  - Stack.Init
+  - Stack.Ls
+  - Stack.New
+  - Stack.Nix
+  - Stack.Options.BenchParser
+  - Stack.Options.BuildMonoidParser
+  - Stack.Options.BuildParser
+  - Stack.Options.CleanParser
+  - Stack.Options.ConfigParser
+  - Stack.Options.Completion
+  - Stack.Options.DockerParser
+  - Stack.Options.DotParser
+  - Stack.Options.ExecParser
+  - Stack.Options.FreezeParser
+  - Stack.Options.GhcBuildParser
+  - Stack.Options.GhciParser
+  - Stack.Options.GhcVariantParser
+  - Stack.Options.GlobalParser
+  - Stack.Options.HaddockParser
+  - Stack.Options.HpcReportParser
+  - Stack.Options.LogLevelParser
+  - Stack.Options.NewParser
+  - Stack.Options.NixParser
+  - Stack.Options.PackageParser
+  - Stack.Options.ResolverParser
+  - Stack.Options.ScriptParser
+  - Stack.Options.SDistParser
+  - Stack.Options.SolverParser
+  - Stack.Options.TestParser
+  - Stack.Options.Utils
+  - Stack.Package
+  - Stack.PackageDump
+  - Stack.Path
+  - Stack.Prelude
+  - Stack.PrettyPrint
+  - Stack.Runners
+  - Stack.Script
+  - Stack.SDist
+  - Stack.Setup
+  - Stack.Setup.Installed
+  - Stack.SetupCmd
+  - Stack.Sig
+  - Stack.Sig.GPG
+  - Stack.Sig.Sign
+  - Stack.Snapshot
+  - Stack.Solver
+  - Stack.StoreTH
+  - Stack.Types.Build
+  - Stack.Types.BuildPlan
+  - Stack.Types.CompilerBuild
+  - Stack.Types.Urls
+  - Stack.Types.Compiler
+  - Stack.Types.Config
+  - Stack.Types.Config.Build
+  - Stack.Types.Docker
+  - Stack.Types.GhcPkgId
+  - Stack.Types.Image
+  - Stack.Types.NamedComponent
+  - Stack.Types.Nix
+  - Stack.Types.Package
+  - Stack.Types.PackageDump
+  - Stack.Types.PackageName
+  - Stack.Types.PrettyPrint
+  - Stack.Types.Resolver
+  - Stack.Types.Runner
+  - Stack.Types.Sig
+  - Stack.Types.StylesUpdate
+  - Stack.Types.TemplateName
+  - Stack.Types.Version
+  - Stack.Types.VersionIntervals
+  - Stack.Unpack
+  - Stack.Upgrade
+  - Stack.Upload
+  - Text.PrettyPrint.Leijen.Extended
+  - System.Permissions
+  - System.Process.PagerEditor
+  - System.Terminal
+  when:
+  - condition: 'os(windows)'
+    then:
+      source-dirs: src/windows/
+    else:
+      source-dirs: src/unix/
+      c-sources: src/unix/cbits/uname.c
+executables:
+  stack:
+    main: Main.hs
+    source-dirs: src/main
+    generated-other-modules:
+    - Build_stack,
+    - Paths_stack
+    ghc-options:
+    - -threaded
+    - -rtsopts
+    dependencies:
+    - stack
+    when:
+    - condition: flag(static)
+      ld-options:
+      - -static
+      - -pthread
+    - condition: ! '!(flag(disable-git-info))'
+      cpp-options: -DUSE_GIT_INFO
+      dependencies:
+      - githash
+      - optparse-simple
+    - condition: flag(hide-dependency-versions)
+      cpp-options: -DHIDE_DEP_VERSIONS
+    - condition: flag(supported-build)
+      cpp-options: -DSUPPORTED_BUILD
+tests:
+  stack-test:
+    main: Spec.hs
+    source-dirs: src/test
+    ghc-options:
+    - -threaded
+    dependencies:
+    - QuickCheck
+    - hspec
+    - stack
+    - smallcheck
+  stack-integration-test:
+    main: IntegrationSpec.hs
+    source-dirs:
+    - test/integration
+    - test/integration/lib
+    ghc-options:
+    - -threaded
+    - -rtsopts
+    - -with-rtsopts=-N
+    dependencies:
+    - hspec
+    when:
+    - condition: ! '!(flag(integration-tests))'
+      buildable: false
+flags:
+  static:
+    description: Pass -static/-pthread to ghc when linking the stack binary.
+    manual: true
+    default: false
+  disable-git-info:
+    description: Disable compile-time inclusion of current git info in stack
+    manual: true
+    default: false
+  hide-dependency-versions:
+    description: Hides dependency versions from "stack --version", used only by building
+      with stack.yaml
+    manual: true
+    default: false
+  integration-tests:
+    description: Run the integration test suite
+    manual: true
+    default: false
+  supported-build:
+    description: If false, causes "stack --version" to issue a warning about the build being unsupported.  True only if building with stack.yaml
+    manual: true
+    default: false
diff --git a/test/golden/test-files/real-world/stack/stack.cabal b/test/golden/test-files/real-world/stack/stack.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.cabal
@@ -0,0 +1,629 @@
+cabal-version: 2.0
+
+-- This file has been generated from stack.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 33d90e3e81d97f3c404a9e20246cf4aa6942dc054db675cadd50b1edd68582ce
+
+name:           stack
+version:        1.10.0
+synopsis:       The Haskell Tool Stack
+description:    Please see the README.md for usage information, and
+                the wiki on Github for more details.  Also, note that
+                the API for the library is not currently stable, and may
+                change significantly, even between minor releases. It is
+                currently only intended for use by the executable.
+category:       Development
+homepage:       http://haskellstack.org
+bug-reports:    https://github.com/commercialhaskell/stack/issues
+author:         Commercial Haskell SIG
+maintainer:     manny@fpcomplete.com
+license:        BSD3
+build-type:     Custom
+extra-source-files:
+    CONTRIBUTING.md
+    ChangeLog.md
+    README.md
+    src/setup-shim/StackSetupShim.hs
+    stack.yaml
+    test/package-dump/ghc-7.10.txt
+    test/package-dump/ghc-7.8.4-osx.txt
+    test/package-dump/ghc-7.8.txt
+
+source-repository head
+  type: git
+  location: https://github.com/commercialhaskell/stack
+
+custom-setup
+  setup-depends:
+      Cabal >=2.4
+    , base >=4.10 && <5
+    , filepath
+
+flag disable-git-info
+  description: Disable compile-time inclusion of current git info in stack
+  manual: True
+  default: False
+
+flag hide-dependency-versions
+  description: Hides dependency versions from "stack --version", used only by building with stack.yaml
+  manual: True
+  default: False
+
+flag integration-tests
+  description: Run the integration test suite
+  manual: True
+  default: False
+
+flag static
+  description: Pass -static/-pthread to ghc when linking the stack binary.
+  manual: True
+  default: False
+
+flag supported-build
+  description: If false, causes "stack --version" to issue a warning about the build being unsupported.  True only if building with stack.yaml
+  manual: True
+  default: False
+
+library
+  exposed-modules:
+      Control.Concurrent.Execute
+      Data.Attoparsec.Args
+      Data.Attoparsec.Combinators
+      Data.Attoparsec.Interpreter
+      Data.Monoid.Map
+      Network.HTTP.Download
+      Network.HTTP.Download.Verified
+      Network.HTTP.StackClient
+      Options.Applicative.Args
+      Options.Applicative.Builder.Extra
+      Options.Applicative.Complicated
+      Path.CheckInstall
+      Path.Extra
+      Path.Find
+      Stack.Build
+      Stack.Build.Cache
+      Stack.Build.ConstructPlan
+      Stack.Build.Execute
+      Stack.Build.Haddock
+      Stack.Build.Installed
+      Stack.Build.Source
+      Stack.Build.Target
+      Stack.BuildPlan
+      Stack.Clean
+      Stack.Config
+      Stack.Config.Build
+      Stack.Config.Urls
+      Stack.Config.Docker
+      Stack.Config.Nix
+      Stack.ConfigCmd
+      Stack.Constants
+      Stack.Constants.Config
+      Stack.Coverage
+      Stack.DefaultColorWhen
+      Stack.DefaultStyles
+      Stack.Docker
+      Stack.Docker.GlobalDB
+      Stack.Dot
+      Stack.FileWatch
+      Stack.Freeze
+      Stack.GhcPkg
+      Stack.Ghci
+      Stack.Ghci.Script
+      Stack.Hoogle
+      Stack.IDE
+      Stack.Image
+      Stack.Init
+      Stack.Ls
+      Stack.New
+      Stack.Nix
+      Stack.Options.BenchParser
+      Stack.Options.BuildMonoidParser
+      Stack.Options.BuildParser
+      Stack.Options.CleanParser
+      Stack.Options.ConfigParser
+      Stack.Options.Completion
+      Stack.Options.DockerParser
+      Stack.Options.DotParser
+      Stack.Options.ExecParser
+      Stack.Options.FreezeParser
+      Stack.Options.GhcBuildParser
+      Stack.Options.GhciParser
+      Stack.Options.GhcVariantParser
+      Stack.Options.GlobalParser
+      Stack.Options.HaddockParser
+      Stack.Options.HpcReportParser
+      Stack.Options.LogLevelParser
+      Stack.Options.NewParser
+      Stack.Options.NixParser
+      Stack.Options.PackageParser
+      Stack.Options.ResolverParser
+      Stack.Options.ScriptParser
+      Stack.Options.SDistParser
+      Stack.Options.SolverParser
+      Stack.Options.TestParser
+      Stack.Options.Utils
+      Stack.Package
+      Stack.PackageDump
+      Stack.Path
+      Stack.Prelude
+      Stack.PrettyPrint
+      Stack.Runners
+      Stack.Script
+      Stack.SDist
+      Stack.Setup
+      Stack.Setup.Installed
+      Stack.SetupCmd
+      Stack.Sig
+      Stack.Sig.GPG
+      Stack.Sig.Sign
+      Stack.Snapshot
+      Stack.Solver
+      Stack.StoreTH
+      Stack.Types.Build
+      Stack.Types.BuildPlan
+      Stack.Types.CompilerBuild
+      Stack.Types.Urls
+      Stack.Types.Compiler
+      Stack.Types.Config
+      Stack.Types.Config.Build
+      Stack.Types.Docker
+      Stack.Types.GhcPkgId
+      Stack.Types.Image
+      Stack.Types.NamedComponent
+      Stack.Types.Nix
+      Stack.Types.Package
+      Stack.Types.PackageDump
+      Stack.Types.PackageName
+      Stack.Types.PrettyPrint
+      Stack.Types.Resolver
+      Stack.Types.Runner
+      Stack.Types.Sig
+      Stack.Types.StylesUpdate
+      Stack.Types.TemplateName
+      Stack.Types.Version
+      Stack.Types.VersionIntervals
+      Stack.Unpack
+      Stack.Upgrade
+      Stack.Upload
+      Text.PrettyPrint.Leijen.Extended
+      System.Permissions
+      System.Process.PagerEditor
+      System.Terminal
+      Paths_stack
+  autogen-modules:
+      Paths_stack
+  hs-source-dirs:
+      src/
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -fwarn-identities
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if os(windows)
+    hs-source-dirs:
+        src/windows/
+  else
+    hs-source-dirs:
+        src/unix/
+    c-sources:
+        src/unix/cbits/uname.c
+  default-language: Haskell2010
+
+executable stack
+  main-is: Main.hs
+  other-modules:
+      Build_stack
+      Paths_stack
+  autogen-modules:
+      Build_stack
+      Paths_stack
+  hs-source-dirs:
+      src/main
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded -rtsopts
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stack
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if flag(static)
+    ld-options: -static -pthread
+  if !(flag(disable-git-info))
+    cpp-options: -DUSE_GIT_INFO
+    build-depends:
+        githash
+      , optparse-simple
+  if flag(hide-dependency-versions)
+    cpp-options: -DHIDE_DEP_VERSIONS
+  if flag(supported-build)
+    cpp-options: -DSUPPORTED_BUILD
+  default-language: Haskell2010
+
+test-suite stack-integration-test
+  type: exitcode-stdio-1.0
+  main-is: IntegrationSpec.hs
+  other-modules:
+      Paths_stack
+  hs-source-dirs:
+      test/integration
+      test/integration/lib
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded -rtsopts -with-rtsopts=-N
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , hspec
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if !flag(integration-tests)
+    buildable: False
+  default-language: Haskell2010
+
+test-suite stack-test
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  other-modules:
+      Paths_stack
+  hs-source-dirs:
+      src/test
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded
+  build-depends:
+      Cabal >=2.4
+    , QuickCheck
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , hspec
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , smallcheck
+    , split
+    , stack
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  default-language: Haskell2010
diff --git a/test/golden/test-files/real-world/stack/stack.cabal.golden b/test/golden/test-files/real-world/stack/stack.cabal.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.cabal.golden
@@ -0,0 +1,629 @@
+cabal-version: 2.0
+
+-- This file has been generated from stack.dhall by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 33d90e3e81d97f3c404a9e20246cf4aa6942dc054db675cadd50b1edd68582ce
+
+name:           stack
+version:        1.10.0
+synopsis:       The Haskell Tool Stack
+description:    Please see the README.md for usage information, and
+                the wiki on Github for more details.  Also, note that
+                the API for the library is not currently stable, and may
+                change significantly, even between minor releases. It is
+                currently only intended for use by the executable.
+category:       Development
+homepage:       http://haskellstack.org
+bug-reports:    https://github.com/commercialhaskell/stack/issues
+author:         Commercial Haskell SIG
+maintainer:     manny@fpcomplete.com
+license:        BSD3
+build-type:     Custom
+extra-source-files:
+    CONTRIBUTING.md
+    ChangeLog.md
+    README.md
+    src/setup-shim/StackSetupShim.hs
+    stack.yaml
+    test/package-dump/ghc-7.10.txt
+    test/package-dump/ghc-7.8.4-osx.txt
+    test/package-dump/ghc-7.8.txt
+
+source-repository head
+  type: git
+  location: https://github.com/commercialhaskell/stack
+
+custom-setup
+  setup-depends:
+      Cabal >=2.4
+    , base >=4.10 && <5
+    , filepath
+
+flag disable-git-info
+  description: Disable compile-time inclusion of current git info in stack
+  manual: True
+  default: False
+
+flag hide-dependency-versions
+  description: Hides dependency versions from "stack --version", used only by building with stack.yaml
+  manual: True
+  default: False
+
+flag integration-tests
+  description: Run the integration test suite
+  manual: True
+  default: False
+
+flag static
+  description: Pass -static/-pthread to ghc when linking the stack binary.
+  manual: True
+  default: False
+
+flag supported-build
+  description: If false, causes "stack --version" to issue a warning about the build being unsupported.  True only if building with stack.yaml
+  manual: True
+  default: False
+
+library
+  exposed-modules:
+      Control.Concurrent.Execute
+      Data.Attoparsec.Args
+      Data.Attoparsec.Combinators
+      Data.Attoparsec.Interpreter
+      Data.Monoid.Map
+      Network.HTTP.Download
+      Network.HTTP.Download.Verified
+      Network.HTTP.StackClient
+      Options.Applicative.Args
+      Options.Applicative.Builder.Extra
+      Options.Applicative.Complicated
+      Path.CheckInstall
+      Path.Extra
+      Path.Find
+      Stack.Build
+      Stack.Build.Cache
+      Stack.Build.ConstructPlan
+      Stack.Build.Execute
+      Stack.Build.Haddock
+      Stack.Build.Installed
+      Stack.Build.Source
+      Stack.Build.Target
+      Stack.BuildPlan
+      Stack.Clean
+      Stack.Config
+      Stack.Config.Build
+      Stack.Config.Urls
+      Stack.Config.Docker
+      Stack.Config.Nix
+      Stack.ConfigCmd
+      Stack.Constants
+      Stack.Constants.Config
+      Stack.Coverage
+      Stack.DefaultColorWhen
+      Stack.DefaultStyles
+      Stack.Docker
+      Stack.Docker.GlobalDB
+      Stack.Dot
+      Stack.FileWatch
+      Stack.Freeze
+      Stack.GhcPkg
+      Stack.Ghci
+      Stack.Ghci.Script
+      Stack.Hoogle
+      Stack.IDE
+      Stack.Image
+      Stack.Init
+      Stack.Ls
+      Stack.New
+      Stack.Nix
+      Stack.Options.BenchParser
+      Stack.Options.BuildMonoidParser
+      Stack.Options.BuildParser
+      Stack.Options.CleanParser
+      Stack.Options.ConfigParser
+      Stack.Options.Completion
+      Stack.Options.DockerParser
+      Stack.Options.DotParser
+      Stack.Options.ExecParser
+      Stack.Options.FreezeParser
+      Stack.Options.GhcBuildParser
+      Stack.Options.GhciParser
+      Stack.Options.GhcVariantParser
+      Stack.Options.GlobalParser
+      Stack.Options.HaddockParser
+      Stack.Options.HpcReportParser
+      Stack.Options.LogLevelParser
+      Stack.Options.NewParser
+      Stack.Options.NixParser
+      Stack.Options.PackageParser
+      Stack.Options.ResolverParser
+      Stack.Options.ScriptParser
+      Stack.Options.SDistParser
+      Stack.Options.SolverParser
+      Stack.Options.TestParser
+      Stack.Options.Utils
+      Stack.Package
+      Stack.PackageDump
+      Stack.Path
+      Stack.Prelude
+      Stack.PrettyPrint
+      Stack.Runners
+      Stack.Script
+      Stack.SDist
+      Stack.Setup
+      Stack.Setup.Installed
+      Stack.SetupCmd
+      Stack.Sig
+      Stack.Sig.GPG
+      Stack.Sig.Sign
+      Stack.Snapshot
+      Stack.Solver
+      Stack.StoreTH
+      Stack.Types.Build
+      Stack.Types.BuildPlan
+      Stack.Types.CompilerBuild
+      Stack.Types.Urls
+      Stack.Types.Compiler
+      Stack.Types.Config
+      Stack.Types.Config.Build
+      Stack.Types.Docker
+      Stack.Types.GhcPkgId
+      Stack.Types.Image
+      Stack.Types.NamedComponent
+      Stack.Types.Nix
+      Stack.Types.Package
+      Stack.Types.PackageDump
+      Stack.Types.PackageName
+      Stack.Types.PrettyPrint
+      Stack.Types.Resolver
+      Stack.Types.Runner
+      Stack.Types.Sig
+      Stack.Types.StylesUpdate
+      Stack.Types.TemplateName
+      Stack.Types.Version
+      Stack.Types.VersionIntervals
+      Stack.Unpack
+      Stack.Upgrade
+      Stack.Upload
+      Text.PrettyPrint.Leijen.Extended
+      System.Permissions
+      System.Process.PagerEditor
+      System.Terminal
+      Paths_stack
+  autogen-modules:
+      Paths_stack
+  hs-source-dirs:
+      src/
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -fwarn-identities
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if os(windows)
+    hs-source-dirs:
+        src/windows/
+  else
+    hs-source-dirs:
+        src/unix/
+    c-sources:
+        src/unix/cbits/uname.c
+  default-language: Haskell2010
+
+executable stack
+  main-is: Main.hs
+  other-modules:
+      Build_stack
+      Paths_stack
+  autogen-modules:
+      Build_stack
+      Paths_stack
+  hs-source-dirs:
+      src/main
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded -rtsopts
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stack
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if flag(static)
+    ld-options: -static -pthread
+  if !(flag(disable-git-info))
+    cpp-options: -DUSE_GIT_INFO
+    build-depends:
+        githash
+      , optparse-simple
+  if flag(hide-dependency-versions)
+    cpp-options: -DHIDE_DEP_VERSIONS
+  if flag(supported-build)
+    cpp-options: -DSUPPORTED_BUILD
+  default-language: Haskell2010
+
+test-suite stack-integration-test
+  type: exitcode-stdio-1.0
+  main-is: IntegrationSpec.hs
+  other-modules:
+      Paths_stack
+  hs-source-dirs:
+      test/integration
+      test/integration/lib
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded -rtsopts -with-rtsopts=-N
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , hspec
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if !flag(integration-tests)
+    buildable: False
+  default-language: Haskell2010
+
+test-suite stack-test
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  other-modules:
+      Paths_stack
+  hs-source-dirs:
+      src/test
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded
+  build-depends:
+      Cabal >=2.4
+    , QuickCheck
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , hspec
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , smallcheck
+    , split
+    , stack
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  default-language: Haskell2010
diff --git a/test/golden/test-files/real-world/stack/stack.dhall b/test/golden/test-files/real-world/stack/stack.dhall
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.dhall
@@ -0,0 +1,401 @@
+{ name =
+    "stack"
+, version =
+    "1.10.0"
+, synopsis =
+    "The Haskell Tool Stack"
+, description =
+    ''
+    Please see the README.md for usage information, and
+    the wiki on Github for more details.  Also, note that
+    the API for the library is not currently stable, and may
+    change significantly, even between minor releases. It is
+    currently only intended for use by the executable.''
+, category =
+    "Development"
+, author =
+    "Commercial Haskell SIG"
+, maintainer =
+    "manny@fpcomplete.com"
+, license =
+    "BSD3"
+, github =
+    "commercialhaskell/stack"
+, homepage =
+    "http://haskellstack.org"
+, custom-setup =
+    { dependencies = [ "base >=4.10 && < 5", "Cabal >= 2.4", "filepath" ] }
+, extra-source-files =
+    [ "CONTRIBUTING.md"
+    , "ChangeLog.md"
+    , "README.md"
+    , "doc/*.md"
+    , "src/setup-shim/StackSetupShim.hs"
+    , "stack.yaml"
+    , "test/package-dump/ghc-7.10.txt"
+    , "test/package-dump/ghc-7.8.4-osx.txt"
+    , "test/package-dump/ghc-7.8.txt"
+    ]
+, ghc-options =
+    [ "-Wall"
+    , "-fwarn-tabs"
+    , "-fwarn-incomplete-uni-patterns"
+    , "-fwarn-incomplete-record-updates"
+    , "-optP-Wno-nonportable-include-path # workaround [Filename case on macOS \u00B7 Issue #4739 \u00B7 haskell/cabal](https://github.com/haskell/cabal/issues/4739)"
+    ]
+, dependencies =
+    [ "Cabal >= 2.4"
+    , "aeson"
+    , "annotated-wl-pprint"
+    , "ansi-terminal >= 0.8.1"
+    , "array"
+    , "async"
+    , "attoparsec"
+    , "base >=4.10 && < 5"
+    , "base64-bytestring"
+    , "bytestring"
+    , "colour"
+    , "conduit"
+    , "conduit-extra"
+    , "containers"
+    , "cryptonite"
+    , "cryptonite-conduit"
+    , "deepseq"
+    , "directory"
+    , "echo"
+    , "exceptions"
+    , "extra"
+    , "file-embed"
+    , "filelock"
+    , "filepath"
+    , "fsnotify"
+    , "generic-deriving"
+    , "hackage-security"
+    , "hashable"
+    , "hpack"
+    , "hpc"
+    , "http-client"
+    , "http-client-tls"
+    , "http-conduit"
+    , "http-types"
+    , "memory"
+    , "microlens"
+    , "mintty"
+    , "monad-logger"
+    , "mono-traversable"
+    , "mtl"
+    , "mustache"
+    , "neat-interpolation"
+    , "network-uri"
+    , "open-browser"
+    , "optparse-applicative"
+    , "pantry"
+    , "path"
+    , "path-io"
+    , "persistent"
+    , "persistent-sqlite"
+    , "persistent-template"
+    , "pretty"
+    , "primitive"
+    , "process"
+    , "project-template"
+    , "regex-applicative-text"
+    , "resourcet"
+    , "retry >= 0.7"
+    , "rio"
+    , "semigroups"
+    , "split"
+    , "stm"
+    , "store-core"
+    , "streaming-commons"
+    , "tar"
+    , "template-haskell"
+    , "temporary"
+    , "text"
+    , "text-metrics"
+    , "th-reify-many"
+    , "time"
+    , "tls"
+    , "transformers"
+    , "typed-process"
+    , "unicode-transforms"
+    , "unix-compat"
+    , "unliftio >= 0.2.8.0"
+    , "unordered-containers"
+    , "vector"
+    , "yaml"
+    , "zip-archive"
+    , "zlib"
+    ]
+, when =
+    { condition =
+        "os(windows)"
+    , `then` =
+        { cpp-options = [ "-DWINDOWS" ], dependencies = [ "Win32" ] }
+    , `else` =
+        { build-tools = [ "hsc2hs" ], dependencies = [ "unix" ] }
+    }
+, library =
+    { source-dirs =
+        "src/"
+    , ghc-options =
+        [ "-fwarn-identities" ]
+    , generated-exposed-modules =
+        [ "Paths_stack" ]
+    , exposed-modules =
+        [ "Control.Concurrent.Execute"
+        , "Data.Attoparsec.Args"
+        , "Data.Attoparsec.Combinators"
+        , "Data.Attoparsec.Interpreter"
+        , "Data.Monoid.Map"
+        , "Network.HTTP.Download"
+        , "Network.HTTP.Download.Verified"
+        , "Network.HTTP.StackClient"
+        , "Options.Applicative.Args"
+        , "Options.Applicative.Builder.Extra"
+        , "Options.Applicative.Complicated"
+        , "Path.CheckInstall"
+        , "Path.Extra"
+        , "Path.Find"
+        , "Stack.Build"
+        , "Stack.Build.Cache"
+        , "Stack.Build.ConstructPlan"
+        , "Stack.Build.Execute"
+        , "Stack.Build.Haddock"
+        , "Stack.Build.Installed"
+        , "Stack.Build.Source"
+        , "Stack.Build.Target"
+        , "Stack.BuildPlan"
+        , "Stack.Clean"
+        , "Stack.Config"
+        , "Stack.Config.Build"
+        , "Stack.Config.Urls"
+        , "Stack.Config.Docker"
+        , "Stack.Config.Nix"
+        , "Stack.ConfigCmd"
+        , "Stack.Constants"
+        , "Stack.Constants.Config"
+        , "Stack.Coverage"
+        , "Stack.DefaultColorWhen"
+        , "Stack.DefaultStyles"
+        , "Stack.Docker"
+        , "Stack.Docker.GlobalDB"
+        , "Stack.Dot"
+        , "Stack.FileWatch"
+        , "Stack.Freeze"
+        , "Stack.GhcPkg"
+        , "Stack.Ghci"
+        , "Stack.Ghci.Script"
+        , "Stack.Hoogle"
+        , "Stack.IDE"
+        , "Stack.Image"
+        , "Stack.Init"
+        , "Stack.Ls"
+        , "Stack.New"
+        , "Stack.Nix"
+        , "Stack.Options.BenchParser"
+        , "Stack.Options.BuildMonoidParser"
+        , "Stack.Options.BuildParser"
+        , "Stack.Options.CleanParser"
+        , "Stack.Options.ConfigParser"
+        , "Stack.Options.Completion"
+        , "Stack.Options.DockerParser"
+        , "Stack.Options.DotParser"
+        , "Stack.Options.ExecParser"
+        , "Stack.Options.FreezeParser"
+        , "Stack.Options.GhcBuildParser"
+        , "Stack.Options.GhciParser"
+        , "Stack.Options.GhcVariantParser"
+        , "Stack.Options.GlobalParser"
+        , "Stack.Options.HaddockParser"
+        , "Stack.Options.HpcReportParser"
+        , "Stack.Options.LogLevelParser"
+        , "Stack.Options.NewParser"
+        , "Stack.Options.NixParser"
+        , "Stack.Options.PackageParser"
+        , "Stack.Options.ResolverParser"
+        , "Stack.Options.ScriptParser"
+        , "Stack.Options.SDistParser"
+        , "Stack.Options.SolverParser"
+        , "Stack.Options.TestParser"
+        , "Stack.Options.Utils"
+        , "Stack.Package"
+        , "Stack.PackageDump"
+        , "Stack.Path"
+        , "Stack.Prelude"
+        , "Stack.PrettyPrint"
+        , "Stack.Runners"
+        , "Stack.Script"
+        , "Stack.SDist"
+        , "Stack.Setup"
+        , "Stack.Setup.Installed"
+        , "Stack.SetupCmd"
+        , "Stack.Sig"
+        , "Stack.Sig.GPG"
+        , "Stack.Sig.Sign"
+        , "Stack.Snapshot"
+        , "Stack.Solver"
+        , "Stack.StoreTH"
+        , "Stack.Types.Build"
+        , "Stack.Types.BuildPlan"
+        , "Stack.Types.CompilerBuild"
+        , "Stack.Types.Urls"
+        , "Stack.Types.Compiler"
+        , "Stack.Types.Config"
+        , "Stack.Types.Config.Build"
+        , "Stack.Types.Docker"
+        , "Stack.Types.GhcPkgId"
+        , "Stack.Types.Image"
+        , "Stack.Types.NamedComponent"
+        , "Stack.Types.Nix"
+        , "Stack.Types.Package"
+        , "Stack.Types.PackageDump"
+        , "Stack.Types.PackageName"
+        , "Stack.Types.PrettyPrint"
+        , "Stack.Types.Resolver"
+        , "Stack.Types.Runner"
+        , "Stack.Types.Sig"
+        , "Stack.Types.StylesUpdate"
+        , "Stack.Types.TemplateName"
+        , "Stack.Types.Version"
+        , "Stack.Types.VersionIntervals"
+        , "Stack.Unpack"
+        , "Stack.Upgrade"
+        , "Stack.Upload"
+        , "Text.PrettyPrint.Leijen.Extended"
+        , "System.Permissions"
+        , "System.Process.PagerEditor"
+        , "System.Terminal"
+        ]
+    , when =
+        { condition =
+            "os(windows)"
+        , `then` =
+            { source-dirs = [ "src/windows/" ] }
+        , `else` =
+            { source-dirs =
+                [ "src/unix/" ]
+            , c-sources =
+                [ "src/unix/cbits/uname.c" ]
+            }
+        }
+    }
+, executables =
+    { stack =
+        { main =
+            "Main.hs"
+        , source-dirs =
+            [ "src/main" ]
+        , generated-other-modules =
+            [ "Build_stack", "Paths_stack" ]
+        , ghc-options =
+            [ "-threaded", "-rtsopts" ]
+        , dependencies =
+            [ "stack" ]
+        , when =
+            [ { condition =
+                  "flag(static)"
+              , cpp-options =
+                  [] : List Text
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [ "-static", "-pthread" ]
+              }
+            , { condition =
+                  "!(flag(disable-git-info))"
+              , cpp-options =
+                  [ "-DUSE_GIT_INFO" ]
+              , dependencies =
+                  [ "githash", "optparse-simple" ]
+              , ld-options =
+                  [] : List Text
+              }
+            , { condition =
+                  "flag(hide-dependency-versions)"
+              , cpp-options =
+                  [ "-DHIDE_DEP_VERSIONS" ]
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [] : List Text
+              }
+            , { condition =
+                  "flag(supported-build)"
+              , cpp-options =
+                  [ "-DSUPPORTED_BUILD" ]
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [] : List Text
+              }
+            ]
+        }
+    }
+, tests =
+    { stack-test =
+        { main =
+            "Spec.hs"
+        , source-dirs =
+            [ "src/test" ]
+        , ghc-options =
+            [ "-threaded" ]
+        , dependencies =
+            [ "QuickCheck", "hspec", "stack", "smallcheck" ]
+        }
+    , stack-integration-test =
+        { main =
+            "IntegrationSpec.hs"
+        , source-dirs =
+            [ "test/integration", "test/integration/lib" ]
+        , ghc-options =
+            [ "-threaded", "-rtsopts", "-with-rtsopts=-N" ]
+        , dependencies =
+            [ "hspec" ]
+        , when =
+            { condition = "!flag(integration-tests)", buildable = False }
+        }
+    }
+, flags =
+    { static =
+        { description =
+            "Pass -static/-pthread to ghc when linking the stack binary."
+        , manual =
+            True
+        , default =
+            False
+        }
+    , disable-git-info =
+        { description =
+            "Disable compile-time inclusion of current git info in stack"
+        , manual =
+            True
+        , default =
+            False
+        }
+    , hide-dependency-versions =
+        { description =
+            "Hides dependency versions from \"stack --version\", used only by building with stack.yaml"
+        , manual =
+            True
+        , default =
+            False
+        }
+    , integration-tests =
+        { description =
+            "Run the integration test suite"
+        , manual =
+            True
+        , default =
+            False
+        }
+    , supported-build =
+        { description =
+            "If false, causes \"stack --version\" to issue a warning about the build being unsupported.  True only if building with stack.yaml"
+        , manual =
+            True
+        , default =
+            False
+        }
+    }
+}
diff --git a/test/golden/test-files/real-world/stack/stack.dhall.golden b/test/golden/test-files/real-world/stack/stack.dhall.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.dhall.golden
@@ -0,0 +1,401 @@
+{ name =
+    "stack"
+, version =
+    "1.10.0"
+, synopsis =
+    "The Haskell Tool Stack"
+, description =
+    ''
+    Please see the README.md for usage information, and
+    the wiki on Github for more details.  Also, note that
+    the API for the library is not currently stable, and may
+    change significantly, even between minor releases. It is
+    currently only intended for use by the executable.''
+, category =
+    "Development"
+, author =
+    "Commercial Haskell SIG"
+, maintainer =
+    "manny@fpcomplete.com"
+, license =
+    "BSD3"
+, github =
+    "commercialhaskell/stack"
+, homepage =
+    "http://haskellstack.org"
+, custom-setup =
+    { dependencies = [ "base >=4.10 && < 5", "Cabal >= 2.4", "filepath" ] }
+, extra-source-files =
+    [ "CONTRIBUTING.md"
+    , "ChangeLog.md"
+    , "README.md"
+    , "doc/*.md"
+    , "src/setup-shim/StackSetupShim.hs"
+    , "stack.yaml"
+    , "test/package-dump/ghc-7.10.txt"
+    , "test/package-dump/ghc-7.8.4-osx.txt"
+    , "test/package-dump/ghc-7.8.txt"
+    ]
+, ghc-options =
+    [ "-Wall"
+    , "-fwarn-tabs"
+    , "-fwarn-incomplete-uni-patterns"
+    , "-fwarn-incomplete-record-updates"
+    , "-optP-Wno-nonportable-include-path # workaround [Filename case on macOS \u00B7 Issue #4739 \u00B7 haskell/cabal](https://github.com/haskell/cabal/issues/4739)"
+    ]
+, dependencies =
+    [ "Cabal >= 2.4"
+    , "aeson"
+    , "annotated-wl-pprint"
+    , "ansi-terminal >= 0.8.1"
+    , "array"
+    , "async"
+    , "attoparsec"
+    , "base >=4.10 && < 5"
+    , "base64-bytestring"
+    , "bytestring"
+    , "colour"
+    , "conduit"
+    , "conduit-extra"
+    , "containers"
+    , "cryptonite"
+    , "cryptonite-conduit"
+    , "deepseq"
+    , "directory"
+    , "echo"
+    , "exceptions"
+    , "extra"
+    , "file-embed"
+    , "filelock"
+    , "filepath"
+    , "fsnotify"
+    , "generic-deriving"
+    , "hackage-security"
+    , "hashable"
+    , "hpack"
+    , "hpc"
+    , "http-client"
+    , "http-client-tls"
+    , "http-conduit"
+    , "http-types"
+    , "memory"
+    , "microlens"
+    , "mintty"
+    , "monad-logger"
+    , "mono-traversable"
+    , "mtl"
+    , "mustache"
+    , "neat-interpolation"
+    , "network-uri"
+    , "open-browser"
+    , "optparse-applicative"
+    , "pantry"
+    , "path"
+    , "path-io"
+    , "persistent"
+    , "persistent-sqlite"
+    , "persistent-template"
+    , "pretty"
+    , "primitive"
+    , "process"
+    , "project-template"
+    , "regex-applicative-text"
+    , "resourcet"
+    , "retry >= 0.7"
+    , "rio"
+    , "semigroups"
+    , "split"
+    , "stm"
+    , "store-core"
+    , "streaming-commons"
+    , "tar"
+    , "template-haskell"
+    , "temporary"
+    , "text"
+    , "text-metrics"
+    , "th-reify-many"
+    , "time"
+    , "tls"
+    , "transformers"
+    , "typed-process"
+    , "unicode-transforms"
+    , "unix-compat"
+    , "unliftio >= 0.2.8.0"
+    , "unordered-containers"
+    , "vector"
+    , "yaml"
+    , "zip-archive"
+    , "zlib"
+    ]
+, when =
+    { condition =
+        "os(windows)"
+    , `then` =
+        { cpp-options = [ "-DWINDOWS" ], dependencies = [ "Win32" ] }
+    , `else` =
+        { build-tools = [ "hsc2hs" ], dependencies = [ "unix" ] }
+    }
+, library =
+    { source-dirs =
+        "src/"
+    , ghc-options =
+        [ "-fwarn-identities" ]
+    , generated-exposed-modules =
+        [ "Paths_stack" ]
+    , exposed-modules =
+        [ "Control.Concurrent.Execute"
+        , "Data.Attoparsec.Args"
+        , "Data.Attoparsec.Combinators"
+        , "Data.Attoparsec.Interpreter"
+        , "Data.Monoid.Map"
+        , "Network.HTTP.Download"
+        , "Network.HTTP.Download.Verified"
+        , "Network.HTTP.StackClient"
+        , "Options.Applicative.Args"
+        , "Options.Applicative.Builder.Extra"
+        , "Options.Applicative.Complicated"
+        , "Path.CheckInstall"
+        , "Path.Extra"
+        , "Path.Find"
+        , "Stack.Build"
+        , "Stack.Build.Cache"
+        , "Stack.Build.ConstructPlan"
+        , "Stack.Build.Execute"
+        , "Stack.Build.Haddock"
+        , "Stack.Build.Installed"
+        , "Stack.Build.Source"
+        , "Stack.Build.Target"
+        , "Stack.BuildPlan"
+        , "Stack.Clean"
+        , "Stack.Config"
+        , "Stack.Config.Build"
+        , "Stack.Config.Urls"
+        , "Stack.Config.Docker"
+        , "Stack.Config.Nix"
+        , "Stack.ConfigCmd"
+        , "Stack.Constants"
+        , "Stack.Constants.Config"
+        , "Stack.Coverage"
+        , "Stack.DefaultColorWhen"
+        , "Stack.DefaultStyles"
+        , "Stack.Docker"
+        , "Stack.Docker.GlobalDB"
+        , "Stack.Dot"
+        , "Stack.FileWatch"
+        , "Stack.Freeze"
+        , "Stack.GhcPkg"
+        , "Stack.Ghci"
+        , "Stack.Ghci.Script"
+        , "Stack.Hoogle"
+        , "Stack.IDE"
+        , "Stack.Image"
+        , "Stack.Init"
+        , "Stack.Ls"
+        , "Stack.New"
+        , "Stack.Nix"
+        , "Stack.Options.BenchParser"
+        , "Stack.Options.BuildMonoidParser"
+        , "Stack.Options.BuildParser"
+        , "Stack.Options.CleanParser"
+        , "Stack.Options.ConfigParser"
+        , "Stack.Options.Completion"
+        , "Stack.Options.DockerParser"
+        , "Stack.Options.DotParser"
+        , "Stack.Options.ExecParser"
+        , "Stack.Options.FreezeParser"
+        , "Stack.Options.GhcBuildParser"
+        , "Stack.Options.GhciParser"
+        , "Stack.Options.GhcVariantParser"
+        , "Stack.Options.GlobalParser"
+        , "Stack.Options.HaddockParser"
+        , "Stack.Options.HpcReportParser"
+        , "Stack.Options.LogLevelParser"
+        , "Stack.Options.NewParser"
+        , "Stack.Options.NixParser"
+        , "Stack.Options.PackageParser"
+        , "Stack.Options.ResolverParser"
+        , "Stack.Options.ScriptParser"
+        , "Stack.Options.SDistParser"
+        , "Stack.Options.SolverParser"
+        , "Stack.Options.TestParser"
+        , "Stack.Options.Utils"
+        , "Stack.Package"
+        , "Stack.PackageDump"
+        , "Stack.Path"
+        , "Stack.Prelude"
+        , "Stack.PrettyPrint"
+        , "Stack.Runners"
+        , "Stack.Script"
+        , "Stack.SDist"
+        , "Stack.Setup"
+        , "Stack.Setup.Installed"
+        , "Stack.SetupCmd"
+        , "Stack.Sig"
+        , "Stack.Sig.GPG"
+        , "Stack.Sig.Sign"
+        , "Stack.Snapshot"
+        , "Stack.Solver"
+        , "Stack.StoreTH"
+        , "Stack.Types.Build"
+        , "Stack.Types.BuildPlan"
+        , "Stack.Types.CompilerBuild"
+        , "Stack.Types.Urls"
+        , "Stack.Types.Compiler"
+        , "Stack.Types.Config"
+        , "Stack.Types.Config.Build"
+        , "Stack.Types.Docker"
+        , "Stack.Types.GhcPkgId"
+        , "Stack.Types.Image"
+        , "Stack.Types.NamedComponent"
+        , "Stack.Types.Nix"
+        , "Stack.Types.Package"
+        , "Stack.Types.PackageDump"
+        , "Stack.Types.PackageName"
+        , "Stack.Types.PrettyPrint"
+        , "Stack.Types.Resolver"
+        , "Stack.Types.Runner"
+        , "Stack.Types.Sig"
+        , "Stack.Types.StylesUpdate"
+        , "Stack.Types.TemplateName"
+        , "Stack.Types.Version"
+        , "Stack.Types.VersionIntervals"
+        , "Stack.Unpack"
+        , "Stack.Upgrade"
+        , "Stack.Upload"
+        , "Text.PrettyPrint.Leijen.Extended"
+        , "System.Permissions"
+        , "System.Process.PagerEditor"
+        , "System.Terminal"
+        ]
+    , when =
+        { condition =
+            "os(windows)"
+        , `then` =
+            { source-dirs = [ "src/windows/" ] }
+        , `else` =
+            { source-dirs =
+                [ "src/unix/" ]
+            , c-sources =
+                [ "src/unix/cbits/uname.c" ]
+            }
+        }
+    }
+, executables =
+    { stack =
+        { main =
+            "Main.hs"
+        , source-dirs =
+            [ "src/main" ]
+        , generated-other-modules =
+            [ "Build_stack", "Paths_stack" ]
+        , ghc-options =
+            [ "-threaded", "-rtsopts" ]
+        , dependencies =
+            [ "stack" ]
+        , when =
+            [ { condition =
+                  "flag(static)"
+              , cpp-options =
+                  [] : List Text
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [ "-static", "-pthread" ]
+              }
+            , { condition =
+                  "!(flag(disable-git-info))"
+              , cpp-options =
+                  [ "-DUSE_GIT_INFO" ]
+              , dependencies =
+                  [ "githash", "optparse-simple" ]
+              , ld-options =
+                  [] : List Text
+              }
+            , { condition =
+                  "flag(hide-dependency-versions)"
+              , cpp-options =
+                  [ "-DHIDE_DEP_VERSIONS" ]
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [] : List Text
+              }
+            , { condition =
+                  "flag(supported-build)"
+              , cpp-options =
+                  [ "-DSUPPORTED_BUILD" ]
+              , dependencies =
+                  [] : List Text
+              , ld-options =
+                  [] : List Text
+              }
+            ]
+        }
+    }
+, tests =
+    { stack-test =
+        { main =
+            "Spec.hs"
+        , source-dirs =
+            [ "src/test" ]
+        , ghc-options =
+            [ "-threaded" ]
+        , dependencies =
+            [ "QuickCheck", "hspec", "stack", "smallcheck" ]
+        }
+    , stack-integration-test =
+        { main =
+            "IntegrationSpec.hs"
+        , source-dirs =
+            [ "test/integration", "test/integration/lib" ]
+        , ghc-options =
+            [ "-threaded", "-rtsopts", "-with-rtsopts=-N" ]
+        , dependencies =
+            [ "hspec" ]
+        , when =
+            { condition = "!flag(integration-tests)", buildable = False }
+        }
+    }
+, flags =
+    { static =
+        { description =
+            "Pass -static/-pthread to ghc when linking the stack binary."
+        , manual =
+            True
+        , default =
+            False
+        }
+    , disable-git-info =
+        { description =
+            "Disable compile-time inclusion of current git info in stack"
+        , manual =
+            True
+        , default =
+            False
+        }
+    , hide-dependency-versions =
+        { description =
+            "Hides dependency versions from \"stack --version\", used only by building with stack.yaml"
+        , manual =
+            True
+        , default =
+            False
+        }
+    , integration-tests =
+        { description =
+            "Run the integration test suite"
+        , manual =
+            True
+        , default =
+            False
+        }
+    , supported-build =
+        { description =
+            "If false, causes \"stack --version\" to issue a warning about the build being unsupported.  True only if building with stack.yaml"
+        , manual =
+            True
+        , default =
+            False
+        }
+    }
+}
diff --git a/test/golden/test-files/real-world/stack/stack.json b/test/golden/test-files/real-world/stack/stack.json
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.json
@@ -0,0 +1,410 @@
+{
+    "name": "stack",
+    "version": "1.10.0",
+    "synopsis": "The Haskell Tool Stack",
+    "description": "Please see the README.md for usage information, and\nthe wiki on Github for more details.  Also, note that\nthe API for the library is not currently stable, and may\nchange significantly, even between minor releases. It is\ncurrently only intended for use by the executable.",
+    "category": "Development",
+    "homepage": "http://haskellstack.org",
+    "author": "Commercial Haskell SIG",
+    "maintainer": "manny@fpcomplete.com",
+    "license": "BSD3",
+    "github": "commercialhaskell/stack",
+    "extra-source-files": [
+        "CONTRIBUTING.md",
+        "ChangeLog.md",
+        "README.md",
+        "doc/*.md",
+        "src/setup-shim/StackSetupShim.hs",
+        "stack.yaml",
+        "test/package-dump/ghc-7.10.txt",
+        "test/package-dump/ghc-7.8.4-osx.txt",
+        "test/package-dump/ghc-7.8.txt"
+    ],
+    "ghc-options": [
+        "-Wall",
+        "-fwarn-tabs",
+        "-fwarn-incomplete-uni-patterns",
+        "-fwarn-incomplete-record-updates",
+        "-optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739)"
+    ],
+    "dependencies": [
+        "Cabal >= 2.4",
+        "aeson",
+        "annotated-wl-pprint",
+        "ansi-terminal >= 0.8.1",
+        "array",
+        "async",
+        "attoparsec",
+        "base >=4.10 && < 5",
+        "base64-bytestring",
+        "bytestring",
+        "colour",
+        "conduit",
+        "conduit-extra",
+        "containers",
+        "cryptonite",
+        "cryptonite-conduit",
+        "deepseq",
+        "directory",
+        "echo",
+        "exceptions",
+        "extra",
+        "file-embed",
+        "filelock",
+        "filepath",
+        "fsnotify",
+        "generic-deriving",
+        "hackage-security",
+        "hashable",
+        "hpack",
+        "hpc",
+        "http-client",
+        "http-client-tls",
+        "http-conduit",
+        "http-types",
+        "memory",
+        "microlens",
+        "mintty",
+        "monad-logger",
+        "mono-traversable",
+        "mtl",
+        "mustache",
+        "neat-interpolation",
+        "network-uri",
+        "open-browser",
+        "optparse-applicative",
+        "pantry",
+        "path",
+        "path-io",
+        "persistent",
+        "persistent-sqlite",
+        "persistent-template",
+        "pretty",
+        "primitive",
+        "process",
+        "project-template",
+        "regex-applicative-text",
+        "resourcet",
+        "retry >= 0.7",
+        "rio",
+        "semigroups",
+        "split",
+        "stm",
+        "store-core",
+        "streaming-commons",
+        "tar",
+        "template-haskell",
+        "temporary",
+        "text",
+        "text-metrics",
+        "th-reify-many",
+        "time",
+        "tls",
+        "transformers",
+        "typed-process",
+        "unicode-transforms",
+        "unix-compat",
+        "unliftio >= 0.2.8.0",
+        "unordered-containers",
+        "vector",
+        "yaml",
+        "zip-archive",
+        "zlib"
+    ],
+    "when": {
+        "condition": "os(windows)",
+        "then": {
+            "cpp-options": [
+                "-DWINDOWS"
+            ],
+            "dependencies": [
+                "Win32"
+            ]
+        },
+        "else": {
+            "dependencies": [
+                "unix"
+            ],
+            "build-tools": [
+                "hsc2hs"
+            ]
+        }
+    },
+    "custom-setup": {
+        "dependencies": [
+            "base >=4.10 && < 5",
+            "Cabal >= 2.4",
+            "filepath"
+        ]
+    },
+    "flags": {
+        "disable-git-info": {
+            "description": "Disable compile-time inclusion of current git info in stack",
+            "manual": true,
+            "default": false
+        },
+        "hide-dependency-versions": {
+            "description": "Hides dependency versions from \"stack --version\", used only by building with stack.yaml",
+            "manual": true,
+            "default": false
+        },
+        "integration-tests": {
+            "description": "Run the integration test suite",
+            "manual": true,
+            "default": false
+        },
+        "static": {
+            "description": "Pass -static/-pthread to ghc when linking the stack binary.",
+            "manual": true,
+            "default": false
+        },
+        "supported-build": {
+            "description": "If false, causes \"stack --version\" to issue a warning about the build being unsupported.  True only if building with stack.yaml",
+            "manual": true,
+            "default": false
+        }
+    },
+    "library": {
+        "exposed-modules": [
+            "Control.Concurrent.Execute",
+            "Data.Attoparsec.Args",
+            "Data.Attoparsec.Combinators",
+            "Data.Attoparsec.Interpreter",
+            "Data.Monoid.Map",
+            "Network.HTTP.Download",
+            "Network.HTTP.Download.Verified",
+            "Network.HTTP.StackClient",
+            "Options.Applicative.Args",
+            "Options.Applicative.Builder.Extra",
+            "Options.Applicative.Complicated",
+            "Path.CheckInstall",
+            "Path.Extra",
+            "Path.Find",
+            "Stack.Build",
+            "Stack.Build.Cache",
+            "Stack.Build.ConstructPlan",
+            "Stack.Build.Execute",
+            "Stack.Build.Haddock",
+            "Stack.Build.Installed",
+            "Stack.Build.Source",
+            "Stack.Build.Target",
+            "Stack.BuildPlan",
+            "Stack.Clean",
+            "Stack.Config",
+            "Stack.Config.Build",
+            "Stack.Config.Urls",
+            "Stack.Config.Docker",
+            "Stack.Config.Nix",
+            "Stack.ConfigCmd",
+            "Stack.Constants",
+            "Stack.Constants.Config",
+            "Stack.Coverage",
+            "Stack.DefaultColorWhen",
+            "Stack.DefaultStyles",
+            "Stack.Docker",
+            "Stack.Docker.GlobalDB",
+            "Stack.Dot",
+            "Stack.FileWatch",
+            "Stack.Freeze",
+            "Stack.GhcPkg",
+            "Stack.Ghci",
+            "Stack.Ghci.Script",
+            "Stack.Hoogle",
+            "Stack.IDE",
+            "Stack.Image",
+            "Stack.Init",
+            "Stack.Ls",
+            "Stack.New",
+            "Stack.Nix",
+            "Stack.Options.BenchParser",
+            "Stack.Options.BuildMonoidParser",
+            "Stack.Options.BuildParser",
+            "Stack.Options.CleanParser",
+            "Stack.Options.ConfigParser",
+            "Stack.Options.Completion",
+            "Stack.Options.DockerParser",
+            "Stack.Options.DotParser",
+            "Stack.Options.ExecParser",
+            "Stack.Options.FreezeParser",
+            "Stack.Options.GhcBuildParser",
+            "Stack.Options.GhciParser",
+            "Stack.Options.GhcVariantParser",
+            "Stack.Options.GlobalParser",
+            "Stack.Options.HaddockParser",
+            "Stack.Options.HpcReportParser",
+            "Stack.Options.LogLevelParser",
+            "Stack.Options.NewParser",
+            "Stack.Options.NixParser",
+            "Stack.Options.PackageParser",
+            "Stack.Options.ResolverParser",
+            "Stack.Options.ScriptParser",
+            "Stack.Options.SDistParser",
+            "Stack.Options.SolverParser",
+            "Stack.Options.TestParser",
+            "Stack.Options.Utils",
+            "Stack.Package",
+            "Stack.PackageDump",
+            "Stack.Path",
+            "Stack.Prelude",
+            "Stack.PrettyPrint",
+            "Stack.Runners",
+            "Stack.Script",
+            "Stack.SDist",
+            "Stack.Setup",
+            "Stack.Setup.Installed",
+            "Stack.SetupCmd",
+            "Stack.Sig",
+            "Stack.Sig.GPG",
+            "Stack.Sig.Sign",
+            "Stack.Snapshot",
+            "Stack.Solver",
+            "Stack.StoreTH",
+            "Stack.Types.Build",
+            "Stack.Types.BuildPlan",
+            "Stack.Types.CompilerBuild",
+            "Stack.Types.Urls",
+            "Stack.Types.Compiler",
+            "Stack.Types.Config",
+            "Stack.Types.Config.Build",
+            "Stack.Types.Docker",
+            "Stack.Types.GhcPkgId",
+            "Stack.Types.Image",
+            "Stack.Types.NamedComponent",
+            "Stack.Types.Nix",
+            "Stack.Types.Package",
+            "Stack.Types.PackageDump",
+            "Stack.Types.PackageName",
+            "Stack.Types.PrettyPrint",
+            "Stack.Types.Resolver",
+            "Stack.Types.Runner",
+            "Stack.Types.Sig",
+            "Stack.Types.StylesUpdate",
+            "Stack.Types.TemplateName",
+            "Stack.Types.Version",
+            "Stack.Types.VersionIntervals",
+            "Stack.Unpack",
+            "Stack.Upgrade",
+            "Stack.Upload",
+            "Text.PrettyPrint.Leijen.Extended",
+            "System.Permissions",
+            "System.Process.PagerEditor",
+            "System.Terminal"
+        ],
+        "generated-exposed-modules": [
+            "Paths_stack"
+        ],
+        "source-dirs": "src/",
+        "ghc-options": [
+            "-fwarn-identities"
+        ],
+        "when": {
+            "condition": "os(windows)",
+            "then": {
+                "source-dirs": [
+                    "src/windows/"
+                ]
+            },
+            "else": {
+                "source-dirs": [
+                    "src/unix/"
+                ],
+                "c-sources": [
+                    "src/unix/cbits/uname.c"
+                ]
+            }
+        }
+    },
+    "executables": {
+        "stack": {
+            "main": "Main.hs",
+            "generated-other-modules": [
+                "Build_stack",
+                "Paths_stack"
+            ],
+            "source-dirs": [
+                "src/main"
+            ],
+            "ghc-options": [
+                "-threaded",
+                "-rtsopts"
+            ],
+            "dependencies": [
+                "stack"
+            ],
+            "when": [
+                {
+                    "condition": "flag(static)",
+                    "cpp-options": [],
+                    "ld-options": [
+                        "-static",
+                        "-pthread"
+                    ],
+                    "dependencies": []
+                },
+                {
+                    "condition": "!(flag(disable-git-info))",
+                    "cpp-options": [
+                        "-DUSE_GIT_INFO"
+                    ],
+                    "ld-options": [],
+                    "dependencies": [
+                        "githash",
+                        "optparse-simple"
+                    ]
+                },
+                {
+                    "condition": "flag(hide-dependency-versions)",
+                    "cpp-options": [
+                        "-DHIDE_DEP_VERSIONS"
+                    ],
+                    "ld-options": [],
+                    "dependencies": []
+                },
+                {
+                    "condition": "flag(supported-build)",
+                    "cpp-options": [
+                        "-DSUPPORTED_BUILD"
+                    ],
+                    "ld-options": [],
+                    "dependencies": []
+                }
+            ]
+        }
+    },
+    "tests": {
+        "stack-integration-test": {
+            "main": "IntegrationSpec.hs",
+            "source-dirs": [
+                "test/integration",
+                "test/integration/lib"
+            ],
+            "ghc-options": [
+                "-threaded",
+                "-rtsopts",
+                "-with-rtsopts=-N"
+            ],
+            "dependencies": [
+                "hspec"
+            ],
+            "when": {
+                "condition": "!flag(integration-tests)",
+                "buildable": false
+            }
+        },
+        "stack-test": {
+            "main": "Spec.hs",
+            "source-dirs": [
+                "src/test"
+            ],
+            "ghc-options": [
+                "-threaded"
+            ],
+            "dependencies": [
+                "QuickCheck",
+                "hspec",
+                "stack",
+                "smallcheck"
+            ]
+        }
+    }
+}
diff --git a/test/golden/test-files/real-world/stack/stack.json.golden b/test/golden/test-files/real-world/stack/stack.json.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.json.golden
@@ -0,0 +1,410 @@
+{
+    "name": "stack",
+    "version": "1.10.0",
+    "synopsis": "The Haskell Tool Stack",
+    "description": "Please see the README.md for usage information, and\nthe wiki on Github for more details.  Also, note that\nthe API for the library is not currently stable, and may\nchange significantly, even between minor releases. It is\ncurrently only intended for use by the executable.",
+    "category": "Development",
+    "homepage": "http://haskellstack.org",
+    "author": "Commercial Haskell SIG",
+    "maintainer": "manny@fpcomplete.com",
+    "license": "BSD3",
+    "github": "commercialhaskell/stack",
+    "extra-source-files": [
+        "CONTRIBUTING.md",
+        "ChangeLog.md",
+        "README.md",
+        "doc/*.md",
+        "src/setup-shim/StackSetupShim.hs",
+        "stack.yaml",
+        "test/package-dump/ghc-7.10.txt",
+        "test/package-dump/ghc-7.8.4-osx.txt",
+        "test/package-dump/ghc-7.8.txt"
+    ],
+    "ghc-options": [
+        "-Wall",
+        "-fwarn-tabs",
+        "-fwarn-incomplete-uni-patterns",
+        "-fwarn-incomplete-record-updates",
+        "-optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739)"
+    ],
+    "dependencies": [
+        "Cabal >= 2.4",
+        "aeson",
+        "annotated-wl-pprint",
+        "ansi-terminal >= 0.8.1",
+        "array",
+        "async",
+        "attoparsec",
+        "base >=4.10 && < 5",
+        "base64-bytestring",
+        "bytestring",
+        "colour",
+        "conduit",
+        "conduit-extra",
+        "containers",
+        "cryptonite",
+        "cryptonite-conduit",
+        "deepseq",
+        "directory",
+        "echo",
+        "exceptions",
+        "extra",
+        "file-embed",
+        "filelock",
+        "filepath",
+        "fsnotify",
+        "generic-deriving",
+        "hackage-security",
+        "hashable",
+        "hpack",
+        "hpc",
+        "http-client",
+        "http-client-tls",
+        "http-conduit",
+        "http-types",
+        "memory",
+        "microlens",
+        "mintty",
+        "monad-logger",
+        "mono-traversable",
+        "mtl",
+        "mustache",
+        "neat-interpolation",
+        "network-uri",
+        "open-browser",
+        "optparse-applicative",
+        "pantry",
+        "path",
+        "path-io",
+        "persistent",
+        "persistent-sqlite",
+        "persistent-template",
+        "pretty",
+        "primitive",
+        "process",
+        "project-template",
+        "regex-applicative-text",
+        "resourcet",
+        "retry >= 0.7",
+        "rio",
+        "semigroups",
+        "split",
+        "stm",
+        "store-core",
+        "streaming-commons",
+        "tar",
+        "template-haskell",
+        "temporary",
+        "text",
+        "text-metrics",
+        "th-reify-many",
+        "time",
+        "tls",
+        "transformers",
+        "typed-process",
+        "unicode-transforms",
+        "unix-compat",
+        "unliftio >= 0.2.8.0",
+        "unordered-containers",
+        "vector",
+        "yaml",
+        "zip-archive",
+        "zlib"
+    ],
+    "when": {
+        "condition": "os(windows)",
+        "then": {
+            "cpp-options": [
+                "-DWINDOWS"
+            ],
+            "dependencies": [
+                "Win32"
+            ]
+        },
+        "else": {
+            "dependencies": [
+                "unix"
+            ],
+            "build-tools": [
+                "hsc2hs"
+            ]
+        }
+    },
+    "custom-setup": {
+        "dependencies": [
+            "base >=4.10 && < 5",
+            "Cabal >= 2.4",
+            "filepath"
+        ]
+    },
+    "flags": {
+        "disable-git-info": {
+            "description": "Disable compile-time inclusion of current git info in stack",
+            "manual": true,
+            "default": false
+        },
+        "hide-dependency-versions": {
+            "description": "Hides dependency versions from \"stack --version\", used only by building with stack.yaml",
+            "manual": true,
+            "default": false
+        },
+        "integration-tests": {
+            "description": "Run the integration test suite",
+            "manual": true,
+            "default": false
+        },
+        "static": {
+            "description": "Pass -static/-pthread to ghc when linking the stack binary.",
+            "manual": true,
+            "default": false
+        },
+        "supported-build": {
+            "description": "If false, causes \"stack --version\" to issue a warning about the build being unsupported.  True only if building with stack.yaml",
+            "manual": true,
+            "default": false
+        }
+    },
+    "library": {
+        "exposed-modules": [
+            "Control.Concurrent.Execute",
+            "Data.Attoparsec.Args",
+            "Data.Attoparsec.Combinators",
+            "Data.Attoparsec.Interpreter",
+            "Data.Monoid.Map",
+            "Network.HTTP.Download",
+            "Network.HTTP.Download.Verified",
+            "Network.HTTP.StackClient",
+            "Options.Applicative.Args",
+            "Options.Applicative.Builder.Extra",
+            "Options.Applicative.Complicated",
+            "Path.CheckInstall",
+            "Path.Extra",
+            "Path.Find",
+            "Stack.Build",
+            "Stack.Build.Cache",
+            "Stack.Build.ConstructPlan",
+            "Stack.Build.Execute",
+            "Stack.Build.Haddock",
+            "Stack.Build.Installed",
+            "Stack.Build.Source",
+            "Stack.Build.Target",
+            "Stack.BuildPlan",
+            "Stack.Clean",
+            "Stack.Config",
+            "Stack.Config.Build",
+            "Stack.Config.Urls",
+            "Stack.Config.Docker",
+            "Stack.Config.Nix",
+            "Stack.ConfigCmd",
+            "Stack.Constants",
+            "Stack.Constants.Config",
+            "Stack.Coverage",
+            "Stack.DefaultColorWhen",
+            "Stack.DefaultStyles",
+            "Stack.Docker",
+            "Stack.Docker.GlobalDB",
+            "Stack.Dot",
+            "Stack.FileWatch",
+            "Stack.Freeze",
+            "Stack.GhcPkg",
+            "Stack.Ghci",
+            "Stack.Ghci.Script",
+            "Stack.Hoogle",
+            "Stack.IDE",
+            "Stack.Image",
+            "Stack.Init",
+            "Stack.Ls",
+            "Stack.New",
+            "Stack.Nix",
+            "Stack.Options.BenchParser",
+            "Stack.Options.BuildMonoidParser",
+            "Stack.Options.BuildParser",
+            "Stack.Options.CleanParser",
+            "Stack.Options.ConfigParser",
+            "Stack.Options.Completion",
+            "Stack.Options.DockerParser",
+            "Stack.Options.DotParser",
+            "Stack.Options.ExecParser",
+            "Stack.Options.FreezeParser",
+            "Stack.Options.GhcBuildParser",
+            "Stack.Options.GhciParser",
+            "Stack.Options.GhcVariantParser",
+            "Stack.Options.GlobalParser",
+            "Stack.Options.HaddockParser",
+            "Stack.Options.HpcReportParser",
+            "Stack.Options.LogLevelParser",
+            "Stack.Options.NewParser",
+            "Stack.Options.NixParser",
+            "Stack.Options.PackageParser",
+            "Stack.Options.ResolverParser",
+            "Stack.Options.ScriptParser",
+            "Stack.Options.SDistParser",
+            "Stack.Options.SolverParser",
+            "Stack.Options.TestParser",
+            "Stack.Options.Utils",
+            "Stack.Package",
+            "Stack.PackageDump",
+            "Stack.Path",
+            "Stack.Prelude",
+            "Stack.PrettyPrint",
+            "Stack.Runners",
+            "Stack.Script",
+            "Stack.SDist",
+            "Stack.Setup",
+            "Stack.Setup.Installed",
+            "Stack.SetupCmd",
+            "Stack.Sig",
+            "Stack.Sig.GPG",
+            "Stack.Sig.Sign",
+            "Stack.Snapshot",
+            "Stack.Solver",
+            "Stack.StoreTH",
+            "Stack.Types.Build",
+            "Stack.Types.BuildPlan",
+            "Stack.Types.CompilerBuild",
+            "Stack.Types.Urls",
+            "Stack.Types.Compiler",
+            "Stack.Types.Config",
+            "Stack.Types.Config.Build",
+            "Stack.Types.Docker",
+            "Stack.Types.GhcPkgId",
+            "Stack.Types.Image",
+            "Stack.Types.NamedComponent",
+            "Stack.Types.Nix",
+            "Stack.Types.Package",
+            "Stack.Types.PackageDump",
+            "Stack.Types.PackageName",
+            "Stack.Types.PrettyPrint",
+            "Stack.Types.Resolver",
+            "Stack.Types.Runner",
+            "Stack.Types.Sig",
+            "Stack.Types.StylesUpdate",
+            "Stack.Types.TemplateName",
+            "Stack.Types.Version",
+            "Stack.Types.VersionIntervals",
+            "Stack.Unpack",
+            "Stack.Upgrade",
+            "Stack.Upload",
+            "Text.PrettyPrint.Leijen.Extended",
+            "System.Permissions",
+            "System.Process.PagerEditor",
+            "System.Terminal"
+        ],
+        "generated-exposed-modules": [
+            "Paths_stack"
+        ],
+        "source-dirs": "src/",
+        "ghc-options": [
+            "-fwarn-identities"
+        ],
+        "when": {
+            "condition": "os(windows)",
+            "then": {
+                "source-dirs": [
+                    "src/windows/"
+                ]
+            },
+            "else": {
+                "source-dirs": [
+                    "src/unix/"
+                ],
+                "c-sources": [
+                    "src/unix/cbits/uname.c"
+                ]
+            }
+        }
+    },
+    "executables": {
+        "stack": {
+            "main": "Main.hs",
+            "generated-other-modules": [
+                "Build_stack",
+                "Paths_stack"
+            ],
+            "source-dirs": [
+                "src/main"
+            ],
+            "ghc-options": [
+                "-threaded",
+                "-rtsopts"
+            ],
+            "dependencies": [
+                "stack"
+            ],
+            "when": [
+                {
+                    "condition": "flag(static)",
+                    "cpp-options": [],
+                    "ld-options": [
+                        "-static",
+                        "-pthread"
+                    ],
+                    "dependencies": []
+                },
+                {
+                    "condition": "!(flag(disable-git-info))",
+                    "cpp-options": [
+                        "-DUSE_GIT_INFO"
+                    ],
+                    "ld-options": [],
+                    "dependencies": [
+                        "githash",
+                        "optparse-simple"
+                    ]
+                },
+                {
+                    "condition": "flag(hide-dependency-versions)",
+                    "cpp-options": [
+                        "-DHIDE_DEP_VERSIONS"
+                    ],
+                    "ld-options": [],
+                    "dependencies": []
+                },
+                {
+                    "condition": "flag(supported-build)",
+                    "cpp-options": [
+                        "-DSUPPORTED_BUILD"
+                    ],
+                    "ld-options": [],
+                    "dependencies": []
+                }
+            ]
+        }
+    },
+    "tests": {
+        "stack-integration-test": {
+            "main": "IntegrationSpec.hs",
+            "source-dirs": [
+                "test/integration",
+                "test/integration/lib"
+            ],
+            "ghc-options": [
+                "-threaded",
+                "-rtsopts",
+                "-with-rtsopts=-N"
+            ],
+            "dependencies": [
+                "hspec"
+            ],
+            "when": {
+                "condition": "!flag(integration-tests)",
+                "buildable": false
+            }
+        },
+        "stack-test": {
+            "main": "Spec.hs",
+            "source-dirs": [
+                "src/test"
+            ],
+            "ghc-options": [
+                "-threaded"
+            ],
+            "dependencies": [
+                "QuickCheck",
+                "hspec",
+                "stack",
+                "smallcheck"
+            ]
+        }
+    }
+}
diff --git a/test/golden/test-files/real-world/stack/stack.yaml b/test/golden/test-files/real-world/stack/stack.yaml
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.yaml
@@ -0,0 +1,361 @@
+name: stack
+version: 1.10.0
+synopsis: The Haskell Tool Stack
+description: ! 'Please see the README.md for usage information, and
+
+  the wiki on Github for more details.  Also, note that
+
+  the API for the library is not currently stable, and may
+
+  change significantly, even between minor releases. It is
+
+  currently only intended for use by the executable.'
+category: Development
+homepage: http://haskellstack.org
+author: Commercial Haskell SIG
+maintainer: manny@fpcomplete.com
+license: BSD3
+github: commercialhaskell/stack
+extra-source-files:
+- CONTRIBUTING.md
+- ChangeLog.md
+- README.md
+- doc/*.md
+- src/setup-shim/StackSetupShim.hs
+- stack.yaml
+- test/package-dump/ghc-7.10.txt
+- test/package-dump/ghc-7.8.4-osx.txt
+- test/package-dump/ghc-7.8.txt
+ghc-options:
+- -Wall
+- -fwarn-tabs
+- -fwarn-incomplete-uni-patterns
+- -fwarn-incomplete-record-updates
+- ! '-optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue
+  #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739)'
+dependencies:
+- Cabal >= 2.4
+- aeson
+- annotated-wl-pprint
+- ansi-terminal >= 0.8.1
+- array
+- async
+- attoparsec
+- base >=4.10 && < 5
+- base64-bytestring
+- bytestring
+- colour
+- conduit
+- conduit-extra
+- containers
+- cryptonite
+- cryptonite-conduit
+- deepseq
+- directory
+- echo
+- exceptions
+- extra
+- file-embed
+- filelock
+- filepath
+- fsnotify
+- generic-deriving
+- hackage-security
+- hashable
+- hpack
+- hpc
+- http-client
+- http-client-tls
+- http-conduit
+- http-types
+- memory
+- microlens
+- mintty
+- monad-logger
+- mono-traversable
+- mtl
+- mustache
+- neat-interpolation
+- network-uri
+- open-browser
+- optparse-applicative
+- pantry
+- path
+- path-io
+- persistent
+- persistent-sqlite
+- persistent-template
+- pretty
+- primitive
+- process
+- project-template
+- regex-applicative-text
+- resourcet
+- retry >= 0.7
+- rio
+- semigroups
+- split
+- stm
+- store-core
+- streaming-commons
+- tar
+- template-haskell
+- temporary
+- text
+- text-metrics
+- th-reify-many
+- time
+- tls
+- transformers
+- typed-process
+- unicode-transforms
+- unix-compat
+- unliftio >= 0.2.8.0
+- unordered-containers
+- vector
+- yaml
+- zip-archive
+- zlib
+when:
+  condition: os(windows)
+  then:
+    cpp-options:
+    - -DWINDOWS
+    dependencies:
+    - Win32
+  else:
+    dependencies:
+    - unix
+    build-tools:
+    - hsc2hs
+custom-setup:
+  dependencies:
+  - base >=4.10 && < 5
+  - Cabal >= 2.4
+  - filepath
+flags:
+  disable-git-info:
+    description: Disable compile-time inclusion of current git info in stack
+    manual: true
+    default: false
+  hide-dependency-versions:
+    description: Hides dependency versions from "stack --version", used only by building
+      with stack.yaml
+    manual: true
+    default: false
+  integration-tests:
+    description: Run the integration test suite
+    manual: true
+    default: false
+  static:
+    description: Pass -static/-pthread to ghc when linking the stack binary.
+    manual: true
+    default: false
+  supported-build:
+    description: If false, causes "stack --version" to issue a warning about the build
+      being unsupported.  True only if building with stack.yaml
+    manual: true
+    default: false
+library:
+  exposed-modules:
+  - Control.Concurrent.Execute
+  - Data.Attoparsec.Args
+  - Data.Attoparsec.Combinators
+  - Data.Attoparsec.Interpreter
+  - Data.Monoid.Map
+  - Network.HTTP.Download
+  - Network.HTTP.Download.Verified
+  - Network.HTTP.StackClient
+  - Options.Applicative.Args
+  - Options.Applicative.Builder.Extra
+  - Options.Applicative.Complicated
+  - Path.CheckInstall
+  - Path.Extra
+  - Path.Find
+  - Stack.Build
+  - Stack.Build.Cache
+  - Stack.Build.ConstructPlan
+  - Stack.Build.Execute
+  - Stack.Build.Haddock
+  - Stack.Build.Installed
+  - Stack.Build.Source
+  - Stack.Build.Target
+  - Stack.BuildPlan
+  - Stack.Clean
+  - Stack.Config
+  - Stack.Config.Build
+  - Stack.Config.Urls
+  - Stack.Config.Docker
+  - Stack.Config.Nix
+  - Stack.ConfigCmd
+  - Stack.Constants
+  - Stack.Constants.Config
+  - Stack.Coverage
+  - Stack.DefaultColorWhen
+  - Stack.DefaultStyles
+  - Stack.Docker
+  - Stack.Docker.GlobalDB
+  - Stack.Dot
+  - Stack.FileWatch
+  - Stack.Freeze
+  - Stack.GhcPkg
+  - Stack.Ghci
+  - Stack.Ghci.Script
+  - Stack.Hoogle
+  - Stack.IDE
+  - Stack.Image
+  - Stack.Init
+  - Stack.Ls
+  - Stack.New
+  - Stack.Nix
+  - Stack.Options.BenchParser
+  - Stack.Options.BuildMonoidParser
+  - Stack.Options.BuildParser
+  - Stack.Options.CleanParser
+  - Stack.Options.ConfigParser
+  - Stack.Options.Completion
+  - Stack.Options.DockerParser
+  - Stack.Options.DotParser
+  - Stack.Options.ExecParser
+  - Stack.Options.FreezeParser
+  - Stack.Options.GhcBuildParser
+  - Stack.Options.GhciParser
+  - Stack.Options.GhcVariantParser
+  - Stack.Options.GlobalParser
+  - Stack.Options.HaddockParser
+  - Stack.Options.HpcReportParser
+  - Stack.Options.LogLevelParser
+  - Stack.Options.NewParser
+  - Stack.Options.NixParser
+  - Stack.Options.PackageParser
+  - Stack.Options.ResolverParser
+  - Stack.Options.ScriptParser
+  - Stack.Options.SDistParser
+  - Stack.Options.SolverParser
+  - Stack.Options.TestParser
+  - Stack.Options.Utils
+  - Stack.Package
+  - Stack.PackageDump
+  - Stack.Path
+  - Stack.Prelude
+  - Stack.PrettyPrint
+  - Stack.Runners
+  - Stack.Script
+  - Stack.SDist
+  - Stack.Setup
+  - Stack.Setup.Installed
+  - Stack.SetupCmd
+  - Stack.Sig
+  - Stack.Sig.GPG
+  - Stack.Sig.Sign
+  - Stack.Snapshot
+  - Stack.Solver
+  - Stack.StoreTH
+  - Stack.Types.Build
+  - Stack.Types.BuildPlan
+  - Stack.Types.CompilerBuild
+  - Stack.Types.Urls
+  - Stack.Types.Compiler
+  - Stack.Types.Config
+  - Stack.Types.Config.Build
+  - Stack.Types.Docker
+  - Stack.Types.GhcPkgId
+  - Stack.Types.Image
+  - Stack.Types.NamedComponent
+  - Stack.Types.Nix
+  - Stack.Types.Package
+  - Stack.Types.PackageDump
+  - Stack.Types.PackageName
+  - Stack.Types.PrettyPrint
+  - Stack.Types.Resolver
+  - Stack.Types.Runner
+  - Stack.Types.Sig
+  - Stack.Types.StylesUpdate
+  - Stack.Types.TemplateName
+  - Stack.Types.Version
+  - Stack.Types.VersionIntervals
+  - Stack.Unpack
+  - Stack.Upgrade
+  - Stack.Upload
+  - Text.PrettyPrint.Leijen.Extended
+  - System.Permissions
+  - System.Process.PagerEditor
+  - System.Terminal
+  generated-exposed-modules:
+  - Paths_stack
+  source-dirs: src/
+  ghc-options:
+  - -fwarn-identities
+  when:
+    condition: os(windows)
+    then:
+      source-dirs:
+      - src/windows/
+    else:
+      source-dirs:
+      - src/unix/
+      c-sources:
+      - src/unix/cbits/uname.c
+executables:
+  stack:
+    main: Main.hs
+    generated-other-modules:
+    - Build_stack
+    - Paths_stack
+    source-dirs:
+    - src/main
+    ghc-options:
+    - -threaded
+    - -rtsopts
+    dependencies:
+    - stack
+    when:
+    - condition: flag(static)
+      cpp-options: []
+      ld-options:
+      - -static
+      - -pthread
+      dependencies: []
+    - condition: ! '!(flag(disable-git-info))'
+      cpp-options:
+      - -DUSE_GIT_INFO
+      ld-options: []
+      dependencies:
+      - githash
+      - optparse-simple
+    - condition: flag(hide-dependency-versions)
+      cpp-options:
+      - -DHIDE_DEP_VERSIONS
+      ld-options: []
+      dependencies: []
+    - condition: flag(supported-build)
+      cpp-options:
+      - -DSUPPORTED_BUILD
+      ld-options: []
+      dependencies: []
+tests:
+  stack-integration-test:
+    main: IntegrationSpec.hs
+    source-dirs:
+    - test/integration
+    - test/integration/lib
+    ghc-options:
+    - -threaded
+    - -rtsopts
+    - -with-rtsopts=-N
+    dependencies:
+    - hspec
+    when:
+      condition: ! '!flag(integration-tests)'
+      buildable: false
+  stack-test:
+    main: Spec.hs
+    source-dirs:
+    - src/test
+    ghc-options:
+    - -threaded
+    dependencies:
+    - QuickCheck
+    - hspec
+    - stack
+    - smallcheck
diff --git a/test/golden/test-files/real-world/stack/stack.yaml.cabal b/test/golden/test-files/real-world/stack/stack.yaml.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.yaml.cabal
@@ -0,0 +1,629 @@
+cabal-version: 2.0
+
+-- This file has been generated from stack.yaml by hpack version 0.31.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 33d90e3e81d97f3c404a9e20246cf4aa6942dc054db675cadd50b1edd68582ce
+
+name:           stack
+version:        1.10.0
+synopsis:       The Haskell Tool Stack
+description:    Please see the README.md for usage information, and
+                the wiki on Github for more details.  Also, note that
+                the API for the library is not currently stable, and may
+                change significantly, even between minor releases. It is
+                currently only intended for use by the executable.
+category:       Development
+homepage:       http://haskellstack.org
+bug-reports:    https://github.com/commercialhaskell/stack/issues
+author:         Commercial Haskell SIG
+maintainer:     manny@fpcomplete.com
+license:        BSD3
+build-type:     Custom
+extra-source-files:
+    CONTRIBUTING.md
+    ChangeLog.md
+    README.md
+    src/setup-shim/StackSetupShim.hs
+    stack.yaml
+    test/package-dump/ghc-7.10.txt
+    test/package-dump/ghc-7.8.4-osx.txt
+    test/package-dump/ghc-7.8.txt
+
+source-repository head
+  type: git
+  location: https://github.com/commercialhaskell/stack
+
+custom-setup
+  setup-depends:
+      Cabal >=2.4
+    , base >=4.10 && <5
+    , filepath
+
+flag disable-git-info
+  description: Disable compile-time inclusion of current git info in stack
+  manual: True
+  default: False
+
+flag hide-dependency-versions
+  description: Hides dependency versions from "stack --version", used only by building with stack.yaml
+  manual: True
+  default: False
+
+flag integration-tests
+  description: Run the integration test suite
+  manual: True
+  default: False
+
+flag static
+  description: Pass -static/-pthread to ghc when linking the stack binary.
+  manual: True
+  default: False
+
+flag supported-build
+  description: If false, causes "stack --version" to issue a warning about the build being unsupported.  True only if building with stack.yaml
+  manual: True
+  default: False
+
+library
+  exposed-modules:
+      Control.Concurrent.Execute
+      Data.Attoparsec.Args
+      Data.Attoparsec.Combinators
+      Data.Attoparsec.Interpreter
+      Data.Monoid.Map
+      Network.HTTP.Download
+      Network.HTTP.Download.Verified
+      Network.HTTP.StackClient
+      Options.Applicative.Args
+      Options.Applicative.Builder.Extra
+      Options.Applicative.Complicated
+      Path.CheckInstall
+      Path.Extra
+      Path.Find
+      Stack.Build
+      Stack.Build.Cache
+      Stack.Build.ConstructPlan
+      Stack.Build.Execute
+      Stack.Build.Haddock
+      Stack.Build.Installed
+      Stack.Build.Source
+      Stack.Build.Target
+      Stack.BuildPlan
+      Stack.Clean
+      Stack.Config
+      Stack.Config.Build
+      Stack.Config.Urls
+      Stack.Config.Docker
+      Stack.Config.Nix
+      Stack.ConfigCmd
+      Stack.Constants
+      Stack.Constants.Config
+      Stack.Coverage
+      Stack.DefaultColorWhen
+      Stack.DefaultStyles
+      Stack.Docker
+      Stack.Docker.GlobalDB
+      Stack.Dot
+      Stack.FileWatch
+      Stack.Freeze
+      Stack.GhcPkg
+      Stack.Ghci
+      Stack.Ghci.Script
+      Stack.Hoogle
+      Stack.IDE
+      Stack.Image
+      Stack.Init
+      Stack.Ls
+      Stack.New
+      Stack.Nix
+      Stack.Options.BenchParser
+      Stack.Options.BuildMonoidParser
+      Stack.Options.BuildParser
+      Stack.Options.CleanParser
+      Stack.Options.ConfigParser
+      Stack.Options.Completion
+      Stack.Options.DockerParser
+      Stack.Options.DotParser
+      Stack.Options.ExecParser
+      Stack.Options.FreezeParser
+      Stack.Options.GhcBuildParser
+      Stack.Options.GhciParser
+      Stack.Options.GhcVariantParser
+      Stack.Options.GlobalParser
+      Stack.Options.HaddockParser
+      Stack.Options.HpcReportParser
+      Stack.Options.LogLevelParser
+      Stack.Options.NewParser
+      Stack.Options.NixParser
+      Stack.Options.PackageParser
+      Stack.Options.ResolverParser
+      Stack.Options.ScriptParser
+      Stack.Options.SDistParser
+      Stack.Options.SolverParser
+      Stack.Options.TestParser
+      Stack.Options.Utils
+      Stack.Package
+      Stack.PackageDump
+      Stack.Path
+      Stack.Prelude
+      Stack.PrettyPrint
+      Stack.Runners
+      Stack.Script
+      Stack.SDist
+      Stack.Setup
+      Stack.Setup.Installed
+      Stack.SetupCmd
+      Stack.Sig
+      Stack.Sig.GPG
+      Stack.Sig.Sign
+      Stack.Snapshot
+      Stack.Solver
+      Stack.StoreTH
+      Stack.Types.Build
+      Stack.Types.BuildPlan
+      Stack.Types.CompilerBuild
+      Stack.Types.Urls
+      Stack.Types.Compiler
+      Stack.Types.Config
+      Stack.Types.Config.Build
+      Stack.Types.Docker
+      Stack.Types.GhcPkgId
+      Stack.Types.Image
+      Stack.Types.NamedComponent
+      Stack.Types.Nix
+      Stack.Types.Package
+      Stack.Types.PackageDump
+      Stack.Types.PackageName
+      Stack.Types.PrettyPrint
+      Stack.Types.Resolver
+      Stack.Types.Runner
+      Stack.Types.Sig
+      Stack.Types.StylesUpdate
+      Stack.Types.TemplateName
+      Stack.Types.Version
+      Stack.Types.VersionIntervals
+      Stack.Unpack
+      Stack.Upgrade
+      Stack.Upload
+      Text.PrettyPrint.Leijen.Extended
+      System.Permissions
+      System.Process.PagerEditor
+      System.Terminal
+      Paths_stack
+  autogen-modules:
+      Paths_stack
+  hs-source-dirs:
+      src/
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -fwarn-identities
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if os(windows)
+    hs-source-dirs:
+        src/windows/
+  else
+    hs-source-dirs:
+        src/unix/
+    c-sources:
+        src/unix/cbits/uname.c
+  default-language: Haskell2010
+
+executable stack
+  main-is: Main.hs
+  other-modules:
+      Build_stack
+      Paths_stack
+  autogen-modules:
+      Build_stack
+      Paths_stack
+  hs-source-dirs:
+      src/main
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded -rtsopts
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stack
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if flag(static)
+    ld-options: -static -pthread
+  if !(flag(disable-git-info))
+    cpp-options: -DUSE_GIT_INFO
+    build-depends:
+        githash
+      , optparse-simple
+  if flag(hide-dependency-versions)
+    cpp-options: -DHIDE_DEP_VERSIONS
+  if flag(supported-build)
+    cpp-options: -DSUPPORTED_BUILD
+  default-language: Haskell2010
+
+test-suite stack-integration-test
+  type: exitcode-stdio-1.0
+  main-is: IntegrationSpec.hs
+  other-modules:
+      Paths_stack
+  hs-source-dirs:
+      test/integration
+      test/integration/lib
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded -rtsopts -with-rtsopts=-N
+  build-depends:
+      Cabal >=2.4
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , hspec
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , split
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  if !flag(integration-tests)
+    buildable: False
+  default-language: Haskell2010
+
+test-suite stack-test
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  other-modules:
+      Paths_stack
+  hs-source-dirs:
+      src/test
+  ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739) -threaded
+  build-depends:
+      Cabal >=2.4
+    , QuickCheck
+    , aeson
+    , annotated-wl-pprint
+    , ansi-terminal >=0.8.1
+    , array
+    , async
+    , attoparsec
+    , base >=4.10 && <5
+    , base64-bytestring
+    , bytestring
+    , colour
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , deepseq
+    , directory
+    , echo
+    , exceptions
+    , extra
+    , file-embed
+    , filelock
+    , filepath
+    , fsnotify
+    , generic-deriving
+    , hackage-security
+    , hashable
+    , hpack
+    , hpc
+    , hspec
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-types
+    , memory
+    , microlens
+    , mintty
+    , monad-logger
+    , mono-traversable
+    , mtl
+    , mustache
+    , neat-interpolation
+    , network-uri
+    , open-browser
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite
+    , persistent-template
+    , pretty
+    , primitive
+    , process
+    , project-template
+    , regex-applicative-text
+    , resourcet
+    , retry >=0.7
+    , rio
+    , semigroups
+    , smallcheck
+    , split
+    , stack
+    , stm
+    , store-core
+    , streaming-commons
+    , tar
+    , template-haskell
+    , temporary
+    , text
+    , text-metrics
+    , th-reify-many
+    , time
+    , tls
+    , transformers
+    , typed-process
+    , unicode-transforms
+    , unix-compat
+    , unliftio >=0.2.8.0
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+    , zlib
+  if os(windows)
+    cpp-options: -DWINDOWS
+    build-depends:
+        Win32
+  else
+    build-tools:
+        hsc2hs
+    build-depends:
+        unix
+  default-language: Haskell2010
diff --git a/test/golden/test-files/real-world/stack/stack.yaml.golden b/test/golden/test-files/real-world/stack/stack.yaml.golden
new file mode 100644
--- /dev/null
+++ b/test/golden/test-files/real-world/stack/stack.yaml.golden
@@ -0,0 +1,361 @@
+name: stack
+version: 1.10.0
+synopsis: The Haskell Tool Stack
+description: ! 'Please see the README.md for usage information, and
+
+  the wiki on Github for more details.  Also, note that
+
+  the API for the library is not currently stable, and may
+
+  change significantly, even between minor releases. It is
+
+  currently only intended for use by the executable.'
+category: Development
+homepage: http://haskellstack.org
+author: Commercial Haskell SIG
+maintainer: manny@fpcomplete.com
+license: BSD3
+github: commercialhaskell/stack
+extra-source-files:
+- CONTRIBUTING.md
+- ChangeLog.md
+- README.md
+- doc/*.md
+- src/setup-shim/StackSetupShim.hs
+- stack.yaml
+- test/package-dump/ghc-7.10.txt
+- test/package-dump/ghc-7.8.4-osx.txt
+- test/package-dump/ghc-7.8.txt
+ghc-options:
+- -Wall
+- -fwarn-tabs
+- -fwarn-incomplete-uni-patterns
+- -fwarn-incomplete-record-updates
+- ! '-optP-Wno-nonportable-include-path # workaround [Filename case on macOS · Issue
+  #4739 · haskell/cabal](https://github.com/haskell/cabal/issues/4739)'
+dependencies:
+- Cabal >= 2.4
+- aeson
+- annotated-wl-pprint
+- ansi-terminal >= 0.8.1
+- array
+- async
+- attoparsec
+- base >=4.10 && < 5
+- base64-bytestring
+- bytestring
+- colour
+- conduit
+- conduit-extra
+- containers
+- cryptonite
+- cryptonite-conduit
+- deepseq
+- directory
+- echo
+- exceptions
+- extra
+- file-embed
+- filelock
+- filepath
+- fsnotify
+- generic-deriving
+- hackage-security
+- hashable
+- hpack
+- hpc
+- http-client
+- http-client-tls
+- http-conduit
+- http-types
+- memory
+- microlens
+- mintty
+- monad-logger
+- mono-traversable
+- mtl
+- mustache
+- neat-interpolation
+- network-uri
+- open-browser
+- optparse-applicative
+- pantry
+- path
+- path-io
+- persistent
+- persistent-sqlite
+- persistent-template
+- pretty
+- primitive
+- process
+- project-template
+- regex-applicative-text
+- resourcet
+- retry >= 0.7
+- rio
+- semigroups
+- split
+- stm
+- store-core
+- streaming-commons
+- tar
+- template-haskell
+- temporary
+- text
+- text-metrics
+- th-reify-many
+- time
+- tls
+- transformers
+- typed-process
+- unicode-transforms
+- unix-compat
+- unliftio >= 0.2.8.0
+- unordered-containers
+- vector
+- yaml
+- zip-archive
+- zlib
+when:
+  condition: os(windows)
+  then:
+    cpp-options:
+    - -DWINDOWS
+    dependencies:
+    - Win32
+  else:
+    dependencies:
+    - unix
+    build-tools:
+    - hsc2hs
+custom-setup:
+  dependencies:
+  - base >=4.10 && < 5
+  - Cabal >= 2.4
+  - filepath
+flags:
+  disable-git-info:
+    description: Disable compile-time inclusion of current git info in stack
+    manual: true
+    default: false
+  hide-dependency-versions:
+    description: Hides dependency versions from "stack --version", used only by building
+      with stack.yaml
+    manual: true
+    default: false
+  integration-tests:
+    description: Run the integration test suite
+    manual: true
+    default: false
+  static:
+    description: Pass -static/-pthread to ghc when linking the stack binary.
+    manual: true
+    default: false
+  supported-build:
+    description: If false, causes "stack --version" to issue a warning about the build
+      being unsupported.  True only if building with stack.yaml
+    manual: true
+    default: false
+library:
+  exposed-modules:
+  - Control.Concurrent.Execute
+  - Data.Attoparsec.Args
+  - Data.Attoparsec.Combinators
+  - Data.Attoparsec.Interpreter
+  - Data.Monoid.Map
+  - Network.HTTP.Download
+  - Network.HTTP.Download.Verified
+  - Network.HTTP.StackClient
+  - Options.Applicative.Args
+  - Options.Applicative.Builder.Extra
+  - Options.Applicative.Complicated
+  - Path.CheckInstall
+  - Path.Extra
+  - Path.Find
+  - Stack.Build
+  - Stack.Build.Cache
+  - Stack.Build.ConstructPlan
+  - Stack.Build.Execute
+  - Stack.Build.Haddock
+  - Stack.Build.Installed
+  - Stack.Build.Source
+  - Stack.Build.Target
+  - Stack.BuildPlan
+  - Stack.Clean
+  - Stack.Config
+  - Stack.Config.Build
+  - Stack.Config.Urls
+  - Stack.Config.Docker
+  - Stack.Config.Nix
+  - Stack.ConfigCmd
+  - Stack.Constants
+  - Stack.Constants.Config
+  - Stack.Coverage
+  - Stack.DefaultColorWhen
+  - Stack.DefaultStyles
+  - Stack.Docker
+  - Stack.Docker.GlobalDB
+  - Stack.Dot
+  - Stack.FileWatch
+  - Stack.Freeze
+  - Stack.GhcPkg
+  - Stack.Ghci
+  - Stack.Ghci.Script
+  - Stack.Hoogle
+  - Stack.IDE
+  - Stack.Image
+  - Stack.Init
+  - Stack.Ls
+  - Stack.New
+  - Stack.Nix
+  - Stack.Options.BenchParser
+  - Stack.Options.BuildMonoidParser
+  - Stack.Options.BuildParser
+  - Stack.Options.CleanParser
+  - Stack.Options.ConfigParser
+  - Stack.Options.Completion
+  - Stack.Options.DockerParser
+  - Stack.Options.DotParser
+  - Stack.Options.ExecParser
+  - Stack.Options.FreezeParser
+  - Stack.Options.GhcBuildParser
+  - Stack.Options.GhciParser
+  - Stack.Options.GhcVariantParser
+  - Stack.Options.GlobalParser
+  - Stack.Options.HaddockParser
+  - Stack.Options.HpcReportParser
+  - Stack.Options.LogLevelParser
+  - Stack.Options.NewParser
+  - Stack.Options.NixParser
+  - Stack.Options.PackageParser
+  - Stack.Options.ResolverParser
+  - Stack.Options.ScriptParser
+  - Stack.Options.SDistParser
+  - Stack.Options.SolverParser
+  - Stack.Options.TestParser
+  - Stack.Options.Utils
+  - Stack.Package
+  - Stack.PackageDump
+  - Stack.Path
+  - Stack.Prelude
+  - Stack.PrettyPrint
+  - Stack.Runners
+  - Stack.Script
+  - Stack.SDist
+  - Stack.Setup
+  - Stack.Setup.Installed
+  - Stack.SetupCmd
+  - Stack.Sig
+  - Stack.Sig.GPG
+  - Stack.Sig.Sign
+  - Stack.Snapshot
+  - Stack.Solver
+  - Stack.StoreTH
+  - Stack.Types.Build
+  - Stack.Types.BuildPlan
+  - Stack.Types.CompilerBuild
+  - Stack.Types.Urls
+  - Stack.Types.Compiler
+  - Stack.Types.Config
+  - Stack.Types.Config.Build
+  - Stack.Types.Docker
+  - Stack.Types.GhcPkgId
+  - Stack.Types.Image
+  - Stack.Types.NamedComponent
+  - Stack.Types.Nix
+  - Stack.Types.Package
+  - Stack.Types.PackageDump
+  - Stack.Types.PackageName
+  - Stack.Types.PrettyPrint
+  - Stack.Types.Resolver
+  - Stack.Types.Runner
+  - Stack.Types.Sig
+  - Stack.Types.StylesUpdate
+  - Stack.Types.TemplateName
+  - Stack.Types.Version
+  - Stack.Types.VersionIntervals
+  - Stack.Unpack
+  - Stack.Upgrade
+  - Stack.Upload
+  - Text.PrettyPrint.Leijen.Extended
+  - System.Permissions
+  - System.Process.PagerEditor
+  - System.Terminal
+  generated-exposed-modules:
+  - Paths_stack
+  source-dirs: src/
+  ghc-options:
+  - -fwarn-identities
+  when:
+    condition: os(windows)
+    then:
+      source-dirs:
+      - src/windows/
+    else:
+      source-dirs:
+      - src/unix/
+      c-sources:
+      - src/unix/cbits/uname.c
+executables:
+  stack:
+    main: Main.hs
+    generated-other-modules:
+    - Build_stack
+    - Paths_stack
+    source-dirs:
+    - src/main
+    ghc-options:
+    - -threaded
+    - -rtsopts
+    dependencies:
+    - stack
+    when:
+    - condition: flag(static)
+      cpp-options: []
+      ld-options:
+      - -static
+      - -pthread
+      dependencies: []
+    - condition: ! '!(flag(disable-git-info))'
+      cpp-options:
+      - -DUSE_GIT_INFO
+      ld-options: []
+      dependencies:
+      - githash
+      - optparse-simple
+    - condition: flag(hide-dependency-versions)
+      cpp-options:
+      - -DHIDE_DEP_VERSIONS
+      ld-options: []
+      dependencies: []
+    - condition: flag(supported-build)
+      cpp-options:
+      - -DSUPPORTED_BUILD
+      ld-options: []
+      dependencies: []
+tests:
+  stack-integration-test:
+    main: IntegrationSpec.hs
+    source-dirs:
+    - test/integration
+    - test/integration/lib
+    ghc-options:
+    - -threaded
+    - -rtsopts
+    - -with-rtsopts=-N
+    dependencies:
+    - hspec
+    when:
+      condition: ! '!flag(integration-tests)'
+      buildable: false
+  stack-test:
+    main: Spec.hs
+    source-dirs:
+    - src/test
+    ghc-options:
+    - -threaded
+    dependencies:
+    - QuickCheck
+    - hspec
+    - stack
+    - smallcheck
