record-hasfield-1.0: A version of GHC.Records as available in future GHCs.

Safe HaskellSafe
LanguageHaskell2010

GHC.Records.Extra

Contents

Description

Extensions over a future version of GHC.Records. Provides the function modifyField plus the orphan instances:

  • HasField '(x1,x2) for selecting first the x1 field, then the x2 field. Available for () and tuples up to arity 5.
  • HasField "_1" (a,b) a for selecting the first compomnent of a pair, plus similarly for all fields up of all tuples up to arity 5.

Using these functions together you get:

modifyField @'("_1","_2") negate ((1,2),3,4,5) == ((1,-2),3,4,5)
Synopsis

Documentation

modifyField :: forall x r a. HasField x r a => r -> (a -> a) -> r Source #

Modify a field in a record.

Orphan instances

HasField () a a Source # 
Instance details

Methods

hasField :: a -> (a -> a, a) Source #

HasField "_1" (a, b) a Source # 
Instance details

Methods

hasField :: (a, b) -> (a -> (a, b), a) Source #

HasField "_2" (a, b) b Source # 
Instance details

Methods

hasField :: (a, b) -> (b -> (a, b), b) Source #

HasField "_1" (a, b, c) a Source # 
Instance details

Methods

hasField :: (a, b, c) -> (a -> (a, b, c), a) Source #

HasField "_2" (a, b, c) b Source # 
Instance details

Methods

hasField :: (a, b, c) -> (b -> (a, b, c), b) Source #

HasField "_3" (a, b, c) c Source # 
Instance details

Methods

hasField :: (a, b, c) -> (c -> (a, b, c), c) Source #

HasField "_1" (a, b, c, d) a Source # 
Instance details

Methods

hasField :: (a, b, c, d) -> (a -> (a, b, c, d), a) Source #

HasField "_2" (a, b, c, d) b Source # 
Instance details

Methods

hasField :: (a, b, c, d) -> (b -> (a, b, c, d), b) Source #

HasField "_3" (a, b, c, d) c Source # 
Instance details

Methods

hasField :: (a, b, c, d) -> (c -> (a, b, c, d), c) Source #

HasField "_4" (a, b, c, d) d Source # 
Instance details

Methods

hasField :: (a, b, c, d) -> (d -> (a, b, c, d), d) Source #

HasField "_1" (a, b, c, d, e) a Source # 
Instance details

Methods

hasField :: (a, b, c, d, e) -> (a -> (a, b, c, d, e), a) Source #

HasField "_2" (a, b, c, d, e) b Source # 
Instance details

Methods

hasField :: (a, b, c, d, e) -> (b -> (a, b, c, d, e), b) Source #

HasField "_3" (a, b, c, d, e) c Source # 
Instance details

Methods

hasField :: (a, b, c, d, e) -> (c -> (a, b, c, d, e), c) Source #

HasField "_4" (a, b, c, d, e) d Source # 
Instance details

Methods

hasField :: (a, b, c, d, e) -> (d -> (a, b, c, d, e), d) Source #

HasField "_5" (a, b, c, d, e) e Source # 
Instance details

Methods

hasField :: (a, b, c, d, e) -> (e -> (a, b, c, d, e), e) Source #

(a1 ~ r2, HasField x1 r1 a1, HasField x2 r2 a2) => HasField ((,) x1 x2 :: (k2, k1)) r1 a2 Source # 
Instance details

Methods

hasField :: r1 -> (a2 -> r1, a2) Source #

(a1 ~ r2, a2 ~ r3, HasField x1 r1 a1, HasField x2 r2 a2, HasField x3 r3 a3) => HasField ((,,) x1 x2 x3 :: (k3, k2, k1)) r1 a3 Source # 
Instance details

Methods

hasField :: r1 -> (a3 -> r1, a3) Source #

(a1 ~ r2, a2 ~ r3, a3 ~ r4, HasField x1 r1 a1, HasField x2 r2 a2, HasField x3 r3 a3, HasField x4 r4 a4) => HasField ((,,,) x1 x2 x3 x4 :: (k4, k3, k2, k1)) r1 a4 Source # 
Instance details

Methods

hasField :: r1 -> (a4 -> r1, a4) Source #

(a1 ~ r2, a2 ~ r3, a3 ~ r4, a4 ~ r5, HasField x1 r1 a1, HasField x2 r2 a2, HasField x3 r3 a3, HasField x4 r4 a4, HasField x5 r5 a5) => HasField ((,,,,) x1 x2 x3 x4 x5 :: (k5, k4, k3, k2, k1)) r1 a5 Source # 
Instance details

Methods

hasField :: r1 -> (a5 -> r1, a5) Source #