earldouglas/sbt-frege

Doesn't appear to support files with imports?

Closed this issue · 3 comments

Compiling a simple hello world .fr file with the plugin works fine for me. Problems arise when I try to use imports in the .fr files.

When I compile with the command line compiler using -make:

fregec -sp src/main/frege -fp build -make src/main/frege/Main.fr

I can compile the three files below without trouble. However, the sbt plugin always fails to compile them due to a class not found exception like this:

E [path]/src/main/frege/Main.fr:3: Could
    not import package example.Hello (java.lang.ClassNotFoundException:
    example.Hello)
E [path]/src/main/frege/Main.fr:4: Could
    not import package example.Other (java.lang.ClassNotFoundException:
    example.Other)
runtime 2.739 wallclock seconds.
[trace] Stack trace suppressed: run 'last compile:managedSources' for the full output.

last compile:managedSources gives this:

> last compile:managedSources
java.lang.RuntimeException: Frege compilation error
    at SbtFrege$.fregec(SbtFrege.scala:38)
    at SbtFrege$$anonfun$projectSettings$4$$anonfun$3.apply(SbtFrege.scala:52)
    at SbtFrege$$anonfun$projectSettings$4$$anonfun$3.apply(SbtFrege.scala:52)
    at sbt.FileFunction$$anonfun$cached$1.apply(Tracked.scala:186)
    at sbt.FileFunction$$anonfun$cached$1.apply(Tracked.scala:186)
    at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3$$anonfun$apply$4.apply(Tracked.scala:200)
    at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3$$anonfun$apply$4.apply(Tracked.scala:196)
    at sbt.Difference.apply(Tracked.scala:175)
    at sbt.Difference.apply(Tracked.scala:157)
    at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3.apply(Tracked.scala:196)
    at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3.apply(Tracked.scala:195)
    at sbt.Difference.apply(Tracked.scala:175)
    at sbt.Difference.apply(Tracked.scala:151)
    at sbt.FileFunction$$anonfun$cached$2.apply(Tracked.scala:195)
    at sbt.FileFunction$$anonfun$cached$2.apply(Tracked.scala:193)
    at SbtFrege$$anonfun$projectSettings$4.apply(SbtFrege.scala:56)
    at SbtFrege$$anonfun$projectSettings$4.apply(SbtFrege.scala:48)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] (compile:managedSources) Frege compilation error

I have this structure:

src/main/frege:
Main.fr

src/main/frege/example:
Hello.fr
Other.fr

Here are the contents of each:

Main.fr:

module Main where

import example.Hello
import example.Other

main = putStrLn "this is the main"

Hello.fr:

module example.Hello where

data Other = Any | Old

showOther :: Other -> String
showOther Any = "any"
showOther Old = "old"

main :: [String] -> IO ()
main _ = println "Hello, world!"

Other.fr:

module example.Other where

data Other = Any | Old

main :: [String] -> IO ()
main _ = do
  putStrLn "This is the other"

Looks to me like sbt is not using (or propagating) the -make option.

In that case you'd need to specify all source files in dependency order.
Or just use fregec directly for such a tiny thing.

This should be fixed in 0.5.0 -- give it a try and let me know.

project/plugins.sbt:

addSbtPlugin("com.earldouglas" % "sbt-frege" % "0.5.0")

Works! Thanks for the super-quick response!