# \[ANN\] inline-python — python in haskell

**URL:** <https://discourse.haskell.org/t/ann-inline-python-python-in-haskell/11237>\
**Category:** Announcements\
**Created:** [January 19, 2025, 1:42pm UTC](https://discourse.haskell.org/t/ann-inline-python-python-in-haskell/11237 "2025-01-19T13:42:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shimuuar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/shimuuar/32/4876_2.png) [@Shimuuar](https://discourse.haskell.org/u/Shimuuar)\
**Post date:** [January 19, 2025, 1:42pm UTC](https://discourse.haskell.org/t/ann-inline-python-python-in-haskell/11237/1 "2025-01-19T13:42:42Z")

</div>

I want to announce first release of [inline-python](https://hackage.haskell.org/package/inline-python-0.1). It’s inspired by `inline-r` and allows to embed python snippets which can capture values including haskell function from outside scope. For example:

```haskell
{-# 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] |]

```

python variables ending in `_hs` are captured from outside scope. Python’s list then converted back to haskell so program would print:

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

```

This is alpha quality software so one shouldn’t get surprised by memory leaks, deadlocks, segfaults and things not working in general.
