You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In quoted expressions or reflected definitions operators involved in constraints are not permitted although a named method with the same constraint is?
#6344
Closed
7sharp9 opened this issue
Mar 20, 2019
· 3 comments
Please provide a succinct description of the issue.
Repro steps
Provide the steps required to reproduce the problem
In Falanx we consuming Fleece for record type like this, using combinators to form codecs for transforming to and from json types:
typeNewSampleMessage={mutable martId :int optionmutable test_oneof :string option }static memberJsonObjCodec=fun m t ->{martId = m; test_oneof = t}<!> jopt "martId"(fun b -> b.martId)<*> jopt "test_oneof"(fun a -> a.test_oneof)
With these definitions you are not allowed to add the reflected definition attribute:
[<ReflectedDefinition>]static memberJsonObjCodec=fun m t ->{martId = m; test_oneof = t}<!> jopt "martId"(fun b -> b.martId)<*> jopt "test_oneof"(fun a -> a.test_oneof)
But adding some extension methods that use exactly the same constraints works fine:
[<AutoOpen>]moduleFleeceExtensions =openFSharpPlusopenFleece.NewtonsofttypeConcreteCodec<'S1,'S2,'t1,'t2>withstatic member inlinemap(field:ConcreteCodec<'S,'S,'f,'T>)(f)=
f <!> field
static member inlineapply(currentField:ConcreteCodec<'S,'S,'f,'T>)(remainderFields:ConcreteCodec<'S,'S,'f->'r,'T>)=
remainderFields <*> currentField
typeNewSampleMessage={mutable martId :int optionmutable test_oneof :string option }[<ReflectedDefinition>]static memberJsonObjCodec=fun m t ->{martId = m; test_oneof = t}|> ConcreteCodec.map (jopt "martId"(fun b -> b.martId))|> ConcreteCodec.apply (jopt "test_oneof"(fun a -> a.test_oneof))
The reflected definition can be easily extracted now:
If we can quote the named versions I don't see why the operator version will not work either? Is this an artificial constraint or an edge case that has not yet been plumbed in?
Expected behavior
The expressions that can be quoted with a named function should be able to be quoted with an operator version.
Actual behavior
Only the named function version can be quoted
Known workarounds
Don't use operators, although the code in this instance is not as well defined as using the operators, the operator style combinators in fleece is easy to understand and has no parenthesis.
@7sharp9 Yes, trait calls aren't represented in quotations and you'll get a compile-time error if you use one. Calling a method that happens to have a trait constraint is not a trait call.
So this is by design but is a limitation we should look at lifting.
Please provide a succinct description of the issue.
Repro steps
Provide the steps required to reproduce the problem
In Falanx we consuming Fleece for record type like this, using combinators to form codecs for transforming to and from json types:
With these definitions you are not allowed to add the reflected definition attribute:
But adding some extension methods that use exactly the same constraints works fine:
The reflected definition can be easily extracted now:
If we can quote the named versions I don't see why the operator version will not work either? Is this an artificial constraint or an edge case that has not yet been plumbed in?
Expected behavior
The expressions that can be quoted with a named function should be able to be quoted with an operator version.
Actual behavior
Only the named function version can be quoted
Known workarounds
Don't use operators, although the code in this instance is not as well defined as using the operators, the operator style combinators in fleece is easy to understand and has no parenthesis.
Related information
Provide any related information
The text was updated successfully, but these errors were encountered: