Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.