Skip to content

Instantly share code, notes, and snippets.

@xaviervia
Created February 18, 2017 20:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xaviervia/05c38cfb7ce26b809b0a4f7f93c4c9ce to your computer and use it in GitHub Desktop.
Save xaviervia/05c38cfb7ce26b809b0a4f7f93c4c9ce to your computer and use it in GitHub Desktop.
2017-02-18
  • Blockchain of blockchains with RSA public keys for resource registry (domain + intents/messages accepted)
  • Go down from HTTP/WS to have a simpler/more essential protocol for communication. Protocol not based on simple human analogies (verb, noun)
  • Protocol is (hopefully) implementation of Real OOP.
  • External resources in the language are represented with URLs
  • Discovery/caching decisions (URL resolution) is delegated to the runtime
  • Runtime should eventually be a hypervisor that only manages resource allocation. Or dedicated hardware, programs for FPGA. High level functional language for FPGA programming.
  • Language is expressed in an AST. AST can be formatted in different transport encodings (JSON for example).
  • Language is just representation of category theory operations between the resources, assuming they fulfillthe expected types.
  • Language is lazy and asynchonous by default. Tagline: "sync is just async that works very fast"
  • Under the hood, operations are Real OOP (messages)
  • Even if everything is actually local, the language and module system are modelled to be "internet native". The language is a "systems language", much like Erlang/Rust, but where the "system" is the internet. Purely functional, strongly typed systems programming language.
@xaviervia
Copy link
Author

// concatenate two lists
[
  {
    nodeType: 'Link',
    alias: 'List',
    url: 'http://dormammu.com/List'
  },
  {
    nodeType: 'EntrypointList',
    references: [
      {
        type: 'List',
        name: 'firstList'
      },
      {
        type: 'List',
        name: 'secondList'
      }
    ]
  },
  {
    nodeType: 'Operation/Concatenation',
    arguments: ['firstList', 'secondList'],
    resultName: 'result'
  },
  {
    nodeType: 'ReturnValue',
    referenceName: 'result'
  }
]
// inverse concatenation
[
  {
    nodeType: 'SemiGroup',
    alias: 'SemiGroup',
    url: 'http://dormammu.com/SemiGroup'
  },
  {
    nodeType: 'EntrypointList',
    references: [
      {
        type: 'SemiGroup',
        name: 'firstSemiGroup'
      },
      {
        type: 'SemiGroup',
        name: 'secondSemiGroup'
      }
    ]
  },
  {
    nodeType: 'Operation/Concatenation',
    arguments: ['secondSemiGroup', 'firstSemiGroup'],
    resultName: 'result'
  },
  {
    nodeType: 'ReturnValue',
    referenceName: 'result'
  }
]

@xaviervia
Copy link
Author

xaviervia commented Feb 18, 2017

more concise:

// inverse concatenation
[
  {
    id: 1,
    nodeType: 'Link',
    alias: 'SemiGroup',
    url: 'http://dormammu.com/SemiGroup'
  },
  {
    id: 2
    nodeType: 'ValueReference',
    type: 1
  },
  {
    id: 3
    nodeType: 'ValueReference',
    type: 1
  },
  {
    id: 4,
    nodeType: 'EntrypointList',
    references: [2, 3]
  },
  {
    id: 5,
    nodeType: 'Operation/Concatenation',
    arguments: [2, 2]
  },
  {
    id: 6
    nodeType: 'ReturnValue',
    reference: 5
  }
]

@xaviervia
Copy link
Author

