diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-09-02 15:33:34 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-09-02 15:33:34 -0400 |
commit | 0ec4376902ee88a77a9f2ac9f3c03a4432455320 (patch) | |
tree | 38c65eb2d5813da45690ded6e1ec05b0c9c15edd /libraries/base/GHC/Generics.hs | |
parent | 8e4229ab3dc3e1717ad557ef00f3518da6b5c523 (diff) | |
download | haskell-0ec4376902ee88a77a9f2ac9f3c03a4432455320.tar.gz |
Document the Generic(1) laws
Summary:
Some code that @dfeuer was writing implicitly depended on these laws,
but they didn't appear to be enshrined in the Haddocks. Let's do so.
Test Plan: Read it
Reviewers: austin, hvr, bgamari, dfeuer
Reviewed By: dfeuer
Subscribers: rwbarton, thomie, dfeuer
Differential Revision: https://phabricator.haskell.org/D3908
Diffstat (limited to 'libraries/base/GHC/Generics.hs')
-rw-r--r-- | libraries/base/GHC/Generics.hs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libraries/base/GHC/Generics.hs b/libraries/base/GHC/Generics.hs index d4e9583d70..5bc9c55059 100644 --- a/libraries/base/GHC/Generics.hs +++ b/libraries/base/GHC/Generics.hs @@ -1147,8 +1147,15 @@ instance (SingI mn, SingI su, SingI ss, SingI ds) selSourceStrictness _ = fromSing (sing :: Sing ss) selDecidedStrictness _ = fromSing (sing :: Sing ds) --- | Representable types of kind *. --- This class is derivable in GHC with the DeriveGeneric flag on. +-- | Representable types of kind @*@. +-- This class is derivable in GHC with the @DeriveGeneric@ flag on. +-- +-- A 'Generic' instance must satisfy the following laws: +-- +-- @ +-- 'from' . 'to' ≡ 'id' +-- 'to' . 'from' ≡ 'id' +-- @ class Generic a where -- | Generic representation type type Rep a :: * -> * @@ -1161,6 +1168,13 @@ class Generic a where -- | Representable types of kind @* -> *@ (or kind @k -> *@, when @PolyKinds@ -- is enabled). -- This class is derivable in GHC with the @DeriveGeneric@ flag on. +-- +-- A 'Generic1' instance must satisfy the following laws: +-- +-- @ +-- 'from1' . 'to1' ≡ 'id' +-- 'to1' . 'from1' ≡ 'id' +-- @ class Generic1 (f :: k -> *) where -- | Generic representation type type Rep1 f :: k -> * |