[GHC] #8354: Add INLINE (or at least INLINABLE) pragmas for methods of Ord in ghc-prim
GHC
ghc-devs at haskell.org
Wed Nov 19 21:11:20 UTC 2014
#8354: Add INLINE (or at least INLINABLE) pragmas for methods of Ord in ghc-prim
-------------------------------------+-------------------------------------
Reporter: guest | Owner: ekmett
Type: feature | Status: new
request | Milestone:
Priority: normal | Version: 7.6.3
Component: Core | Keywords: ghc-prim
Libraries | Architecture: Unknown/Multiple
Resolution: | Difficulty: Unknown
Operating System: | Blocked By:
Unknown/Multiple | Related Tickets:
Type of failure: |
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by dfeuer):
I'm wondering if we should revert the `Eq` and `Ord` specialization for
`String` and instead try to have some fun with fusion, doing something
much like what we do with `foldr2`. If I'm not mistaken,
{{{#!hs
xs == ys = foldr go null xs ys
where
go _x _r [] = False
go x r (z:zs)
| x == z = r zs
| otherwise = False
}}}
{{{#!hs
compare xs ys = foldr go (bool LT EQ . null) xs ys
where
go _x _r [] = GT
go x r (z:zs) =
case compare x z of
LT -> LT
GT -> GT
EQ -> r zs
}}}
and similarly (carefully) reversing the roles of `xs` and `ys`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8354#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list