Specialize sconcat for the Semigroup instance of First
The default sconcat
implementation is overly strict in the spine in the specific case of Data.Semigroup.First
>>> sconcat $ First () :| undefined
First {getFirst = *** Exception: Prelude.undefined
...
A very simple, lazier, implementation of sconcat as sconcat (x :| _) = x
would get rid of this problem.
This can also have performance benefits when the spine takes a long time to compute.
>>> sconcat $ First () :| undefined
First {getFirst = ()}
Edited by Jade