Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,3 @@
main = print $ "Incoming error--" ++ undefined
-- When run in GHC:
-- "Incoming error--*** Exception: Prelude.undefined

View file

@ -0,0 +1 @@
main = print $ length [undefined, undefined, 1 `div` 0]

View file

@ -0,0 +1 @@
resurrect 0 = error "I'm out of orange smoke!"

View file

@ -0,0 +1,2 @@
undefined :: a
undefined = error "Prelude.undefined"

View file

@ -0,0 +1,16 @@
import Control.Exception (catch, evaluate, ErrorCall)
import System.IO.Unsafe (unsafePerformIO)
import Prelude hiding (catch)
import Control.DeepSeq (NFData, deepseq)
scoopError :: (NFData a) => a -> Either String a
scoopError x = unsafePerformIO $ catch right left
where right = deepseq x $ return $ Right x
left e = return $ Left $ show (e :: ErrorCall)
safeHead :: (NFData a) => [a] -> Either String a
safeHead = scoopError . head
main = do
print $ safeHead ([] :: String)
print $ safeHead ["str"]