Fable
Fable copied to clipboard
[Rust] Feature tracking
Feature tracking issue for Rust
language support:
(see also previous list in #2523)
- [x] Rust AST
- [x] Rust AST Printer
- [ ]
Fable2Rust
:- [x] modules
- [x] namespaces
- [x] primitives
- [x] bool
- [x] char
- [x] string
- [x] integers
- [x] floats
- [x] control flow
- [x] functions
- [x] lambdas
- [x] records
- [x] unions
- [x] tuples
- [x] arrays
- [x] lists
- [x] sequences
- [x] options
- [x] results
- [x] choices
- [x] lazy values
- [x] refcells, byrefs
- [x] enums (some)
- [x] classes (some)
- [x] interfaces (most)
- [x] object expressions (some)
- [x] type extensions (most)
- [x] imports (most)
- [x] comparers (some)
- [x] conversions (some)
- [x] formatting (some)
- [x] async (some)
- [x] threading (some)
- [x] exceptions (some)
- [x] inheritance (some)
- [ ] reflection
- [ ]
fable-library-rust
- [x] Array (most)
- [x] ResizeArray (most)
- [x] List (most)
- [x] Seq (most)
- [x] Option (most)
- [x] Range
- [x] Result
- [x] Choice
- [x] Lazy
- [x] Map (most)
- [x] Set (most)
- [x] Dictionary (most)
- [x] HashSet (most)
- [x] String (some)
- [x] Char (some)
- [x] Decimal
- [x] BigInt
- [x] Guid (some)
- [x] DateTime (most)
- [x] DateTimeOffset (most)
- [x] DateOnly (most)
- [x] TimeOnly (most)
- [x] TimeSpan (most)
- [x] Convert (most)
- [x] Encoding (some)
- [x] BitConverter (most)
- [x] RegExp (most)
- [ ] Timer
- [ ] Event
- [ ] Observable
- [ ] other FSharp.Core modules
- [ ] other .NET BCL implementations
This is great @ncave, thank you! It's very nice to be able to easily the current status of Rus compilation. I just created one of this new Github projects for Beyond. If you want you can use it to track the progress or we can just link to this issue from there: https://github.com/orgs/fable-compiler/projects/6/views/1
This is great @ncave, thank you! It's very nice to be able to easily the current status of Rus compilation. I just created one of this new Github projects for Beyond. If you want you can use it to track the progress or we can just link to this issue from there: https://github.com/orgs/fable-compiler/projects/6/views/1
Sorry to interrupt, but the link above seems to be broken (or private ? not sure how it works)
Thanks for letting me know @delneg! Seems the project had private visibility by default, I've changed it. Can you please try again?

Hey @ncave, I was reading around and found this discussion on dyn* sizing the other day. I know we currently have a solution for interfaces (wrapping in Rc<dyn IThing>
), but on the surface it appears this might help substantially simplify the approach long term. Seems like early days yet but one to keep an eye on anyway.
I feel like this is getting close to being able to actually use it. I have been thinking about perhaps using this for a smallish toy project (specifically a wasm target). Perhaps even a game or something with bevy, where the interop layer will all be in Rust, but all high level logic in F#.
I noticed that crates.io does not yet have fable-core reserved. What steps realistically need to be done to set up publishing? Are we even close to considering this? Perhaps I can look at using git in the meantime.
A fun thought: Perhaps some day, as how fable-compiler can fully target js, perhaps it may even be able to compile to Rust to wasm for fast browser (or even node ecosystem) compilation.
@alexswan10k
Fable.Core
doesn't actually contain any code, just metadata, so no need to publish that as a crate.
For fable-library-rust
, even though for now it's copied directly to the output folder by the fable
tool, we probably do want to reserve the crate name.
Oh, that is kind of a nice way of doing it too, although perhaps not the first thing a Rust user would expect. I will experiment with this for now, cheers. Is there some kind of example? I believe your raytracer example was using local relative paths to core fable repo.
@alexswan10k
Any project you compile with fable
gets the fable-library-*
local package copied in the outDir/fable_modules
folder.
Fable.Core
is something else, it's just a metadata assembly (published on Nuget) that you reference in your F# project, that has some basic bindings and types.
Sorry probably just me using the incorrect name.
Just tested, this works great. Thanks. I will have a play with this.
@ncave I have another conundrum.
[<Struct>]
type Vector2<[<Measure>] 'a> = {
x: float32<'a>
y: float32<'a>
}
with
static member (+) (v1 : Vector2<'a>, v2: Vector2<'a>) =
{ x = v1.x + v2.x; y = v1.y + v2.y }
static member (-) (v1 : Vector2<'a>, v2: Vector2<'a>) =
{ x = v1.x - v2.x; y = v1.y - v2.y }
static member (+) (v : Vector2<'a>, s) =
{ x = s + v.x; y = s + v.y }
This spits out generic parameters for [<Measure>]
leading to all sorts of interesting problems
pub struct Vector2<a: Clone + 'static> {
pub x: f32,
pub y: f32,
}
impl <a: Clone + 'static> Entities::Vector2<a> {
pub fn op_Addition__1A4083A0(v1: Entities::Vector2<a>,
v2: Entities::Vector2<a>)
-> Entities::Vector2<_> {
Entities::Vector2::<_>{x: v1.x + v2.x, y: v1.y + v2.y,}
}
pub fn op_Subtract
What would be best to fix this? It seems plausible to just erase [<Measure>]
generics, but I am not confident that will not lead to other problems.
Happy to write up some tests etc for this scenario shortly.
@alexswan10k I haven't used generic units of measure much, do you want to open a separate issue for discussion? We can keep this one just for Rust feature tracking and related topics.
@alexswan10k GenericParams include now a isMeasure
field. In Dart for example we use it to discard measure parameters: https://github.com/fable-compiler/Fable/blob/ea973444f30662deddf8c85053f76fc9baf6db7e/src/Fable.Transforms/Dart/Fable2Dart.fs#L488-L493