[GHC] #9908: Improve enumFromX support for OverloadedLists
GHC
ghc-devs at haskell.org
Fri Dec 19 20:47:14 UTC 2014
#9908: Improve enumFromX support for OverloadedLists
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: ekmett
Type: feature request | Status: new
Priority: normal | Milestone: 7.12.1
Component: Core Libraries | Version: 7.9
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure:
Blocked By: | None/Unknown
Related Tickets: | Test Case:
| Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
At present, `OverloadedLists` desugars `[m..n]` as `fromList (enumFromTo m
n)`. This is sometimes okay, but terrible for `Data.Sequence`. In
particular, I want, for example,
{{{#!hs
[m..n] :: Seq Int
}}}
to end up as `fromFunction (n-m+1) (+m)`, which performs much better.
There are a few approaches that look reasonable:
1. Try to catch `fromList (enumFromTo m n)` before `enumFromTo` becomes
`eftInt`. This does not, unfortunately, seem to work.
2. Grab `eftInt` after it gets written back from `eftIntFB`. This would
probably work, but it's currently impossible because `eftInt` is not
exported from `GHC.Exts` or even `GHC.Enum`.
3. Add `enumFromTo`, etc., to the `IsList` class. Default to the current
behavior, but if possible use `fromListN` for well-known `Enum` types.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9908>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list