From 6bce3670d74dcb1172e0c158f59160c6428bd091 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= <mordae@anilinux.org>
Date: Sun, 16 May 2021 22:05:22 +0200
Subject: [PATCH] Add configGet for convenience
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

At the cost of safety. :'-(

Signed-off-by: Jan Hamal Dvořák <mordae@anilinux.org>
---
 lib/Hikaru/Config.hs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/Hikaru/Config.hs b/lib/Hikaru/Config.hs
index 8131f18..e0a914c 100644
--- a/lib/Hikaru/Config.hs
+++ b/lib/Hikaru/Config.hs
@@ -27,6 +27,7 @@ module Hikaru.Config
   , configDefault
 
   -- * Reading Config
+  , configGet
   , configGetMaybe
   , configGetDefault
 
@@ -107,6 +108,16 @@ where
                           ]
 
 
+  -- |
+  -- Obtain value of a configuration key or raise an error.
+  -- You really should not use this function, you know?
+  --
+  configGet :: (Param a) => Text -> Config -> a
+  configGet name cfg = case configGetMaybe name cfg of
+                         Just value -> value
+                         Nothing -> error (name <> " not set!")
+
+
   -- |
   -- Try to obtain value of a configuration key.
   --
-- 
GitLab