@@ -75,32 +75,32 @@ instance PathPiece All
7575instance PathPiece Any
7676
7777instance PathPiece a => PathPiece (Dual a) where
78− toPathPiece = unsafeToPathPiece1
79− fromPathPiece = unsafeFromPathPiece1
78+ toPathPiece = toPathPiece1
79+ fromPathPiece = fromPathPiece1
8080
8181instance PathPiece a => PathPiece (Sum a) where
82− toPathPiece = unsafeToPathPiece1
83− fromPathPiece = unsafeFromPathPiece1
82+ toPathPiece = toPathPiece1
83+ fromPathPiece = fromPathPiece1
8484
8585instance PathPiece a => PathPiece (Product a) where
86− toPathPiece = unsafeToPathPiece1
87− fromPathPiece = unsafeFromPathPiece1
86+ toPathPiece = toPathPiece1
87+ fromPathPiece = fromPathPiece1
8888
8989instance PathPiece a => PathPiece (First a) where
90− toPathPiece = unsafeToPathPiece1
91− fromPathPiece = unsafeFromPathPiece1
90+ toPathPiece = toPathPiece1
91+ fromPathPiece = fromPathPiece1
9292
9393instance PathPiece a => PathPiece (Last a) where
94− toPathPiece = unsafeToPathPiece1
95− fromPathPiece = unsafeFromPathPiece1
94+ toPathPiece = toPathPiece1
95+ fromPathPiece = fromPathPiece1
9696
9797instance PathPiece a => PathPiece (Maybe a) where
98− toPathPiece = unsafeToPathPiece1
99− fromPathPiece = unsafeFromPathPiece1
98+ toPathPiece = toPathPiece1
99+ fromPathPiece = fromPathPiece1
100100
101101instance (PathPiece a, PathPiece b) => PathPiece (Either a b) where
102− toPathPiece = unsafeToPathPiece2
103− fromPathPiece = unsafeFromPathPiece2
102+ toPathPiece = toPathPiece2
103+ fromPathPiece = fromPathPiece2
104104
105105-- | Wrapped @'PathPiece'@ value.
106106newtype WrappedPathPiece a = WrappedPathPiece { unwrapPathPiece :: a }
@@ -111,17 +111,21 @@ instance PathPiece a => ToHttpApiData (WrappedPathPiece a) where
111111instance PathPiece a => FromHttpApiData (WrappedPathPiece a) where
112112 parseUrlPiece = fmap WrappedPathPiece . parseMaybeHttpApiData fromPathPiece
113113
114−unsafeToPathPiece1 :: forall f a. (PathPiece a, ToHttpApiData (f (WrappedPathPiece a))) => f a -> S.Text
115−unsafeToPathPiece1 = toUrlPiece . (unsafeCoerce :: f a -> f (WrappedPathPiece a))
114+-- | Convert value to route piece using @'PathPiece'@ instance for its parameter.
115+toPathPiece1 :: forall f a. (PathPiece a, ToHttpApiData (f (WrappedPathPiece a))) => f a -> S.Text
116+toPathPiece1 = toUrlPiece . (unsafeCoerce :: f a -> f (WrappedPathPiece a))
116117
117−unsafeFromPathPiece1 :: forall f a. (PathPiece a, FromHttpApiData (f (WrappedPathPiece a))) => S.Text -> Maybe (f a)
118−unsafeFromPathPiece1 = either (const Nothing) (Just . (unsafeCoerce :: f (WrappedPathPiece a) -> f a)) . parseUrlPiece
118+-- | Parse value from route piece using @'PathPiece'@ instance for its parameter.
119+fromPathPiece1 :: forall f a. (PathPiece a, FromHttpApiData (f (WrappedPathPiece a))) => S.Text -> Maybe (f a)
120+fromPathPiece1 = either (const Nothing) (Just . (unsafeCoerce :: f (WrappedPathPiece a) -> f a)) . parseUrlPiece
119121
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))
122+-- | Convert value to route piece using @'PathPiece'@ instance for its parameters.
123+toPathPiece2 :: forall f a b. (PathPiece a, PathPiece b, ToHttpApiData (f (WrappedPathPiece a) (WrappedPathPiece b))) => f a b -> S.Text
124+toPathPiece2 = toUrlPiece . (unsafeCoerce :: f a b -> f (WrappedPathPiece a) (WrappedPathPiece b))
122125
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
126+-- | Parse value from route piece using @'PathPiece'@ instance for its parameters.
127+fromPathPiece2 :: forall f a b. (PathPiece a, PathPiece b, FromHttpApiData (f (WrappedPathPiece a) (WrappedPathPiece b))) => S.Text -> Maybe (f a b)
128+fromPathPiece2 = either (const Nothing) (Just . (unsafeCoerce :: f (WrappedPathPiece a) (WrappedPathPiece b) -> f a b)) . parseUrlPiece
125129
126130-- | Convert Haskell values to and from sequence of route pieces.
127131class PathMultiPiece s where