hs2ats 0.2.0.1 → 0.2.0.3
raw patch · 3 files changed
+20/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +9/−1
- hs2ats.cabal +1/−1
- src/Language/ATS/Generate.hs +10/−4
README.md view
@@ -1,4 +1,12 @@ # hs2ats This is a tool to convert Haskell types to ATS types. So far it works quite-well, but documentation and error messages are nearly nonexistent.+well, but documentation is sparse.++Example use:++```+hs2ats --src DataTypes.hs --target generated_types.sats+```++Note also that `hs2ats` does not preserve strictness semantics.
hs2ats.cabal view
@@ -1,5 +1,5 @@ name: hs2ats-version: 0.2.0.1+version: 0.2.0.3 synopsis: Create ATS types from Haskell types description: This package enables scanning Haskell source files for data types and then generating [ATS](http://www.ats-lang.org/) types from them. homepage: https://github.com/vmchale/hs2ats#readme
src/Language/ATS/Generate.hs view
@@ -98,12 +98,16 @@ qualConDeclToLeaf (EmptyQualCon _ cd) = Leaf [] <$> (over _head toUpper . convertConventions . fst <$> conDeclToType cd) <*> pure [] <*> (snd <$> conDeclToType cd) qualConDeclToLeaf _ = unsupported "qualConDeclToLeaf" +addNils :: [Arg] -> [Arg]+addNils [] = [NoArgs]+addNils x = x+ -- TODO if it derives functor, use + asATSType :: Decl a -> ErrM Declaration-asATSType (TypeDecl _ dh t) = ViewTypeDef undefined <$> (fst <$> asATSName dh) <*> (snd <$> asATSName dh) <*> typeToType t-asATSType (DataDecl _ NewType{} _ dh [qcd] _) = ViewTypeDef undefined <$> (fst <$> asATSName dh) <*> (snd <$> asATSName dh) <*> qualConDeclToType qcd-asATSType (DataDecl _ DataType{} _ dh [qcd] _) = ViewTypeDef undefined <$> (fst <$> asATSName dh) <*> (snd <$> asATSName dh) <*> qualConDeclToType qcd-asATSType (DataDecl _ DataType{} _ dh qcds _) = SumViewType <$> (fst <$> asATSName dh) <*> (snd <$> asATSName dh) <*> mapM qualConDeclToLeaf (reverse qcds)+asATSType (TypeDecl _ dh t) = ViewTypeDef undefined <$> (fst <$> asATSName dh) <*> (addNils . snd <$> asATSName dh) <*> typeToType t+asATSType (DataDecl _ NewType{} _ dh [qcd] _) = ViewTypeDef undefined <$> (fst <$> asATSName dh) <*> (addNils . snd <$> asATSName dh) <*> qualConDeclToType qcd+asATSType (DataDecl _ DataType{} _ dh [qcd] _) = ViewTypeDef undefined <$> (fst <$> asATSName dh) <*> (addNils . snd <$> asATSName dh) <*> qualConDeclToType qcd+asATSType (DataDecl _ DataType{} _ dh qcds _) = SumViewType <$> (fst <$> asATSName dh) <*> (addNils . snd <$> asATSName dh) <*> mapM qualConDeclToLeaf (reverse qcds) asATSType _ = unsupported "asATSType" -- TODO GDataDecl and DataFamDecl@@ -129,6 +133,8 @@ extends = defaultParseMode { extensions = [EnableExtension StandaloneDeriving] } +-- | Given a string containing Haskell, return a string containing ATS and+-- a list of warnings. generateATS :: String -> ErrM (String, [GenerateError]) generateATS hsSrc = modulePrint <$> case parseModuleWithMode extends hsSrc of ParseOk x -> Right x