Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
{-# LANGUAGE AllowAmbiguousTypes, FlexibleInstances, MultiParamTypeClasses, ScopedTypeVariables, TypeApplications, UndecidableInstances #-}
class Lift' m a b where
lift' :: m a -> b
instance (Applicative m) => Lift' m a (m a) where
lift' = id
instance (Applicative m, Lift' m a b) => Lift' m (x -> a) (m x -> b) where
lift' f = lift' . ((<*>) f)
lift :: forall m a b. (Applicative m, Lift' m a b) => a -> b
lift = lift' . pure @m
main = do
a <- ((lift @IO :: (String -> String -> String) -> (IO String -> IO String -> IO String)) (++)) (pure "Hello, ") (pure "world")
putStrLn a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment