diff options
author | Jakub Hampl <kopomir@gmail.com> | 2019-02-14 15:23:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-14 15:23:49 +0000 |
commit | 6bd5f8ccbd8c44c3311ef36b0e2de9ede4fa71ed (patch) | |
tree | de40a36d34cb734c2765a705506436f8b38e28a9 /style-generator/src/MyElm/Advanced.elm | |
parent | f0c36a3d49fad46e0fb6cafeb7a021dd5d775993 (diff) |
New Style Generator (#8)
Diffstat (limited to 'style-generator/src/MyElm/Advanced.elm')
-rw-r--r-- | style-generator/src/MyElm/Advanced.elm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/style-generator/src/MyElm/Advanced.elm b/style-generator/src/MyElm/Advanced.elm new file mode 100644 index 0000000..7f88ab2 --- /dev/null +++ b/style-generator/src/MyElm/Advanced.elm @@ -0,0 +1,46 @@ +module MyElm.Advanced exposing (aliasedName, exposedName, cheat) + +{-| This module allows you to mess with some of the the little things at the cost of a more verbose API. + +@docs aliasedName, exposedName, cheat + +-} + +import MyElm.Types exposing (Expression(..), Ident(..), QualifiedName(..)) + + +{-| Specify a name using a module Alias. If it is a constructor, you must specify the type name as well. +-} +aliasedName : + { modulePath : List String + , aliasName : String + , name : String + , typeName : Maybe String + } + -> QualifiedName +aliasedName opts = + case opts.typeName of + Just tpn -> + Aliased opts.modulePath opts.aliasName (Constructor tpn opts.name) + + Nothing -> + Aliased opts.modulePath opts.aliasName (ValueOrType opts.name) + + +{-| Import a name and expose it. +-} +exposedName : List String -> String -> QualifiedName +exposedName modulePath name = + Bare modulePath (ValueOrType name) + + +{-| Sometimes it is easier to just include a string of Elm code rather than build it up. + +This function will allow you to do that. However, using this breaks the guarantee that the +generated Elm code will be valid. You should be careful to take into consideration things like +brackets in the context where you will use this expression. + +-} +cheat : String -> Expression +cheat = + Literal |