mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 12:52:27 +03:00
Extract helper.
This commit is contained in:
parent
09d127c3e1
commit
42d5bc2de2
30
codegen/Elm/Extra.elm
Normal file
30
codegen/Elm/Extra.elm
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
module Elm.Extra exposing (topLevelValue)
|
||||||
|
|
||||||
|
import Elm
|
||||||
|
import Elm.Declare
|
||||||
|
|
||||||
|
|
||||||
|
topLevelValue :
|
||||||
|
String
|
||||||
|
-> Elm.Expression
|
||||||
|
->
|
||||||
|
{ declaration : Elm.Declaration
|
||||||
|
, reference : Elm.Expression
|
||||||
|
, referenceFrom : List String -> Elm.Expression
|
||||||
|
}
|
||||||
|
topLevelValue name expression =
|
||||||
|
let
|
||||||
|
declaration_ :
|
||||||
|
{ declaration : Elm.Declaration
|
||||||
|
, call : List Elm.Expression -> Elm.Expression
|
||||||
|
, callFrom : List String -> List Elm.Expression -> Elm.Expression
|
||||||
|
}
|
||||||
|
declaration_ =
|
||||||
|
Elm.Declare.function name
|
||||||
|
[]
|
||||||
|
(\_ -> expression)
|
||||||
|
in
|
||||||
|
{ declaration = declaration_.declaration
|
||||||
|
, reference = declaration_.call []
|
||||||
|
, referenceFrom = \from -> declaration_.callFrom from []
|
||||||
|
}
|
@ -7,6 +7,7 @@ import Elm.Annotation
|
|||||||
import Elm.Case
|
import Elm.Case
|
||||||
import Elm.CodeGen
|
import Elm.CodeGen
|
||||||
import Elm.Declare
|
import Elm.Declare
|
||||||
|
import Elm.Extra exposing (topLevelValue)
|
||||||
import Elm.Op
|
import Elm.Op
|
||||||
import Elm.Pretty
|
import Elm.Pretty
|
||||||
import Gen.Basics
|
import Gen.Basics
|
||||||
@ -366,32 +367,6 @@ routeToPath routes =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
topLevelValue :
|
|
||||||
String
|
|
||||||
-> Elm.Expression
|
|
||||||
->
|
|
||||||
{ declaration : Elm.Declaration
|
|
||||||
, reference : Elm.Expression
|
|
||||||
, referenceFrom : List String -> Elm.Expression
|
|
||||||
}
|
|
||||||
topLevelValue name expression =
|
|
||||||
let
|
|
||||||
declaration_ :
|
|
||||||
{ declaration : Elm.Declaration
|
|
||||||
, call : List Elm.Expression -> Elm.Expression
|
|
||||||
, callFrom : List String -> List Elm.Expression -> Elm.Expression
|
|
||||||
}
|
|
||||||
declaration_ =
|
|
||||||
Elm.Declare.function name
|
|
||||||
[]
|
|
||||||
(\_ -> expression)
|
|
||||||
in
|
|
||||||
{ declaration = declaration_.declaration
|
|
||||||
, reference = declaration_.call []
|
|
||||||
, referenceFrom = \from -> declaration_.callFrom from []
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
expose : Elm.Declaration -> Elm.Declaration
|
expose : Elm.Declaration -> Elm.Declaration
|
||||||
expose declaration =
|
expose declaration =
|
||||||
declaration
|
declaration
|
||||||
|
Loading…
Reference in New Issue
Block a user