{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude #-}

module Protolude.Unsafe (
  unsafeHead,
  unsafeTail,
  unsafeInit,
  unsafeLast,
  unsafeFromJust,
  unsafeIndex,
  unsafeThrow,
  unsafeRead,
) where

import Protolude.Base (Int)
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

unsafeHead :: [a] -> a
unsafeHead :: [a] -> a
unsafeHead = [a] -> a
forall a. [a] -> a
List.head

unsafeTail :: [a] -> [a]
unsafeTail :: [a] -> [a]
unsafeTail = [a] -> [a]
forall a. [a] -> [a]
List.tail

unsafeInit :: [a] -> [a]
unsafeInit :: [a] -> [a]
unsafeInit = [a] -> [a]
forall a. [a] -> [a]
List.init

unsafeLast :: [a] -> a
unsafeLast :: [a] -> a
unsafeLast = [a] -> a
forall a. [a] -> a
List.last

unsafeFromJust :: Maybe.Maybe a -> a
unsafeFromJust :: Maybe a -> a
unsafeFromJust = Maybe a -> a
forall a. HasCallStack => Maybe a -> a
Maybe.fromJust

unsafeIndex :: [a] -> Int -> a
unsafeIndex :: [a] -> Int -> a
unsafeIndex = [a] -> Int -> a
forall a. [a] -> Int -> a
(List.!!)

unsafeThrow :: Exc.Exception e => e -> a
unsafeThrow :: e -> a
unsafeThrow = e -> a
forall a e. Exception e => e -> a
Exc.throw

unsafeRead :: Read a => [Char] -> a
unsafeRead :: [Char] -> a
unsafeRead = [Char] -> a
forall a. Read a => [Char] -> a
Text.Read.read