add tuple fields

This commit is contained in:
Rhiannon Morris 2020-07-18 11:46:10 +02:00
parent 9ddb7a726e
commit e9c19b2955

View file

@ -10,3 +10,16 @@ import GHC.OverloadedLabels
instance HasField x r a => IsLabel x (r -> a) where
fromLabel = getField @x
instance HasField "first" (a, b) a where getField (x, _) = x
instance HasField "second" (a, b) b where getField (_, y) = y
instance HasField "first" (a, b, c) a where getField (x, _, _) = x
instance HasField "second" (a, b, c) b where getField (_, y, _) = y
instance HasField "third" (a, b, c) c where getField (_, _, z) = z
instance HasField "first" (a, b, c, d) a where getField (x, _, _, _) = x
instance HasField "second" (a, b, c, d) b where getField (_, y, _, _) = y
instance HasField "third" (a, b, c, d) c where getField (_, _, z, _) = z
instance HasField "fourth" (a, b, c, d) d where getField (_, _, _, w) = w