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

Literate Haskell Semantics - Syntax #1102

Merged
merged 7 commits into from
Nov 21, 2020
Merged

Conversation

Gabriella439
Copy link
Contributor

Related to: #959

This is the first step towards an executable reference implementation by
creating a Haskell project which contains the Haskell type for the AST.

The Haskell project is built by CI, in order to catch any errors.

Note that the long-term goal is to standardize a normalization-by-evaluation
approach for the semantics in order to make it easier for
implementers to build efficient implementations. However, in the short-term
I'm translating the semantics as literally as possible to Haskell
code and then I'll do a separate pass later on to switch to
normalization-by-evaluation.

Related to: #959

This is the first step towards an executable reference implementation by
creating a Haskell project which contains the Haskell type for the AST.

The Haskell project is built by CI, in order to catch any errors.

Note that the long-term goal is to standardize a normalization-by-evaluation
approach for the semantics in order to make it easier for
implementers to build efficient implementations.  However, in the short-term
I'm translating the semantics as literally as possible to Haskell
code and then I'll do a separate pass later on to switch to
normalization-by-evaluation.
@Nadrieril
Copy link
Member

Yay thanks for doing this! Could you add a note in the README explaining how to compile this?

… while still keeping the constructor name of `Chunks`

```bash
$ nix-shell # Optional, if you want to use the exact same environment as CI
$ cabal build
Copy link
Collaborator

Choose a reason for hiding this comment

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

I tried without nix-shell, since nix-shell disappears every time I restart my computer.

Here's what happens when I try to build. It's entirely possible I'm doing something silly:

~/dhall-lang/standard[gabriel/executable_ast] ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.4
~/dhall-lang/standard[gabriel/executable_ast] cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library
~/dhall-lang/standard[gabriel/executable_ast] cabal build
Build profile: -w ghc-8.8.4 -O1
In order, the following will be built (use -v for more details):
 - standard-1.0.0 (lib) (first run)
Preprocessing library for standard-1.0.0..
Building library for standard-1.0.0..
ghc: could not execute: markdown-unlit

standard/standard.cabal Show resolved Hide resolved
standard/README.md Show resolved Hide resolved
@Gabriella439
Copy link
Contributor Author

I'll let people comment on whether they prefer Haskell or Agda for this purpose. If nobody comments then I'll throw in my own preference after a few days

@Gabriella439
Copy link
Contributor Author

I'll insert my own preference now since a few people have already commented on the issues I believe are relevant to the comparison. My suggestion is:

  • go with just the Haskell implementation for now
  • later on, possibly replace the natural deduction notation in the standard with Agda (but still keep the Haskell implementation)

My main reason is that the original motivation for doing this work is to make it as easy as possible for new language bindings to translate the semantics to their respective languages. In other words, this implementation needs to act like a "Rosetta stone" for people without a PLT background who need to understand the correspondence between natural deduction and code.

I think Haskell is slightly better suited in that regard because I intend to use a highly simplified subset of functional programming to implement the semantics, and Haskell is idiomatically better suited to that subset than Agda. If we go with Agda, there will be pressure to use Agda's more advanced features (like mixfix notation), which will interfere with the above goal of "explaining" the natural deduction notation.

There are also technical issues that limit the Agda implementation. @Nadrieril pointed out that we will likely need to FFI out to a non-trivial amount of Haskell functionality, and maintaining a mixed Haskell + Agda implementation might be too much complexity for contributors to the standard.

Also, one last reason I prefer Haskell over Agda is that Haskell has broader editor support, whereas Agda is somewhat tightly coupled to emacs. I'd like to make it as easy as possible for contributors to amend the standard.

@TristanCacqueray
Copy link
Collaborator

Thank you @Gabriel439 for proposing such reference implementation here, it seems like this would also be very useful to validate changes to the Dhall standard. Agda looks ideal, but if it's going to require Haskell, then starting with Haskell sounds better. I'm looking forward how Dhall can be implemented with highly simplified fp!

@Gabriella439 Gabriella439 merged commit ea93a65 into master Nov 21, 2020
@Gabriella439 Gabriella439 deleted the gabriel/executable_ast branch November 21, 2020 19:42
Gabriella439 added a commit that referenced this pull request Nov 24, 2020
This builds upon #1102 by adding a literate Haskell
implementation of shifting and substitution.  Note that once we
switch to normalization-by-evaluation these two utilities will
eventually disappear, but I started with them since they are the
most self-contained functions in the standard.
Gabriella439 added a commit that referenced this pull request Nov 30, 2020
This builds upon #1102 by adding a literate Haskell
implementation of shifting and substitution.  Note that once we
switch to normalization-by-evaluation these two utilities will
eventually disappear, but I started with them since they are the
most self-contained functions in the standard.
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

4 participants