Coder Social home page Coder Social logo

pym-s's Introduction

Pym-s

Python with a sweet functionnal taste

Pyms is a transpiler. It produces clean and reliable python modules from OCaml-like type definitions. Pym-s is mainly designed to make symbolic manipulations easier and safer in python3.

Python modules generated with Pym-s are annotated according to the PEP 484 making them well suited for use with modern linters or type checkers such as pyre. Future versions of Pym-s will also include an option to generate dynamic type verification.

Example :

# bintree.pyms

typedef binary_tree =
  | Node of int * binary_tree * binary_tree
  | Leaf of int
# main.py

from bintree import *

def count_leafs(bt : binary_tree):
  if isinstance(bt, Leaf):
    return 1
  else:
    _, child1, child2 = bt
    return count_leafs(child1) + count_leafs(child2)

# outputs 2
print(count_leafs(Node(0, Leaf(1), Leaf(2))))

The preceding exemple need to be compiled down to pure python prior to execution :

$ pyms -i bintree.pyms -o bintree.py
$ python3 main.py

Install

Installing Pyms requires opam and a working ocaml environnement. While waiting for Pyms to be published on Opam, it is still possible to install it easily.

To install ocaml and opam, please visit this link

If you just have opam installed :

git clone [email protected]:jdrprod/Pym-s.git
cd Pym-s
opam pin .
opam install .

If you already use dune :

git clone [email protected]:jdrprod/Pym-s.git
cd Pym-s
dune build @install
dune install

pym-s's People

Contributors

acorrenson avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.