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

F# Interactive displays enums unnecessarily verbosely. #12127

Closed
teo-tsirpanis opened this issue Sep 7, 2021 · 4 comments · Fixed by #12321
Closed

F# Interactive displays enums unnecessarily verbosely. #12127

teo-tsirpanis opened this issue Sep 7, 2021 · 4 comments · Fixed by #12321
Labels
Area-FSI Bug Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.

Comments

@teo-tsirpanis
Copy link
Contributor

On .NET 6 SDK Preview 7, .NET SDK 5.0.400 and .NET Core SDK 3.1.412, writing something like

System.Char.GetUnicodeCategory 'a';;

will display

val it : System.Globalization.UnicodeCategory = LowercaseLetter {value__ = 1;}

while it could display

val it : System.Globalization.UnicodeCategory = LowercaseLetter

I persume it is a side-effect of #5002. It does not happen when using sprintf "%A".

@smoothdeveloper
Copy link
Contributor

I personally find the additional information useful, maybe it could pretty printed while retaining the actual value, keeping how it behaves when displayed in FSI versus what "%A" does.

@dsyme
Copy link
Contributor

dsyme commented Sep 8, 2021

This should be fixed, we don't intend to show value__

@dsyme dsyme added Bug Area-FSI Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language. labels Sep 8, 2021
@joshuapassos
Copy link
Contributor

@dsyme, if I change the pattern matching by adding the enum type check, can maybe I resolve the problem?

| ObjectValue obj ->
let ty = obj.GetType()
match obj with
| :? string as s ->
stringValueL s
| :? Array as arr ->
arrayValueL depthLim arr
| _ when isSetOrMapType ty ->
mapSetValueL depthLim prec ty obj
| :? System.Collections.IEnumerable as ie ->
sequenceValueL showMode depthLim prec ie
| _ when showMode = ShowTopLevelBinding && typeUsesSystemObjectToString ty ->
emptyL
| _ when opts.ShowProperties ->
countNodes 1
objectValueWithPropertiesL depthLim (ty: Type) (obj: obj)
| _ ->
countNodes 1
// This buries an obj in the layout, rendered at squash time via a leafFormatter.
Layout.objL obj

  | :? Enum -> 
    countNodes 1
    Layout.objL obj

@dsyme
Copy link
Contributor

dsyme commented Oct 31, 2021

Yes! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-FSI Bug Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants