[GHC] #11650: Default definitions for Alternative(some, many) can easily blow up
GHC
ghc-devs at haskell.org
Fri Feb 26 11:54:51 UTC 2016
#11650: Default definitions for Alternative(some, many) can easily blow up
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Documentation | Version: 7.10.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Consider this case (taken from #11649)
{{{#!hs
import Control.Applicative
data U1 p = U1
instance Functor U1 where
fmap f U1 = U1
instance Applicative U1 where
pure _ = U1
U1 <*> U1 = U1
instance Alternative U1 where
empty = U1
U1 <|> U1 = U1
instance Show (U1 p) where
show U1 = "U1"
main = print (some U1)
}}}
This looks fine, right? Wrong,
{{{
$ ./Main
Main: <<loop>>
}}}
It seems that the default definitions of `some` and `many` will produce
looping code in these cases (although it's not entirely clear to me which
cases "these" cases are).
I suppose this is due to the fact that `U1` will always "succeed". We
should ensure that this is noted in the documentation to ensure that users
don't end up with accidentally bottoming instances.
Well, consider what happens
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11650>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list