mmzk-typeid-0.4.0.1: src/Data/KindID/V1/Unsafe.hs
-- |
-- Module : Data.KindID.V1.Unsafe
-- License : MIT
-- Maintainer : mmzk1526@outlook.com
-- Portability : GHC
--
-- Unsafe 'KindIDV1' functions.
--
module Data.KindID.V1.Unsafe
(
-- * Unsafe 'KindIDV1' decoding ('KindIDV1'-specific)
unsafeParseString
, unsafeParseText
, unsafeParseByteString
-- * Unsafe 'KindIDV1' decoding (class methods)
, unsafeString2ID
, unsafeText2ID
, unsafeByteString2ID
-- * Unsafe conversion
, unsafeFromTypeID
) where
import Data.ByteString.Lazy (ByteString)
import Data.KindID.Class
import Data.KindID.Internal (KindID')
import qualified Data.KindID.Internal as KID
import Data.KindID.V1 (KindIDV1)
import Data.TypeID.Internal (TypeID')
import Data.TypeID.V1 (TypeIDV1)
import Data.Text (Text)
import Data.TypeID.Class
-- | Parse a 'KindIDV1' from its 'String' representation, but does not behave
-- correctly when parsing fails.
--
-- More specifically, if the prefix does not match, it will not complain and
-- produce the wrong 'KindIDV1'. If there are other parse errors, it will crash.
unsafeParseString :: (ToPrefix prefix, ValidPrefix (PrefixSymbol prefix))
=> String -> KindIDV1 prefix
unsafeParseString = KID.unsafeParseString
{-# INLINE unsafeParseString #-}
-- | Parse a 'KindIDV1' from its string representation as a strict 'Text', but
-- does not behave correctly when parsing fails.
--
-- More specifically, if the prefix does not match, it will not complain and
-- produce the wrong 'KindIDV1'. If there are other parse errors, it will crash.
unsafeParseText :: (ToPrefix prefix, ValidPrefix (PrefixSymbol prefix))
=> Text -> KindIDV1 prefix
unsafeParseText = KID.unsafeParseText
{-# INLINE unsafeParseText #-}
-- | Parse a 'KindIDV1' from its string representation as a lazy 'ByteString',
-- but does not behave correctly when parsing fails.
--
-- More specifically, if the prefix does not match, it will not complain and
-- produce the wrong 'KindIDV1'. If there are other parse errors, it will crash.
unsafeParseByteString :: (ToPrefix prefix, ValidPrefix (PrefixSymbol prefix))
=> ByteString -> KindIDV1 prefix
unsafeParseByteString = KID.unsafeParseByteString
{-# INLINE unsafeParseByteString #-}
-- | Convert a 'TypeIDV1' to a 'KindIDV1'. If the actual prefix does not match
-- with the expected one as defined by the type, it does not complain and
-- produces a wrong 'KindIDV1'.
unsafeFromTypeID :: (ToPrefix prefix, ValidPrefix (PrefixSymbol prefix))
=> TypeIDV1 -> KindIDV1 prefix
unsafeFromTypeID = KID.unsafeFromTypeID
{-# INLINE unsafeFromTypeID #-}