Skip to content

Latest commit

 

History

History
160 lines (152 loc) · 8.21 KB

todo.org

File metadata and controls

160 lines (152 loc) · 8.21 KB

NOTES

<2017-09-05 Tue> Fixing HKT substitutions

Not propagating up the type substitutions.

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:22]
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:22]

Need to rethink how I’m stringifying the type.

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:22]
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:22]

Look into replacing the current tuple setup of type vars with a map.

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:23]
    Stuck with a list, just subbing out when substitution occurs.
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:23]

Should I just use the to string protocol instead of putting str in the Type struct?

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:23]
    Switched to protocol for types.
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:23]

TODOs

[#A] prelude

  • State “INPROGRESS” from “TODO” [2017-08-04 Fri 10:22]

Standard library [0/2]

  • [ ] Add new functions [0/2]
    • [ ] map, filter, fold, etc…
    • [ ] length, etc…
  • [ ] Rewrite some of the built-in functions that are currently in elixir in terp.

[#A] clean up parser and terp implementations

  • State “INPROGRESS” from “TODO” [2017-08-06 Sun 13:32]

There’s duplication and stuff that can likely be removed now that more functionality is built out. Would like to redo some of the early parsers in the style of more recent ones, e.g. tagging the value.

Checklist [3/5]:

  • [X] Clean up parsers
  • [X] Pull out condition bodies from the big case in terp.eval_trees
  • [X] Improve documentation
  • [ ] Rename some poorly named functions
  • [ ] Add typespecs

Product Types

Recursive types

Need to y-combinate them as well

Type classes

Pattern match things other than value constructors

Documentation extraction and hosting

[#B] improve error handling

  • State “INPROGRESS” from “TODO” [2017-09-01 Fri 13:16]

Propagate error messages instead of ending in crashes

Convert to AST before type checking and eval

Currently converting a raw string in both steps. Should just do it once.:w

[#B] variable/defined function hoisting

Separate terp data structures from elixir data structures

  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:19]

Particularly noticeable in the return of cdr; should be returning a terp list instead of an elixir list.

Terp.Value

This is underway; Terp.Value is currently used when constructing values using HKTs.

Remove circular dependencies

Many of the functions that were split out of the eval function still reference it to evaluate their internals.

Archive

[#B] pattern matching

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:17]
    Basic pattern matching is implemented using the match function. Caveat is that matching is only currently done against value constructors for HKTs, and there is no wildcard yet either.
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:17]

pmatch or equivalent, a list of possible cases and evaluate the first that’s true <2017-08-03 Thu> - Added cond for multi-possibility conditionals. Pattern matching still to come.

Type system

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:14]
    Calling the basic type system done. There are improvements that can be made (not least of which is a pass through to clean stuff up, but type inference generally works.

    This includes inference for higher-kinded types (granted, I have only experimented with one and two variable HKTs, I’m assuming it should work further as well).

    Defining new types works. Annotating types of functions works, which although it isn’t necessary, makes for nice documentation.

    Sum types are implemented. Still need products.

HM type inference

need to pass in the environment so that let definitions can be type checked?

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:13]
    Type checking works for defined functions/variables.
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:12]

bubble errors up in a meaningful way

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:13]
    Most type errors (e.g. unification, annotation) pass errors back up for pretty printing.
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:13]

if, cond

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:14]
    These statements now type check
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:14]

list type, and handlers for associated functions

  • State “DONE” from “INPROGRESS” [2017-09-10 Sun 09:14]
    Have type checking for lists. A future refactor is to make lists HKTs and not rely on Elixir’s lists.
  • State “INPROGRESS” from “TODO” [2017-09-10 Sun 09:14]

[#C] repl

  • State “DONE” from “INPROGRESS” [2017-08-09 Wed 21:08]
    Initial implementation merged today. Doesn’t have scrollback, tab completion, etc… might have to actually hijack the erlang shell to get those.
  • State “INPROGRESS” from “TODO” [2017-08-09 Wed 21:08]

An elixir shell that just waits for input and runs terp eval on it?

[#A] module system

  • State “DONE” from “INPROGRESS” [2017-08-05 Sat 14:09]
    Export with provide, import with require.
  • State “INPROGRESS” from “TODO” [2017-08-04 Fri 10:22]

Example syntax:

module followed by the module’s name and a list of the functions it exports:

(module Prelude.List
        '(length
         reverse
         ...])

To import:

(import Prelude.List) ;; import all functions from the module

(import Prelude.List
        '(length))    ;; import just a given function

<2017-08-04 Fri 16:45> Scrapping the above idea and going with something more akin to Racket’s module system. <2017-08-05 Sat 14:05> Gave up yesterday on figuring out how to only export certain functions without having to worry about what might happen if only the exported function was imported but it depended on something that wasn’t exported. Decided to just import everything and have nothing be private. This morning, realized I could load everything, then unbind the hidden functions by updating the environment.

recursive functions

letrec to define a recursive function This was a huge headache to actually get working, but so exciting when it did finally work.

My naive attempt was to set up a dummy environment record for the function name so that the name wouldn’t be unbound in the function body. This didn’t end up working very well.

Opted instead to pull out the free variable (e.g. function’s name) from the function body, wrap the definition in an anonymous function, and use the Y-combinator to get the function’s fixpoint. Then set the fixpoint function to the name in the environment.

add strings

Strings are now valid.