-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python support for Fable 🎉 #2345
Conversation
More Python AST fixes
Remove test file Pythagoras.s
- Add tmp fix to Map.fs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome @dbrattli! 👏 👏 👏 I just had a quick look at the common files and left a few minor comments. I will try to check the big files in Transforms/Python tomorrow, but I don't see any problem to merge this to next
branch and hopefully release an alpha version soon. Thanks a lot for this!
@@ -9,6 +9,7 @@ module Util = | |||
try failwith "JS only" // try/catch is just for padding so it doesn't get optimized | |||
with ex -> raise ex | |||
|
|||
let inline pyNative<'T> : 'T = jsNative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can just use a single helper (nativeOnly
or similar) that can be used for bindings of any language?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's good idea. Perhaps in another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the pyNative
at the end of lines of 12 and 14 in /tests/python/util.fs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @IltaySaeedi! They are replaced in the next
branch now 👍
@@ -539,7 +431,7 @@ let choose (chooser: 'T->'U option) (array: 'T[]) ([<Inject>] cons: Cons<'U>) = | |||
match chooser array.[i] with | |||
| None -> () | |||
| Some y -> pushImpl res y |> ignore | |||
if jsTypeof cons = "function" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alfonsogarciacaro How can we write test this using non-js code? This is why I added that callable
to Fable.Core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used jsTypeof cons = "function"
because it's what I usually do in JS, but I guess we can add [<AllowNullLiteral>]
to type Cons
and then just make a null check because we're not going to pass anything through that argument that's not a constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't understand add [} to type Cons`. Please explain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will boxing work with a null check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed a quote and the text was not well formatted 😅 If we add AllowNullLiteral
attribute we shouldn't need the boxing. I can do that 👍
- Add more union tests - Add comment for None arg
Will boxing work with a null check?
Ok, let's merge this. We can keep evolving Python support in follow-up PRs. Thanks a lot for this impressive work @dbrattli! |
Could this be used in a Jupyter notebook transpiling the code prior to notebook eval? cc/ @dbrattli |
Wow! This is unbelievably great work! |
Work in progress Python support for Fable that hopefully one day will fix #2339. Ready for review. Still a lot more work needed but this PR have over 100 passing unit-tests.
TODO:
.fs
implementations