aboutsummaryrefslogtreecommitdiffstats
path: root/app/Tuple.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-30 04:02:11 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-30 04:02:17 +0100
commit80d1737c7ca12d3338428553968b37e3f5c2de4a (patch)
treeffaf44cb2577417261d5c2a9f58e3d8e4ef9e44f /app/Tuple.hs
parent650d139254a0e17be0b1011f2fda6ea67f903e71 (diff)
chore: define `(._N)` accessors for tuples
Diffstat (limited to 'app/Tuple.hs')
-rw-r--r--app/Tuple.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/Tuple.hs b/app/Tuple.hs
new file mode 100644
index 0000000..8b43279
--- /dev/null
+++ b/app/Tuple.hs
@@ -0,0 +1,20 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Tuple where
+
+import GHC.Records (HasField (..))
+
+instance HasField "_1" (a, b) a where
+ getField (a, _) = a
+
+instance HasField "_2" (a, b) b where
+ getField (_, b) = b
+
+instance HasField "_1" (a, b, c) a where
+ getField (a, _, _) = a
+
+instance HasField "_2" (a, b, c) b where
+ getField (_, b, _) = b
+
+instance HasField "_3" (a, b, c) c where
+ getField (_, _, c) = c