PUBLIC
Hi,
I’d like to instantiate Core definitions. For example, suppose I have the following Core definition:
foo :: forall m a b. Monad m => m a -> m b -> m b
foo = \ @m ($d :: Monad m) @a @b (ma :: m a) (mb :: m b) -> ...
Now let’s say I’d like to instantiate it for m ~ IO. It is quite straightforward to go from the above to:
foo_IO_0 :: forall a b. Monad IO => IO a -> IO b -> IO b
foo_IO_0 = \ ($d :: Monad IO) @a @b (ma :: IO a) (mb :: IO b) -> ...
However, I would like to go all the way to:
foo_IO :: forall a b. IO a -> IO b -> IO b
foo_IO = \ @a @b (ma :: IO a) (mb :: IO b) -> ...
Because instances are coherent, it should be sound to replace all occurrences of
$d with “the” dictionary for
Monad IO. However, the places I’ve found for this kind of query seem to live in the typechecker. How do I access this information
while working with Core?
Thanks,
Gergo