mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-24 06:54:03 +03:00
49 lines
1.2 KiB
Elm
49 lines
1.2 KiB
Elm
module Elm.Extra exposing (expose, fnIgnore, 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
|
|
, value : List String -> 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 declaration =
|
|
declaration
|
|
|> Elm.exposeWith
|
|
{ exposeConstructor = True
|
|
, group = Nothing
|
|
}
|
|
|
|
|
|
fnIgnore : Elm.Expression -> Elm.Expression
|
|
fnIgnore expression =
|
|
Elm.fn ( "_", Nothing )
|
|
(\_ ->
|
|
expression
|
|
)
|