The default implementation of sconcat is strict in its spine.
This means that even though in the instance of First a we have the lazy x <> _ = x, sconcat $ First () :| undefined outputs First {getFirst = *** Exception: Prelude.undefined....
I think this should be changed, by having a non-default implementation of sconcat as
This will also have performance benefits when the spine takes time to compute.
This is 'breaking' in the sense that a program that might previously have errored would work fine now. No program that previously worked would not work with this change unless the strictness in the spine triggered a side-effect, which would only be possible with unsafePerformIO I believe.
This would make this instance more in line with other Semigroup instances like () which also provides a custom sconcat implementation for laziness.
The default implementation of
sconcatis strict in its spine.This means that even though in the instance of
First awe have the lazyx <> _ = x,sconcat $ First () :| undefinedoutputsFirst {getFirst = *** Exception: Prelude.undefined....I think this should be changed, by having a non-default implementation of
sconcatasThis will also have performance benefits when the spine takes time to compute.
This is 'breaking' in the sense that a program that might previously have errored would work fine now. No program that previously worked would not work with this change unless the strictness in the spine triggered a side-effect, which would only be possible with
unsafePerformIOI believe.This would make this instance more in line with other
Semigroupinstances like()which also provides a customsconcatimplementation for laziness.