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

stdlib and prelude #59

Merged
merged 1 commit into from
May 5, 2020
Merged

Conversation

langston-barrett
Copy link
Collaborator

@langston-barrett langston-barrett commented May 2, 2020

Progress on #54, requires #57, fixes #64

@langston-barrett langston-barrett force-pushed the lb/prelude branch 2 times, most recently from 2748e4a to d9b0e06 Compare May 2, 2020 20:58
@langston-barrett
Copy link
Collaborator Author

Honestly, in the spirit of small, atomic changes, we could just merge this as-is and add more stuff to the prelude and stdlib in follow-up PRs.

@david-christiansen
Copy link
Collaborator

I like having small atomic changes :-)

I have a concern about this way of doing it. I am afraid that it ties Klister to running from the root of the repository.

Shouldn't we be using Cabal's data-files feature to arrange for the stdlib to be available, so that Klister need not be run from the source repository?

@langston-barrett
Copy link
Collaborator Author

I think that "stdlib" should be removed from Main.hs, then your KLISTERPATH determines where to find the prelude and standard library. Does that address your concern?

@langston-barrett
Copy link
Collaborator Author

I like the idea of installing the stdlib using data-files.

@david-christiansen
Copy link
Collaborator

I think that "stdlib" should be removed from Main.hs, then your KLISTERPATH determines where to find the prelude and standard library. Does that address your concern?

It does not!

I'd like Klister programs that use the standard library to just work, regardless of the CWD or the setting of environment variables. In other words, the Klister executable should be able to find the stdlib directory to consider as part of its search path.

I think there's three reasonable ways to achieve this:

  1. Require that the stdlib be near the executable. This means that users can't stick the executable in /usr/bin, so I'm not a big fan.
  2. Use Cabal's data-files feature, which will point source-local builds at the stdlib in the source tree, and installed ones at something like /usr/local/share/klister/stdlib, but it means that we basically just ignore it and let Cabal solve it. Idris does this. In this solution, it's almost like the stdlib is baked into the compiler, which I like for the simplicity of it.
  3. Use XDG directories, so it's something like ~/.local/share/klister, perhaps with fallback to /usr/local/share or something. This lets people mess with their stdlib more easily.

I like 2, because the standard library is standard, and really part of the language, and should just always be there.

@gelisam
Copy link
Owner

gelisam commented May 3, 2020

I like having small atomic changes :-)

me too! large changes take me forever to review (sorry it's taking me so long)

@david-christiansen
Copy link
Collaborator

One further issue to think of: with KLISTERPATH, I can break a library by adding a local file with a name that conflicts. The import in the library, which may be a purely internal thing, might become ambiguous with something I've just created.

What about resolving ambiguities thusly: first, check for adjacent files with the given name. Then, check for stdlib. Only after that, fall back on KLISTERPATH.

Or we could indicate these situations by expanding the concrete syntax of module paths a la Racket.

@langston-barrett
Copy link
Collaborator Author

What about resolving ambiguities thusly: first, check for adjacent files with the given name. Then, check for stdlib. Only after that, fall back on KLISTERPATH.

I like this! Eventually, we could also have logical module paths like Haskell or Coq, rather than a flat namespace. I think that would complement the search order.

I will make the change to use Cabal data files before merging.

@langston-barrett
Copy link
Collaborator Author

I think there's three reasonable ways to achieve this:

One other way (maybe this fell outside of "reasonable" 😄) would be to bake the standard library into the Klister executable using Template Haskell. This has the advantage of always "just working" for the user, and has some performance advantages (no need to touch the filesystem, do expansion, nor parse when importing a stdlib module).

@langston-barrett
Copy link
Collaborator Author

Use Cabal's data-files feature, which will point source-local builds at the stdlib in the source tree, and installed ones at something like /usr/local/share/klister/stdlib, but it means that we basically just ignore it and let Cabal solve it. Idris does this. In this solution, it's almost like the stdlib is baked into the compiler, which I like for the simplicity of it.

For precedent on this approach, we can look to Cryptol: https://github.com/GaloisInc/cryptol/blob/7e841e915f34a21bbfad67070c7338662ac28601/cryptol.cabal

@langston-barrett langston-barrett marked this pull request as ready for review May 3, 2020 18:58
@langston-barrett langston-barrett changed the title WIP: stdlib and prelude stdlib and prelude May 3, 2020
Copy link
Collaborator

@david-christiansen david-christiansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good!

src/KlisterPath.hs Show resolved Hide resolved
src/KlisterPath.hs Outdated Show resolved Hide resolved
@langston-barrett langston-barrett merged commit 8209d8e into gelisam:master May 5, 2020
@langston-barrett langston-barrett deleted the lb/prelude branch May 5, 2020 17:08
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.

Module search order
3 participants