fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

Update of FSharp.Core and language to F# v6 ? #405

Open Thorium opened 3 months ago

Thorium commented 3 months ago

Would it be possible to update the current FSharp.Core 4.7.1 to 6.0.1, and update F# language version to 6.0 ?

Or is there still really justification to support F# core 4.7.1 ? This is nothing to do with .NET Framework support, which I still would like to keep as is: .Net Standard 2.0 and .Net Standard 2.1.

I was testing the performance, and seems the CodeGenerator is bit slow, and making the current active patterns to Structs would actually help quite a bit:

https://github.com/fsprojects/FSharp.TypeProviders.SDK/blob/3a9510e466cb8ab04e0b86841dc777994909f881/src/ProvidedTypes.fs#L14047

        let makeTypePattern tp = 
            let tt = convTypeToTgt tp
            fun (t : Type) -> if t = tt then ValueSome() else ValueNone

        [<return: Struct>]
        let (|Bool|_|) = makeTypePattern(typeof<bool>)
        [<return: Struct>]
        let (|SByte|_|) = makeTypePattern(typeof<sbyte>)
        [<return: Struct>]
        let (|Int16|_|) = makeTypePattern(typeof<int16>)
        [<return: Struct>]
        let (|Int32|_|) = makeTypePattern(typeof<int32>)
        [<return: Struct>]
        let (|Int64|_|) = makeTypePattern(typeof<int64>)
        [<return: Struct>]
        let (|Byte|_|) = makeTypePattern(typeof<byte>)
        [<return: Struct>]
        let (|UInt16|_|) = makeTypePattern(typeof<uint16>)
        [<return: Struct>]
        let (|UInt32|_|) = makeTypePattern(typeof<uint32>)
        [<return: Struct>]
        let (|UInt64|_|) = makeTypePattern(typeof<uint64>)
        [<return: Struct>]
        let (|Single|_|) = makeTypePattern(typeof<single>)
        [<return: Struct>]
        let (|Double|_|) = makeTypePattern(typeof<double>)
        [<return: Struct>]
        let (|Char|_|) = makeTypePattern(typeof<char>)
        [<return: Struct>]
        let (|Decimal|_|) = makeTypePattern(typeof<decimal>)
        [<return: Struct>]
        let (|String|_|) = makeTypePattern(typeof<string>)

//... and (|NaN|_|) and (|NaNSingle|_|) could also be struct-tuples

The other option would be adding more compiler directives, because most of the F# TypeProviders refer this still as external file and not Nuget-package. So would you rather accept something like #if FSHARP6 code-block PR?

Thorium commented 3 months ago

There are some code not needed in ProvidedTypes.fs if F# 6 would be used, for example:

These are in F# core now: https://github.com/fsprojects/FSharp.TypeProviders.SDK/blob/3a9510e466cb8ab04e0b86841dc777994909f881/src/ProvidedTypes.fs#L27

https://github.com/fsprojects/FSharp.TypeProviders.SDK/blob/3a9510e466cb8ab04e0b86841dc777994909f881/src/ProvidedTypes.fs#L36