cat/instances/natural
Examples of transformations
between functors
.
Values
pub fn list_length_transformation(
,
) -> natural.NaturalTransformation(
types.ListF,
types.ConstF(Int),
a,
b,
List(a),
List(b),
c,
d,
cat.Const(Int, c),
cat.Const(Int, d),
)
Natural transformation from List
to Const Int
.
Examples
[]
|> {list_length_transformation() |> transform()}
// -> Const(0)
[1, 2, 3, 4]
|> {list_length_transformation() |> transform()}
// -> Const(4)
pub fn list_option_head_transformation(
,
) -> natural.NaturalTransformation(
types.ListF,
types.OptionF,
a,
b,
List(a),
List(b),
a,
c,
option.Option(a),
option.Option(c),
)
Natural transformation from List
to Option
.
Examples
[]
|> {list_option_head_transformation() |> transform()}
// -> None
[1, 2, 3]
|> {list_option_head_transformation() |> transform()}
// -> Some(1)
pub fn option_list_transformation(
,
) -> natural.NaturalTransformation(
types.OptionF,
types.ListF,
a,
b,
option.Option(a),
option.Option(b),
a,
c,
List(a),
List(c),
)
Natural transformation from Option
to List
.
Examples
None
|> {option_list_transformation() |> transform()}
// -> []
Some(7)
|> {option_list_transformation() |> transform()}
// -> [7]