Alternative instance for Data.Functor.Compose causes <<loop>>s with some types
many
and some
are omitted and are filled in by their defaults from Alternative
, instead of re-using the definitions provided for f
; this manifests as infinite grammars being created in the case of the Earley parsing library, resulting in <<loop>>
errors at runtime.
The fix is just to add:
many = Compose . fmap sequenceA . many . getCompose
some = Compose . fmap sequenceA . some . getCompose
Related twitter thread: https://twitter.com/ollfredo/status/1067498140100628480
(It seems like this bug has been around for some time: https://github.com/feuerbach/regex-applicative/issues/19)
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |