{-# LANGUAGE CPP #-} {-# LANGUAGE Unsafe #-} {-# LANGUAGE NoImplicitPrelude #-} module Protolude.Unsafe ( unsafeHead, unsafeTail, unsafeInit, unsafeLast, unsafeFromJust, unsafeIndex, unsafeThrow, unsafeRead, ) where import Protolude.Base (Int) #if ( __GLASGOW_HASKELL__ >= 800 ) import Protolude.Base (HasCallStack) #endif import Data.Char (Char) import Text.Read (Read, read) import qualified Data.List as List import qualified Data.Maybe as Maybe import qualified Control.Exception as Exc unsafeThrow :: Exc.Exception e => e -> a unsafeThrow :: forall e a. Exception e => e -> a unsafeThrow = e -> a forall a e. Exception e => e -> a Exc.throw #if ( __GLASGOW_HASKELL__ >= 800 ) unsafeHead :: HasCallStack => [a] -> a unsafeHead :: forall a. HasCallStack => [a] -> a unsafeHead = [a] -> a forall a. HasCallStack => [a] -> a List.head unsafeTail :: HasCallStack => [a] -> [a] unsafeTail :: forall a. HasCallStack => [a] -> [a] unsafeTail = [a] -> [a] forall a. HasCallStack => [a] -> [a] List.tail unsafeInit :: HasCallStack => [a] -> [a] unsafeInit :: forall a. HasCallStack => [a] -> [a] unsafeInit = [a] -> [a] forall a. HasCallStack => [a] -> [a] List.init unsafeLast :: HasCallStack => [a] -> a unsafeLast :: forall a. HasCallStack => [a] -> a unsafeLast = [a] -> a forall a. HasCallStack => [a] -> a List.last unsafeFromJust :: HasCallStack => Maybe.Maybe a -> a unsafeFromJust :: forall a. HasCallStack => Maybe a -> a unsafeFromJust = Maybe a -> a forall a. HasCallStack => Maybe a -> a Maybe.fromJust unsafeIndex :: HasCallStack => [a] -> Int -> a unsafeIndex :: forall a. HasCallStack => [a] -> Int -> a unsafeIndex = [a] -> Int -> a forall a. HasCallStack => [a] -> Int -> a (List.!!) unsafeRead :: (HasCallStack, Read a) => [Char] -> a unsafeRead :: forall a. (HasCallStack, Read a) => [Char] -> a unsafeRead = [Char] -> a forall a. Read a => [Char] -> a Text.Read.read #endif #if ( __GLASGOW_HASKELL__ < 800 ) unsafeHead :: [a] -> a unsafeHead = List.head unsafeTail :: [a] -> [a] unsafeTail = List.tail unsafeInit :: [a] -> [a] unsafeInit = List.init unsafeLast :: [a] -> a unsafeLast = List.last unsafeFromJust :: Maybe.Maybe a -> a unsafeFromJust = Maybe.fromJust unsafeIndex :: [a] -> Int -> a unsafeIndex = (List.!!) unsafeRead :: Read a => [Char] -> a unsafeRead = Text.Read.read #endif