diff --git a/CommonCLI.hs b/CommonCLI.hs
--- a/CommonCLI.hs
+++ b/CommonCLI.hs
@@ -1,17 +1,21 @@
 module CommonCLI(TypeOpts(..), unflag, tyOptParser) where
 
+
 import           Data.Monoid                    ((<>))
 import           Options.Applicative
 import           System.Process                 (system)
 import qualified System.Environment             (lookupEnv)
 import           System.Exit                    (ExitCode)
 
+import           Data.Aeson.AutoType.CodeGen    (Lang(..))
+
 data TypeOpts = TyOptions {
                   autounify :: Bool
                 , toplevel  :: String
                 , debug     :: Bool
                 , test      :: Bool
                 , suggest   :: Bool
+                , lang      :: Lang
                 }
 
 unflag :: Mod FlagFields Bool -> Parser Bool
@@ -26,4 +30,10 @@
             <*> switch (long "debug"        <> help "Set this flag to see more debugging info"       )
             <*> unflag (long "no-test"      <> help "Do not run generated parser afterwards"         )
             <*> unflag (long "no-suggest"   <> help "Do not suggest candidates for unification"      )
+            <*> langOpts
+
+
+langOpts :: Parser Lang
+langOpts  =  flag Haskell Haskell (long "haskell")
+         <|> flag Haskell Elm     (long "elm")
 
diff --git a/GenerateJSONParser.hs b/GenerateJSONParser.hs
--- a/GenerateJSONParser.hs
+++ b/GenerateJSONParser.hs
@@ -42,7 +42,6 @@
                , typecheck :: Bool
                , yaml :: Bool
                , preprocessor :: Bool
-               , lang :: Lang
                , filenames :: [FilePath]
                }
 
@@ -58,13 +57,8 @@
              <*> switch    (short 'p'             <>
                             long "preprocessor"   <>
                               help "Work as GHC preprocessor (and skip preprocessor pragma)")
-             <*> langOpts
              <*> some (argument str (metavar "FILES..."))
 
-langOpts :: Parser Lang
-langOpts  =  flag Haskell Haskell (long "haskell")
-         <|> flag Haskell Elm     (long "elm")
-
 -- | Report an error to error output.
 report   :: Text -> IO ()
 report    = Text.hPutStrLn stderr
@@ -122,7 +116,11 @@
 
 -- | Take a set of JSON input filenames, Haskell output filename, and generate module parsing these JSON files.
 generateHaskellFromJSONs :: Options -> [FilePath] -> FilePath -> IO ()
