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