Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewthad/9b6ef0e8621a23e858b55da79066e88e to your computer and use it in GitHub Desktop.
Save andrewthad/9b6ef0e8621a23e858b55da79066e88e to your computer and use it in GitHub Desktop.
Confusing behavior of Implicit Params
{-# LANGUAGE ImplicitParams #-}
example1 :: (?a :: Int) => [Int]
example1 = let ?a = 4 in [foo,bar + bar,(?a + 3) + (?a + 3)]
where
foo = bar + bar
bar = ?a + 3
example2 :: (?a :: Int) => [Int]
example2 = let ?a = 4 in [foo,bar + bar,(?a + 3) + (?a + 3)]
where
foo :: (?a :: Int) => Int
foo = bar + bar
bar :: (?a :: Int) => Int
bar = ?a + 3
main :: IO ()
main = do
print (let ?a = 11 in example1)
print (let ?a = 11 in example2)
-- $ ./implicit_badness
-- [28,28,14]
-- [14,14,14]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment