arthi-chaud / seminal-haskell Goto Github PK
View Code? Open in Web Editor NEWBetter Type Error Messages for Haskell (Implementation of Seminal for Haskell, Master Project)
License: MIT License
Better Type Error Messages for Haskell (Implementation of Seminal for Haskell, Master Project)
License: MIT License
On case xx of
, enumerate changes for the returned value
In the case of
head $ case list of
[a] -> a
_ -> list
We would be suggested to do
head $ case list of
[a] -> [a]
_ -> list
On application, one (wildcard) argument should be added
In the case of
const 1
We would be suggested to do
const 1 undefined
const undefined 1
Currently, we use a silencer to hide the error message during the GHC Session.
However, Some dynamic flags allow hiding them directly. (See doc.)
Moreover, this would make debugging easier.
In let x = ..
, replace right-hand side with undefined
.
In the case of
let (a:b) = [] in ...
We would be suggested to do
let (a:b) = undefined in ...
See example
In the case of
a = 1 + [2, 3]
We would be suggested to do
a = 1 : [2, 3]
Some Changes come with custom messages (e.g. for if ... then ... else ...
expressions).
These messages should be handled, formatted and presented to the user
The do
expressions need to be traversed
In the case of
main :: IO ()
main = do
return 1
We would be suggested to do
main :: IO ()
main = do
return ()
Go through where
clauses: left-hand and right-hand sides
In the case of
where
(a, b) = length []
We would be suggested to do
where
(a, b) = undefined
Seminal's workflow involved calling the compiler frequently.
We need to setup a subroutine (i.e. function) that allows us to
There are two Haskell parsing libraries on hackage:
These libraries are similar but have various level of complexity and the latter is less maintained
We need to decide which library to use to get the AST of the file to compile.
PoC for these libraries will be in the poc
directory
On If xx then .. else ..
, replace the condition with True
.
This is a 'Wildcard' change
In the case of
if length []
then True
else False
We would be suggested to do
if True
then True
else False
The enumerator should try to call fromIntegral
to
In the case of
a = length []
b :: Integer
b = a
We would be suggested to do
a = length []
b :: Integer
b = fromIntegral a
In the case of
type A = Int
a :: A
a = ()
We would be suggested to do
type A = ()
a :: A
a = ()
On application, arguments should be turned into a tuple
In the case of
fst 1 2
We would be suggested to do
fst (1, 2)
We would need a CLI flag to count and print the number of calls to the typechecker that are done.
We need check that a change does not break the project (compilation, tests, etc.). To do so, we need to setup some Github Actions
We want better error messages than GHC's.
Suggestions are not enough, there should be a proper message with each one of them
The enumerator should go through type signatures
*
kinds, change into
()
* -> *
kinds (e.g. Maybe
)Maybe Char
to Char
)Maybe Int
to Maybe Integer
)* -> * -> *
kinds (e.g. Either
)Either a b
to Either b a
)[Char]
to Char)a
to a -> _
)a -> b
to b -> a
)In the case of
a :: Float
a = fromIntegral 0.0 :: Double
We would be suggested to do
a :: Double
a = fromIntegral 0.0 :: Double
We would need a flag that would, for each change, print:
We need to define how the project will be structured.
According to Seminal's algorithm, it should have the following components:
Should the Searcher call the enumerator? Or Should there be a global orchestrator ?
On case xx of
, remove one match if there are multiple
In the case of
case undefined of
x -> undefined
_ -> undefined
We would be suggested to do
case undefined of
_ -> undefined
More GitHub actions could be setup to check the project's code quality
Some changes on their own do not allow to check if the code typechecks.
Sometimes, multiple wildcard changes might allow the code to check, which would lead the AST to be traversed for each of these successful changes.
Instead of doing these changes parallelly, we should group these changes together
On case match, replace match with wildcard
In the case of
case [1, 2, 3] of
1 -> undefined
_ -> undefined
We would be suggested to do
case [1, 2, 3] of
_ -> undefined
_ -> undefined
In the case of
a = length 'A'
The enumerator suggest to replace length 'A'
with undefined
It might be related to the fact that length
is overloaded.
As a solution, we should consider a new type of Wildcard: []
The expected change would be
a = length "A"
Score errors (for variables or type) happen when an import is missing or incomplete.
Seminal does not mention such case.
We need to know if a code with a reference to a variable/type not in scope should be processed
The basic implementation is supposed to handle one file at a time.
An evolved version should allow to compile multiple files that need each other
The enumerator should go through operation expressions (OpApp
)
In the case of
a = 1 + [1]
We would be suggested to do
a = 1 + 1
The enumerator should try to convert a literal string into a number.
This should be done for
In the case of
a :: Int
a = "20"
-- or a = ['2', '0']
We would be suggested to do
a :: Int
a = 20
The compilation of the program should be possible through multiple versions of GHC.
Moreover, the program should be platform independent
On application, one argument should be deleted
In the case of
const 1 2 3
We would be suggested to do
const 1 2
-- or
const 2 3
-- or
const 1 3
On function application, arguments should be swapped
In the case of
fmap [1] id
We would be suggested to do
fmap id [1]
Alongside with the suggested changes, we should also display GHC's compilation error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.