summaryrefslogtreecommitdiff
path: root/Utility/BadPrelude.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-09 18:10:41 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-09 18:10:41 -0400
commit28699c95a7de284f07a5c0e34fb1755868301f3c (patch)
treeef6b372edf27c9cbb508169e7adf707dc25a84c6 /Utility/BadPrelude.hs
parent95e748cbd4bb858a3b87621e60f5b43d53b50480 (diff)
some work on avoiding partial functions
There are still hundreds of places that use partial functions head, tail, init, and last.
Diffstat (limited to 'Utility/BadPrelude.hs')
-rw-r--r--Utility/BadPrelude.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/Utility/BadPrelude.hs b/Utility/BadPrelude.hs
new file mode 100644
index 000000000..1bb70adfb
--- /dev/null
+++ b/Utility/BadPrelude.hs
@@ -0,0 +1,24 @@
+{- Some stuff from Prelude should not be used, as it tends to be a source
+ - of bugs.
+ -
+ - This exports functions that conflict with the prelude, which avoids
+ - them being accidentially used.
+ -}
+
+module Utility.BadPrelude where
+
+{- head is a partial function; head [] is an error -}
+head :: [a] -> a
+head = Prelude.head
+
+{- tail is also partial -}
+tail :: [a] -> a
+tail = Prelude.tail
+
+{- init too -}
+init :: [a] -> a
+init = Prelude.init
+
+{- last too -}
+last :: [a] -> a
+last = Prelude.last