Skip to content

Transpile With Type Checks #2

@sharpvik

Description

@sharpvik

Since we support compiling singular Pure modules into JavaScript, we have to understand that they might be called from the loosely typed JS environment (they all are).

As of now, a function like

f :: Int -> Int -> String

will compile to

function f(x) {return function(y) {return /* ... */;};}

and can be called with arguments of the wrong type

f(false)("hey")

We can

  • Choose to ignore this and let programmers deal with this themselves;
  • Alter the export syntax to automatically include type checks for some functions.

Example:

export (
  !f,
  otherFunction
);

In this case, the transpiled function f would include type assertions. This would make things a bit more obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions