Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler in infinite loop #14

Closed
Arjuna144 opened this issue Feb 6, 2016 · 2 comments
Closed

Compiler in infinite loop #14

Arjuna144 opened this issue Feb 6, 2016 · 2 comments

Comments

@Arjuna144
Copy link

Hello there,

I was playing with lux a bit, and ran into an infinite loop with this code:

 lux (lux (host jvm io)
          (control monad functor)
          (codata io)
          (data
           (number #open ("int:" Int/Number))
           (maybe #as May))))

(def (>>= m ma f)
  (All [m a b]
    (-> (Monad m) (m a) (-> a (m b)) (m b)))
  (using m
    (join (map f ma))))

(def (tellWhat a)
  (-> (Maybe Text) (IO (,)))
  (case a
    #;None (print-line "none")
    (#;Some b) (print-line b)))

(def (echo)
  (IO (,))
  (>>= IO/Monad read-line tellWhat))

Most likely the mistake is on my side too, since I still don't understand all, what I am using there...
I am still using luxc3.1.jar since I am getting the following error with luxc.3.2.jar and the following

project.clj:
(defproject lux/testingLux "0.1.0-SNAPSHOT"
  :plugins [[lux/lein "0.1.0"]]
  :dependencies [[lux/stdlib "0.3.2"]]
  :lux/program "testingLux")
lein luxc compile
[BEGIN]

Exception in thread "main" java.lang.AssertionError: Assert failed: @ lux,7,0
[Analyser Error] Unknown syntax: "(_lux_def Bool (10 [\"lux\" \"Bool\"] (0 \"java.lang.Boolean\" (0))))"

false
    at lux.compiler$compile_program.invoke(compiler.clj:556)
    at lux$_main.doInvoke(lux.clj:17)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at lux.main(Unknown Source)
[END]
@Arjuna144
Copy link
Author

My bad, I found my errors!

@LuxLang
Copy link
Collaborator

LuxLang commented Feb 7, 2016

Hi, @Arjuna144

I am still using luxc3.1.jar since I am getting the following error with luxc.3.2.jar and the following

There were some important changes to Lux as a language in v0.3.2 that cause the v0.3.1 stdlib to not compile (which was probably the error you got, since I see the _lux_def form you showed there lacks meta-data, which was a v0.3.2 addition).

I'm waiting until I'm done with v0.3.3 to document those changes, since some stuff requires a bit more polishing (I fixed a bug with tuples and I'm working on fixing one with variants, both of which were introduced in a major change during v0.3.2).

I've also abstained from talking about JVM interop because I'm still adding a bit more features on that front, plus polishing what's already there, since it's usable, but not terribly comfortable as of v0.3.2 (importing them is great, but defining new classes is still somewhat of a hassle).

Anyway... regarding the infinite loop!
You didn't post the error, so I can only speculate, but I'm aware of a stack-overflow error that sometimes happens in the type-checking phase that gets solved by just adding a bit more type annotations.
I imagine you got that one and fixed it in that way.

By the way, when you define this:

(def (echo)
  (IO (,))
  (>>= IO/Monad read-line tellWhat))

You don't need to put echo in parentheses. You can, if you want, but it's not mandatory.

The parentheses syntax on def is just there as a convenience to save people from having to add an extra lambda form.

Consider this:

(def (>>= m ma f)
  (All [m a b]
    (-> (Monad m) (m a) (-> a (m b)) (m b)))
  (using m
    (join (map f ma))))

Versus this:

(def >>=
  (All [m a b]
    (-> (Monad m) (m a) (-> a (m b)) (m b)))
  (lambda [m ma f]
    (using m
      (join (map f ma)))))

Oh... and remember that to run a program you need a (program args ...) form, which is basically your "main" method.

@LuxLang LuxLang reopened this Feb 7, 2016
@LuxLang LuxLang closed this as completed Feb 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant