{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans -O0 #-} {-# OPTIONS_GHC -Wno-unused-top-binds #-} module EmbedTest (specsWith, cleanDB, embedMigrate) where import Control.Exception (Exception, throw) import Data.List.NonEmpty hiding (insert, length) import qualified Data.Map as M import qualified Data.Text as T import qualified Data.Set as S import EntityEmbedTest import Init data TestException = TestException deriving (Int -> TestException -> ShowS [TestException] -> ShowS TestException -> String (Int -> TestException -> ShowS) -> (TestException -> String) -> ([TestException] -> ShowS) -> Show TestException forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [TestException] -> ShowS $cshowList :: [TestException] -> ShowS show :: TestException -> String $cshow :: TestException -> String showsPrec :: Int -> TestException -> ShowS $cshowsPrec :: Int -> TestException -> ShowS Show, TestException -> TestException -> Bool (TestException -> TestException -> Bool) -> (TestException -> TestException -> Bool) -> Eq TestException forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: TestException -> TestException -> Bool $c/= :: TestException -> TestException -> Bool == :: TestException -> TestException -> Bool $c== :: TestException -> TestException -> Bool Eq) instance Exception TestException instance PersistFieldSql a => PersistFieldSql (NonEmpty a) where sqlType :: Proxy (NonEmpty a) -> SqlType sqlType Proxy (NonEmpty a) _ = SqlType SqlString instance PersistField a => PersistField (NonEmpty a) where toPersistValue :: NonEmpty a -> PersistValue toPersistValue = [a] -> PersistValue forall a. PersistField a => a -> PersistValue toPersistValue ([a] -> PersistValue) -> (NonEmpty a -> [a]) -> NonEmpty a -> PersistValue forall b c a. (b -> c) -> (a -> b) -> a -> c . NonEmpty a -> [a] forall a. NonEmpty a -> [a] toList fromPersistValue :: PersistValue -> Either Text (NonEmpty a) fromPersistValue PersistValue pv = do [a] xs <- PersistValue -> Either Text [a] forall a. PersistField a => PersistValue -> Either Text a fromPersistValue PersistValue pv case [a] xs of [] -> Text -> Either Text (NonEmpty a) forall a b. a -> Either a b Left Text "PersistField: NonEmpty found unexpected Empty List" (a l:[a] ls) -> NonEmpty a -> Either Text (NonEmpty a) forall a b. b -> Either a b Right (a la -> [a] -> NonEmpty a forall a. a -> [a] -> NonEmpty a :|[a] ls)