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

Allow both relative and absolute module paths. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Fuuzetsu
Copy link

This allows for the following to work:

[nix-shell:~/programming/easyspec]$ stack build --nix easyspec && stack exec --nix -- easyspec discover ../../../../tmp/MySort.hs MySort.mySort
mySort xs <= xs = y <= y
mySort (mySort xs) = mySort xs

[nix-shell:~/programming/easyspec]$ stack build --nix easyspec && stack exec --nix -- easyspec discover /tmp/MySort.hs MySort.mySort
mySort xs <= xs = y <= y
mySort (mySort xs) = mySort xs

I may or may not have broken stuff in easyspec-evaluate: I mostly
just changed the types to line up there. If there's a good way to test
that, I can do it.

Not only can we use absolute paths now, relative paths of the
src/Foo/Bar.hs sort are fixed: we ask GHC to give us the module name
instead of trying to guess it. In general it's not possible to guess a
module name from the file path with any accuracy.

This allows for the following to work:

```
[nix-shell:~/programming/easyspec]$ stack build --nix easyspec && stack exec --nix -- easyspec discover ../../../../tmp/MySort.hs MySort.mySort
mySort xs <= xs = y <= y
mySort (mySort xs) = mySort xs

[nix-shell:~/programming/easyspec]$ stack build --nix easyspec && stack exec --nix -- easyspec discover /tmp/MySort.hs MySort.mySort
mySort xs <= xs = y <= y
mySort (mySort xs) = mySort xs
```

I may or may not have broken stuff in `easyspec-evaluate`: I mostly
just changed the types to line up there. If there's a good way to test
that, I can do it.

Not only can we use absolute paths now, relative paths of the
`src/Foo/Bar.hs` sort are fixed: we ask GHC to give us the module name
instead of trying to guess it. In general it's not possible to guess a
module name from the file path with any accuracy.
@Fuuzetsu
Copy link
Author

Also this is without zifter; I tried to run it but

diff --git a/zift.hs b/zift.hs
index 4793fe2..9b844d8 100755
--- a/zift.hs
+++ b/zift.hs
@@ -1,5 +1,7 @@
 #!/usr/bin/env stack
 {- stack
+    --nix
+    --system-ghc
     --install-ghc
     runghc
     --package zifter
[nix-shell:~/programming/easyspec]$ /tmp/zifter/zift.hs run
Completed 15 action(s).
PREPROCESSOR STARTING
  RECURSIVE PREPROCESSING STARTING/bin/sh: cabal: command not found
 FROM /home/shana/progr/bin/sh: wget: command not found
amming/easyspec/

cabal /bin/sh: /home/shana/.local/bin/hindent: No such file or directory
--version failed with exit code 127

So I just gave up.

@Fuuzetsu
Copy link
Author

Blocked on #2 I guess.

@NorfairKing
Copy link
Owner

NorfairKing commented Sep 10, 2017

You could already specify paths from any directiry with --base-dir. Otherwise imports don't work anymore, right?
Do the easyspec tests still pass? Travis doesn't run them, if I recall correctly, for reasons related to quick iteration.

@Fuuzetsu
Copy link
Author

I have not tried with imports nor didn't try running the tests. I will try in coming days. I don't see why imports should become broken as far as GHC is concerned at least: it should be able to find modules just by walking the hierarchy fine.

@NorfairKing
Copy link
Owner

it should be able to find modules just by walking the hierarchy fine.

Okay, but how do you know the difference between module MySort in a Tmp directory and module Tmp.MySort in your new system?

@Fuuzetsu
Copy link
Author

GHC tells us the module name. It's either in the file or Main.

@NorfairKing
Copy link
Owner

GHC tells us the module name. It's either in the file or Main.

Genius! I'll take a closer look at this PR when we've chosen a license (and only if you're okay with it) and try to fix this.

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

Successfully merging this pull request may close these issues.

None yet

2 participants