module Network.JsonRpc.ServerAdapter (
toServerMethod
, ConvertParams ) where
import Network.JsonRpc.Client( Signature (..), (:::) (..))
import Network.JsonRpc.Server( Method, MethodParams
, Parameter (..), toMethod, (:+:) (..))
toServerMethod :: (ConvertParams ps1 ps2, MethodParams f ps2 m r) => Signature ps1 r -> f -> Method m
toServerMethod (Signature name ps) f = toMethod name f $ _toServerParams ps
class ConvertParams ps1 ps2 | ps1 -> ps2, ps2 -> ps1 where
_toServerParams :: ps1 -> ps2
instance ConvertParams () () where
_toServerParams = id
instance ConvertParams ps1 ps2 => ConvertParams (p ::: ps1) (p :+: ps2) where
_toServerParams (name ::: ps1) = Required name :+: _toServerParams ps1