Top-level declaration, be it a function, constant or a type definition.
{ module_ : String
, name : String
, body : DeclarationBody expr
}
x = 1
--> Value (Int 1)
type alias X = Int
--> TypeAlias [] Int
type alias X a = Maybe a
--> TypeAlias ["a"] (Maybe (Var 0))
{ name : String
, arguments : List Elm.Data.Type.TypeArgument
}
Constructor of a custom type.
type Foo = Bar
--> CustomType [] [Constructor "Bar" []]
type Foo a = Bar
--> CustomType [] [Constructor "Bar" []]
type Foo a = Bar a
--> CustomType ["a"] [Constructor "Bar" ["a"]]
type Foo = Bar | Baz
--> CustomType []
[ Constructor "Bar" []
, Constructor "Baz" []
]
map : (a -> b) -> Declaration a -> Declaration b
Apply a function to the expression inside the declaration.
mapBody : (a -> b) -> DeclarationBody a -> DeclarationBody b
Apply a function to the expression inside the declaration body.
combine : DeclarationBody (Result err a) -> Result err (DeclarationBody a)
Switch the Result and the expression inside the declaration body.
Similar to Result.Extra.combine
.
combine (Value (Ok (Int 5)))
--> Ok (Value (Int 5))