From 6bd5f8ccbd8c44c3311ef36b0e2de9ede4fa71ed Mon Sep 17 00:00:00 2001 From: Jakub Hampl Date: Thu, 14 Feb 2019 15:23:49 +0000 Subject: New Style Generator (#8) --- style-generator/src/MyElm/Advanced.elm | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 style-generator/src/MyElm/Advanced.elm (limited to 'style-generator/src/MyElm/Advanced.elm') 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 -- cgit v1.2.3