aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-12-06 15:40:52 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-06 15:40:52 +0200
commite73ad00f44479e3065ccf12d07ca3ae22ca1f3f0 (patch)
tree628c4957a9e53815d1ccf49f87a1002ccc059ac6
parent21ee11d3df3000a77d5b36d3c7e0a18d9a07d599 (diff)
Remove ! from end of builtin top-level functions
-rw-r--r--examples/aoc22_1.milch25
-rw-r--r--examples/effects-concept.milch4
-rw-r--r--examples/fibo.milch2
-rw-r--r--examples/import.milch4
-rw-r--r--examples/impure-concept.milch6
-rw-r--r--examples/purity-test.milch8
-rw-r--r--examples/records-concept.milch12
-rw-r--r--examples/test.milch32
-rw-r--r--examples/types-concept.milch10
-rw-r--r--spec.md6
-rw-r--r--src/Builtins.hs26
-rw-r--r--src/Interpreter.hs31
-rw-r--r--stdlib/common.milch80
-rw-r--r--stdlib/maybe-with-unions.milch14
-rw-r--r--stdlib/maybe.milch22
-rw-r--r--test/Spec.hs2
16 files changed, 169 insertions, 115 deletions
diff --git a/examples/aoc22_1.milch b/examples/aoc22_1.milch
index 4170661..7a4520a 100644
--- a/examples/aoc22_1.milch
+++ b/examples/aoc22_1.milch
@@ -1,23 +1,23 @@
-(import! "stdlib/common.milch")
+(import "stdlib/common.milch")
;; utils
; convert ["a" "b" "c"] into "abc"
-(let! str-from-vec (\[vec]
+(let str-from-vec (\[vec]
(foldr concat "" vec)))
;; solution
-(let! sample-path "examples/aoc22_1.txt")
-(let! sample-input (read-file! sample-path))
+(let sample-path "examples/aoc22_1.txt")
+(let sample-input (read-file! sample-path))
(print-fmt! "Read {0} characters from \"{1}\"\n" [
(len sample-input)
sample-path])
-(let! sample-vec (to-vec sample-input))
+(let sample-vec (to-vec sample-input))
-(let! result1 (pipe sample-vec [
+(let result1 (pipe sample-vec [
(split-by "\n")
(map str-from-vec)
(split-by "")
@@ -27,3 +27,16 @@
]))
(print-fmt! "Result 1: {0}\n" [result1])
+
+(let result2 (pipe sample-vec [
+ (split-by "\n")
+ (map str-from-vec)
+ (split-by "")
+ (map (map parse-int))
+ (map (foldr + 0))
+ (sort-by (* -1))
+ (take 3)
+ (foldr + 0)
+]))
+
+(print-fmt! "Result 2: {0}\n" [result2])
diff --git a/examples/effects-concept.milch b/examples/effects-concept.milch
index 5ea90d7..0bde72f 100644
--- a/examples/effects-concept.milch
+++ b/examples/effects-concept.milch
@@ -1,7 +1,7 @@
; FUNCTIONS
-(let! prompt-input (\[]
- (let! p "> ")
+(let prompt-input (\[]
+ (let p "> ")
(do get-user-input "prompted" p)))
; SIGNAL HANDLERS
diff --git a/examples/fibo.milch b/examples/fibo.milch
index 26c74a1..c08fdd4 100644
--- a/examples/fibo.milch
+++ b/examples/fibo.milch
@@ -1,4 +1,4 @@
-(let! fibo (\[n]
+(let fibo (\[n]
(match n
0 0
1 1
diff --git a/examples/import.milch b/examples/import.milch
index e839ef0..47a7477 100644
--- a/examples/import.milch
+++ b/examples/import.milch
@@ -1,2 +1,2 @@
-(import! "stdlib/common.milch")
-(import! M "stdlib/maybe.milch")
+(import "stdlib/common.milch")
+(import M "stdlib/maybe.milch")
diff --git a/examples/impure-concept.milch b/examples/impure-concept.milch
index 893b29e..c767914 100644
--- a/examples/impure-concept.milch
+++ b/examples/impure-concept.milch
@@ -3,10 +3,10 @@
; Pure functions can only call pure functions.
; Impure function names end in an exclamation mark (!) by convention.
; The top-level context is impure but has special rules
-; related to `import!`, `let!`, and other builtins.
+; related to `import`, `let`, and other builtins.
; pure function
-(let! f (\[x] x))
+(let f (\[x] x))
; impure function
-(let! g! (\![x] (print! x)))
+(let g! (\![x] (print! x)))
diff --git a/examples/purity-test.milch b/examples/purity-test.milch
index 6e8faea..f7c77e5 100644
--- a/examples/purity-test.milch
+++ b/examples/purity-test.milch
@@ -1,22 +1,22 @@
; utils
-(let! println! (\![x]
+(let println! (\![x]
(print! (fmt "{0}\n" [x]))))
; pure vs. impure demo
; this is a pure function
-(let! f (\[x] x))
+(let f (\[x] x))
(f 10) ; works
; this is an impure function
-(let! g! (\![x] (println! x)))
+(let g! (\![x] (println! x)))
(g! "foo") ; works
; this is a pure function that tries to call an impure function
-(let! h (\[x] (g! x)))
+(let h (\[x] (g! x)))
(h "bar")
; error: cannot call impure function in pure context
diff --git a/examples/records-concept.milch b/examples/records-concept.milch
index 420fa9f..1686d75 100644
--- a/examples/records-concept.milch
+++ b/examples/records-concept.milch
@@ -1,16 +1,16 @@
-; Records are named tuples with an identifier. `record!` is a builtin function
+; Records are named tuples with an identifier. `record` is a builtin function
; that generates functions for creating, reading and modifying a record.
; In type system terms, records are intersections.
-; `record!` can only be called in the top-level context.
+; `record` can only be called in the top-level context.
-(record! Ns/User
+(record Ns/User
name
phone-number)
; Generates the following functions:
-(let! user
+(let user
(Ns/User/create "John" "010-123-456"))
; user ~> (Ns/User name:"John" phone-number:"010-123-456")
@@ -36,8 +36,8 @@
; Generates the following functions:
-(let! m1 (Ns/Maybe/just 10)) ; m1 ~> (Ns/Maybe/Just value:10)
-(let! m2 (Ns/Maybe/nothing)) ; m2 ~> (Ns/Maybe/Nothing)
+(let m1 (Ns/Maybe/just 10)) ; m1 ~> (Ns/Maybe/Just value:10)
+(let m2 (Ns/Maybe/nothing)) ; m2 ~> (Ns/Maybe/Nothing)
(Ns/Maybe/Just/get-value m1) ; => 10
diff --git a/examples/test.milch b/examples/test.milch
index 84193eb..fc41266 100644
--- a/examples/test.milch
+++ b/examples/test.milch
@@ -1,27 +1,27 @@
-(let! compose (\[f g]
+(let compose (\[f g]
(\[x] (f (g x)))))
((compose (+ 1) (+ 2)) 3)
-(let! id (\[a] a))
+(let id (\[a] a))
-(let! mod (\[n k]
+(let mod (\[n k]
(- n (* k (/ n k)))))
-(let! not (\[b]
+(let not (\[b]
(match b
true false
false true)))
-(let! is-even (\[n]
+(let is-even (\[n]
(match (mod n 2)
0 true
1 false)))
-(let! is-odd (compose not is-even))
+(let is-odd (compose not is-even))
;; map :: (a -> b) -> [a] -> [b]
-(let! map (\[f lst]
+(let map (\[f lst]
(match lst
[]
[]
@@ -31,7 +31,7 @@
(map (+ 1) [1 2 3])
;; foldr :: (a -> b -> b) -> b -> [a] -> b
-(let! foldr (\[f accumulator lst]
+(let foldr (\[f accumulator lst]
(match lst
[]
accumulator
@@ -41,7 +41,7 @@
(foldr + 0 [1 2 3])
;; filter :: (a -> Bool) -> [a] -> [a]
-(let! filter (\[pred lst]
+(let filter (\[pred lst]
(match lst
[] []
otherwise (match (pred (head lst))
@@ -52,20 +52,20 @@
(filter is-even [0 1 2 3 4 5])
-(let! reverse_ (\[v a]
- (let! lazy x (head v))
- (let! lazy xs (tail v))
- (let! lazy xa (prepend x a))
+(let reverse_ (\[v a]
+ (let lazy x (head v))
+ (let lazy xs (tail v))
+ (let lazy xa (prepend x a))
(match v
[] a
_ (reverse_ xs xa))))
-(let! reverse (\[v]
+(let reverse (\[v]
(reverse_ v [])))
(reverse [1 2 3])
-(let! flow (\[fs] (foldr compose id (reverse fs))))
-(let! pipe (\[x fs] ((flow fs) x)))
+(let flow (\[fs] (foldr compose id (reverse fs))))
+(let pipe (\[x fs] ((flow fs) x)))
(pipe 10 [(+ 1) (+ 2)])
diff --git a/examples/types-concept.milch b/examples/types-concept.milch
index 8359c6b..9496ffe 100644
--- a/examples/types-concept.milch
+++ b/examples/types-concept.milch
@@ -5,26 +5,26 @@
(\[b] c) ; f
(\[a] b)] ; g
(\[a] c)))
-(let!
+(let
compose (\[f g] (\[x] (f (g x)))))
((compose (+ 1) (+ 2)) 3)
(type id (\[a] a))
-(let! id (\[a] a))
+(let id (\[a] a))
(type mod (\[Int Int] Int))
-(let! mod (\[n k]
+(let mod (\[n k]
(- n (* k (/ n k)))))
(type not (\[Bool] Bool))
-(let! not (\[b]
+(let not (\[b]
(match b
true false
false true)))
(type is-even (\[Int] Bool))
-(let! is-even (\[n]
+(let is-even (\[n]
(match (mod n 2)
0 true
1 false)))
diff --git a/spec.md b/spec.md
index 19992b1..953b672 100644
--- a/spec.md
+++ b/spec.md
@@ -29,8 +29,8 @@ Calling the builtin variadic function '\' constructs a new function. The first a
Functions are automatically curried
E.g.
- (let! f1 (\[x y] (+ x y)))
- (let! f2 (\[x] (\[y] (+ x y))))
+ (let f1 (\[x y] (+ x y)))
+ (let f2 (\[x] (\[y] (+ x y))))
; f1 equivalent to f2
## Some builtin functions
@@ -38,7 +38,7 @@ E.g.
`let`
Evaluates second argument and stores the resulting value in the environment.
- (let! sum2 (\[x y] (+ x y)))
+ (let sum2 (\[x y] (+ x y)))
`\`
Defines a function.
diff --git a/src/Builtins.hs b/src/Builtins.hs
index b731e66..7ad966a 100644
--- a/src/Builtins.hs
+++ b/src/Builtins.hs
@@ -4,6 +4,7 @@ module Builtins where
import qualified Data.Map as M
import qualified Data.Text as T
import qualified Text.Read as TR
+import qualified Data.List as L
import Control.Monad.Except
import Utils
@@ -26,6 +27,7 @@ builtinEnv = M.fromList [
builtinHead,
builtinTail,
builtinPrepend,
+ builtinSortByFirst,
-- string operations
builtinSubstr,
builtinStrToVec,
@@ -45,10 +47,10 @@ builtinEnv = M.fromList [
builtinKind,
-- reserved keywords
reservedKeyword "\\",
- reservedKeyword "let!",
+ reservedKeyword "let",
reservedKeyword "match",
- reservedKeyword "env!",
- reservedKeyword "record!"
+ reservedKeyword "Debug/env",
+ reservedKeyword "record"
]
argError1 :: String -> AST -> String
@@ -308,3 +310,21 @@ builtinAppendFile = (name, makeNonsenseAST $ ASTFunction False fn1) where
Nothing -> throwL (astPos ast1) $ "failed to append to file: " ++ filePath
fn2 ast2 = throwL (astPos ast2) $ argError2 name ast1 ast2
fn1 ast1 = throwL (astPos ast1) $ argError1 name ast1
+
+builtinSortByFirst :: (String, AST)
+builtinSortByFirst = (name, makeNonsenseAST $ ASTFunction True fn1) where
+ name = "sort-by-first"
+ fn1 ast1@AST { astNode = ASTVector elems } = do
+ pairs <- mapM elemToPair elems
+ let sorted = L.sortBy (\(a, _) (b, _) -> compare a b) pairs
+ let sortedASTS = map (\(k, v) -> makeNonsenseAST $
+ ASTVector [makeNonsenseAST $ ASTInteger k, v]) sorted
+ return $ makeNonsenseAST $ ASTVector sortedASTS where
+ itemsToPair [AST { astNode = ASTInteger k }, v] =
+ return $ (k, v)
+ itemsToPair items = throwL (astPos ast1) $
+ "invalid element in vector supplied to sort-by-first: " ++ show items
+ elemToPair AST { astNode = ASTVector items } =
+ itemsToPair items
+ elemToPair ast2 = throwL (astPos ast2) $ argError1 name ast1
+ fn1 ast1 = throwL (astPos ast1) $ argError1 name ast1
diff --git a/src/Interpreter.hs b/src/Interpreter.hs
index 6e9e770..de77fc9 100644
--- a/src/Interpreter.hs
+++ b/src/Interpreter.hs
@@ -65,7 +65,7 @@ letArgsToSymValPairs args =
return (symbol', evaledValue)
[AST { astNode = ASTSymbol "lazy" }, AST { astNode = ASTSymbol symbol' }, value'] -> do
return (symbol', value')
- other -> throwL (astPos $ head other) $ "let! called with invalid args " ++ show other
+ other -> throwL (astPos $ head other) $ "let called with invalid args " ++ show other
defineUserFunction :: AST -> [AST] -> LContext LFunction
defineUserFunction paramAst@AST { astNode = ASTSymbol param } exprs = return fn where
@@ -139,7 +139,7 @@ evaluateFunctionDef isPure asts = do
fn <- defineUserFunctionWithLetExprs params exprs
return $ defAst { astNode = ASTFunction isPure fn }
where
- isLetAST AST { astNode = ASTFunctionCall (AST { astNode = ASTSymbol "let!" }:_) } = True
+ isLetAST AST { astNode = ASTFunctionCall (AST { astNode = ASTSymbol "let" }:_) } = True
isLetAST _ = False
asSymbol AST { astNode = ASTSymbol sym } = sym
asSymbol ast = error $ "unreachable: evaluateFunctionDef asSymbol, ast: " ++ show ast
@@ -179,7 +179,7 @@ evaluateLet asts = do
args = tail asts
d <- getDepth
- when (d > 1) $ throwL (astPos letAst) $ "let! can only be called on the top level or in a function definition, current depth: " ++ show d
+ when (d > 1) $ throwL (astPos letAst) $ "let can only be called on the top level or in a function definition, current depth: " ++ show d
(symbol, value) <- letArgsToSymValPairs args
env <- getEnv
@@ -187,13 +187,10 @@ evaluateLet asts = do
insertThisEnv symbol value
return $ letAst { astNode = ASTUnit }
-evaluateEnv :: [AST] -> LContext AST
-evaluateEnv asts = do
+evaluateDebugEnv :: [AST] -> LContext AST
+evaluateDebugEnv asts = do
let envAst = head asts
- d <- getDepth
- when (d > 1) $ throwL (astPos envAst) $ "env! can only be called on the top level, current depth: " ++ show d
-
env <- getEnv
let pairs = M.assocs (M.union (envThis env) (envImported env))
let longestKey = L.maximumBy (compare `on` (length . fst)) pairs $> fst
@@ -208,7 +205,7 @@ evaluateImport asts = do
args = tail asts
d <- getDepth
- when (d > 1) $ throwL (astPos importAst) $ "import! can only be called on the top level, current depth: " ++ show d
+ when (d > 1) $ throwL (astPos importAst) $ "import can only be called on the top level, current depth: " ++ show d
config <- getConfig
let initialState = LState {
@@ -228,7 +225,7 @@ evaluateImport asts = do
putImportedEnv $ M.union importedEnv exportedEnvMap
return $ importAst { astNode = ASTUnit }
- _ -> throwL (astPos importAst) $ "invalid arguments passed to import!: " ++ show args
+ _ -> throwL (astPos importAst) $ "invalid arguments passed to import: " ++ show args
evaluateRecord :: [AST] -> LContext AST
evaluateRecord asts = do
@@ -236,7 +233,7 @@ evaluateRecord asts = do
args = tail asts
d <- getDepth
- when (d > 1) $ throwL (astPos recordAst) $ "record! can only be called on the top level, current depth: " ++ show d
+ when (d > 1) $ throwL (astPos recordAst) $ "record can only be called on the top level, current depth: " ++ show d
case args of
(AST { astNode = ASTSymbol ns }:rest) -> do
@@ -286,7 +283,7 @@ evaluateRecord asts = do
return $ recordAst { astNode = ASTUnit }
- _ -> throwL (astPos recordAst) $ "invalid arguments passed to import!: " ++ show args
+ _ -> throwL (astPos recordAst) $ "invalid arguments passed to import: " ++ show args
where
isSymbolAST AST { astNode = ASTSymbol _ } = True
@@ -365,13 +362,13 @@ evaluate ast@AST { astNode = fnc@(ASTFunctionCall args@(x:_)) } =
evaluateFunctionDef False args
ASTSymbol "match" ->
evaluateMatch args
- ASTSymbol "let!" ->
+ ASTSymbol "let" ->
evaluateLet args
- ASTSymbol "env!" ->
- evaluateEnv args
- ASTSymbol "import!" ->
+ ASTSymbol "Debug/env" ->
+ evaluateDebugEnv args
+ ASTSymbol "import" ->
evaluateImport args
- ASTSymbol "record!" ->
+ ASTSymbol "record" ->
evaluateRecord args
_ ->
evaluateUserFunction args
diff --git a/stdlib/common.milch b/stdlib/common.milch
index b69452e..f05c6a5 100644
--- a/stdlib/common.milch
+++ b/stdlib/common.milch
@@ -1,25 +1,25 @@
-(let! compose (\[f g]
+(let compose (\[f g]
(\[x] (f (g x)))))
-(let! id (\[a] a))
+(let id (\[a] a))
-(let! mod (\[n k]
+(let mod (\[n k]
(- n (* k (/ n k)))))
-(let! not (\[b]
+(let not (\[b]
(match b
true false
false true)))
-(let! is-even (\[n]
+(let is-even (\[n]
(match (mod n 2)
0 true
1 false)))
-(let! is-odd (compose not is-even))
+(let is-odd (compose not is-even))
;; map :: (a -> b) -> [a] -> [b]
-(let! map (\[f lst]
+(let map (\[f lst]
(match lst
[]
[]
@@ -29,7 +29,7 @@
; (map (+ 1) [1 2 3])
;; foldr :: (a -> b -> b) -> b -> [a] -> b
-(let! foldr (\[f accumulator lst]
+(let foldr (\[f accumulator lst]
(match lst
[]
accumulator
@@ -37,7 +37,7 @@
(f (head lst) (foldr f accumulator (tail lst))))))
;; filter :: (a -> Bool) -> [a] -> [a]
-(let! filter (\[pred lst]
+(let filter (\[pred lst]
(match lst
[] []
otherwise (match (pred (head lst))
@@ -46,44 +46,44 @@
false
(filter pred (tail lst))))))
-(let! reverse_ (\[v a]
- (let! lazy x (head v))
- (let! lazy xs (tail v))
- (let! lazy xa (prepend x a))
+(let reverse_ (\[v a]
+ (let lazy x (head v))
+ (let lazy xs (tail v))
+ (let lazy xa (prepend x a))
(match v
[] a
_ (reverse_ xs xa))))
-(let! reverse (\[v]
+(let reverse (\[v]
(reverse_ v [])))
-(let! flow (\[fs] (foldr compose id (reverse fs))))
-(let! pipe (\[x fs] ((flow fs) x)))
+(let flow (\[fs] (foldr compose id (reverse fs))))
+(let pipe (\[x fs] ((flow fs) x)))
-(let! leq? (\[a b]
+(let leq? (\[a b]
(or?
(eq? a b)
(lt? a b))))
-(let! rt? (compose not leq?))
-(let! req? (compose not lt?))
+(let rt? (compose not leq?))
+(let req? (compose not lt?))
-(let! max2 (\[a b]
+(let max2 (\[a b]
(match (lt? a b)
true b
false a)))
-(let! max (\[vals]
- (let! lazy v (head vals))
- (let! vs (tail vals))
+(let max (\[vals]
+ (let lazy v (head vals))
+ (let vs (tail vals))
(match vs
[] v
otherwise (max2 v (max vs)))))
-(let! split-by' (\[delim acc vals]
- (let! lazy v (head vals))
- (let! vs (tail vals))
+(let split-by' (\[delim acc vals]
+ (let lazy v (head vals))
+ (let vs (tail vals))
(match vs
[] (match v
@@ -94,8 +94,32 @@
otherwise (split-by' delim (prepend v acc) vs)))))
; split vector by delimiter
-(let! split-by (\[delim vals]
+(let split-by (\[delim vals]
(split-by' delim [] vals)))
-(let! print-fmt! (\![fstr args]
+(let at (\[n seq]
+ (match seq
+ [] (fatal! (fmt "at out of bounds, n: {0}" [n]))
+ otherwise (match n
+ 0 (head seq)
+ otherwise (at (- n 1) (tail seq))))))
+
+(let print-fmt! (\![fstr args]
(print! (fmt fstr args))))
+
+(let sort-by (\[keyf vals]
+ (let sorted (sort-by-first
+ (map (\[v]
+ [(keyf v) v]) vals)))
+
+ (map (at 1) sorted)))
+
+(let take (\[n xs]
+ (match n
+ 0 []
+ otherwise (prepend (head xs) (take (- n 1) (tail xs))))))
+
+(let drop (\[n xs]
+ (match n
+ 0 xs
+ otherwise (drop (- n 1) (tail xs)))))
diff --git a/stdlib/maybe-with-unions.milch b/stdlib/maybe-with-unions.milch
index 53a5024..8a15471 100644
--- a/stdlib/maybe-with-unions.milch
+++ b/stdlib/maybe-with-unions.milch
@@ -4,23 +4,23 @@
(just value)
(nothing))
-(let! Maybe/map (\[f m]
+(let Maybe/map (\[f m]
(match (kind m)
"Maybe/Just" (Maybe/just (f (Maybe/Just/get-value m)))
"Maybe/Nothing" (Maybe/nothing))))
-(let! Maybe/and-then (\[f m]
+(let Maybe/and-then (\[f m]
(match (kind m)
"Maybe/Just" (f (Maybe/Just/get-value m))
"Maybe/Nothing" (Maybe/nothing))))
; TESTING
-;; (let! print-line! (\[s]
+;; (let print-line! (\[s]
;; (print! (concat s "\n"))))
-;; (let! a (Maybe/just 10))
-;; (let! b (Maybe/nothing))
+;; (let a (Maybe/just 10))
+;; (let b (Maybe/nothing))
;; (Maybe/map (+ 5) a)
;; (Maybe/map (+ 5) b)
@@ -28,14 +28,14 @@
;; (Maybe/and-then (\[n] (Maybe/just (+ n 5))) a)
;; (Maybe/and-then (\[n] (Maybe/just (+ n 5))) b)
-;; (let! m (Maybe/just 10))
+;; (let m (Maybe/just 10))
;; (match m
;; (Maybe/just _)
;; (print-line! (fmt "found just {0}!" [(Maybe/Just/get-value m)]))
;; (Maybe/nothing)
;; (print-line! "found nothing!"))
-;; (let! m (Maybe/just 10))
+;; (let m (Maybe/just 10))
;; (pipe m [
;; (Maybe/map (+ 5))
;; (Maybe/and-then (\[val] (Maybe/just (- val 3))))
diff --git a/stdlib/maybe.milch b/stdlib/maybe.milch
index 086b0dc..4114e22 100644
--- a/stdlib/maybe.milch
+++ b/stdlib/maybe.milch
@@ -1,11 +1,11 @@
; LIB
-(let! Maybe/just (\[a]
+(let Maybe/just (\[a]
["Maybe" "just" a]))
-(let! Maybe/nothing (\[]
+(let Maybe/nothing (\[]
["Maybe" "nothing"]))
-(let! Maybe/#at (\[n seq]
+(let Maybe/#at (\[n seq]
(match seq
[]
(fatal! "Maybe/#at out of bounds")
@@ -16,26 +16,26 @@
otherwise
(Maybe/#at (- n 1) (tail seq))))))
-(let! Maybe/unpack (Maybe/#at 2))
-(let! Maybe/kind (Maybe/#at 1))
+(let Maybe/unpack (Maybe/#at 2))
+(let Maybe/kind (Maybe/#at 1))
-(let! Maybe/map (\[f m]
+(let Maybe/map (\[f m]
(match (Maybe/kind m)
"just" (Maybe/just (f (Maybe/unpack m)))
"nothing" (Maybe/nothing))))
-(let! Maybe/and-then (\[f m]
+(let Maybe/and-then (\[f m]
(match (Maybe/kind m)
"just" (f (Maybe/unpack m))
"nothing" (Maybe/nothing))))
; TESTING
-;; (let! print-line! (\[s]
+;; (let print-line! (\[s]
;; (print! (concat s "\n"))))
-;; (let! a (Maybe/just 10))
-;; (let! b (Maybe/nothing))
+;; (let a (Maybe/just 10))
+;; (let b (Maybe/nothing))
;; (Maybe/map (+ 5) a)
;; (Maybe/map (+ 5) b)
@@ -43,7 +43,7 @@
;; (Maybe/and-then (\[n] (Maybe/just (+ n 5))) a)
;; (Maybe/and-then (\[n] (Maybe/just (+ n 5))) b)
-;; (let! m (Maybe/just 10))
+;; (let m (Maybe/just 10))
;; (match m
;; (Maybe/just _)
;; (print-line! (fmt "found just {0}!" [(Maybe/unpack m)]))
diff --git a/test/Spec.hs b/test/Spec.hs
index e67f2b7..2a1e54c 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -38,7 +38,7 @@ evaluateTests = testGroup "evaluate" [
e2eTests = testGroup "e2e" [
do let env = M.fromList [builtinSubtract2] :: Env
- let script1 = "(let! sub2 (\\[a b] (- a b)))\n(sub2 3 2)"
+ let script1 = "(let sub2 (\\[a b] (- a b)))\n(sub2 3 2)"
(gotASTs, LState { stateEnv = gotEnv }) <- expectSuccessL env $
runInlineScript "<test>" script1