Skip to content

Instantly share code, notes, and snippets.

@nghamilton
Created August 13, 2024 05:53
Show Gist options
  • Save nghamilton/551cd612390336a4a4d9fedd81fe0023 to your computer and use it in GitHub Desktop.
Save nghamilton/551cd612390336a4a4d9fedd81fe0023 to your computer and use it in GitHub Desktop.
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE DeepSubsumption #-}
import Prelude
main :: IO ()
main = let ?implicit = "yeah" in flipOut printImplicit
where
printImplicit :: (?implicit :: String) => IO ()
printImplicit = putStrLn ?implicit
f :: forall a b. (?implicit :: String) => b -> ((?implicit :: String) => a) -> a
f _wotevs i = let ?implicit = "nah" in i
-- Using `flip` produces a different result.
flipOut :: (?implicit :: String) => ((?implicit :: String) => a) -> a
flipOut a = flip f a undefined
flipOut a = f undefined a
@nghamilton
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment