diff options
author | Eduardo Julian | 2015-07-25 20:19:43 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-07-25 20:19:43 -0400 |
commit | 4cd9b0c9242f1105e50ad9b42b7f6f5d074f14b4 (patch) | |
tree | d8828396e3f76e5b5dabb1f530234047ec239794 /source/lux/data/io.lux | |
parent | 6c51e5e50aa98bb26a3e2b34f57a0e24f8537d93 (diff) |
- The output directory is now being used as the cache.
- "input" has been renamed as "source" and "output" has been renamed as "target".
Diffstat (limited to 'source/lux/data/io.lux')
-rw-r--r-- | source/lux/data/io.lux | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/source/lux/data/io.lux b/source/lux/data/io.lux new file mode 100644 index 000000000..c08023df5 --- /dev/null +++ b/source/lux/data/io.lux @@ -0,0 +1,51 @@ +## Copyright (c) Eduardo Julian. All rights reserved. +## The use and distribution terms for this software are covered by the +## Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +## which can be found in the file epl-v10.html at the root of this distribution. +## By using this software in any fashion, you are agreeing to be bound by +## the terms of this license. +## You must not remove this notice, or any other, from this software. + +(;import lux + (lux/meta macro) + (lux/control (functor #as F) + (monad #as M)) + lux/data/list) + +## Types +(deftype #export (IO a) + (-> (,) a)) + +## Syntax +(defmacro #export (io tokens state) + (case tokens + (\ (list value)) + (let [blank (symbol$ ["" ""])] + (#;Right [state (list (` (_lux_lambda (~ blank) (~ blank) (~ value))))])) + + _ + (#;Left "Wrong syntax for io"))) + +## Structures +(defstruct #export IO/Functor (F;Functor IO) + (def (F;map f ma) + (io (f (ma []))))) + +(defstruct #export IO/Monad (M;Monad IO) + (def M;_functor IO/Functor) + + (def (M;wrap x) + (io x)) + + (def (M;join mma) + (mma []))) + +## Functions +(def #export (print x) + (-> Text (IO (,))) + (io (_jvm_invokevirtual java.io.PrintStream print [java.lang.Object] + (_jvm_getstatic java.lang.System out) [x]))) + +(def #export (println x) + (-> Text (IO (,))) + (print (text:++ x "\n"))) |