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 your last example ("I see the property, but no value:"),
that was probably because you used () as property value type.
If the property value is (), greskell won't try parsing the
value at all and just return (). Use Int instead in this case.
However, I had not actually specified the type (). Rather, I had omitted the type signature. Experimenting after your comment, I found that if I use a type variable, it's as if I specified ():
Is this behavior intentional? It seems as if () serves as the default type when none is specified -- but even when the type is unspecified (as in the variable d above), the AVertexProperty object indicates the payload's type, as in the flagged line below:
Is this behavior intentional? It seems as if () serves as the default type when none is specified
No, that is not intentional, and GHC usually doesn't do such kind of type defaulting. The reason why the type variable was defaulting to () is probably because you used GHCi. For convenience, GHCi enables ExtendedDefaultRules extension by default, which allows type defaulting to ().
I tried your example in IndexTest.hs in my test branch. When I ran stack build, GHC failed because it could not infer the result type.
I think the current behavior is not a problem, because (1) as I said, GHC (not GHCi) is conservative in type defaulting, so it can detect ambiguous type variables (2) in practice, you will use the result data obtained from the server. In that case, you will assume a concrete type for it anyway.
Therefore a more closely-fitting default type might be possible.
It might be. However, types are usually compile-time information in Haskell, while GraphSON's @type field is run-time information. It's impossible to set compile-time information from run-time information. Maybe it's possible to use a type dependent on some run-time information in Haskell, but I don't know how to do it. If we could customize the default types used by GHCi, it would be convenient in the interactive environment.
GraphSON's @type field is mainly for dynamic type languages such as Groovy and Python, I guess. In Haskell, we can use it for validation purposes. To do that, you can use parseTypedGraphSON function from Data.Greskell.GraphSON in your implementation of FromGraphSON class.
In an earlier issue, you wrote:
However, I had not actually specified the type
()
. Rather, I had omitted the type signature. Experimenting after your comment, I found that if I use a type variable, it's as if I specified()
:Is this behavior intentional? It seems as if
()
serves as the default type when none is specified -- but even when the type is unspecified (as in the variabled
above), theAVertexProperty
object indicates the payload's type, as in the flagged line below:Therefore a more closely-fitting default type might be possible.
The text was updated successfully, but these errors were encountered: