Algae v0.12.2 Algae View Source
Link to this section Summary
Link to this section Types
Link to this section Functions
Link to this function
call_type(new_module, module_ctx)
View Source
call_type(module, [module]) :: ast
Construct a data type AST
—- Id —
defmodule Id do defdata do: id :: any() end
—- Sum —-
defmodule Either do defsum do
defdata Left :: any()
defdata Right :: any()
end end
defmodule Either do defdata do: Left :: any() | Right :: any() end
—- Product —
defmodule Rectangle do data do: width :: number(), height :: number() end
— Both —
data Stree a = Tip | Node (Stree a) a (Stree a) defmodule Stree do defdata do
Tip :: any() | Node :: (left :: t()), (middle = 42 :: any()), (right :: t())
end end
defmodule Stree do defsum do
defdata Tip :: any()
defproduct Node do
left :: Stree.t()
middle = 42 :: any()
right :: Stree.t()
end
end end
Generate the AST for a sum type definition
Link to this function
extract_name(module_chain)
View Source
extract_name({any, any, atom} | [module]) :: [module]
Link to this function
extract_part_name(arg)
View Source
extract_part_name({:defdata, any, [{:::, any, [any]}]}) :: [module]