Package: pythas
PythasImport Haskell modules as if they were Python modules. If an imported name does not exist as Python module/package, Pythas will traverse the specified subdirectory below yourcwdto look for a matching Haskell file. If one is found it is imported just as if it was a Python module.If you have a fileExample.hslike in theexampledirectory, it will be imported and can be used like such:>>>importpythas>>>importexample.examplease>>>e.hello()HellofromHaskell!You can also justfrom * import. Try:>>>fromexample.exampleimportmultisin>>>frommathimportpi>>>multisin(2,pi)2.4492935982947064e-16and you'll see: It doesn't stop at invoking side-effects.SequencesPythonSequencescan be passed as linked lists or as arrays. Depending on which flavour of programming you want to embrace. Currently for speed and space reasons arrays are used by the backend, but it should be no problem to change that for those hardcore FP nerds stuck inHaskell-land.
Try things like:>>>fromexample.exampleimportmapQuarter>>>mapQuarter(range(1000,5000,1000))[250.0,500.0,750.0,1000.0]While in Haskell listshaveto be used, in Python any kind of sequence can be handed over. Needless to say, varying types won't be supported.TuplesYou can use tuples to pack results of different types into a single one. It is no problem to nest them and lists or vice versa. Checkouttest.hs.Test.hsto see what Pythas is (successfully) tested for.>>>fromexample.exampleimporttuple,hsnd>>>tuple()(1,"a")>>>hsnd((1,2))2RequirementsPlease make sure thatGHCis located in your$PATH.Pythasrequires at leastGHCversion8.0.2. It defaults to usingstack ghc. To check if yourGHCversion is compatible run:$stackghc----versionor withoutstackinstalled:$ghc--versionPythasis written with compatibility and ease of use in mind. All libraries used in theHaskellbackend are contained in the standard installation of GHC. No requirements exist on thePythonic side of life.InstallPythascan be installed using pip. Run the following command to install and compile it at once:$pipinstallpythas&&python-c"import pythas"or from source:$gitclonehttps://github.com/pinselimo/Pythas.git&&cdPythas
$pipinstall.&&python-c"import pythas"ConstraintsOnly Python versions 3.7 and up are supported. Unfortunately, only [PEP 562] introduced__getattr__for modules. This renders the level of abstractionPythasaims for impossible on lower Python versions.Only functions having their type declared will be imported. You can handle the export of the function yourself by adding aforeign export ccallfor the function, otherwisePythaswill do that for you. To exclude a function just omit the functions type. Functions of types that are not supported won't get exported either.All Haskell constants in the IO monad are imported as functions. Due to lists being turned intoCArrays even constant lists must be called like a function without arguments:>>>fromexample.exampleimportsomeConstant,haskellList>>>someConstant63>>>haskellList()[63]The same is true for tuples which are turned into orCTuple{x}s.Pythasenforces the file naming scheme of Haskell for.hsfiles as does theGHC! This is primarily due toGHCfailing to find the imported module at compile time. Thus, we fail early and raise aModuleNotFoundError.DocsPlentiful documentation is available atReadTheDocs.ioPractical examples can be found in thesister repositoryContributingMeaningful contributions are always welcome, please refer toCONTRIBUTING.mdfor details.TestingThe sub-repositories Pythas incorporates all ship their own testing facilities. Testing of thepythaspackage itself therefore focuses on the main functionality and user interface. It incorporates some unit tests and property based testing mostly focusing on ensuring the interface does not alter any data. To execute the tests in bulk just move to the project root and execute:$pytestLicenseThe Software in this repository is licensed under the LGPLv3 License.
See COPYING.LESSER file for details.Pythas  Copyright (C) 2020  Simon Plakolb
This program comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see COPYING and COPYING.LESSER.