#1449: Bug in instance MonadFix []
-----------------------------------+----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 6.6.1
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Os: Unknown | Testcase: mfix (([1,2]++).(:[]))
Architecture: Unknown |
-----------------------------------+----------------------------------------
Comment (by [EMAIL PROTECTED]):
I realized that my solution does not give a particularly useful result
when fix (f . head) is a single element list. Since any number of
repetitions is a fixpoint in this case, it is not entirely obvious which
one to choose (1 or infinitely many, I guess.) The following returns an
infinite list, and is still slightly nonstrict for x = (y:undefined):
{{{
instance MonadFix [] where
mfix f = l where
l = case fix (f . head) of
[] -> []
x@(_:r) -> x ++ case r of
[] -> l
_ -> concatMap f (tail l)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1449>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs