Skip to content

Conversation

@gusty
Copy link
Member

@gusty gusty commented Nov 14, 2022

Reverts #503 because of this:

> open FSharpPlus.Control ;;
> IsLeftZero.Invoke empty<OptionT<Task<Option<int>>>> ;;
Binding session to 'C:/Users/gmpl2/.nuget/packages/fsharpplus/1.3.0-ci02744/lib/net6.0/FSharpPlus.dll'...
System.TypeInitializationException: The type initializer for 'FSharpPlus.Control.IsLeftZeroHelper`1' threw an exception.
 ---> System.ArgumentException: The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic argument must be provided for each generic parameter.
   at System.RuntimeType.SanityCheckGenericArguments(RuntimeType[] genericArguments, RuntimeType[] genericParameters)
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
   at <StartupCode$FSharpPlus>.$Applicative..cctor$cont@195-1[a](Type ty, Type[] targs, Unit unitVar)
   at <StartupCode$FSharpPlus>.$Applicative..cctor$cont@172[a](Type ty, Type helperTy, Type[] targs, Unit unitVar)
   at FSharpPlus.Control.IsLeftZeroHelper`1..cctor()
   --- End of inner exception stack trace ---
   at FSharpPlus.Control.IsLeftZeroHelper`1.Invoke(a x)
   at <StartupCode$FSI_0006>.$FSI_0006.main@() in C:\Lula\stdin:line 5
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error

that's because Empty on OptionT (as well as in other monads) uses SRTPs

therefore stuff like

> sequence [OptionT [Some 1]; OptionT [None]] ;;
System.TypeInitializationException: The type initializer for 'FSharpPlus.Control.IsLeftZeroHelper`1' threw an exception.
 ---> System.ArgumentException: The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic argument must be provided for each generic parameter.
   at System.RuntimeType.SanityCheckGenericArguments(RuntimeType[] genericArguments, RuntimeType[] genericParameters)
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
   at <StartupCode$FSharpPlus>.$Applicative..cctor$cont@195-1[a](Type ty, Type[] targs, Unit unitVar)
>    at <StartupCode$FSharpPlus>.$Applicative..cctor$cont@172[a](Type ty, Type helperTy, Type[] targs, Unit unitVar)
   at FSharpPlus.Control.IsLeftZeroHelper`1..cctor()
   --- End of inner exception stack trace ---
   at FSharpPlus.Control.IsLeftZeroHelper`1.Invoke(a x)
   at <StartupCode$FSI_0007>.$FSI_0007.main@() in C:\Lula\stdin:line 6
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error

won't work

Its really a shame but I think we can keep these bits and use them in other places where this situation doesn't happen.

@gusty gusty merged commit c290e60 into master Nov 14, 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