From d2a4aac2226b5cca59be236d3228fe5e5b17b8de Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 14 Sep 2015 23:37:10 -0400 Subject: - Renamed "this" to "_jvm_this". - Movied lux/data/io to lux/codata/io. --- source/lux/codata/io.lux | 42 ++++++++++++++++++++++++++++++++++++++++++ source/lux/data/io.lux | 42 ------------------------------------------ source/lux/host/io.lux | 4 ++-- src/lux/analyser/base.clj | 2 ++ src/lux/analyser/host.clj | 2 +- src/lux/analyser/lux.clj | 7 +++---- 6 files changed, 50 insertions(+), 49 deletions(-) create mode 100644 source/lux/codata/io.lux delete mode 100644 source/lux/data/io.lux diff --git a/source/lux/codata/io.lux b/source/lux/codata/io.lux new file mode 100644 index 000000000..195aef616 --- /dev/null +++ b/source/lux/codata/io.lux @@ -0,0 +1,42 @@ +## Copyright (c) Eduardo Julian. All rights reserved. +## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +## If a copy of the MPL was not distributed with this file, +## You can obtain one at http://mozilla.org/MPL/2.0/. + +(;import lux + (lux (control (functor #as F) + (monad #as M)) + (data list))) + +## [Types] +(deftype #export (IO a) + (-> (,) a)) + +## [Syntax] +(defmacro #export (@io tokens state) + (case tokens + (\ (@list value)) + (let [blank (: AST [["" -1 -1] (#;SymbolS ["" ""])])] + (#;Right [state (@list (` (;_lux_lambda (~ blank) (~ blank) (~ value))))])) + + _ + (#;Left "Wrong syntax for @io"))) + +## [Structures] +(defstruct #export IO/Functor (F;Functor IO) + (def (map f ma) + (@io (f (ma []))))) + +(defstruct #export IO/Monad (M;Monad IO) + (def _functor IO/Functor) + + (def (wrap x) + (@io x)) + + (def (join mma) + (mma []))) + +## [Functions] +(def #export (run-io io) + (All [a] (-> (IO a) a)) + (io [])) diff --git a/source/lux/data/io.lux b/source/lux/data/io.lux deleted file mode 100644 index 973d37e38..000000000 --- a/source/lux/data/io.lux +++ /dev/null @@ -1,42 +0,0 @@ -## Copyright (c) Eduardo Julian. All rights reserved. -## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -## If a copy of the MPL was not distributed with this file, -## You can obtain one at http://mozilla.org/MPL/2.0/. - -(;import lux - (lux (control (functor #as F) - (monad #as M))) - (.. list)) - -## [Types] -(deftype #export (IO a) - (-> (,) a)) - -## [Syntax] -(defmacro #export (@io tokens state) - (case tokens - (\ (@list value)) - (let [blank (: AST [["" -1 -1] (#;SymbolS ["" ""])])] - (#;Right [state (@list (` (;_lux_lambda (~ blank) (~ blank) (~ value))))])) - - _ - (#;Left "Wrong syntax for @io"))) - -## [Structures] -(defstruct #export IO/Functor (F;Functor IO) - (def (map f ma) - (@io (f (ma []))))) - -(defstruct #export IO/Monad (M;Monad IO) - (def _functor IO/Functor) - - (def (wrap x) - (@io x)) - - (def (join mma) - (mma []))) - -## [Functions] -(def #export (run-io io) - (All [a] (-> (IO a) a)) - (io [])) diff --git a/source/lux/host/io.lux b/source/lux/host/io.lux index 99e15722d..220f089a2 100644 --- a/source/lux/host/io.lux +++ b/source/lux/host/io.lux @@ -4,8 +4,8 @@ ## You can obtain one at http://mozilla.org/MPL/2.0/. (;import lux - (lux (data io - (list #refer #all #open ("" List/Fold))) + (lux (data (list #refer #all #open ("" List/Fold))) + (codata io) (meta ast syntax lux) diff --git a/src/lux/analyser/base.clj b/src/lux/analyser/base.clj index 8df7f23b2..b12425ac7 100644 --- a/src/lux/analyser/base.clj +++ b/src/lux/analyser/base.clj @@ -155,6 +155,8 @@ (|let [[_ type] syntax+] type)) +(def jvm-this "_jvm_this") + (defn cap-1 [action] (|do [result action] (|case result diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index f6963d8bf..681f22168 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -411,7 +411,7 @@ (if (= "void" method-output) (&&/analyse-1+ analyse method-body) (&&/analyse-1 analyse (&type/Data$ (as-otype method-output) &/Nil$) method-body)) - (&/|reverse (&/Cons$ (&/T "this" owner-class) + (&/|reverse (&/Cons$ (&/T &&/jvm-this owner-class) =method-inputs)))] (return {:name method-name :modifiers =method-modifiers diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj index 3de4db89f..6546990e6 100644 --- a/src/lux/analyser/lux.clj +++ b/src/lux/analyser/lux.clj @@ -275,10 +275,9 @@ endo-type)))) state) - [_] - (do ;; (prn 'analyse-symbol/_2.1.2 ?module name name) - (fail* "[Analyser Error] Can't have anything other than a global def in the global environment.")))) - (fail* "_{_ analyse-symbol _}_"))) + _ + (fail* "[Analyser Error] Can't have anything other than a global def in the global environment."))) + (fail* ""))) (&/$Cons top-outer _) (do ;; (prn 'analyse-symbol/_3 ?module name) -- cgit v1.2.3