James Note: I am not sure that these are the best examples but it is a starting point.

Option types like Maybe can be used poorly or verbosely when they are not used to their full potential or when they are used where they are not needed. Here are some examples:

Poor/Verbose usage:

import { Maybe } from 'purify-ts/Maybe';
 
// Using Maybe just to wrap and unwrap a value
 
const maybeContractor = Maybe.fromNullable(footerProps.contractor);
 
const contractor = maybeContractor.orDefault('');
 
// Using Maybe when a simple null check would suffice
 
const displayContractor = maybeContractor.isJust() ? maybeContractor.unsafeCoerce() : 'No contractor';

In the above examples, Maybe is used unnecessarily. The first example simply wraps and unwraps a value, which could be done more simply with a null check. The second example uses Maybe for a conditional, but a simple null check would be more straightforward and less verbose.

Effective usage:

 
import { Maybe } from 'purify-ts/Maybe';
 
// Using Maybe to safely handle a potentially null value
 
const maybeContractor = Maybe.fromNullable(footerProps.contractor);
 
const displayContractor = maybeContractor.orDefault('No contractor');
 
// Using Maybe to chain operations that may fail
 
const maybeURL = Maybe.fromNullable(footerProps.website)
  .chain(url => isValidURL(url) ? Maybe.Just(url) : Maybe.Nothing())
  .map(formatDisplayUrl);
 
const displayURL = maybeURL.orDefault('No website');

In these examples, Maybe is used to handle potentially null values in a safe way. The chain method is used to perform an operation that may fail, and map is used to transform the value if it exists. This makes the code safer and more expressive, and takes full advantage of the Maybe type.