You may run into situations where you want to generate a function, and then call that generated function somewhere else.
This module will help you do that.
Here's an example, let's define a new function called add42
renderFile =
let
add42 =
Elm.Declare.fn "add42"
( "firstInt", Nothing )
(\firstArgument ->
Elm.plus
(Elm.int 42)
firstArgument
)
in
Elm.file [ "MyFile" ]
-- add our declaration to our file
[ add42.declaration
-- and another place where we call that function!
, Elm.declaration "mySweetNumber"
(add42.call (Elm.int 82))
]Depending on your situation, you may want to define a function in one file, but call it from another.
In that case you can do something like this using callFrom:
renderFileList =
let
add42 =
Elm.Declare.fn "add42"
( "firstInt", Nothing )
(\firstArgument ->
Elm.plus
(Elm.int 42)
firstArgument
)
in
[ Elm.file [ "MyFile" ]
-- add our declaration to our file
[ add42.declaration
]
, Elm.file [ "MyOtherFile" ]
-- and call from another file
[ Elm.declaration "mySweetNumber"
(add42.callFrom [ "MyFile" ] (Elm.int 82))
]
]