summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2021-12-14 19:24:20 +0100
committerAndreas Klebinger <klebinger.andreas@gmx.at>2021-12-14 19:24:20 +0100
commitc43ee6b81bd544ae338f9287a7b1edb646d51531 (patch)
treec66d5fbb9e8a3c1ada6014f3b3135c21f3419103
parent401ddd5300c8be2ee03bf040146e7f2878bae0a9 (diff)
downloadhaskell-c43ee6b81bd544ae338f9287a7b1edb646d51531.tar.gz
GHC.Utils.Misc.only: Add doc string.
This function expects a singleton list as argument but only checks this in debug builds. I've added a docstring saying so. Fixes #20797
-rw-r--r--compiler/GHC/Utils/Misc.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/GHC/Utils/Misc.hs b/compiler/GHC/Utils/Misc.hs
index fbf52d1bdb..29cad99cd3 100644
--- a/compiler/GHC/Utils/Misc.hs
+++ b/compiler/GHC/Utils/Misc.hs
@@ -493,6 +493,10 @@ isSingleton _ = False
notNull :: Foldable f => f a -> Bool
notNull = not . null
+-- | Utility function to go from a singleton list to it's element.
+--
+-- Wether or not the argument is a singleton list is only checked
+-- in debug builds.
only :: [a] -> a
#if defined(DEBUG)
only [a] = a