-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A version of GHC.Records as available in future GHCs.
--   
--   This package provides a version of <a>GHC.Records</a> as it will be
--   after the implementation of <a>GHC proposal #42</a>, plus some helper
--   functions over it.
@package record-hasfield
@version 1.0.1


-- | This module provides a version of <a>GHC.Records</a> as it will be
--   after the implementation of <a>GHC proposal #42</a>.
--   
--   In future GHC versions it will be an alias for <a>GHC.Records</a>.
module GHC.Records.Compat

-- | Constraint representing the fact that the field <tt>x</tt> can be get
--   and set on the record type <tt>r</tt> and has field type <tt>a</tt>.
--   This constraint will be solved automatically, but manual instances may
--   be provided as well.
--   
--   The function should satisfy the invariant:
--   
--   <pre>
--   uncurry ($) (hasField @x r) == r
--   </pre>
class HasField (x :: k) r a | x r -> a

-- | Function to get and set a field in a record.
hasField :: HasField x r a => r -> (a -> r, a)

-- | Get a field in a record.
getField :: forall {k} (x :: k) r a. HasField x r a => r -> a

-- | Set a field in a record.
setField :: forall {k} (x :: k) r a. HasField x r a => r -> a -> r


-- | Extensions over a future version of <a>GHC.Records</a>. Provides the
--   function <a>modifyField</a> plus the orphan instances:
--   
--   <ul>
--   <li><tt>HasField '(x1,x2)</tt> for selecting first the <tt>x1</tt>
--   field, then the <tt>x2</tt> field. Available for <tt>()</tt> and
--   tuples up to arity 5.</li>
--   <li><tt>HasField "_1" (a,b) a</tt> for selecting the first compomnent
--   of a pair, plus similarly for all fields up of all tuples up to arity
--   5.</li>
--   </ul>
--   
--   Using these functions together you get:
--   
--   <pre>
--   modifyField @'("_1","_2") negate ((1,2),3,4,5) == ((1,-2),3,4,5)
--   </pre>
module GHC.Records.Extra

-- | Modify a field in a record.
modifyField :: forall {k} (x :: k) r a. HasField x r a => r -> (a -> a) -> r
instance GHC.Records.Compat.HasField "_2" (a, b) b
instance GHC.Records.Compat.HasField "_1" (a, b) a
instance GHC.Records.Compat.HasField "_3" (a, b, c) c
instance GHC.Records.Compat.HasField "_2" (a, b, c) b
instance GHC.Records.Compat.HasField "_1" (a, b, c) a
instance GHC.Records.Compat.HasField "_4" (a, b, c, d) d
instance GHC.Records.Compat.HasField "_3" (a, b, c, d) c
instance GHC.Records.Compat.HasField "_2" (a, b, c, d) b
instance GHC.Records.Compat.HasField "_1" (a, b, c, d) a
instance GHC.Records.Compat.HasField "_5" (a, b, c, d, e) e
instance GHC.Records.Compat.HasField "_4" (a, b, c, d, e) d
instance GHC.Records.Compat.HasField "_3" (a, b, c, d, e) c
instance GHC.Records.Compat.HasField "_2" (a, b, c, d, e) b
instance GHC.Records.Compat.HasField "_1" (a, b, c, d, e) a
instance forall k1 k2 a1 r2 (x1 :: k1) r1 (x2 :: k2) a2. (a1 GHC.Types.~ r2, GHC.Records.Compat.HasField x1 r1 a1, GHC.Records.Compat.HasField x2 r2 a2) => GHC.Records.Compat.HasField '(x1, x2) r1 a2
instance forall k1 k2 k3 a1 r2 a2 r3 (x1 :: k1) r1 (x2 :: k2) (x3 :: k3) a3. (a1 GHC.Types.~ r2, a2 GHC.Types.~ r3, GHC.Records.Compat.HasField x1 r1 a1, GHC.Records.Compat.HasField x2 r2 a2, GHC.Records.Compat.HasField x3 r3 a3) => GHC.Records.Compat.HasField '(x1, x2, x3) r1 a3
instance forall k1 k2 k3 k4 a1 r2 a2 r3 a3 r4 (x1 :: k1) r1 (x2 :: k2) (x3 :: k3) (x4 :: k4) a4. (a1 GHC.Types.~ r2, a2 GHC.Types.~ r3, a3 GHC.Types.~ r4, GHC.Records.Compat.HasField x1 r1 a1, GHC.Records.Compat.HasField x2 r2 a2, GHC.Records.Compat.HasField x3 r3 a3, GHC.Records.Compat.HasField x4 r4 a4) => GHC.Records.Compat.HasField '(x1, x2, x3, x4) r1 a4
instance forall k1 k2 k3 k4 k5 a1 r2 a2 r3 a3 r4 a4 r5 (x1 :: k1) r1 (x2 :: k2) (x3 :: k3) (x4 :: k4) (x5 :: k5) a5. (a1 GHC.Types.~ r2, a2 GHC.Types.~ r3, a3 GHC.Types.~ r4, a4 GHC.Types.~ r5, GHC.Records.Compat.HasField x1 r1 a1, GHC.Records.Compat.HasField x2 r2 a2, GHC.Records.Compat.HasField x3 r3 a3, GHC.Records.Compat.HasField x4 r4 a4, GHC.Records.Compat.HasField x5 r5 a5) => GHC.Records.Compat.HasField '(x1, x2, x3, x4, x5) r1 a5
instance GHC.Records.Compat.HasField '() a a
