Skip to content

Embedding of python interpreter into haskell programs

License

Notifications You must be signed in to change notification settings

Shimuuar/inline-python

Repository files navigation

inline-python

This is library which embeds python interpreter into haskell programs and allows calling python code from haskell and haskell from python seamlessly. This project is inspired by haskell-R. and tries to use similar conventions.

As an example take following program. It captures from environment variables with _hs suffix. This includes haskell functions.

{-# LANGUAGE QuasiQuotes #-}
import Python.Inline
import Python.Inline.QQ

main :: IO ()
main = withPython $ do
  let input = [1..10] :: [Int]
  let square :: Int -> IO Int
      square x = pure (x * x)
  print =<< runPy $ do
    fromPy' @[Int] =<< [pye| [ square_hs(x) for x in input_hs ] |]

it would output:

[1,4,9,16,25,36,49,64,81,100]

About

Embedding of python interpreter into haskell programs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages