Skip to content

Instantly share code, notes, and snippets.

@dramforever
Last active April 21, 2020 05:31
Show Gist options
  • Save dramforever/f96dc331301364a0d16e202e8b5c6b3b to your computer and use it in GitHub Desktop.
Save dramforever/f96dc331301364a0d16e202e8b5c6b3b to your computer and use it in GitHub Desktop.
vscode-ghc-simple new bios design

A bit of extra stuff

  • TODO Make on-configuration-change restart more specific
  • TODO Alert users for configuration migration
    • ghcSimple.useObjectCode is gone.
    • ghcSimple.workspaceType is gone.

Considerations not mentioned

  • Configuration options?
    • Preferably minimal, delegate most to hie.yaml or .ghcid
    • Let the user override the detection mechanism?
  • startupCommands

GHCi session sharing

  • Implicit sharing
  • Documents each get their own configuration
  • Two documents can share one GHCi instance
    • If the configurations are sharable (flag), and the key field is the same
  • The key is a JSON serializable field emitted along with the configuration
    • Informaation like 'This is a stack project on /path/to/root with component foo'

External extension access to GHCi

  • TextDocumentSession: Same Session for. Suitable for calling one-off commands.
  • ConfigurationSession: More flexible, sharing still possible
    • Specify a 'generic' key → Shared across all extensions
    • Specify an extension-specific key (maybe extensionId in key) → Shared within one extension only
    • ... Other use cases?
    • Can also specify non-sharable session
  • Probably also access to configuration detection algorithm.

Dependency

  • Each configuration can specify a set of glob patterns
  • If any of these fiels are changed, the configuration's session is killed
  • Dependency of shared sessions is the union of

New detection logic:

Legends:

  • (TODO): I know how this works, but I didn't write the code yet
  • (???): I still need to figure out how this works

For each file, considered separately:

  • If file has no workspace
    • If stack runnable, file-stack
    • Else, file
  • Else, If workspace has custom command
    • If replScope is workspace, custom-workspace
    • Else: custom-file
  • Else, if hie.yaml in workspace root:
    • This is a hie-bios-cradle workspace
    • Find Cradle match in hie.yaml (TODO)
    • Find GHCi command like hie-bios (???)
    • Find deps like hie-bios (???)
  • Else, if .ghcid in workspace root
    • This is a ghcid workspace
    • Start GHCi using specified commands (TODO)
    • Deps as specified (TODO)
  • Else, if stack.yaml in workspace root:
    • stack query to get targets (TODO)
    • stack repl $target (TODO)
    • Deps (???)
  • Else, if *.cabal or cabal.project or cabal.project.local in workspace root:
    • cabal v2-repl all (TODO)
    • Deps (???)

Example hie.yaml

cradle:
  cabal: # Or stack
  - path: "./src"
    component: "lib:hie-bios" # cabal v2-repl lib:hie-bios
  - path: "./test"
    component: "test:bios-tests" # cabal v2-repl test:bios-tests

  cabal:
    component: "lib:hie-bios" # cabal v2-repl lib:hie-bios
  stack:
    component: "hie-bios:lib" # stack repl hie-bios:lib
  bios:
    program: "program to run"
    dependency-program: "optional program to run"
  direct:
    arguments: ["list","of","ghc","arguments"]
  none: # Maybe just fail. Cache the result
  multi: - path: ./
           config: { cradle: ... }

dependencies:
  - someDep

Example .ghcid

(From GHC)

--command sh ./hadrian/ghci
--reload compiler
--reload ghc
--reload includes
--restart hadrian/

This command is unquoted???

How does ghcid really parse these?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment