-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Hello!
I have a minimal example here. the hs-to-coq executable was created with stack install, but there is some nix in here
- ls/tree
$ ls
edits Main.hs hs-to-coq/ shell.nix
Main.hs
module Main where
import Control.Lens
data Datum = Datum { aString :: String, anInt :: Int } deriving Show
foo :: String -> Maybe String
foo "barski" = Just "barski"
foo _ = Nothing
someLens :: Datum -> Maybe Datum
someLens = lens aString (\datum string -> datum {aString = string}) foo
main :: IO ()
main = do
let d = Datum "barski" 1
e = Datum "bazzzz" 1
d' = someLens d
e' = someLens e
print d'
print e'shell.nix
{ pkgs ? import <nixpkgs> {}
, ghcVersion ? "ghc884" # matches hs-to-coq/default.nix
}:
let
hsenv = pkgs.haskell.packages.${ghcVersion}.ghcWithPackages (self: [
self.lens
]);
scratchDev = pkgs.stdenv.mkDerivation {
name = "scratch-lens";
src = ./.;
buildInputs = [ hsenv ];
buildPhase = ''
ghc --version
ghc-pkg list
'';
installPhase = "mkdir -p $out";
};
in
pkgs.mkShell {
# buildInputs is for dependencies you'd need "at run time",
# were you to to use nix-build not nix-shell and build whatever you were working on
buildInputs = [ scratchDev hsenv ];
}Notice that lens appears in hs-to-coq.cabal.
edits
rename value Datum.Datum = Datum.MkDatum
And when we run we fail
$ hs-to-coq --permissive -e hs-to-coq/base/edits --iface-dir hs-to-coq/base -e edits Main.hs -o .
Main.hs:3:1: error:
Could not find module ‘Control.Lens’
Use -v to see a list of the files searched for.
|
3 | import Control.Lens
| ^^^^^^^^^^^^^^^^^^^
Perhaps this is what --import-dir is for?
- where are my libraries for this version of ghc?
nix-shell
which ghc
# /nix/store/b33hk9dshra06v2z140zf0nr8gw9hk3h-ghc-8.8.4-with-packages/bin/ghc
ls /nix/store/b33hk9dshra06v2z140zf0nr8gw9hk3h-ghc-8.8.4-with-packages/lib/ghc-8.8.4/x86_64-linux-ghc-8.8.4/
# .... lens-4.19.2-DKB7mu1opy3FSq86GPdtGR ...
ok, lens is in that directory. So if we run...
hs-to-coq --permissive -e hs-to-coq/base/edits --iface-dir hs-to-coq/base --import-dir //nix/store/b33hk9dshra06v2z140zf0nr8gw9hk3h-ghc-8.8.4-with-packages/lib/ghc-8.8.4/x86_64-linux-ghc-8.8.4/ -e edits Main.hs -o .
...well, we get the same error.
Let's add
axiomatize module Control.Lens
to edits.
Same error.
It seems to me like there's a version of ghc running inside the executable. Is this basically correct? If so, it would make sense that another version of ghc wouldn't be able to make this work.
It'd be great to have isolation and not have to install packages to some global ghc that the hs-to-coq executable calls upon. Moreover, it'd be great to have observability into what packages are reachable by the ghc that the hs-to-coq executable calls upon.