Git Product home page Git Product logo

seminal-haskell's People

Contributors

arthi-chaud avatar

Watchers

 avatar

seminal-haskell's Issues

Change: Go through 'case' values

Description

On case xx of, enumerate changes for the returned value

Example

In the case of

head $ case list of
  [a] -> a
  _ -> list

We would be suggested to do

head $ case list of
  [a] -> [a]
  _ -> list

Change: Add Single Argument

Description

On application, one (wildcard) argument should be added

Example

In the case of

const 1

We would be suggested to do

const 1 undefined
const undefined 1

Change: 'Let' value to undefined

Description

In let x = .., replace right-hand side with undefined.

Example

In the case of

let (a:b) = [] in ...

We would be suggested to do

let (a:b) = undefined in ...

Format Custom Change Messages

Some Changes come with custom messages (e.g. for if ... then ... else ... expressions).

These messages should be handled, formatted and presented to the user

Change: Go Through `do` expressions

Description

The do expressions need to be traversed

Example

In the case of

main :: IO ()
main = do
  return 1

We would be suggested to do

main :: IO ()
main = do
  return ()

Change: go through `where` clause

Description

Go through where clauses: left-hand and right-hand sides

Example

In the case of

where
  (a, b) = length []

We would be suggested to do

where
  (a, b) = undefined

GHC Subroutine

Seminal's workflow involved calling the compiler frequently.
We need to setup a subroutine (i.e. function) that allows us to

  • Call GHC
  • Pass the AST
  • Retrieve the compilation status
    • Success
    • Syntax Error
    • Type Error
    • Other

Setup Linter

  • There should be a linter configuration
  • There should be a related GitHub Action

Choose What GHC API to use

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

Change: 'If' condition to 'True'

Description

On If xx then .. else .., replace the condition with True.

This is a 'Wildcard' change

Example

In the case of

if length []
then True
else False

We would be suggested to do

if True
then True
else False

Change: Use `fromIntegral`

Description

The enumerator should try to call fromIntegral to

  • convert an Integer into an Int
  • convert an Int into an Integer
  • Convert an Int into a Double
  • Convert an Int into a Float
  • Convert an Integer into a Double
  • Convert an Integer into a Float
  • Convert a Float into a Double
  • Convert a Double into a Float

Example

In the case of

a = length []

b :: Integer
b = a

We would be suggested to do

a = length []

b :: Integer
b = fromIntegral a

Change: Arguments to Tuple

Description

On application, arguments should be turned into a tuple

Example

In the case of

fst 1 2

We would be suggested to do

fst (1, 2)

Basic GitHub Actions

We need check that a change does not break the project (compilation, tests, etc.). To do so, we need to setup some Github Actions

  • Compilation
  • Unit Tests

Change: Go though Type Signatures

Description

The enumerator should go through type signatures

  • For each * kinds, change into
    • Int
    • Integer
    • Float
    • Double
    • String
    • Char
    • Bool
    • ()

  • For each * -> * kinds (e.g. Maybe)
  • Remove the first type argument (e.g. Maybe Char to Char)
  • Change to IO
  • Change to Maybe
  • Call enumerator recursively (e.g. Maybe Int to Maybe Integer)

  • For each * -> * -> * kinds (e.g. Either)
  • Swap types (e.g. Either a b to Either b a)
  • Call enumerator recursively

  • Try to wrap into IO
  • Try to remove brackets (e.g. [Char] to Char)
  • Try to remove type (in the case of a type application)
  • This should be done for each element of a signature
  • Add Type (e.g. a to a -> _)
  • Try to swap types (e.g. a -> b to b -> a)

Example

In the case of

a :: Float
a = fromIntegral 0.0 :: Double

We would be suggested to do

a :: Double
a = fromIntegral 0.0 :: Double

Add flag to trace calls to the typechecker

We would need a flag that would, for each change, print:

  • The File name
  • The Expression position
  • The Source Expression
  • The Changed expression
  • The result of the change (Typecheck or not)

Architecture Plan

We need to define how the project will be structured.
According to Seminal's algorithm, it should have the following components:

  • Ranker
  • Enumerator
  • Searcher
  • GHC subroutine

Should the Searcher call the enumerator? Or Should there be a global orchestrator ?

Change: Remove case match

Description

On case xx of, remove one match if there are multiple

Example

In the case of

case undefined of
  x -> undefined
  _ -> undefined

We would be suggested to do

case undefined of
  _ -> undefined

More GitHub Actions

More GitHub actions could be setup to check the project's code quality

  • Static Analysis
  • Test coverage report (Done in d787f20)

Change Groups

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

Change: Wildcard on 'case' match

Description

On case match, replace match with wildcard

Example

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

Wildcards and Overloaded Functions

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"

Decide if Scope errors should be considered/handled

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

Handle multiple files

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

Change: Go Through operations

Description

The enumerator should go through operation expressions (OpApp)

Example

In the case of

a = 1 + [1]

We would be suggested to do

a = 1 + 1

Change: Literal String to Number

Description

The enumerator should try to convert a literal string into a number.

This should be done for

  • Literal Strings
  • Explicit List of Literal Char

Example

In the case of

a :: Int
a = "20"
-- or a = ['2', '0']

We would be suggested to do

a :: Int
a = 20

Multi-Version and platform support

The compilation of the program should be possible through multiple versions of GHC.
Moreover, the program should be platform independent

Change: Delete Argument

Description

On application, one argument should be deleted

Example

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

Change: Swap Arguments

Description

On function application, arguments should be swapped

Example

In the case of

fmap [1] id

We would be suggested to do

fmap id [1]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.