This project is the result of a Bachelor's thesis in Computer science and engineering (DATX02 / DIT561), given at Chalmers University of Technology and University of Gothenborg.
The purpose of the project is to study how the compiler GHC can be used as a library to build a front-end for Daison. The project focuses in particular on how GHC as a library can be used to build interactive Haskell environments.
-
Setup.hs
- Default setup for building executables. -
src/
- Haskell sourcecodeMain.hs
- Start the programFrontend/
- Contains the Haskell sourcecode.Base.hs
- Session/State handlingContext.hs
- Extensions/Flag handlingEval.hs
- Evaluate expressions sent through the CLIFormat.hs
- Format output from Daison queriesGHCInterface.hs
- No own implementations here, purely for imports.Run.hs
- Loop of the program and definitions of commands that can be runTypecheck.hs
- Typecheck user input to decide how to handle it.
-
tests/
- Contains automated tests for the programTests.hs
- Functional tests run with QuickCheckUnitTests.hs
- Unit tests run with HUnit
We used Cabal to automate dependency installations, building as well as testing the project. Run the following commands from the source folder:
cabal run daison-frontend
cabal test
cabal build exe:daison-frontend
cabal install exe:daison-frontend --install-method=copy --overwrite-policy=always --installdir=dist
- Start the program
~$ daison-frontend
- Open a database
:open database.db
- Load a local file with table and type definitions (
people :: Table Person
,Person :: Person { name :: String, age :: Int}
)
:load People.hs
- Create a table which is defined in People.hs
tryCreateTable people
- Read all entries in the people table
select [x | x <- from people everything]
- Insert a new person into the table people
insert people $ return $ Person "Alice" 15
- Update her age
let pkey = fst it
update people [(pkey, person{age=25}) | person <- from people (at pkey)]
- Close the program
:quit
Command | Description |
---|---|
<statement> |
evaluate/run <statement> |
:dbs | print the list of databases that are currently open |
:?, :help | display this list of commands |
:log path | display the log file's path |
:log show | display the log file's contents |
:log toggle | enable/disable logging |
:log wipe | attempt to wipe the log file's contents |
:type <expr> |
show the type of <expr> |
:q, :quit | quit the program |
:! <command> |
run the shell command <command> |
:close <name> |
close database with <name> if opened |
:mode [mode] |
set access mode to [mode] if provided; displays the current access mode otherwise |
:open <name> |
open database with <name> or set focus to <name> if already opened |
:cd <dir> |
set the current directory to <dir> (relative to current location) |
:module <module> |
import <module> if it exists and is in scope |
:load <filepath> |
load a haskell file from <filepath> |
:set <option> |
set GHC <option> |
Name | GitHub-handle |
---|---|
Christoffer Kaltenbrunner | kaltenbrunner |
Alexander Neldefors | PUGzera |
Hugo Stegrell | steget |
Philip Vedin | pvedin |