aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-12-06 22:20:49 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-06 22:34:36 +0200
commit5147db71d99c38b44a29735c985de90246cda995 (patch)
tree7bd34c504b64fa71827a7a56764a1adb253b2c17
parentd8850b22d21e1a034ed558289c08d36ddd2f796d (diff)
Fix some stuff
-rw-r--r--core/common.milch12
-rw-r--r--examples/aoc22_1.milch3
-rw-r--r--examples/types-concept.milch6
3 files changed, 11 insertions, 10 deletions
diff --git a/core/common.milch b/core/common.milch
index 2aa72a2..cab4203 100644
--- a/core/common.milch
+++ b/core/common.milch
@@ -1,11 +1,11 @@
;; Control flow
;;;;;;;;;;;;;;;;;;;;;;;;;
-(let compose (\[f g]
+(let . (\[f g]
(\[x] (f (g x)))))
(let flow (\[fs]
- (foldr compose id (reverse fs))))
+ (foldr . id (reverse fs))))
(let pipe (\[x fs]
((flow fs) x)))
@@ -52,15 +52,15 @@
0 true
1 false)))
-(let odd? (compose not even?))
+(let odd? (. not even?))
(let leq? (\[a b]
(or?
(eq? a b)
(lt? a b))))
-(let rt? (compose not leq?))
-(let req? (compose not lt?))
+(let rt? (. not leq?))
+(let req? (. not lt?))
(let max (\[a b]
(match (lt? a b)
@@ -80,7 +80,7 @@
(map (\[v]
[(keyf v) v]) vals)))
- (map (at 1) sorted)))
+ (map (. Result/Ok/get-value (at 1)) sorted)))
(let take (\[n xs]
(match n
diff --git a/examples/aoc22_1.milch b/examples/aoc22_1.milch
index ca7bea1..5d7b21b 100644
--- a/examples/aoc22_1.milch
+++ b/examples/aoc22_1.milch
@@ -1,4 +1,5 @@
-(import "core/common.milch")
+(import "core/common")
+(import "core/result")
;; utils
diff --git a/examples/types-concept.milch b/examples/types-concept.milch
index a2126d9..c583314 100644
--- a/examples/types-concept.milch
+++ b/examples/types-concept.milch
@@ -4,14 +4,14 @@
; lowercase types: polymorphic
; everything else: monomorphic
-(type compose (\[
+(type . (\[
(\[b] c) ; f
(\[a] b)] ; g
(\[a] c)))
(let
- compose (\[f g] (\[x] (f (g x)))))
+ . (\[f g] (\[x] (f (g x)))))
-((compose (+ 1) (+ 2)) 3)
+((. (+ 1) (+ 2)) 3)
(type id (\[a] a))
(let id (\[a] a))