-generateHaskellFromJSONs opts@Options { tyOpts=TyOptions { toplevel } } inputFilenames outputFilename = do
+generateHaskellFromJSONs opts@Options { tyOpts=TyOptions { toplevel
+                                                         , lang
+                                                         , test }
+                                      }
+                         inputFilenames outputFilename = do
   -- Read type from each file
   (filenames,
    typeForEachFile,
@@ -151,9 +149,9 @@
                     else splitted
     myTrace $ "UNIFIED:\n" ++ pretty unified
     -- We start by writing module header
-    writeModule (lang opts) outputFilename toplevelName unified
-    when (test $ tyOpts opts) $
-      exitWith =<< runModule (lang opts) (outputFilename:passedTypeCheck)
+    writeModule lang outputFilename toplevelName unified
+    when test $
+      exitWith =<< runModule lang (outputFilename:passedTypeCheck)
   where
     -- | Works like @Debug.trace@ when the --debug flag is enabled, and does nothing otherwise.
     myTrace :: String -> IO ()
diff --git a/GenerateTestJSON.hs b/GenerateTestJSON.hs
--- a/GenerateTestJSON.hs
+++ b/GenerateTestJSON.hs
@@ -32,13 +32,14 @@
 import           Text.PrettyPrint.GenericPretty (pretty)
 import           Test.QuickCheck
 
-import           Data.Aeson.AutoType.Pretty
-import           Data.Aeson.AutoType.Type
+import           Data.Aeson.AutoType.CodeGen(writeModule, runModule, Lang(..))
 import           Data.Aeson.AutoType.Extract
 import           Data.Aeson.AutoType.Format
-import           Data.Aeson.AutoType.CodeGen
-import           Data.Aeson.AutoType.Util
+import           Data.Aeson.AutoType.Pretty
+import           Data.Aeson.AutoType.Split
 import           Data.Aeson.AutoType.Test
+import           Data.Aeson.AutoType.Type
+import           Data.Aeson.AutoType.Util
 import           Options.Applicative
 
 import           CommonCLI
@@ -170,10 +171,10 @@
                           else splitted
           myTrace $ "UNIFIED:\n" ++ pretty unified
           -- We start by writing module header
-          writeHaskellModule outputFilename toplevelName unified
+          writeModule lang outputFilename toplevelName unified
           if test
             then do
-              r <- (==ExitSuccess) <$> runModule (lang opts) [outputFilename, inputFilename]
+              r <- (==ExitSuccess) <$> runModule lang [outputFilename, inputFilename]
               when r $ mapM_ removeFile [inputFilename, outputFilename]
               return r
             else
diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,8 @@
 Changelog
 =========
+    1.1.1  Mar 2018
+        * Fixed test builds (for Haskell).
+
     1.1.0  Mar 2018
         * Partial support Elm code generation.
 
diff --git a/json-autotype.cabal b/json-autotype.cabal
--- a/json-autotype.cabal
+++ b/json-autotype.cabal
@@ -1,6 +1,6 @@
 -- Build information for the package.
 name:                json-autotype
-version:             1.1.0
+version:             1.1.1
 synopsis:            Automatic type declaration for JSON input data
 description:         Generates datatype declarations with Aeson's "FromJSON" instances
                      from a set of example ".json" files.
@@ -70,7 +70,7 @@
                        Data.Aeson.AutoType.CodeGen.ElmFormat
   build-depends:       base                 >=4.3  && <4.12,
                        GenericPretty        >=1.2  && <1.3,
-                       aeson                >=0.7  && <1.3,
+                       aeson                >=0.7  && <1.4,
                        containers           >=0.3  && <0.6,
                        filepath             >=1.3  && <1.5,
                        hashable             >=1.2  && <1.3,
@@ -114,7 +114,7 @@
                        RecordWildCards
   build-depends:       base                 >=4.3  && <4.12,
                        GenericPretty        >=1.2  && <1.3,
-                       aeson                >=0.7  && <1.3,
+                       aeson                >=0.7  && <1.4,
                        bytestring           >=0.9  && <0.11,
                        containers           >=0.3  && <0.6,
                        filepath             >=1.3  && <1.5,
@@ -156,9 +156,11 @@
                        RecordWildCards
   build-depends:       base                 >=4.3  && <4.12,
                        GenericPretty        >=1.2  && <1.3,
-                       aeson                >=0.7  && <1.3,
+                       aeson                >=0.7  && <1.4,
                        containers           >=0.3  && <0.6,
                        hashable             >=1.2  && <1.3,
+                       lens                 >=4.1  && <4.17,
+                       mtl                  >=2.1  && <2.3,
                        pretty               >=1.1  && <1.3,
                        scientific           >=0.3  && <0.5,
                        smallcheck           >=1.0  && <1.2,
@@ -174,11 +176,17 @@
   type:                exitcode-stdio-1.0
   main-is:             test/TestExamples.hs
   other-modules:       Data.Aeson.AutoType.Util
+                       Data.Aeson.AutoType.CodeGen
+                       Data.Aeson.AutoType.CodeGen.Elm
+                       Data.Aeson.AutoType.CodeGen.ElmFormat
+                       Data.Aeson.AutoType.CodeGen.Haskell
+                       Data.Aeson.AutoType.CodeGen.HaskellFormat
                        Data.Aeson.AutoType.Extract
                        Data.Aeson.AutoType.Format
+                       Data.Aeson.AutoType.Pretty
+                       Data.Aeson.AutoType.Split
                        Data.Aeson.AutoType.Test
                        Data.Aeson.AutoType.Type
-                       Data.Aeson.AutoType.Pretty
                        CommonCLI
   other-extensions:    TemplateHaskell,
                        ScopedTypeVariables,
@@ -190,11 +198,13 @@
                        RecordWildCards
   build-depends:       base                 >=4.3  && <4.12,
                        GenericPretty        >=1.2  && <1.3,
-                       aeson                >=0.7  && <1.3,
+                       aeson                >=0.7  && <1.4,
                        containers           >=0.3  && <0.6,
                        directory            >=1.1  && <1.4,
                        filepath             >=1.3  && <1.5,
                        hashable             >=1.2  && <1.3,
+                       lens                 >=4.1  && <4.17,
+                       mtl                  >=2.1  && <2.3,
                        optparse-applicative >=0.11 && <1.0,
                        pretty               >=1.1  && <1.3,
                        process              >=1.1  && <1.7,
@@ -235,7 +245,7 @@
                        RecordWildCards
   build-depends:       base                 >=4.3  && <4.12,
                        GenericPretty        >=1.2  && <1.3,
-                       aeson                >=0.7  && <1.3,
+                       aeson                >=0.7  && <1.4,
                        bytestring           >=0.9  && <0.11,
                        containers           >=0.3  && <0.6,
                        directory            >=1.1  && <1.4,
diff --git a/test/TestExamples.hs b/test/TestExamples.hs
--- a/test/TestExamples.hs
+++ b/test/TestExamples.hs
@@ -8,8 +8,11 @@
 import System.Directory(doesDirectoryExist, getDirectoryContents)
 import System.FilePath((</>), (<.>), takeBaseName, replaceFileName)
 import System.Exit(ExitCode(..))
+import Data.Aeson.AutoType.CodeGen(runModule, Lang(Haskell))
 
-import CommonCLI
+--import CommonCLI
+
+runghc = runModule Haskell
 
 -- |  <http://book.realworldhaskell.org/read/io-case-study-a-library-for-searching-the-filesystem.html>
 getRecursiveContents :: FilePath -> IO [FilePath]
