module Prelude
  ( module Exports,
    -- | Custom prelude functions
    parseInt,
    headMay,
  )
where

import Control.Monad.Trans.Resource as Exports
  ( ResourceT,
    liftResourceT,
    runResourceT,
  )
import qualified Data.Text.Read as TR
-- Text formatting
import Formatting as Exports (format, sformat, (%))
import Formatting.ShortFormatters as Exports (d, sh, st, t)
import Network.HTTP.Types as Exports
import Network.Wai as Exports
import Relude as Exports hiding (get, put)
import UnliftIO.Exception as Exports (throwIO)

parseInt :: Integral a => Text -> Maybe a
parseInt :: forall a. Integral a => Text -> Maybe a
parseInt Text
t' = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall a b. a -> b -> a
const forall a. Maybe a
Nothing) (forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) (forall a. Integral a => Reader a
TR.decimal Text
t')

headMay :: [a] -> Maybe a
headMay :: forall a. [a] -> Maybe a
headMay [] = forall a. Maybe a
Nothing
headMay (a
a : [a]
_) = forall a. a -> Maybe a
Just a
a