packages feed

hpack-dhall (empty) → 0.1.0

raw patch · 6 files changed

+145/−0 lines, 6 filesdep +aesondep +basedep +dhallsetup-changed

Dependencies added: aeson, base, dhall, dhall-json, hpack, hspec, interpolate, mockery, text, transformers, trifecta

Files

+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ driver/Main.hs view
@@ -0,0 +1,6 @@+module Main (main) where++import qualified Hpack.Dhall++main :: IO ()+main = Hpack.Dhall.main
+ hpack-dhall.cabal view
@@ -0,0 +1,66 @@+-- This file has been generated from package.yaml by hpack version 0.23.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: c298d477b6c09e70c97fdc47ae58b23f965424ab7ecd301c4ab4372a2851cbe7++name:           hpack-dhall+version:        0.1.0+synopsis:       Dhall support for Hpack+description:    This package allows you to use the Dhall configuration language to specify+                Haskell packages.+category:       Development+homepage:       https://github.com/sol/hpack-dhall#readme+bug-reports:    https://github.com/sol/hpack-dhall/issues+license:        PublicDomain+build-type:     Simple+cabal-version:  >= 1.10++source-repository head+  type: git+  location: https://github.com/sol/hpack-dhall++executable hpack-dhall+  main-is: Main.hs+  other-modules:+      Hpack.Dhall+      Paths_hpack_dhall+  hs-source-dirs:+      src+      driver+  ghc-options: -Wall+  build-depends:+      aeson+    , base ==4.*+    , dhall+    , dhall-json+    , hpack >=0.23.0+    , text+    , transformers+    , trifecta+  default-language: Haskell2010++test-suite spec+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Hpack.Dhall+      Hpack.DhallSpec+      Paths_hpack_dhall+  hs-source-dirs:+      src+      test+  ghc-options: -Wall+  build-depends:+      aeson+    , base ==4.*+    , dhall+    , dhall-json+    , hpack >=0.23.0+    , hspec ==2.*+    , interpolate+    , mockery+    , text+    , transformers+    , trifecta+  default-language: Haskell2010
+ src/Hpack/Dhall.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE NoMonomorphismRestriction #-}+module Hpack.Dhall where++import           Control.Monad.Trans.Except+import           Control.Monad.IO.Class+import           Data.Bifunctor+import           Data.Aeson+import qualified Data.Text.Lazy.IO as LT+import qualified Data.Text as T+import           Data.Text.Encoding (encodeUtf8)+import           Text.Trifecta.Delta (Delta(..))+import qualified Dhall.Parser+import qualified Dhall.Import+import qualified Dhall.TypeCheck+import qualified Dhall.JSON++import qualified Hpack++packageConfig :: FilePath+packageConfig = "package.dhall"++readDhall :: FilePath -> IO (Either String Value)+readDhall file = runExceptT $ do+  expr <- readInput >>= parseExpr >>= liftIO . Dhall.Import.load+  _ <- liftResult $ Dhall.TypeCheck.typeOf expr+  liftResult $ Dhall.JSON.dhallToJSON expr+  where+    readInput = liftIO (LT.readFile file)+    parseExpr = liftResult . Dhall.Parser.exprFromText (Directed (encodeUtf8 $ T.pack file) 0 0 0 0)+    liftResult = ExceptT . return . first show++main :: IO ()+main = Hpack.mainWith packageConfig readDhall
+ test/Hpack/DhallSpec.hs view
@@ -0,0 +1,36 @@+{-# LANGUAGE QuasiQuotes #-}+module Hpack.DhallSpec (spec) where++import           Test.Hspec+import           Test.Mockery.Directory+import           Data.String.Interpolate+import           Data.String.Interpolate.Util++import           Data.Version (showVersion)+import qualified Hpack++import           Hpack.Dhall++spec :: Spec+spec = do+  describe "main" $ do+    it "generates cabal files" $ do+      inTempDirectory $ do+        writeFile packageConfig [i|+        {+          name = "foo"+        }+        |]+        main+        readFile "foo.cabal" `shouldReturn` unindent [i|+        -- This file has been generated from package.dhall by hpack version #{showVersion Hpack.version}.+        --+        -- see: https://github.com/sol/hpack+        --+        -- hash: 19abf59677a84e0a8a49435b80f42f6007f6cdacd2b09c43514ab2b46d6c5927++        name:           foo+        version:        0.0.0+        build-type:     Simple+        cabal-version:  >= 1.10+        |]
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -fforce-recomp -F -pgmF hspec-discover #-}