[GHC] #15992: Alternative instance for Data.Functor.Compose causes <<loop>>s with some types

GHC ghc-devs at haskell.org
Tue Dec 4 18:24:50 UTC 2018


#15992: Alternative instance for Data.Functor.Compose causes <<loop>>s with some
types
-------------------------------------+-------------------------------------
           Reporter:  glaebhoerl     |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.3
          Component:                 |           Version:  8.6.2
  libraries/base                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Runtime crash
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 `many` and `some` are
 [http://hackage.haskell.org/package/base-4.12.0.0/docs/src/Data.Functor.Compose.html#line-119
 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:

 {{{#!hs
     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)

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15992>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list