Tweak the HasLink instance for QueryParam, fixes #129

This commit is contained in:
Alp Mestanogullari 2015-06-18 18:03:48 +02:00
parent 9b9ea1059c
commit e8bae7d035

View file

@ -273,10 +273,10 @@ instance (KnownSymbol sym, HasLink sub) => HasLink (sym :> sub) where
-- QueryParam instances -- QueryParam instances
instance (KnownSymbol sym, ToText v, HasLink sub) instance (KnownSymbol sym, ToText v, HasLink sub)
=> HasLink (QueryParam sym v :> sub) where => HasLink (QueryParam sym v :> sub) where
type MkLink (QueryParam sym v :> sub) = v -> MkLink sub type MkLink (QueryParam sym v :> sub) = Maybe v -> MkLink sub
toLink _ l v = toLink _ l mv =
toLink (Proxy :: Proxy sub) toLink (Proxy :: Proxy sub) $
(addQueryParam (SingleParam k (toText v)) l) maybe id (addQueryParam . SingleParam k . toText) mv l
where where
k :: String k :: String
k = symbolVal (Proxy :: Proxy sym) k = symbolVal (Proxy :: Proxy sym)