Various "hello world" level examples for wrapping python code in haskell. "Batteries included" python-haskell integration.
Haskell needs to do away with its fixation on being difficult. To do so, we need to dovetail Haskell products into peoples' existing workflows in a "batteries included" way: by providing python integration.
- Supports piping serialized as json using shell-conduit out of the box.
- Supports python bindings through the common C Foreign Function Interface via cpython.
- Immediately, needs a comprehensive dockerfile for explicit instructions on
finessing the python environment - those instructions are currently roughly
available in the
setup
section below. (Note: the CI build is currently failing because this dockerfile doesn't exist) - Support for quickcheck etc. on bound python modules
- Type inference for python functions (leveraging GHC rather than python 3rd party)
Setting up the python environment for this project is, as most python environments admittedly are, a bear. There's some explicit versioning and pkg-config munging to be done.
- install python3.4, ghc (glassgow haskell compiler), pkg-config, and stack (pip for ghc)
stack run
find / -name 'python-3.4.pc' -print
and export that as PKG_CONFIG_PATH
in
your ~/.zshrc
(e.g. export PKG_CONFIG_PATH=/Library/Frameworks/Python.framework/Versions/3.4/lib/pkgconfig
)
This allows the cpython
binding in the haskell program to access the
pkg-config
declaration of the python-3.4
requirement.
Also export PYTHONPATH=$(pwd)/src
When you run stack build
, the source in app/Main.hs
is compiled as declared
in the package.yaml
; look at app/Main.hs
first. Then, glance over
src/Lib.hs
- that's where the de-serialization of python output takes place.
Run stack test
, and see test/Spec.hs
for details.