Created
May 27, 2021 17:02
-
-
Save nicuveo/d51114800d21bdd1a626ee027d5c15ef to your computer and use it in GitHub Desktop.
TypeApplications bug?
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 AllowAmbiguousTypes #-} | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Foo where | |
import Control.Monad.Reader | |
import Data.Kind (Type) | |
-- non-injective type family | |
class Foo a where | |
type Bar a :: Type | |
-- ambiguous class function | |
class Monad m => MonadFoo m where | |
doTheThing :: forall a. Bar a -> m (Bar a) | |
-- use of type application in function to disambiguate: ok | |
liftFoo :: forall a m t. (MonadFoo m, MonadTrans t) => Bar a -> t m (Bar a) | |
liftFoo v = lift $ doTheThing @m @a v | |
-- use of type application in instance to disambiguate: KO! | |
instance MonadFoo m => MonadFoo (ReaderT r m) where | |
doTheThing :: forall a. Bar a -> ReaderT r m (Bar a) | |
doTheThing = liftFoo @a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment