Opened 6 years ago

Last modified 4 years ago

#8354 new feature request

Add INLINE (or at least INLINABLE) pragmas for methods of Ord in ghc-prim

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Core Libraries Version: 7.6.3
Keywords: ghc-prim Cc: dfeuer, core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Self-explanatory. Eq already has INLINE on (==) and (/=), and it'd be nice to have it on Ord so that SPECIALIZE pragmas on its methods in user code can fire.

Change History (8)

comment:1 Changed 6 years ago by simonpj

Sounds good to me. By all means offer a patch. Worth measuring the effect on binary size, at least as a sanity check.


comment:2 Changed 6 years ago by carter

is there any argument for inline over inlineable here?

this also *should* be emailed to the haskell libraries mailing list, right?

comment:3 Changed 6 years ago by hvr

Keywords: ghc-prim added

comment:4 Changed 5 years ago by thoughtpolice

Component: libraries (other)Core Libraries
Owner: set to ekmett

Moving over to new owning component 'Core Libraries'.

comment:5 Changed 5 years ago by thomie

Cc: dfeuer core-libraries-committee@… added

In commit 4c03791f986509c5d95adf50de555876ed05522e (libraries/ghc-prim/GHC/Classes.hs):

Author: Simon Peyton Jones <>
Date:   Mon May 12 10:53:09 2014 +0100

    Specialise Eq, Ord, Read, Show at Int, Char, String
    These instances are quite common, so it's good to have
    pre-specialised versions available

comment:6 Changed 5 years ago 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,

xs == ys = foldr go null xs ys
    go _x _r [] = False
    go  x  r (z:zs)
      | x == z    = r zs
      | otherwise = False
compare xs ys = foldr go (bool LT EQ . null) xs ys
    go _x _r [] = GT
    go  x  r (z:zs) =
      case compare x z of
        EQ -> r zs
        c  -> c

and similarly (carefully) reversing the roles of xs and ys.

Last edited 5 years ago by dfeuer (previous) (diff)

comment:7 Changed 4 years ago by thomie

Owner: ekmett deleted

comment:8 Changed 4 years ago by thomie

Type of failure: None/UnknownRuntime performance bug
Note: See TracTickets for help on using tickets.