3232 * @param <A> the optional parameter type
3333 * @see Optional
3434 */
35- public abstract class Maybe <A > implements CoProduct2 <Unit , A , Maybe <A >>, Monad <A , Maybe >, Traversable <A , Maybe > {
35+ public abstract class Maybe <A > implements
36+ CoProduct2 <Unit , A , Maybe <A >>,
37+ Monad <A , Maybe <?>>,
38+ Traversable <A , Maybe <?>> {
3639
3740 private Maybe () {
3841 }
@@ -131,7 +134,7 @@ public final <B> Maybe<B> fmap(Function<? super A, ? extends B> fn) {
131134 * {@inheritDoc}
132135 */
133136 @ Override
134- public final <B > Maybe <B > zip (Applicative <Function <? super A , ? extends B >, Maybe > appFn ) {
137+ public final <B > Maybe <B > zip (Applicative <Function <? super A , ? extends B >, Maybe <?> > appFn ) {
135138 return Monad .super .zip (appFn ).coerce ();
136139 }
137140
@@ -143,7 +146,7 @@ public final <B> Maybe<B> zip(Applicative<Function<? super A, ? extends B>, Mayb
143146 * @return the zipped {@link Maybe}
144147 */
145148 @ Override
146- public <B > Lazy <Maybe <B >> lazyZip (Lazy <Applicative <Function <? super A , ? extends B >, Maybe >> lazyAppFn ) {
149+ public <B > Lazy <Maybe <B >> lazyZip (Lazy <Applicative <Function <? super A , ? extends B >, Maybe <?> >> lazyAppFn ) {
147150 return match (constantly (lazy (nothing ())),
148151 a -> lazyAppFn .fmap (maybeF -> maybeF .<B >fmap (f -> f .apply (a )).coerce ()));
149152 }
@@ -152,24 +155,25 @@ public <B> Lazy<Maybe<B>> lazyZip(Lazy<Applicative<Function<? super A, ? extends
152155 * {@inheritDoc}
153156 */
154157 @ Override
155- public final <B > Maybe <B > discardL (Applicative <B , Maybe > appB ) {
158+ public final <B > Maybe <B > discardL (Applicative <B , Maybe <?> > appB ) {
156159 return Monad .super .discardL (appB ).coerce ();
157160 }
158161
159162 /**
160163 * {@inheritDoc}
161164 */
162165 @ Override
163- public final <B > Maybe <A > discardR (Applicative <B , Maybe > appB ) {
166+ public final <B > Maybe <A > discardR (Applicative <B , Maybe <?> > appB ) {
164167 return Monad .super .discardR (appB ).coerce ();
165168 }
166169
167170 /**
168171 * {@inheritDoc}
169172 */
173+ @ SuppressWarnings ("RedundantTypeArguments" )
170174 @ Override
171- public final <B > Maybe <B > flatMap (Function <? super A , ? extends Monad <B , Maybe >> f ) {
172- return match (constantly (nothing ()), f .andThen (Applicative ::coerce ));
175+ public final <B > Maybe <B > flatMap (Function <? super A , ? extends Monad <B , Maybe <?> >> f ) {
176+ return match (constantly (nothing ()), f .andThen (Monad < B , Maybe <?>> ::coerce ));
173177 }
174178
175179 /**
@@ -208,9 +212,10 @@ public final Maybe<A> peek(Consumer<A> consumer) {
208212
209213 @ Override
210214 @ SuppressWarnings ("unchecked" )
211- public final <B , App extends Applicative , TravB extends Traversable <B , Maybe >, AppB extends Applicative <B , App >, AppTrav extends Applicative <TravB , App >> AppTrav traverse (
212- Function <? super A , ? extends AppB > fn ,
213- Function <? super TravB , ? extends AppTrav > pure ) {
215+ public final <B , App extends Applicative <?, App >, TravB extends Traversable <B , Maybe <?>>,
216+ AppB extends Applicative <B , App >,
217+ AppTrav extends Applicative <TravB , App >> AppTrav traverse (Function <? super A , ? extends AppB > fn ,
218+ Function <? super TravB , ? extends AppTrav > pure ) {
214219 return match (__ -> pure .apply ((TravB ) Maybe .<B >nothing ()), a -> (AppTrav ) fn .apply (a ).fmap (Maybe ::just ));
215220 }
216221
@@ -272,11 +277,11 @@ public static <A> Maybe<A> just(A a) {
272277 */
273278 @ SuppressWarnings ("unchecked" )
274279 public static <A > Maybe <A > nothing () {
275- return Nothing .INSTANCE ;
280+ return ( Maybe < A >) Nothing .INSTANCE ;
276281 }
277282
278283 private static final class Nothing <A > extends Maybe <A > {
279- private static final Nothing INSTANCE = new Nothing ();
284+ private static final Nothing <?> INSTANCE = new Nothing <> ();
280285
281286 private Nothing () {
282287 }
0 commit comments