From daa6c92c14d9b85bf3ade2b6684e3c97dcda851e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 14 Jun 2017 17:57:04 -0400 Subject: - Added Hash and as-is macro.. --- stdlib/source/lux.lux | 9 ++++++--- stdlib/source/lux/data/bool.lux | 8 ++++++++ stdlib/source/lux/host.jvm.lux | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index f801ebebd..a225683e0 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -5573,16 +5573,16 @@ _ (fail "Wrong syntax for $"))) -(def: #export (is left right) +(def: #export (is reference sample) {#;doc (doc "Tests whether the 2 values are identical (not just \"equal\")." "This one should succeed:" (let [value 5] - (is 5 5)) + (is value value)) "This one should fail:" (is 5 (i.+ 2 3)))} (All [a] (-> a a Bool)) - (_lux_proc ["lux" "is"] [left right])) + (_lux_proc ["lux" "is"] [reference sample])) (macro: #export (^@ tokens) {#;doc (doc "Allows you to simultaneously bind and de-structure a value." @@ -5774,3 +5774,6 @@ (def: #export (assume mx) (All [a] (-> (Maybe a) a)) (default (undefined) mx)) + +(macro: #export (as-is tokens state) + (#;Right [state tokens])) diff --git a/stdlib/source/lux/data/bool.lux b/stdlib/source/lux/data/bool.lux index 2d89de635..35c00477f 100644 --- a/stdlib/source/lux/data/bool.lux +++ b/stdlib/source/lux/data/bool.lux @@ -2,6 +2,7 @@ lux (lux (control monoid eq + hash codec))) ## [Structures] @@ -11,6 +12,13 @@ y (not y)))) +(struct: #export _ (Hash Bool) + (def: eq Eq) + (def: (hash value) + (case value + true +1 + false +0))) + (do-template [ ] [(struct: #export (Monoid Bool) (def: unit ) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index b31def073..b4dde1157 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -2025,7 +2025,7 @@ (syntax: #export (array-load idx array) {#;doc (doc "Loads an element from an array." - (array-load 10 my-array))} + (array-load +10 my-array))} (case array [_ (#;Symbol array-name)] (do Monad @@ -2054,7 +2054,7 @@ (syntax: #export (array-store idx value array) {#;doc (doc "Stores an element into an array." - (array-store 10 my-object my-array))} + (array-store +10 my-object my-array))} (case array [_ (#;Symbol array-name)] (do Monad -- cgit v1.2.3