Created
April 22, 2015 16:38
-
-
Save seanparsons/32410870fd203bee4466 to your computer and use it in GitHub Desktop.
Trying to proxy some Thrift calls.
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
proxyCall :: (Typeable a) => String -> a -> Q Exp | |
proxyCall serviceName toProxy = do | |
let parameterCount n a' = case (typeRepArgs a') of | |
[x, xs] -> if tyConName $ typeRepTyCon x == "IO" then n else parameterCount (n + 1) xs | |
_ -> undefined | |
let noOfParameters = parameterCount 0 $ typeOf toProxy | |
fieldNames <- traverse (\n -> mkName ("a" ++ (show n))) [1..noOfParameters] | |
valueName <- fmap fromJust $ lookupValueName serviceName | |
return [p| $(valueName) resource $(fieldNames) = Pool.withResource pool (\(ThriftConnection _ client) -> $(toProxy) client $(fieldNames)) |] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment