Skip to content
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

Feat:Code Organization #25

Merged
merged 14 commits into from
Nov 9, 2023
Merged

Feat:Code Organization #25

merged 14 commits into from
Nov 9, 2023

Conversation

SpiralOSS
Copy link
Collaborator

Attempt at Code Organization section.

@SpiralOSS
Copy link
Collaborator Author

I didn't bother with the do in modules because of how oddly it behaves (dotnet/fsharp#13905); unless, @bartelink, you have a good example (?). Interested in your input either way.

@bartelink
Copy link
Member

bartelink commented Nov 5, 2023

Yes, I agree it's ultra niche and not imprtant. It can be shown in the context of a type anyway.

For that, one might contrast

  1. a public primary ctor with 3 args that composes two via a let and then does something with the third via a do
  2. a private primary ctor that takes one arg, with a 3 arg new() that delegates to it and does the do bit before delegating

Something should show that assembly level attributes get attached to a do() statement though.

(Will review in a bit)

docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
SpiralOSS and others added 6 commits November 7, 2023 07:19
Syntax/Grammar/Wording

Co-authored-by: Ruben Bartelink <[email protected]>
Syntax/Grammar/Wording

Co-authored-by: Ruben Bartelink <[email protected]>
Syntax/Grammar/Wording

Co-authored-by: Ruben Bartelink <[email protected]>
Syntax/Grammar/Wording

Co-authored-by: Ruben Bartelink <[email protected]>
Syntax/Grammar/Wording

Co-authored-by: Ruben Bartelink <[email protected]>
Syntax/Grammar/Wording

Co-authored-by: Ruben Bartelink <[email protected]>
@SpiralOSS SpiralOSS mentioned this pull request Nov 7, 2023
docs/fsharp-cheatsheet.md Outdated Show resolved Hide resolved
@SpiralOSS SpiralOSS merged commit 3373626 into fsprojects:master Nov 9, 2023
@SpiralOSS SpiralOSS deleted the feat/code_organization branch November 9, 2023 01:31
@@ -122,9 +123,6 @@ The `let` keyword also defines named functions.
let square x = x * x
let print x = printfn "The number is: %d" x

let squareNegateThenPrint x =
Copy link
Member

Choose a reason for hiding this comment

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

needs to mvoe to L129

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I'm not understanding this comment. Here is lines 127 to 131:

127 Pipe operator `|>` is used to chain functions and arguments together. Double-backtick identifiers are handy to improve readability especially in unit testing:
128
129    let ``square, negate, then print`` x =
130       x |> square |> negate |> print
131

Copy link
Member

Choose a reason for hiding this comment

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

was saying that there is/was print (square (negate x)), then print x |> square |> negate, then print >> square >> negate
And one of the fns has ' (prime) naming as it was the second.

if you remove the very first one, then the motivaiton for the second is lost
so prob best to move it down and work it into that section

(and consider the flow onward to showing it with >>)


### Namespaces
Namespaces are simply dotted names that prefix other program elements to allow for further hierarchical organization.
All `type` and `module` elements that follow a `namespace` declaration will require an [`open`](#CodeOrganization_OpenAndAutoOpen) or to be dotted-into to access.
Copy link
Member

Choose a reason for hiding this comment

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

that follow -> within ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"following in the file" ?

Copy link
Member

Choose a reason for hiding this comment

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

demarcated by :D

I wanted to allude to a namespace being a grouping construct that things logically within the scope of

And pave the way for saying "and if you use namespace again, then it's an entirely separated new scope with nothing carried over"

I guess module and namespace have that aspect in common


module rec MyNamespace.MonkeyDomain

exception DoNotSqueezeBananaException of Banana // `Banana` has not been defined yet, and would fail without `rec`
Copy link
Member

Choose a reason for hiding this comment

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

this is a valid example, but very esoteric

I'd say most common usage of rec is people saying "well for this file, I just want to list everything alphabetically, regardless of the fact that it's normally good to put low level stuff first and then have the hihger level stuff at the bottom, with some exceptions where you use and to put some irrelevant dependencies underneath"

So while this does illustrate what it does and how to use it, I dont think it conveys what it's for really, so am pretty conflicted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I stole this from MS Learn. I kind of hate it too. The long names get in the way of what's being demonstrated as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I took a walk and realized I'm conflicted because I hate exceptions. :)

Copy link
Member

Choose a reason for hiding this comment

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

@SpiralOSS
Copy link
Collaborator Author

Appears, I was hasty on that merge button. Will review this morning.

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