fsharp / fsharp/fsharp.org

F# Spec doesn't mention private representation Discriminated unions

Offen
#321 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
language-spec
Vorherrschende Sprache
TeX
Sterne
311
Forks
291
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

For example, in this type:

```
type HtmlAttribute =
private | HtmlAttribute of name:string * value:string
```

What's the effect that `private` should have? I see that in C# projects, I no longer have the `NewHtmlAttribute` constructor, but I can keep doing pattern matching and create new values with `HtmlAttribute("a", "b")` in F#. Is that the intended behaviour? I was expecting to not be able to create new values using the union case constructor, and force people to use a static method that normalizes the arguments

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.