[GHC] #15078: base: Customary type class laws (e.g. for Eq) and non-abiding instances (e.g. Float) should be documented

GHC ghc-devs at haskell.org
Sun Jun 17 17:37:47 UTC 2018


#15078: base: Customary type class laws (e.g. for Eq) and non-abiding instances
(e.g. Float) should be documented
-------------------------------------+-------------------------------------
        Reporter:  sjakobi           |                Owner:  Azel
            Type:  feature request   |               Status:  merge
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Core Libraries    |              Version:  8.4.2
      Resolution:                    |             Keywords:  newcomer
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4736
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Old description:

> As beginning Haskellers regularly ask about these laws and instances I
> think it would be good to have them documented where they are defined.
>
> === Documented so far:
>
> (in 793902e6891c30150fd3ac1e0e471269a4766780)
>
> ==== Classes
>
> * `Eq`
> * `Floating`
> * `Fractional`
> * `Integral`
> * `Num`
> * `Ord`
>
> ==== Non-abiding instances
>
> * `CDouble` (shares `Double`'s deficiencies)
> * `CFloat` (shares `Float`'s deficiencies)
> * `Complex a` (inherits deficiencies)
> * `Double`: `Eq`, `Ord`, `Fractional`, `Num`
> * `Float`: `Eq`, `Ord`, `Fractional`, `Num`
> * `Ratio a` (inherits deficiencies)
> * `Natural`: `Num`
>
> === TODO
>
> (This is not an exhaustive list, please add more)
>
> * `RealFrac`

New description:

 As beginning Haskellers regularly ask about these laws and instances I
 think it would be good to have them documented where they are defined.

 === Documented so far:

 (in 793902e6891c30150fd3ac1e0e471269a4766780)

 ==== Classes

 * `Eq`
 * `Floating`
 * `Fractional`
 * `Integral`
 * `Num`
 * `Ord`

 ==== Non-abiding instances

 * `CDouble` (shares `Double`'s deficiencies)
 * `CFloat` (shares `Float`'s deficiencies)
 * `Complex a` (inherits deficiencies)
 * `Double`: `Eq`, `Ord`, `Fractional`, `Num`
 * `Float`: `Eq`, `Ord`, `Fractional`, `Num`
 * `Ratio a` (inherits deficiencies)
 * `Natural`: `Num`

 === TODO

 (This is not an exhaustive list, please add more)

 * `RealFrac`
 * the Arrow classes
 * `Word` & co

--

Comment (by Azel):

 What structure would `RealFrac` represent though? And do all instances of
 `Monad`, `Functor` and `Applicative` in base respect the relevant laws?

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


More information about the ghc-tickets mailing list