@@ -98,6 +98,10 @@ instance PathPiece a => PathPiece (Maybe a) where
98 toPathPiece = unsafeToPathPiece1
98 toPathPiece = unsafeToPathPiece1
99 fromPathPiece = unsafeFromPathPiece1
99 fromPathPiece = unsafeFromPathPiece1
101+instance (PathPiece a, PathPiece b) => PathPiece (Either a b) where
102+ toPathPiece = unsafeToPathPiece2
103+ fromPathPiece = unsafeFromPathPiece2
101-- | Wrapped @'PathPiece'@ value.
105-- | Wrapped @'PathPiece'@ value.
102newtype WrappedPathPiece a = WrappedPathPiece { unwrapPathPiece :: a }
106newtype WrappedPathPiece a = WrappedPathPiece { unwrapPathPiece :: a }
@@ -113,6 +117,12 @@ unsafeToPathPiece1 = toUrlPiece . (unsafeCoerce :: f a -> f (WrappedPathPiece a)
113unsafeFromPathPiece1 :: forall f a. (PathPiece a, FromHttpApiData (f (WrappedPathPiece a))) => S.Text -> Maybe (f a)
117unsafeFromPathPiece1 :: forall f a. (PathPiece a, FromHttpApiData (f (WrappedPathPiece a))) => S.Text -> Maybe (f a)
114unsafeFromPathPiece1 = either (const Nothing) (Just . (unsafeCoerce :: f (WrappedPathPiece a) -> f a)) . parseUrlPiece
118unsafeFromPathPiece1 = either (const Nothing) (Just . (unsafeCoerce :: f (WrappedPathPiece a) -> f a)) . parseUrlPiece
120+unsafeToPathPiece2 :: forall f a b. (PathPiece a, PathPiece b, ToHttpApiData (f (WrappedPathPiece a) (WrappedPathPiece b))) => f a b -> S.Text
121+unsafeToPathPiece2 = toUrlPiece . (unsafeCoerce :: f a b -> f (WrappedPathPiece a) (WrappedPathPiece b))
123+unsafeFromPathPiece2 :: forall f a b. (PathPiece a, PathPiece b, FromHttpApiData (f (WrappedPathPiece a) (WrappedPathPiece b))) => S.Text -> Maybe (f a b)
124+unsafeFromPathPiece2 = either (const Nothing) (Just . (unsafeCoerce :: f (WrappedPathPiece a) (WrappedPathPiece b) -> f a b)) . parseUrlPiece
116-- | Convert Haskell values to and from sequence of route pieces.
126-- | Convert Haskell values to and from sequence of route pieces.
117class PathMultiPiece s where
127class PathMultiPiece s where
118 -- | Convert from sequence of route pieces.
128 -- | Convert from sequence of route pieces.