on master help sign in
Add doctests for 'Void' instances (#90)
commit310e14efdc9b1e1783f0c0b29a5d90dd3ffbecc0 authorCsongor Kiss <kiss.csongor.kiss@gmail.com> dateMon 10 Jun 2019, 13:10 (7 years ago) parent25ea8f1
7 files changed+41−8
src/Data/Generics/Product/Fields.hs+4−1 src/Data/Generics/Product/Positions.hs+4−1 src/Data/Generics/Product/Subtype.hs+8−1 src/Data/Generics/Product/Typed.hs+5−1 src/Data/Generics/Sum/Constructors.hs+6−1 src/Data/Generics/Sum/Subtype.hs+2−2 src/Data/Generics/Sum/Typed.hs+12−1
src/Data/Generics/Product/Fields.hs+4−1
@@ -175,7 +175,10 @@ instance -- see Note [Changing type parameters]
175175 ) => HasField field s t a b where
176176 field f s = field0 @field f s
177177
178−-- -- See Note [Uncluttering type signatures]
178+-- | See Note [Uncluttering type signatures]
179+-- >>> :t field
180+-- field
181+-- :: (HasField field s t a b, Functor f) => (a -> f b) -> s -> f t
179182instance {-# OVERLAPPING #-} HasField f (Void1 a) (Void1 b) a b where
180183 field = undefined
181184
src/Data/Generics/Product/Positions.hs+4−1
@@ -172,7 +172,10 @@ coerced :: forall s t s' t' x a b. (Coercible t t', Coercible s s')
172172coerced = coerce
173173{-# INLINE coerced #-}
174174
175−-- See Note [Uncluttering type signatures]
175+-- | See Note [Uncluttering type signatures]
176+-- >>> :t position
177+-- position
178+-- :: (HasPosition i s t a b, Functor f) => (a -> f b) -> s -> f t
176179instance {-# OVERLAPPING #-} HasPosition f (Void1 a) (Void1 b) a b where
177180 position = undefined
178181
src/Data/Generics/Product/Subtype.hs+8−1
@@ -132,9 +132,16 @@ instance
132132instance {-# OVERLAPPING #-} Subtype a a where
133133 super = id
134134
135−-- See Note [Uncluttering type signatures]
135+-- | See Note [Uncluttering type signatures]
136+-- >>> :t super
137+-- super
138+-- :: (Subtype sup sub, Functor f) => (sup -> f sup) -> sub -> f sub
136139instance {-# OVERLAPPING #-} Subtype a Void where
137140 super = undefined
141+-- | See Note [Uncluttering type signatures]
142+-- >>> :t super @Int
143+-- super @Int
144+-- :: (Subtype Int sub, Functor f) => (Int -> f Int) -> sub -> f sub
138145instance {-# OVERLAPPING #-} Subtype Void a where
139146 super = undefined
140147
src/Data/Generics/Product/Typed.hs+5−1
@@ -127,7 +127,11 @@ instance {-# OVERLAPPING #-} HasType a a where
127127 setTyped a _ = a
128128 {-# INLINE setTyped #-}
129129
130−-- See Note [Uncluttering type signatures]
130+-- | See Note [Uncluttering type signatures]
131+-- >>> :t typed
132+-- typed :: (HasType a s, Functor f) => (a -> f a) -> s -> f s
133+--
134+-- Note that this might not longer be needed given the above 'HasType a a' instance.
131135instance {-# OVERLAPPING #-} HasType a Void where
132136 typed = undefined
133137
src/Data/Generics/Sum/Constructors.hs+6−1
@@ -152,7 +152,12 @@ instance
152152 _Ctor = _Ctor0 @ctor
153153 {-# INLINE[2] _Ctor #-}
154154
155−-- See Note [Uncluttering type signatures]
155+-- | See Note [Uncluttering type signatures]
156+-- >>> :t _Ctor
157+-- _Ctor
158+-- :: (AsConstructor ctor s t a b, Data.Profunctor.Choice.Choice p,
159+-- Applicative f) =>
160+-- p a (f b) -> p s (f t)
156161instance {-# OVERLAPPING #-} AsConstructor ctor (Void1 a) (Void1 b) a b where
157162 _Ctor = undefined
158163
src/Data/Generics/Sum/Subtype.hs+2−2
@@ -114,8 +114,8 @@ instance
114114 {-# INLINE[2] _Sub #-}
115115
116116-- | Reflexive case
117−-- >>> _Sub # dog4 :: Animal
118−-- MkDog {name = "Snowy", age = 4}
117+-- >>> _Sub # dog :: Animal
118+-- Dog (MkDog {name = "Shep", age = 3})
119119instance {-# OVERLAPPING #-} AsSubtype a a where
120120 _Sub = id
121121 {-# INLINE[2] _Sub #-}
src/Data/Generics/Sum/Typed.hs+12−1
@@ -118,11 +118,22 @@ instance
118118 _Typed eta = prismRavel (prismPRavel (repIso . _GTyped @_ @as . tupled)) eta
119119 {-# INLINE[2] _Typed #-}
120120
121−-- See Note [Uncluttering type signatures]
121+-- | See Note [Uncluttering type signatures]
122+-- >>> :t _Typed
123+-- _Typed
124+-- :: (AsType a s, Data.Profunctor.Choice.Choice p, Applicative f) =>
125+-- ...
122126instance {-# OVERLAPPING #-} AsType a Void where
123127 _Typed = undefined
124128 injectTyped = undefined
125129 projectTyped = undefined
130+
131+-- | See Note [Uncluttering type signatures]
132+-- >>> :t _Typed @Int
133+-- _Typed @Int
134+-- :: (AsType Int s, Data.Profunctor.Choice.Choice p,
135+-- Applicative f) =>
136+-- ...
126137instance {-# OVERLAPPING #-} AsType Void a where
127138 _Typed = undefined
128139 injectTyped = undefined