Git Product home page Git Product logo

kitten's Introduction

The Kitten Programming Language

Gitter chat Build Status

Kitten is a statically typed, stack-based functional programming language designed for simplicity, speed, and safety. This is an in-progress implementation of that language, including:

  • An interactive console for testing code

  • An interpreter

  • A native-code compiler producing static executables (incomplete)

Contributing

I need help to make Kitten a reality! If you’re interested in helping in any way, you’re more than welcome, even if you’re not experienced with Haskell or compiler development. You can look at the project for the initial release to see what I’m working on, and check out the contribution guidelines for suggestions on how you can help.

Resources

Building and Installing

If you’re building the compiler just to try it out or work on it, you can follow the preferred build method of using Stack:

git clone https://github.com/evincarofautumn/kitten.git
cd kitten
stack setup  # only necessary on first build
stack build

stack exec kitten
stack exec kitten -- <flags>

However, if you want to install Kitten in a standard location outside the build directory, due to a deficiency in Stack’s support for Cabal’s data-files feature, it is not recommended to use stack install to install a copy of the executable, because this will not install the common vocabulary common.ktn containing Kitten’s standard library.

There are two workarounds. One is to forgo Stack, and build and install Kitten using Cabal directly:

cabal sandbox init
cabal install --only-dependencies
cabal install --prefix="$HOME/.local"

This will correctly install the common vocab so that Kitten can find it. The preferred install location for Kitten is ~/.local on Unix-like systems (so the executable resides at ~/.local/bin/kitten) or %APPDATA%\local on Windows (resp. %APPDATA%\local\bin\kitten.exe).

The other option is to manually copy common.ktn to the install directory:

stack install
cp common.ktn ~/.local/bin/

It’s also recommended to add the install directory (~/.local/bin or %APPDATA\local\bin) to your PATH so that you can invoke kitten directly without a path prefix.

These are the only files installed by Kitten, so to uninstall it, you only need to delete the compiler and common vocab from the install directory.

Miscellany

Kitten is distributed under the terms of the MIT license. Contributors should agree to abide by the code of conduct.

kitten's People

Contributors

colonelj avatar evincarofautumn avatar jeaye avatar kchaloux avatar kevinji avatar kmbn avatar lewurm avatar perimosocordiae avatar strager avatar vmchale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kitten's Issues

Fix library search paths

. and -L are not adequate. Ideas of where kitten should search:

  • An environment variable such as KITTEN_LIBS
  • The directory of the executable
  • That plus /lib
  • An environment variable KITTEN_HOME
  • $KITTEN_HOME/lib

Text builtins

  • __cat_text
  • Relational operations, e.g., __eq_text

Type checker does not check types

The following typechecks but fails during interpretation:

def ; ([a] a -> [a]): prepend

([Char])[]
'a'; 'b';

Type of prepend:

def prepend (a [a] -> [a])

Error:

kitten: user error (Pattern match failure in do expression at lib/Kitten/Interpret.hs:90:5-14)

Capture for vectors

Vectors should allow local variables; should work in much the same way as functions.

README links are broken

"short intro" and "mailing list" -- the latter says no such list is available while the former yields a 404

Allow overriding definitions.

It ought to be possible to define a new word with the same name as another, such that the previous definition is available within the new one. Currently, duplicate definitions are simply ignored, not even flagged as errors.

Test prelude

I'm sure several things about it are semantically wrong, and performance could likely be improved. Mapping and folding should have constant stack depth.

JSON library

Should probably be a wrapper around an existing C library.

Add source locations to types

Types themselves should be better about tracking their provenance so that meaningful lines of reasoning can be presented in error messages.

I/O builtins

__stdin
__stdout
__stderr
__get_line
__open_file
__close_file

Could also be done like Python did, as a stdio wrapper with the FFI.

Int/float suggestions

  • Suggest x.0 if x is a literal int where a float was expected.
  • Suggest +. in x y + if x and y are both float.

Add metadata syntax.

In the interest of providing good editor support, there ought to be syntax for tagging arbitrary expressions with metadata, such as:

  • Documentation
  • Examples
  • Synonyms
  • Tests
  • Types
  • Input methods

The latter is particularly important for Unicode sources; every identifier that includes characters outside of those commonly found on a keyboard should include one or more ASCII-only input methods. There may be overlap between input methods.

FFI

  • Allow declaring foreign modules (dynamic libraries) and importing definitions
  • Make foreign definitions transparently callable

Allow mutually recursive definitions.

Word definitions cannot be mutually recursive because the latter word does not exist at the point of invocation in the first.

$ cat > mutually-recursive.kitten
define a [b]
define b [a]

$ ./kitten mutually-recursive.kitten
Undefined word "b"

Potential solutions include:

  • Allowing forward declarations
  • Delaying parsing of definition bodies
  • Delaying resolution of word names

Move to cabal.

The Haskell sources should be built with cabal rather than the Makefile hackery we have now.

XML library

Should probably be a wrapper around an existing C library.

Change local variable symbol

-> is more mnemonic than \ and has the advantage of looking nicer with multiple variable declaration:

1 -> x
1 2 3 -> (a b c)

Move type promotion out of runtime.

Currently, comparisons and arithmetic operations undergo non-extensible type promotions within the runtime. These ought to be moved into a standard prelude.

Overloading

  • Resolve names into sets of possible overloads
  • Let the typechecker add this information back into the AST
  • During typechecking, select the unique overload that typechecks

Parsing fails on \n

$ cat test.kitten
"hello\n" write
$ ./kitten test.kitten
(line 1, column 8):
unexpected "n"
expecting "\\" or "\""

Improve value representation.

The value representation is just awful and needs to be substantially redone.

Currently all values are boxed, whether inside or outside quotations. That’s fine for now, because removing layers of indirection in general is going to be non-portable. However, as a simple optimisation we can eliminate boxing in homogeneous quotations of integers, floating-point numbers, and characters.

Allow restricted higher-rank polymorphism

It should be possible to write this function:

def trip (a a (a a -> a) -> (a & a & a)):
  -> { a b f }
  a b f@
  a b f@
  a b f@
  pair pair

But its type is:

r s a. r a a (s a as a) → r (a & a & a))

When it should be the rank-2:

r a. r a a (∀s. a as a) → r (a & a & a))

So the compiler complains because f is applied to different stack types.

Fix nested closures

Something about an inner function capturing locals from an enclosing function multiple levels up. To do:

  • Come up with a minimal test case
  • Add internal debugging modes to make this kind of thing easier to catch & fix in the future
  • In debug mode, retypecheck terms after scoping

Add some kind of product type

It doesn’t have to be the final thing. Reinstating tuples (with a new syntax) would be fine until proper structures get in.

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.