Haskell语言特性和标准库的纯Python实现:Hask

dgbm 9年前

Hask是一个纯Python,零依赖库模仿了来自Haskell大部分语言核心语言工具,包括:

  • Full Hindley-Milner type system (with typeclasses) that will typecheck any function decorated with a Hask type signature
  • Easy creation of new algebraic data types and new typeclasses, with Haskell-like syntax
  • Pattern matching withcaseexpressions
  • Automagical function currying/partial application and function composition
  • Efficient, immutable, lazily evaluatedListtype with Haskell-style list comprehensions
  • All your favorite syntax and control flow tools, including operator sections, monadic error handling, guards, and more
  • Python port of (some of) the standard libraries from Haskell'sbase, including:
    • Algebraic datatypes from the HaskellPrelude, includingMaybeandEither
    • Typeclasses from the Haskellbaselibraries, includingFunctor,Applicative,Monad,Enum,Num, and all the rest
    • Standard library functions frombase, including all functions fromPrelude,Data.List,Data.Maybe, and more

Features not yet implemented, but coming soon:

  • Python 3 compatibility
  • Better support for polymorphic return values/type defaulting
  • Better support for lazy evaluation (beyond just theListtype and pattern matching)
  • More of the Haskell standard library (Control.*libraries, QuickCheck, and more)
  • Monadic, lazy I/O

Note that all of this is still very much pre-alpha, and some things may be buggy!

Installation

1)git clone https://github.com/billpmurphy/hask

2)python setup.py install

To run the tests:python tests.py.


项目主页:http://www.open-open.com/lib/view/home/1438309255316