atom-language-idris
atom-language-idris copied to clipboard
Can't find import
This error happens when there is an import from a parent folder. Let's say that we have a little project:
src\main.ipkg
package "main"
main = Main
opts = "--codegen javascript -o ../output/main.js"
modules = Main
, Foo.Foo
, Foo.Bar.Bar
src\Main.idr
module Main
import Foo.Foo
import Foo.Bar.Bar
baz1 : Int -> Int
main : JS_IO ()
main = do
foo
bar
src\Foo\Foo.idr
module Foo.Foo
%access export
baz2 : Int -> Int
foo : JS_IO ()
foo = pure ()
src\Foo\Bar\Bar.idr
module Foo.Bar.Bar
import Foo.Foo
%access export
baz3 : Int -> Int
bar : JS_IO ()
bar = foo
and we use Ctrl+Alt+A on baz1, baz2 and baz3. In case of baz1 and baz2 everything works as expected, but baz3 throws an error:
didn't load C:\Users\bla\bla\bla\src\Foo\Bar\Bar.idr
at line 0, file (no file)
Can't find import Foo\Foo
When you use Ctrl+Alt+A on baz1, baz2 and baz3, developer tools console prints something like this:
{ src : "C:\Users\Makar\repos\coin-hunter-idris\src" }
{ src : "C:\Users\Makar\repos\coin-hunter-idris\src\Foo" }
{ src : "C:\Users\Makar\repos\coin-hunter-idris\src\Foo\Bar" }
There is exectly the same error when you try to use idris Main.idr, idris Foo.idr, idris Bar.idr in command line (first two cases are ok, but the last one is complaining about import), but in this case it is expected behavior, since Idris (sadly) doesn't know anything about project root. The workaround is pretty simple: idris Bar.idr -i ../../
I think there could be two options of how to fix it:
- In settings add an option specifying a project root
- Use a convention that
.ipkgfile should be placed in a root directory and then search for it (I like this one better)
and then add -i root_dir to compiler options when calling Idris.
I'm not sure that I understand correctly how this plugin works, but I hope my suggestion is a good way to fix this bug. It's really annoying to have all this cool features and not being able to use them.
I use Windows 10, Idris 1.1.1, Atom 1.23.1 and atom-language-idris 0.4.10.
Thanks for the suggestion. AFAIk we already search for the ipkg. I check whether we also pass the -i option.