From b887bf08e6fd914d1adc7f13a14d824f74983c9c Mon Sep 17 00:00:00 2001 From: demo Date: Sat, 30 May 2026 11:23:03 -0400 Subject: docs: add godoc to each library function --- hamlet.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'hamlet.go') diff --git a/hamlet.go b/hamlet.go index 2b1c111..3315433 100644 --- a/hamlet.go +++ b/hamlet.go @@ -10,16 +10,20 @@ func (a Assertion) Assert() bool { return a.value } +// New returns a new Assertion. An assertion is true iff its +// underlying value is non-zero in the Go sense. func New(v any) Assertion { return Assertion{!reflect.ValueOf(v).IsZero()} } +// Not computes ~a, given assertion a. func Not(a Assertion) Assertion { negation := !a.value return Assertion{negation} } +// Or computes a v b, given assertions a and b. func Or(a Assertion, b Assertion) Assertion { av := a.value bv := b.value @@ -27,6 +31,7 @@ func Or(a Assertion, b Assertion) Assertion { return Assertion{av || bv} } +// And computes a ^ b, given assertions a and b. func And(a Assertion, b Assertion) Assertion { av := a.value bv := b.value @@ -34,14 +39,17 @@ func And(a Assertion, b Assertion) Assertion { return Assertion{av && bv} } +// If computes a → b, given assertions a and b. func If(a Assertion, b Assertion) Assertion { return Or(Not(a), b) } +// If computes a ↔ b, given assertions a and b. func Iff(a Assertion, b Assertion) Assertion { return And(If(a, b), If(b, a)) } +// Xor computes a ⊻ b, given assertions a and b. func Xor(a Assertion, b Assertion) Assertion { return Not(Iff(a, b)) } -- cgit v1.2.3