From e9c19b295524895a8af4437865c7f4bd49656c34 Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Sat, 18 Jul 2020 11:46:10 +0200 Subject: [PATCH] add tuple fields --- make-pages/Records.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/make-pages/Records.hs b/make-pages/Records.hs index 245e773..a962a5a 100644 --- a/make-pages/Records.hs +++ b/make-pages/Records.hs @@ -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