Skip to content

Commit

Permalink
Merge pull request #3679 from tokiwa-software/lib_add_ignore
Browse files Browse the repository at this point in the history
lib: Add `ignore(T type, x T) unit` to drop a value
  • Loading branch information
michaellilltokiwa authored Aug 30, 2024
2 parents 220d307 + af59beb commit 715f347
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions lib/id.fz
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,35 @@ public id(T type, x T) T => x
#
# or, using an intermediate field,
#
# all_true(s Sequence bool) => f (bool)->bool := id; s ∀ f
# all_true(s Sequence bool) => f (bool)->bool := (x -> id bool x); s ∀ f
# all_true(s Sequence bool) => f (bool)->bool := (x -> id x); s ∀ f
# all_true(s Sequence bool) => f (bool)->bool := identity bool; s ∀ f
# all_true(s Sequence bool) => { f (bool)->bool := id; s ∀ f }
# all_true(s Sequence bool) => { f (bool)->bool := (x -> id bool x); s ∀ f }
# all_true(s Sequence bool) => { f (bool)->bool := (x -> id x); s ∀ f }
# all_true(s Sequence bool) => { f (bool)->bool := identity bool; s ∀ f }
#
public identity(T type) T->T => x->x


# ignore -- function mapping any value to unit
#
# This can be used to ignore the result of an expression, e.g. the
# instance returned by a constructor or the value returned by a fuction.
#
# Ex. with these features
#
# hello is
# say "Hello!"
#
# say_and_inc(x i32) i32 =>
# say x
# x+1
#
# the results can be ignored as follows
#
# hello |> ignore
# (say_and_inc 42) |> ignore
# ignore hello
# ignore (say_and_inc 42)
# _ := hello
# _ := say_and_inc 42
#
public ignore(T type, x T) unit =>

0 comments on commit 715f347

Please sign in to comment.