1module Elm (makeElmModuleFromETypeDef) where
5import Elm.Module hiding (makeElmModuleWithVersion, makeModuleContent, makeModuleContentWithAlterations)
11-- | Creates an Elm module for the given version. This will use the default
12-- type conversion rules (to -- convert @Vector@ to @List@, @HashMap a b@
13-- to @List (a,b)@, etc.).
14makeElmModuleWithVersion ::
18 -- | List of definitions to be included in the module
21makeElmModuleWithVersion elmVersion moduleName defs =
23 [ moduleHeader elmVersion moduleName,
26 "import Json.Encode exposing (Value)",
27 "-- The following module comes from bartavelle/json-helpers",
28 "import Json.Helpers exposing (..)",
29 "import Dict exposing (Dict)",
30 "import Set exposing (Set)",
34 ++ makeModuleContent defs
36-- | Creates an Elm module. This will use the default type conversion rules (to
37-- convert @Vector@ to @List@, @HashMap a b@ to @List (a,b)@, etc.).
40makeElmModuleFromETypeDef ::
43 -- | List of definitions to be included in the module
46makeElmModuleFromETypeDef = makeElmModuleWithVersion Elm0p19
48-- | Generates the content of a module. You will be responsible for
49-- including the required Elm headers. This uses the default type
51makeModuleContent :: [ETypeDef] -> String
52makeModuleContent = makeModuleContentWithAlterations defaultAlterations
54-- | Generates the content of a module, using custom type conversion rules.
55makeModuleContentWithAlterations :: (ETypeDef -> ETypeDef) -> [ETypeDef] -> String
56makeModuleContentWithAlterations alt = intercalate "\n\n" . map mkDef
60 in renderElm def ++ "\n" ++ jsonParserForDef def ++ "\n" ++ jsonSerForDef def ++ "\n"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list