Last active
November 30, 2016 23:49
-
-
Save tdietert/97835bb24ce6acd9334ccbdd90599852 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Query' f r where | |
AccountInfo' :: f A.Account -> Query' f A.Account | |
AccountByName' :: Text -> Query' f A.Account | |
QId' :: (ToJSON a, FromJSON a) => a -> Query' f a | |
QAnd' :: (ToJSON a, FromJSON a, ToJSON b, FromJSON b) => Query' f a -> Query' f b -> Query' f (a,b) | |
data QueryBox' where | |
Qbox :: (ToJSON r, FromJSON r) => Query' Keyed r -> QueryBox' | |
defineToJSONQuery ''Query' ''Keyed | |
instance forall a b c. (ToJSON a, FromJSON a, ToJSON b, FromJSON b, ToJSON c, FromJSON c) => FromJSON QueryBox' where | |
parseJSON (Object o) = do | |
conKey <- o .: "tag" | |
val <- o .: "contents" | |
case (conKey :: String) of | |
"AccountInfo'" -> Qbox . AccountInfo' <$> parseJSON val | |
"AccountByName'" -> Qbox . AccountByName' <$> parseJSON val | |
"QId'" -> Qbox . QId' <$> (parseJSON val :: Parser a) | |
"QAnd'" -> do | |
vs <- parseJSON val | |
(Qbox q) <- (parseJSON $ vs !! 0) | |
(Qbox q') <- (parseJSON $ vs !! 1) | |
return $ Qbox $ QAnd' (q :: Query' Keyed b) (q' :: Query' Keyed c) | |
anystring -> fail "Not implemented yet." | |
Error: | |
/home/thomasd/Documents/github/bd/beautilytics/lib/Beautilytics/TransH/Query.hs:212:22: | |
Could not deduce (ToJSON a) arising from a use of ‘parseJSON’ | |
from the context (ToJSON a1, | |
FromJSON a1, | |
ToJSON b1, | |
FromJSON b1, | |
ToJSON c1, | |
FromJSON c1) | |
bound by the instance declaration | |
at lib/Beautilytics/TransH/Query.hs:202:10-111 | |
The type variable ‘a’ is ambiguous | |
Note: there are several potential instances: | |
instance ToJSON AdGoal -- Defined in ‘Beautilytics.AdTypes’ | |
instance ToJSON AdInterest -- Defined in ‘Beautilytics.AdTypes’ | |
instance ToJSON AdPlacement -- Defined in ‘Beautilytics.AdTypes’ | |
...plus 417 others | |
In the expression: parseJSON | |
In a stmt of a 'do' block: (Qbox q) <- (parseJSON $ vs !! 0) | |
In the expression: | |
do { vs <- parseJSON val; | |
(Qbox q) <- (parseJSON $ vs !! 0); | |
(Qbox q') <- (parseJSON $ vs !! 1); | |
return | |
$ Qbox $ QAnd' (q :: Query' Keyed b) (q' :: Query' Keyed c) } | |
/home/thomasd/Documents/github/bd/beautilytics/lib/Beautilytics/TransH/Query.hs:214:32: | |
Couldn't match type ‘r’ with ‘b1’ | |
‘r’ is a rigid type variable bound by | |
a pattern with constructor | |
Qbox :: forall r. | |
(ToJSON r, FromJSON r) => | |
Query' Keyed r -> QueryBox', | |
in a pattern binding in | |
'do' block | |
at lib/Beautilytics/TransH/Query.hs:212:10 | |
‘b1’ is a rigid type variable bound by | |
the instance declaration at lib/Beautilytics/TransH/Query.hs:202:10 | |
Expected type: Query' Keyed b1 | |
Actual type: Query' Keyed r | |
Relevant bindings include | |
q :: Query' Keyed r | |
(bound at lib/Beautilytics/TransH/Query.hs:212:15) | |
In the first argument of ‘QAnd'’, namely ‘(q :: Query' Keyed b)’ | |
In the second argument of ‘($)’, namely | |
‘QAnd' (q :: Query' Keyed b) (q' :: Query' Keyed c)’ | |
/home/thomasd/Documents/github/bd/beautilytics/lib/Beautilytics/TransH/Query.hs:214:54: | |
Couldn't match type ‘r1’ with ‘c1’ | |
‘r1’ is a rigid type variable bound by | |
a pattern with constructor | |
Qbox :: forall r. | |
(ToJSON r, FromJSON r) => | |
Query' Keyed r -> QueryBox', | |
in a pattern binding in | |
'do' block | |
at lib/Beautilytics/TransH/Query.hs:213:10 | |
‘c1’ is a rigid type variable bound by | |
the instance declaration at lib/Beautilytics/TransH/Query.hs:202:10 | |
Expected type: Query' Keyed c1 | |
Actual type: Query' Keyed r1 | |
Relevant bindings include | |
q' :: Query' Keyed r1 | |
(bound at lib/Beautilytics/TransH/Query.hs:213:15) | |
In the second argument of ‘QAnd'’, namely ‘(q' :: Query' Keyed c)’ | |
In the second argument of ‘($)’, namely | |
‘QAnd' (q :: Query' Keyed b) (q' :: Query' Keyed c)’ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment