You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been interested in making a strict typed system in Python that would be mapable to Haskell.
Type enforcement could be as expensive as we want, and done through assert statements. Asserts go away when the program is compiled with optimization. Ie: python -O myprog.py. Thus in testing, we can iterate through a list just to check that every element is actually an integer, and in deployment we can be confident that lies won't happen and get a seg fault or something if it does.
For instance, if you had
#haskell
data Point = Point Float Float
data Line = Line Point Point
lineLinesIntersect :: Line -> [Line] -> [Maybe Point]
--etc.
Then in python one could have:
#@haskell("Int(a) WorldObject(b) => [a] -> b -> [Maybe Point]")
@haskell("f -> [Maybe Point]")
def line_lines_intersect(indexs,world_object):
#put together a line and some lines in python
#haskell.lineLinesIntersect obviously type enforces before calling haskell
return haskell.lineLinesIntersect(line,lines)
So python functions could be strictly typed, or not. And haskell functions would get garunteed structures suitable for the type constructor. It's cool how Haskell's polymorphism is (or can be) like duck typing and python's class heirarchy, so one could go nuts with this if they wanted to. I think just the minimal to get into Haskell land is enough.
Some mapping of Nothing to None would be awesome. Exceptions could also be passed this way.
Haskell records are so much like named tuples, I think it might make sense to require the Haskell side to define everything as records. These could easily become c structs, Right? But I really don't know enough about the details of communication to know what make sense.
Anyways, I think this is all cool to think about, but would anything I can do towards this help HaPy support, uh, algebraic data types, or custom data types, or whatever they're called? I'm solid with Python and Linux but a noob at Haskell and ctypes/ffi.
The text was updated successfully, but these errors were encountered:
I've been interested in making a strict typed system in Python that would be mapable to Haskell.
Type enforcement could be as expensive as we want, and done through assert statements. Asserts go away when the program is compiled with optimization. Ie:
python -O myprog.py
. Thus in testing, we can iterate through a list just to check that every element is actually an integer, and in deployment we can be confident that lies won't happen and get a seg fault or something if it does.For instance, if you had
Then in python one could have:
So python functions could be strictly typed, or not. And haskell functions would get garunteed structures suitable for the type constructor. It's cool how Haskell's polymorphism is (or can be) like duck typing and python's class heirarchy, so one could go nuts with this if they wanted to. I think just the minimal to get into Haskell land is enough.
Some mapping of Nothing to None would be awesome. Exceptions could also be passed this way.
Haskell records are so much like named tuples, I think it might make sense to require the Haskell side to define everything as records. These could easily become c structs, Right? But I really don't know enough about the details of communication to know what make sense.
Anyways, I think this is all cool to think about, but would anything I can do towards this help HaPy support, uh, algebraic data types, or custom data types, or whatever they're called? I'm solid with Python and Linux but a noob at Haskell and ctypes/ffi.
The text was updated successfully, but these errors were encountered: