packages feed

hs2ats 0.4.0.0 → 0.5.0.0

raw patch · 4 files changed

+18/−5 lines, 4 filesdep +cpphsPVP ok

version bump matches the API change (PVP)

Dependencies added: cpphs

API changes (from Hackage documentation)

- Language.ATS.Generate: genATSTypes :: FilePath -> FilePath -> IO ()
+ Language.ATS.Generate: genATSTypes :: FilePath -> FilePath -> Bool -> IO ()

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # hs2ats +## 0.5.0.0++  * Re-add `cpphs` dependency+ ## 0.4.0.0      * Stop depending on `cpphs`
app/Main.hs view
@@ -12,10 +12,11 @@  data Program = Program { src    :: FilePath <?> "Haskell source file"                        , target :: FilePath <?> "ATS target"+                       , cpphs  :: Bool <?> "Use cpphs as a preprocessor"                        } deriving (Generic, ParseRecord)  main :: IO () main = do     x <- getRecord "Generate ATS types for Haskell source code" :: IO Program     let go = (x &) . (unHelpful .)-    genATSTypes (go src) (go target)+    genATSTypes (go src) (go target) (go cpphs)
hs2ats.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: hs2ats-version: 0.4.0.0+version: 0.5.0.0 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale@@ -41,7 +41,8 @@         microlens -any,         ansi-wl-pprint -any,         composition-prelude -any,-        deepseq -any+        deepseq -any,+        cpphs -any      if flag(development)         ghc-options: -Werror
src/Language/ATS/Generate.hs view
@@ -10,6 +10,7 @@     ) where  import           Control.Arrow+import           Data.Bool                    (bool) import           Data.Char                    (toUpper) import           Data.Either                  (lefts, rights) import           Data.Foldable@@ -19,6 +20,7 @@ import           Language.ATS.Generate.Error import           Language.Haskell.Exts import           Language.Haskell.Exts.Syntax as HS+import           Language.Preprocessor.Cpphs  (defaultCpphsOptions, runCpphs) import           Lens.Micro                   (over, _head) import           Text.Casing                  (quietSnake) @@ -172,10 +174,15 @@     ParseOk x            -> Right x     ParseFailed loc' msg -> syntaxError (loc' { srcFilename = file }) msg +process :: FilePath -> String -> IO String+process p = fmap (unlines . drop 1 . lines) . runCpphs defaultCpphsOptions p+ genATSTypes :: FilePath -- ^ Haskell source file             -> FilePath -- ^ @.sats@ file to be generated+            -> Bool -- ^ Whether to use pre-process the Haskell source (use this if you use @{\#- LANGUAGE CPP \#-}@ anywhere)             -> IO ()-genATSTypes p p' = do-    contents <- readFile p+genATSTypes p p' withCPP = do+    let proc = bool pure (process p) withCPP+    contents <- proc =<< readFile p     let warnDo (x, es) = traverse_ displayErr es *> writeFile p' x     either displayErr warnDo (generateATS p contents)