Last active
July 29, 2024 14:31
-
-
Save ramirez7/41e7f4e48eb00de20c0b52911d62904a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE DataKinds #-} | |
import GHC.TypeLits | |
newtype SqlT m a = SqlT (m a) | |
deriving stock (Functor) | |
deriving newtype (Applicative, Monad) | |
runSqlT :: CanRunSqlT m => SqlT m a -> m a | |
runSqlT (SqlT ma) = ma | |
class CanRunSqlT m | |
instance {-# OVERLAPPABLE #-} CanRunSqlT m | |
instance TypeError (Text "Cannot runSqlT to SqlT") => CanRunSqlT (SqlT m) | |
{- | |
ghci> runSqlT (SqlT (pure ())) :: IO () | |
ghci> runSqlT (SqlT (SqlT (pure ()))) :: SqlT (SqlT IO) () | |
<interactive>:14:1: error: [GHC-64725] | |
• Cannot runSqlT to SqlT | |
• In the expression: | |
runSqlT (SqlT (SqlT (pure ()))) :: SqlT (SqlT IO) () | |
In an equation for ‘it’: | |
it = runSqlT (SqlT (SqlT (pure ()))) :: SqlT (SqlT IO) () | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment