{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans      #-}
{-|
 This module provides a conversion function between a
 'Flake' and a strict 'ByteString'.  The 'ByteString'
 is the series of bytes that make up the 'Flake', with
 the lower bytes being in the lower indecies.
-}

module Data.Snowchecked.Encoding.ByteString
	( module Data.Snowchecked.Encoding.Class
	) where

import           Data.ByteString
import           Data.Snowchecked.Encoding.ByteString.Lazy ()
import           Data.Snowchecked.Encoding.Class

instance IsFlake ByteString where
	fromFlake :: Flake -> ByteString
fromFlake = ByteString -> ByteString
toStrict forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsFlake a => Flake -> a
fromFlake
	{-# INLINE fromFlake #-}

	parseFish :: forall (m :: * -> *).
MonadFail m =>
SnowcheckedConfig -> ByteString -> m Flakeish
parseFish SnowcheckedConfig
cfg ByteString
bs = forall a (m :: * -> *).
(IsFlake a, MonadFail m) =>
SnowcheckedConfig -> a -> m Flakeish
parseFish SnowcheckedConfig
cfg forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString
fromStrict ByteString
bs
	{-# INLINE parseFish #-}