{-# OPTIONS_GHC -Wno-orphans #-}

module Data.Function.FastMemo.ByteString () where

import qualified Data.ByteString as SBS
import qualified Data.ByteString.Lazy as LBS
import Data.Function.FastMemo.Class (Memoizable (..))
import Data.Function.FastMemo.Word ()

instance Memoizable SBS.ByteString where
  memoize :: (ByteString -> b) -> ByteString -> b
memoize ByteString -> b
f = ([Word8] -> b) -> [Word8] -> b
forall a b. Memoizable a => (a -> b) -> a -> b
memoize (ByteString -> b
f (ByteString -> b) -> ([Word8] -> ByteString) -> [Word8] -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Word8] -> ByteString
SBS.pack) ([Word8] -> b) -> (ByteString -> [Word8]) -> ByteString -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [Word8]
SBS.unpack

instance Memoizable LBS.ByteString where
  memoize :: (ByteString -> b) -> ByteString -> b
memoize ByteString -> b
f = ([Word8] -> b) -> [Word8] -> b
forall a b. Memoizable a => (a -> b) -> a -> b
memoize (ByteString -> b
f (ByteString -> b) -> ([Word8] -> ByteString) -> [Word8] -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Word8] -> ByteString
LBS.pack) ([Word8] -> b) -> (ByteString -> [Word8]) -> ByteString -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [Word8]
LBS.unpack