elm-pages-v3-beta/codegen/Elm/Extra.elm

49 lines
1.2 KiB
Elm
Raw Normal View History

2022-09-16 00:10:35 +03:00
module Elm.Extra exposing (expose, fnIgnore, topLevelValue)
2022-09-15 22:27:23 +03:00
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
2022-09-15 22:27:23 +03:00
}
declaration_ =
Elm.Declare.function name
[]
(\_ -> expression)
in
{ declaration = declaration_.declaration
, reference = declaration_.call []
, referenceFrom = \from -> declaration_.callFrom from []
}
2022-09-15 22:31:05 +03:00
expose : Elm.Declaration -> Elm.Declaration
expose declaration =
declaration
|> Elm.exposeWith
{ exposeConstructor = True
, group = Nothing
}
2022-09-16 00:10:35 +03:00
fnIgnore : Elm.Expression -> Elm.Expression
fnIgnore expression =
Elm.fn ( "_", Nothing )
(\_ ->
expression
)