summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-30 11:23:03 -0400
committerdemo <demo@antix1>2026-05-30 11:23:03 -0400
commitb887bf08e6fd914d1adc7f13a14d824f74983c9c (patch)
tree7963e748bef2ad96f138098dc150235c14958abd
parent4018e8570d4a1f2ad1b54201aafc1978de6428dd (diff)
docs: add godoc to each library function
-rw-r--r--hamlet.go8
1 files changed, 8 insertions, 0 deletions
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))
}