octopus 0.0.2.0 → 0.0.2.1
raw patch · 6 files changed
+146/−3 lines, 6 files
Files
- changelog +26/−0
- examples/basis.oct +46/−0
- examples/echo.oct +11/−0
- examples/ski.oct +17/−0
- examples/y.oct +33/−0
- octopus.cabal +13/−3
+ changelog view
@@ -0,0 +1,26 @@+v0.0.1.0-alpha (2014-03-31)+===========================++Initial release version.+ + Turing-complete: `vau`, `eval`, `match`, `extends`.+ + Pattern matching on symbols, seqs, xonses.+ + Primitive operations: xonses, numbers, arithmetic, relationals, strict if-zero+ + Import primitive+ + Expression and file parsers+ + Syntactic sugar: `do`-expressions+ + Syntactic sugar: quoted expressions++v0.0.2.0-alpha (2014-04-06)+===========================++ + Raise and handle exceptions+ + Built-in exceptions+ + I/O primitives+ + Block comments+ + Heredoc text literals+ + Literals for builtins+ + Syntactic sugar: `@`, `:`-syntax, infix `.`-syntax+ + Syntactic sugar: `open` statement+ + Syntactic sugar: non-mutual `letrec` statement + + Draft of `basis.oct`+ - Closures do not print their internals
+ examples/basis.oct view
@@ -0,0 +1,46 @@+### These are the true basis of using the vau calculus. ###+vau: (#<vau> [[{}, var],+ #<vau> [[static, body],+ #<vau> [arg,+ do arg': (#<match> [var, arg])+ env': (#<extends> [arg', static])+ (#<eval> [env', body]);+ ]]])+λ: (vau [{}, var] (vau [static, body] (vau arg+ do arg': (#<eval> arg)+ env': (#<extends> [#<match> [var, arg'], static])+ (#<eval> [env', body]);+ )))+let: __let__+Y: (λ f (let maker (λ x (f (λ arg (x x arg))))+ (maker maker)))+++### These are just prettier ways of getting at important primitives. ###+eval: (λ env (λ ast (#<eval> [env, ast])))+match: (λ var (λ val (#<match> [var, val])))+with: (λ base (λ new (#<extends> [new, base])))+++### These are necessary for syntactic sugar. ###+__lambda__: λ+__Y__: Y+__quote__: (vau [{}, ast] ast)+__get__: (vau [{}, field] (λ x (#<get> [x, field])))+__modify__: (vau [{}, field] (λ f (λ x+ (x .with (field .match (f (__get__ feild x))))+ )))++### Pretty data primitives. Probably should be in their own file. ###+_+_: (λ x (λ y (#<add> [x, y])))+_-_: (λ x (λ y (#<sub> [x, y])))+_*_: (λ x (λ y (#<mul> [x, y])))+_/_: (λ x (λ y (#<div> [x, y])))+++### Now, really common operations. Probably should be in their own file. ###+ifz_then_else_: (λ p (vau c (vau a+ (#<eval> (#<ifz!> [p, c, a])))))+--: (λ x (#<sub> [x, 1]))+swap: (λ [a, b] [b, a])+
+ examples/echo.oct view
@@ -0,0 +1,11 @@+open (#<import> "basis.oct")++letrec loop: (λ {}+ do c: (#<readByte> #<stdin>)+ (#<writeByte> [#<stdout>, c])+ (ifz_then_else_ (#<eq> [c, 10])+ (loop {})+ (#<flush> #<stdout>)+ );)++main: (loop {})
+ examples/ski.oct view
@@ -0,0 +1,17 @@+open (#<import> "basis.oct")++S: (λ x (λ y (\z (x z (y z)))))+K: (λ x (λ {} x))+I: (λ x x)++B: (λ x (λ y (λ z (x (y z)))))+C: (λ x (λ y (λ z (x z y))))+# K already defined+W: (λ x (λ y (x y y)))++X: (λ x (x S K))++T: K+F: (λ {} (λ y y))++Ω: (S I I (S I I))
+ examples/y.oct view
@@ -0,0 +1,33 @@+open (#<import> "basis.oct")++#Curry's doesn't work, apparently; use Turing's.+curry-fixpoint: (λ f (let maker ((λ x (f (x x))+ (maker maker)))))++#Turing's does, but I can't say I understand it+turing-fixpoint: ( (λ x (λ y (y (λ z (x x y z))))) (λ x (λ y (y (λ z (x x y z))))) )++#This looks like an η-expanded version of Curry's+applicative-fixpoint: (λ f (let maker (λ x (f (λ arg (x x arg))))+ (maker maker)))++++++# facRel: (λ self (λ n (ifz_then_else_ n 1+# (_*_ n (self (-- n))))+# ))++# facRel: (λ facRel (λ n (ifz_then_else_ n 1+# (_*_ n (facRel (-- n))))+# ))+# fac: (Y facRel)++hand_fac: (Y (λ hand_fac (λ n (ifz_then_else_ n 1 (_*_ n (hand_fac (-- n))))) ))+letrec fac: (λ n (ifz_then_else_ n 1 (_*_ n (fac (-- n)))))+++#main: (if_then_else_ 1 "a" "b")+main: [fac 1, hand_fac 2, fac 3, hand_fac 4, fac 5, hand_fac 6]+
octopus.cabal view
@@ -2,23 +2,33 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: octopus-version: 0.0.2.0+version: 0.0.2.1 synopsis: Lisp with more dynamism, more power, more simplicity. description: Octopus is a highly dynamic programming language with an astounding (I think) power-to-weight ratio (expressivity-to-complexity). With just a handful of simple primitives, Octopus provides a complete programming environment. Its main focus is on complete programmer control, not on performance or static- analysis. While the user can shoot themselves, the most natural methods will+ analysis. While the user can shoot themselves, the most natural methods should be the most reasonable.++ Octopus' is most useful for well-contained problems, for teaching, as a+ (possibly embedded) scripting language, anywhere boilerplate is a serious issue,+ for problems involving higher math, and for brain-stretching.++ Octopus is currently in the 'useable' stage of development, in the same way+ food might be food might be 'edible' instead of 'tasty'. We are under active+ development, working towards 'featureful'. homepage: https://github.com/Zankoku-Okuno/octopus/ license: GPL-3 license-file: LICENSE+copyright: (c) 2014 Zankoku Okuno author: Zankoku Okuno maintainer: zankoku.okuno@gmail.com--- copyright: +stability: alpha category: Language build-type: Simple cabal-version: >=1.8+extra-source-files: changelog, examples/*.oct library exposed-modules: Language.Octopus,