Git Product home page Git Product logo

lang's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

rien

lang's Issues

Make "is" totally equivalent to ":" (in function declaration), make ("," equivalent to "&")

The : means that the type on the left is a subclass from the type on the right. E.g. in type declarations (a:Eq), category decls: cat Map k v : Set k.

For multiple subclassing, both "&" and "," should be possible: (a:Eq & Ord), (a:Eq, Ord);
cat Map k v : Set k, List b, cat X a b: Monad a & List b

  • Functions: declaration, lawDeclaration (do not touch law!)
  • Typedefs: optNamed, named, subclass
  • Types: reqSep (reuse this rule with a different name). ReqSep is the rule denoting "is subtype"
  • Types: add "disjunction" token, which can be , or &. Also see #54

Automatic Lensing

Automatically add lensing to records.

(Haskell syntax)

Suppose we have a record

data Game = {
    score :: Int,
    player :: Entity
    entities :: [Entity]
}

with Entity:

data Entity = {
    name :: String
    position :: Point
}

and Point:

data Point = {
    x :: Int,
    y :: Int
}

Each record would get automatic lensing. If you want the player entity to go up, you could write:

let game2 = game.player.position.y `modify` (+1)

or

(+=) = flip modify (+)
let game2 = game.player.position.y += 1

To do something for each element in a list, forEach would be a solution:

let game2 = game.entities `forEach` y *= 2

In some cases modify could be left out with automatic function renaming:

let game2 = game.score `modify` (\x -> function x 3)
--equivalent to
let game2 = game.score `function=` 3
let game2 = game.score `modify` double
--equivalent to
let game2 = game.score double!

Maybe operations could be chained together with do by providing a correct Monad instance:

let game2 = do
    game.player.position.y += 1
    game.player.position.x -= 3
    game.entities `update=` game

Improve pattern syntax for deconstructors

Implement guards

f : a -> a -> a
|(>=2) b  = b
_ b          = b

max : (a:Ord) -> a -> a
a |(<a)   = a   -- first arg= a; take this clause if second arg (<a)
_ b         = b

Guards should work both for booleans and Maybe ()

Implement deconstructor expressions

f : { Int --> v } -> v
((lookup 0) v)  = v
dict                  = ...

Better error messages

  • Friendlier output
  • parse world module rule should check if rule exists and is non-empty

Rename 'class' to 'cat' and 'category'

  • Change from "class" to "cat" or "category"
  • Rename class-rulename to cat-rulename in bnf-files
  • Drop ":" on the end
  • Subtypes: allow ":" also (together with "in" and "is", already defined) (also see #49 )

Type requirement syntax

In functions:

f  : a in Ord; b is Eq => a -> a -> b -> b -> Bool

In ADT defs:

data _ BalancedTree (a is Ord) = Top content:a left:(BalancedTree a) right:(BalancedTree a)
    | Nil

In class defs:

class Dict k v where:
    lookup : k -> Dict k v -> v

class Ord a => SortedSet a where:
    getMin : SortedSet a -> a


class SortedSet (a is Ord) where:
    getMin : SortedSet a -> a

class SortedSet a where a is Ord:
    getMin : SortedSet a -> a

Think about list/set syntax

What would be the best syntax for lists?

Patterns:

[a,b:as]  = a + b + f as
[a:b:as]  = a + b + f as

In combination with tuples

[(a,b):abs]
[a,b:c,d:abs]

Right hand side

a:as
[a:as]
[a,b:as]
[a:b:as]
[a,b] ++ as

In combination with tuples

[a,b:c,d:abs]

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.