Import Java library in Frege -


i'm trying out frege, , i'm struggling try use native java libraries.

i'm trying out leiningen plugin, , joda time. apparently lein plugin doesn't take care of correctly seeting classpath fregec, or maybe it's related difference:

java -jar ~/downloads/frege3.22.524-gcc99d7e.jar -fp ~/.m2/repository/joda-time/joda-time/2.7/joda-time-2.7.jar src/hello.fr 

will able find joda, expected, while

java -cp ~/.m2/repository/joda-time/joda-time/2.7/joda-time-2.7.jar -jar ~/downloads/frege3.22.524-gcc99d7e.jar src/hello.fr  

will fail

`org.joda.time.years` not known java class 

this shouldn't happen since, according the wiki

the current class path of running jvm plus target directory on class path.

still, after manually setting -fp, code fails compile:

module hello  data jodayears = native org.joda.time.years    pure native years :: int -> jodayears    pure native getyears org.joda.time.years.getyears :: jodayears -> int    --                   ^ tried both , without 

the error is

instance method or getter must applied java reference type. 

but instance method i'm using (getyears), takes reference type input (jodayears)... tried org.joda.time.years, compilation still fails

thanks might shed light on this

brief answer, since using mobile.

you can't invoke java both -cp , -jar

obviously, class path ignored in case. can try giving both jars in -cp need class run. frege compiler frege.compiler.main

concerning other error think related "years" taken instance method because of simple name. whereas other method taken class method because of qualified name.

the rules defining native function foo thus:

[pure] native foo xxx :: frege type

  1. for instance methods, xxx must simple name. can leave xxx out, in case same frege name you're defining (e.g. foo).
  2. for class methods, xxx must qualified name of method.
  3. for constructors, xxx must "new"
  4. for member access, xxx must ".member" member actual member name.

Comments

Popular posts from this blog

Java 8 + Maven Javadoc plugin: Error fetching URL -

css - SVG using textPath a symbol not rendering in Firefox -

order - Notification for user in user account opencart -