Skip to content

Conversation

@MMagueta
Copy link
Contributor

No description provided.

@MMagueta MMagueta changed the title WIP Add file writing and reading WIP: Add file writing and reading Apr 29, 2022

[<StringEnum>]
type OpenTextModeUpdating =
type OpenTextMode =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So @dbrattli here I did something ugly. I tried to get the OpenTextMode union working with its different open modes but I could only get it working by adding the read, write and update to the same union context. What would you recommend to do here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MMagueta Yes this looks like the right thing to do 👍

result |> equal ()

[<Fact>]
let ``test write works`` () =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to fix this test, don't take it for granted

@dbrattli
Copy link
Collaborator

dbrattli commented May 1, 2022

The other way would be to fix the union to be:

[<Erase>]
type OpenTextMode =
    | OpenTextModeUpdating of OpenTextModeUpdating
    | OpenTextModeWriting of OpenTextModeWriting
    | OpenTextModeReading of OpenTextModeReading

then you can do:

    let result = builtins.``open``(StringPath "test.txt", OpenTextModeWriting OpenTextModeWriting.Write)

But it feels a bit verbose, so I think it's OK to collapse them as you suggest. The inspiration for the code is btw:

@MMagueta
Copy link
Contributor Author

MMagueta commented May 3, 2022

[<Erase>]
type OpenTextMode =
    | OpenTextModeUpdating of OpenTextModeUpdating
    | OpenTextModeWriting of OpenTextModeWriting
    | OpenTextModeReading of OpenTextModeReading

It might be an error I induced, but that was the first thing I tried and the compilation wasn't quite right. Are we supporting nested union structures? I noticed that a lot of the class features in F# aren't being translated, so I thought it might be a wip.

@dbrattli
Copy link
Collaborator

dbrattli commented Jul 3, 2022

Closing because of #58

@dbrattli dbrattli closed this Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants