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

WIP: [Obsolete] Integration of requirements checker plugin #1074

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

starsandspirals
Copy link
Contributor

I don't know if you're looking at this at the same time - no problem if you are - but I thought it was worth making the current state of my efforts more visible in case it makes any issues become apparent.

I've been following along with the advice received from Luite to try and fix my Cabal/GHCJS issues, but have generally just ended up running into different problems, so in the current state this is stuck at another cabal error.

The current issue is that the package ghc-api-ghcjs cannot be found; I've discovered that it's in the build/ghcjs/lib folder, but I don't know how to access it or other ghcjs packages from there in the cabal file! But as a summary of progress made in this pull request so far, I've gotten rid of the old requirements checker code in the compiler folder that's all duplicated in the new requirements folder, added the required plugin arguments to the call to ghcjs in Compile.hs, and implemented the feedback from Luite, i.e. created a stub version of the plugin and separated out the ghc and ghcjs versions to try and avoid the previous issues.

Copy link
Collaborator

@cdsmith cdsmith left a comment

Choose a reason for hiding this comment

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

This seemed to work for me:

(. base.sh && cabal_install --ghcjs \
    ./build/ghcjs/lib/ghc-api-ghcjs \
    ./build/ghcjs/lib/template-haskell-ghcjs \
    ./build/ghcjs/lib/ghci-ghcjs)

If that also works for you, you could add the cabal command into install.sh, just after running ghcjs-boot.

codeworld-compiler/codeworld-compiler.cabal Show resolved Hide resolved
@starsandspirals
Copy link
Contributor Author

Installing the packages using cabal as you suggested worked, so I added this to install.sh.

Now the build process completes successfully again, but I get a new and different error when trying to compile programs using CodeWorld. Now it says:

The value plugin did not have the type Plugin as required

This doesn't really make sense, as the value of plugin in both RequirementsChecker.hs and the stubbed version definitely has type Plugin, so I don't know where this is coming from; but at least it's a different error.

@cdsmith
Copy link
Collaborator

cdsmith commented Aug 9, 2019

@luite Please help!

@luite
Copy link
Contributor

luite commented Aug 10, 2019

Ah the error messages there aren't yet as good as they should be. And the plugin loading mechanism is rather hacky right now.

Right now what GHCJS does is the following:

  1. the plugin name and module is located in the GHCJS package DB. The type of plugin should be ghc:Plugins.Plugin, where ghc is the GHC library from the GHCJS package db.
  2. GHCJS tries to find a module with the same name in the package database specified with -host-package-db
  3. GHCJS checks that the type of the plugin is ghc-api-ghcjs:Plugins.Plugin. This should be the same instance of ghc-api-ghcjs that GHCJS is built against.

Most likely 2 or 3 go wrong. What's the easiest way for me to reproduce the build?

@starsandspirals
Copy link
Contributor Author

starsandspirals commented Aug 12, 2019

With the extra information about how GHCJS deals with plugins, I think I've figured out how to arrange the cabal file so that it should work. The new setup looks more like this:

flag build-plugin-for-ghcjs
  Description: Build for GHCJS
  Default:     False
  Manual:      True

library
  if impl(ghcjs)
    hs-source-dirs:    stub-src
    build-depends:     ghc >= 8.6.5,
                       ghc-boot-th
  else
    hs-source-dirs:    src
    other-modules:     CodeWorld.Requirements.Framework
                       CodeWorld.Requirements.Requirements
                       CodeWorld.Requirements.Checker.Eval
                       CodeWorld.Requirements.Checker.Language
                       CodeWorld.Requirements.Checker.Matcher
                       CodeWorld.Requirements.Checker.Types
    if flag(build-plugin-for-ghcjs)
      build-depends:   ghc-api-ghcjs
    else
      build-depends:   ghc >= 8.6.5,
                       ghc-boot-th

which matches closely with the example setup in Luite's email, and with the addition of the flag and extra conditional should install the packages with the right dependencies.

However, I'm having some trouble when actually trying to build with this flag. After adding "-f build-plugin-for-ghcjs" to the cabal install command, I get this error:

===== RUNNING: cabal_install ./codeworld-server ./codeworld-error-sanitizer ./codeworld-compiler ./codeworld-requirements ./codeworld-game-api ./codeworld-prediction ./codeworld-api ./codeworld-game-server ./codeworld-account ./codeworld-auth -f build-plugin-for-ghcjs
Warning: the --global flag is deprecated -- it is generally considered a bad
idea to install packages into the global store
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: codeworld-requirements-0.1.0.0 (user goal)
[__1] rejecting: codeworld-requirements:-build-plugin-for-ghcjs (constraint
from config file, command line flag, or user target requires opposite flag
selection)
[__1] trying: codeworld-requirements:+build-plugin-for-ghcjs
[__2] unknown package: ghc-api-ghcjs (dependency of codeworld-requirements
+build-plugin-for-ghcjs)
[__2] fail (backjumping, conflict set: codeworld-requirements, ghc-api-ghcjs,
codeworld-requirements:build-plugin-for-ghcjs)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: codeworld-requirements,
codeworld-requirements:build-plugin-for-ghcjs, ghc-api-ghcjs

It's as if ghc-api-ghcjs isn't installed, like before, except that now it is installed and works fine when it isn't being used conditionally as a result of this flag.

Any advice?

@cdsmith
Copy link
Collaborator

cdsmith commented Aug 16, 2019

Daniel, I'm so sorry. I've been swamped at work this week, but I'll try to take a look at this tonight or tomorrow.

Any chance you'll be at ICFP next week?

@starsandspirals
Copy link
Contributor Author

It's no problem at all! I haven't made any progress on this either, unfortunately; I'm happy to keep on pushing with it after GSoC officially finishes, though, so we can get it integrated into CodeWorld properly after we get through all the cabal problems.

I will be at ICFP next week; in fact, I'm writing this at the airport! It'd be great to meet you in person at some point, if you'll be around.

@cdsmith
Copy link
Collaborator

cdsmith commented Aug 16, 2019

Excellent! I'm leaving tomorrow night, and arriving Sunday morning. I look forward to seeing you there.

I am always happy to accept any collaboration on CodeWorld, but I want to be clear that you shouldn't carry forward GSoC obligations past the coding period. Luite is usually at ICFP, and maybe the three of us can find some time and solve this quickly. But if not, you should write a GSoC recap focusing on your GHC plugin running on non-GHCJS code, and show some examples of its use. That will be a successful project. The GHCJS and CodeWorld integration will still happen, but I will not consider you obligated to continue work on it.

@cdsmith cdsmith changed the title WIP: Integration of requirements checker plugin WIP: [Obsolete] Integration of requirements checker plugin Sep 19, 2021
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.

3 participants