// add, then multiply
// addThenMultiply x y z = (x + y) * z
[
  {
    id: 1,
    nodeType: 'Link',
    url: 'http://dormammu.com/Monoid/Add'
  },
  {
    id: 2,
    nodeType: 'Link',
    url: 'http://dormammu.com/Monoid/Multiply'
  },
  {
    id: 3,
    nodeType: 'Link',
    url: 'http://dormammu.com/Data/Natural'
  },
  {
    id: 4,
    nodeType: 'ValueReference',
    type: 3
  },
  {
    id: 5,
    nodeType: 'ValueReference',
    type: 3
  },
  {
    id: 6,
    nodeType: 'ValueReference',
    type: 3
  },
  {
    id: 7,
    nodeType: 'Operation/Lift',
    arguments: [4, 1]
  },
  {
    id: 8,
    nodeType: 'Operation/Lift',
    arguments: [5, 1]
  },
  {
    id: 9,
    nodeType: 'Operation/Lift',
    arguments: [6, 2]
  },
  {
    id: 10,
    nodeType: 'Operation/Concatenation',
    arguments: [7, 8]
  },
  {
    id: 11,
    nodeType: 'Operation/Fold',
    arguments: [10]
  },
  {
    id: 12,
    nodeType: 'Operation/Lift',
    arguments: [11, 2]
  },
  {
    id: 13,
    nodeType: 'Operation/Concatenation',
    arguments: [12, 9]
  },
  {
    id: 14,
    nodeType: 'ReturnValue',
    reference: 13
  }
]

@xaviervia
Copy link
Author

The previous is equivalent to:

import {Add, Multiply} from 'fantasy-monoids'

addThenMultiply = x => y => z => 
  Multiply(Add(x).concat(Add(y)).fold()).concat(Multiply(z))

@xaviervia
Copy link
Author

using types as data:

Note: Mistakes made here: the types are not necessary as argument if lifting is not being done.

[
  {
    id: 1,
    nodeType: 'Link',
    url: 'http://dormammu.com/Monoid'
  },
  {
    id: 2,
    nodeType: 'Link',
    url: 'http://dormammu.com/NaturalTransformation'
  },
  {
    id: 3,
    nodeType: 'ValueReference',
    type: 1
  },
  {
    id: 4,
    nodeType: 'ValueReference',
    type: 1
  },
  {
    id: 5,
    nodeType: 'ValueReference',
    type: 2
  },
  {
    id: 4,
    nodeType: 'ValueReference',
    type: 3
  },
  {
    id: 5,
    nodeType: 'ValueReference',
    type: 3
  },
  {
    id: 6,
    nodeType: 'ValueReference',
    type: 4
  },
  {
    id: 7,
    nodeType: 'Operation/Concatenation',
    arguments: [4, 5]
  },
  {
    id: 8,
    nodeType: 'Operation/NaturalTransformation',
    arguments: [5, 7]
  },
  {
    id: 9,
    nodeType: 'Operation/Concatenation',
    arguments: [8, 6]
  },
  {
    id: 10,
    nodeType: 'ReturnValue',
    reference: 9
  }
]

equivalent to:

import {Add, Multiply} from 'fantasy-monoids'

const fromAddToMultiply = x => Multiply(x.fold())

abstractChainedConcat = a => b => c => x => y => z => 

@xaviervia
Copy link
Author

http://dormammu.com/Monoid : Monoid
http://dormammu.com/Data : Data

-> Monoid : a
-> Monoid : b
-> Data : c
-> c : y
-> c : z

> a (-> c x)) : aX
> a y : aY

+ aX aY : aXY

> b (< aXY) : bXY

<- (+ bXY (> b c))

@xaviervia
Copy link
Author

same program

> a (-> c x)) : aX

-> http://dormammu.com/Monoid : a
http://dormammu.com/Data : Data

-> Monoid : b

> a y : aY

-> c : y

-> Data : c

<- (+ bXY (> b -> z))

+ aX aY : aXY

> b (< aXY) : bXY

@xaviervia
Copy link
Author

> a (-> c x)) : aX

-> http://dormammu.com/Monoid : a
-> http://dormammu.com/Monoid : b
http://dormammu.com/Data : Data

> a y : aY

-> c : y

-> Data : c

<- (+ bXY (> b -> z))

+ aX aY : aXY

> b (< aXY) : bXY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment