GithubHelp home page GithubHelp logo

0x0f0f0f / gobba Goto Github PK

View Code? Open in Web Editor NEW
56.0 56.0 2.0 1.6 MB

A purely functional dynamically typed programming language.

Home Page: https://0x0f0f0f.github.io/gobba-book/

License: MIT License

OCaml 99.21% Makefile 0.79%

gobba's People

Contributors

0x0f0f0f avatar sykhro 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

Watchers

 avatar  avatar  avatar  avatar  avatar

gobba's Issues

Differentiable programming and infinites

If a function in minicaml is pure and does only numerical computations, it should be (possibly) integrable or differentiable.

Differentiation should be straightforward to implement, it should be an interpretation of expressions different from evaluation, returning new expressions. Gradients can be easily obtained by iterating single variable derivation over the body of a "nested" lambda. The concrete syntax for derivation should be derive (some n-ary function).

Single variable integration should be done in a similar manner to derivation. The concrete syntax integrate (some 1-ary function) should return a new function denoting the indefinite integral (antiderivative). The concrete syntax integrate from x to y (some 1-ary function) should return the definite integral calculated as in the second fundamental theorem of calculus. To compute multiple integrals the integrate over (domain) (some n-ary function) concrete syntax should be used. It is to be discussed if the integration (domain) should be expressed as a sequence of inequalities, separated by ;. If so, the interpretation of (domain) expressions should not be normal evaluation, but a process that extracts the integration boundaries for each nested integral.

Computing indefinite multiple integrals is to be debated. See this stackexchange post.

Implementing differentiation implies implementing the algebra of limits and infinite values. I am not sure if to include the Infinity value as a first class value of the language, and therefore extending the numerical primitives so that they can compute in the algebra of limits.

Static typing

Implement static typing for expressions and function:

  • An ADT representing type representations, with an additional number type that includes all the numerical tower types
  • Get all the type info into that type
  • A function that infers an expression type
  • Complete this function
  • Include type information in closures
  • Infer function types automatically, automatically using a generic number type if not strictly imposed.
  • Extend abstract and concrete syntax with haskell-style type annotations

Should the language name be changed to something else?

minicaml is no longer mini at ~2.1k lines of code, and while it still has a lot in common with OCaml, the syntax has diverged and the name minicaml may be misleading for newcomers.
I thought about gobba (camel hump in Italian) name with a .gob extension for language files.
Let me know if you have any other ideas for a project name (or if you like the current name).

The language is missing a logo!

Minicaml needs a logo! Let me know if you have a small cute drawing of a camel or anything related to functional programming that may fit. I'll add you in the thanks section of README and the paper.

Should types representing functions to be moved to a single-argument nested style?

Should the definition for function expressions be like this

type expr = 
...
| Lambda of ide * expr

so that a function that takes 3 arguments becomes (Lambda ("x", (Lambda ("y", Lambda ("z", ...body...))))

Or should i keep the list style?

type expr = 
...
| Lambda of ide list * expr

where a function that takes 3 arguments is
(Lambda (["x"; "y"; "z"], ...body...)

I think the latter is easier to read, but the first one makes currying and static type inference easier.

Recursion with lazy functions

There's a problem with laziness in recursion (with laziness in recursion (with laziness in recursion (with laziness ...))).

Non-recursive lazy functions work as expected, but as soon as a lazyfun is declared in a let rec statement, evaluation is stuck in an endless loop and stack overflows. After investigating a bit (trying factorial and fibonacci functions) I've found out that the problem occurs when arguments are passed to the recursive application. It seems that LazyExpressions passed as recursive application arguments never get evaluated.

https://github.com/0x0f0f0f/minicaml/blob/cfc0537dd8982b6696ba029181ebae956fdeb179/lib/eval.ml#L113-L134

Here's the example I've tried

let rec fib = lazyfun n -> if n < 2 then n else (fib (n - 1)) + (fib (n - 2)) in fib 5

Here's the factorial example

 let rec fact = lazyfun n -> if n < 2 then n else n * fact(n - 1) in fact 5

Error handling

exceptions should be values, but they should float towards the top.

Scientifical Computing

  • Choose an arbitrary precision math library and use it (owl)
  • Natural Logarithm and with base
  • Constants
  • Fixed size homogeneous vectors
  • Matrices
  • Matrix and vector algebra
  • Vector primitives
  • Treat numerical vectors as numerical values and define mathematical operators on them
  • Raise to the power
  • Trigonometry
  • Probability distributions
  • Statistic functions
  • Complex number module
  • Interface to the owl plot function

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.