-
Notifications
You must be signed in to change notification settings - Fork 119
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
[Remote API] Missing Type
constructors?
#1515
Comments
Ouch, I didn't realize we were using catch-all patterns in that |
Oh dear, looks like this is a larger issue – these same constructors also appear to be absent from the |
@m-yac could you please do this on the |
Btw, what is the problem with the |
Well, I'm not sure, maybe there's nothing wrong with it, actually. I just noticed it's missing explicit cases for a number of constructors. For example, |
|
That being said, I'm not exactly sure what the "right" way to make these pattern matches total is. Currently the common pattern is: TCon (TC tc) ts ->
case (tc,ts) of
(TCNum n, []) -> ...
...
(TCFun, [t1,t2]) -> ...
(TCTuple _, fs) -> ...
(_, _) -> ...{fallback}... where each The most obvious way to make this pattern match total is to lift the fallback to each case, as in: TCon (TC tc) ts ->
case tc of
TCNum n -> case ts of
[] -> ...
_ -> ...{fallback}...
...
TCFun -> case ts of
[t1,t2] -> ...
_ -> ...{fallback}...
TCTuple _ -> ... but that's not very nice. Have either of you encountered a situation like this before? Perhaps there's some pattern synonym trickery to do to make this better? |
I noticed that there are a number of constructors missing in the
toJSON
instance forType
, namely:TCFloat
,TCArray
,TCAbstract
PPrime
,PEq
,PLiteralLessThan
,PFLiteral
,PValidFloat
Is this just the result of people forgetting to update the RPC interface when a new constructor is added, or are there reasons why we don't implement these constructors? If it's the latter, is this documented somewhere?
Either way, perhaps we should modify the way we pattern match here to make sure that a warning is generated if a new constructor is added and this function is not updated. The
TF
case of this function does this, for example, and thus is forced to stay up-to-date.The text was updated successfully, but these errors were encountered: