[GHC] #15339: Add function equality instance for finite functions to base

GHC ghc-devs at haskell.org
Wed Jul 4 11:50:33 UTC 2018


#15339: Add function equality instance for finite functions to base
-------------------------------------+-------------------------------------
           Reporter:  madgen         |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  8.6.1
          Component:                 |           Version:  8.4.3
  libraries/base                     |
           Keywords:  base,          |  Operating System:  Unknown/Multiple
  equality, function                 |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 If the input type is bounded and enumerable and the result type can be
 compared for equality, functions can be checked for equality. Basically
 this instance:

 {{{#!hs
 instance (Bounded a, Enum a, Eq b) => Eq (a -> b) where
   f == g = all (\x -> f x == g x) [ minBound..maxBound ]
 }}}

 I often work with functions with finite domains and find [(a,b)] awkward.
 I thought this is generic enough that it might belong to base.

 I'd also submit a patch, but I couldn't quite figure out where it should
 live. GHC.Base doesn't have Enum and Bounded; Enum is not where -> or Eq
 are declared; Eq is not declared anywhere; and Data.Function is only for
 combinators.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15339>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list