Get stuff running again, fix missing nil pattern, play wtih unwrap, default
This commit is contained in:
parent
3a7f86e401
commit
fdaf1068d3
|
@ -4,15 +4,8 @@
|
|||
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
|
||||
:url "https://www.eclipse.org/legal/epl-2.0/"}
|
||||
:dependencies [[org.clojure/clojure "1.11.1"]
|
||||
<<<<<<< HEAD
|
||||
[babashka/fs "0.1.6"]
|
||||
[quil "4.0.0-SNAPSHOT"]]
|
||||
||||||| 1c2ab51
|
||||
[babashka/fs "0.1.6"]]
|
||||
=======
|
||||
[babashka/fs "0.1.6"]
|
||||
[quil "4.0.0-SNAPSHOT-1"]]
|
||||
>>>>>>> 55d76f6854bf67119873d98e2c9c18d8390ab90a
|
||||
:plugins [[lein-cljfmt "0.8.0"]]
|
||||
:repl-options {:init-ns ludus.core}
|
||||
:main ludus.core
|
||||
|
|
29
sandbox.ld
Normal file
29
sandbox.ld
Normal file
|
@ -0,0 +1,29 @@
|
|||
fn unwrap {
|
||||
((:some, value)) -> value
|
||||
((:ok, value)) -> value
|
||||
}
|
||||
|
||||
fn default (default_value) -> fn (maybe) -> match maybe with {
|
||||
(:ok, value) -> value
|
||||
(:err, _) -> default_value
|
||||
nil -> default_value
|
||||
value -> value
|
||||
}
|
||||
|
||||
fn some (value) -> (:some, value)
|
||||
|
||||
fn ok (value) -> (:ok, value)
|
||||
|
||||
let foo = unwrap ((:ok, 42))
|
||||
|
||||
print (:foo, foo)
|
||||
|
||||
let bar = unwrap ((:some, 23))
|
||||
|
||||
print (:bar, bar)
|
||||
|
||||
let baz = do 69 > default (12) > print (:baz, _)
|
||||
|
||||
let quux = do nil > default (12) > print (:quux, _)
|
||||
|
||||
unwrap ((:err, "message"))
|
|
@ -684,7 +684,7 @@
|
|||
|
||||
::token/word (parse-word parser)
|
||||
|
||||
(::token/number ::token/string ::token/keyword) (parse-atom parser)
|
||||
(::token/number ::token/string ::token/keyword ::token/nil) (parse-atom parser)
|
||||
|
||||
::token/lparen (parse-tuple-pattern parser)
|
||||
|
||||
|
@ -1224,7 +1224,7 @@
|
|||
(parser)
|
||||
(parse-script)))
|
||||
|
||||
(do
|
||||
(comment
|
||||
(def my-source "
|
||||
data Foo {foo, bar}
|
||||
data Bar as {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
(:require
|
||||
[ludus.data :as data]
|
||||
[ludus.show :as show]
|
||||
[ludus.draw :as d]))
|
||||
;[ludus.draw :as d]
|
||||
))
|
||||
|
||||
;; TODO: make eq, and, or special forms that short-circuit
|
||||
;; Right now, they evaluate all their args
|
||||
|
@ -94,13 +95,14 @@
|
|||
::data/type ::data/clj
|
||||
:body get})
|
||||
|
||||
(comment
|
||||
(def draw {:name "draw"
|
||||
::data/type ::data/clj
|
||||
:body draw/ludus-draw})
|
||||
|
||||
(def draw {:name "draw"
|
||||
::data/type ::data/clj
|
||||
:body d/draw})
|
||||
:body d/draw}))
|
||||
|
||||
(def prelude {"eq" eq
|
||||
"add" add
|
||||
|
@ -120,5 +122,5 @@
|
|||
"assoc" assoc-
|
||||
"conj" conj-
|
||||
"get" get-
|
||||
"draw" draw
|
||||
;"draw" draw
|
||||
})
|
Loading…
Reference in New Issue
Block a user