Skip to content

peterhil/sagitta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sagitta

Sagitta is a Haskell inspired strict runtime type system for Python. The name Sagitta means ‘arrow‘ in Latin.

It uses several concepts from category theory and the Haskell type system and is usable for both object oriented and functional programming.

Build Status

Arrows and type definitions

Arrows are morphisms (for Sets, that is functions) between categories. Essentially arrows are just typed functions between categories (with the additional requirement of having an associative composition operation). :

from sagitta.arrow import typed
from sagitta.cat import Ord, bool
from sagitta.typevar import A

@typed(A, A, bool, A = Ord)
def greater_than(a, b):
    return (a > b)

Categories (typeclasses)

Categories are like Haskell typeclasses, based on abstract base classes (abc.ABCMeta and numbers): :

import sagitta.cat as cat

from cat import Category, Eq, Ord, Enum, Bounded
from cat import Number, Complex, Real, Rational, Integral
from cat import Arrow, Monad, Functor

Type variables

Type variables are the 'a' in Haskell function type definitions: :

head :: [a] -> a

Equivalent in Python with Sagitta: :

@typed([A], A)
def head(lst): pass

Type constraints

Type constraints are the 'Eq a =>' in Haskell function type definitions: :

=/= :: Eq a => a -> a -> bool

Equivalent in Python with Sagitta: :

@typed(A, A, bool, A = Eq)
def equal(x, y):
    return (x == y)

Sagitta code is at Github.

About

Sagitta is a Haskell inspired strict runtime type system for Python.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages