language-elm 0.0.8.0 → 0.0.9.0
raw patch · 6 files changed
+43/−2 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Elm.Decleration: toDocD :: Dec -> Doc
- Elm.Expression: toDoc :: Expr -> Doc
- Elm.Expression: vop :: Expr -> Doc
- Elm.Import: docItem :: ImportItem -> Doc
- Elm.Import: exposingDoc :: ImportType -> Doc
- Elm.Import: toDocI :: Import -> Doc
- Elm.Program: genProgram :: Program -> Doc
- Elm.Type: toDocT :: TypeDec -> Doc
- Elm.Type: vopParam :: TypeDec -> Doc
- Elm.Type: vopTApp :: TypeDec -> Doc
Files
- language-elm.cabal +2/−2
- src/Elm/Decleration.hs +7/−0
- src/Elm/Expression.hs +14/−0
- src/Elm/Import.hs +6/−0
- src/Elm/Program.hs +5/−0
- src/Elm/Type.hs +9/−0
language-elm.cabal view
@@ -1,5 +1,5 @@ name: language-elm-version: 0.0.8.0+version: 0.0.9.0 synopsis: Generate elm code description: Generate elm code from an ast homepage: https://github.com/eliaslfox/language-elm#readme@@ -15,7 +15,7 @@ library hs-source-dirs: src- exposed-modules: Elm.Expression, Elm.Decleration, Elm.Type, Elm.Import, Elm.Program+ exposed-modules: Elm.Decleration, Elm.Expression, Elm.Import, Elm.Program, Elm.Type build-depends: base >= 4.7 && < 5, pretty, MissingH
src/Elm/Decleration.hs view
@@ -1,12 +1,19 @@+{-# OPTIONS_HADDOCK prune #-}++-- | Top level declerations module Elm.Decleration where import Elm.Type import Elm.Expression import Text.PrettyPrint +-- | Used to declare functions, variables, and types data Dec+ -- | Declare a function = Dec String TypeDec [Expr] Expr+ -- | Declare a type | DecType String [String] [(String, [TypeDec])]+ -- | Declare a type alias | DecTypeAlias String [String] TypeDec toDocD :: Dec -> Doc
src/Elm/Expression.hs view
@@ -1,24 +1,38 @@+{-# OPTIONS_HADDOCK prune #-}++-- | Used to declare expressions module Elm.Expression where import Text.PrettyPrint hiding (Str) import Data.Maybe +-- | The expression type data Expr+ -- | Function application = App String [Expr] | Case Expr [(Expr, Expr)] | Let Expr [(Expr, Expr)] | List [Expr] | Tuple2 Expr Expr | Tuple3 Expr Expr Expr+ -- | Inline operators | Op String Expr Expr+ -- | Expressions wrapped in parens | Parens Expr+ -- | String literals | Str String+ -- | Integer literals | Int Int+ -- | The underscore placeholder | Under+ -- | Boolean false literal | BoolTrue+ -- | Boolean true literal | BoolFalse+ -- | Record creation and update syntax | Record (Maybe Expr) [(String, Expr)] +-- | Shortcut for variables var :: String -> Expr var str = App str []
src/Elm/Import.hs view
@@ -1,17 +1,23 @@+{-# OPTIONS_HADDOCK prune #-}++-- | Ast for expressing imports module Elm.Import where import Text.PrettyPrint +-- | Possible ways to expose an import data ImportType = Everything | Select [ImportItem] | ExposeNothing +-- | Possible ways to expose a sub import data ImportItem = Item String | ItemExposing String [String] | ItemEvery String +-- | A full import data Import = Import String (Maybe String) ImportType docItem :: ImportItem -> Doc
src/Elm/Program.hs view
@@ -1,3 +1,6 @@+{-# OPTIONS_HADDOCK prune #-}++-- | Module for creating a program module Elm.Program where import Elm.Import@@ -6,6 +9,7 @@ import Data.String.Utils import Data.List +-- | Program type data Program = Program String ImportType [Import] [Dec] genProgram :: Program -> Doc@@ -14,6 +18,7 @@ $+$ (foldl ($+$) empty . map toDocI $ imports) $+$ (foldl ($+$) empty . map toDocD $ declerations) +-- | Convert a program to a string of code renderProgram :: Program -> String renderProgram program = let
src/Elm/Type.hs view
@@ -1,16 +1,25 @@+{-# OPTIONS_HADDOCK prune #-} {-# LANGUAGE OverloadedStrings #-} ++-- | Ast for declaring types module Elm.Type where import Elm.Expression import Text.PrettyPrint import Data.Maybe +-- | Data type to represent types data TypeDec+ -- | A type with type paramaters = Params String [TypeDec]+ -- | A function type | TApp [TypeDec]+ -- | A two tuple type | TTuple2 TypeDec TypeDec+ -- | A record type | TRecord (Maybe String) [(String, TypeDec)] +-- | Shortcut for declaring a type variable tvar :: String -> TypeDec tvar str = Params str []