{-# OPTIONS_GHC -Wno-orphans #-} module Data.Function.FastMemo.Vector () where import Data.Function.FastMemo.Class (Memoizable (..)) import qualified Data.Vector as V import qualified Data.Vector.Storable as SV import qualified Data.Vector.Unboxed as UV instance Memoizable a => Memoizable (V.Vector a) where memoize :: (Vector a -> b) -> Vector a -> b memoize Vector a -> b f = ([a] -> b) -> [a] -> b forall a b. Memoizable a => (a -> b) -> a -> b memoize (Vector a -> b f (Vector a -> b) -> ([a] -> Vector a) -> [a] -> b forall b c a. (b -> c) -> (a -> b) -> a -> c . [a] -> Vector a forall a. [a] -> Vector a V.fromList) ([a] -> b) -> (Vector a -> [a]) -> Vector a -> b forall b c a. (b -> c) -> (a -> b) -> a -> c . Vector a -> [a] forall a. Vector a -> [a] V.toList instance (SV.Storable a, Memoizable a) => Memoizable (SV.Vector a) where memoize :: (Vector a -> b) -> Vector a -> b memoize Vector a -> b f = ([a] -> b) -> [a] -> b forall a b. Memoizable a => (a -> b) -> a -> b memoize (Vector a -> b f (Vector a -> b) -> ([a] -> Vector a) -> [a] -> b forall b c a. (b -> c) -> (a -> b) -> a -> c . [a] -> Vector a forall a. Storable a => [a] -> Vector a SV.fromList) ([a] -> b) -> (Vector a -> [a]) -> Vector a -> b forall b c a. (b -> c) -> (a -> b) -> a -> c . Vector a -> [a] forall a. Storable a => Vector a -> [a] SV.toList instance (UV.Unbox a, Memoizable a) => Memoizable (UV.Vector a) where memoize :: (Vector a -> b) -> Vector a -> b memoize Vector a -> b f = ([a] -> b) -> [a] -> b forall a b. Memoizable a => (a -> b) -> a -> b memoize (Vector a -> b f (Vector a -> b) -> ([a] -> Vector a) -> [a] -> b forall b c a. (b -> c) -> (a -> b) -> a -> c . [a] -> Vector a forall a. Unbox a => [a] -> Vector a UV.fromList) ([a] -> b) -> (Vector a -> [a]) -> Vector a -> b forall b c a. (b -> c) -> (a -> b) -> a -> c . Vector a -> [a] forall a. Unbox a => Vector a -> [a] UV.toList