Created
June 13, 2017 14:05
-
-
Save andrewthad/9b6ef0e8621a23e858b55da79066e88e to your computer and use it in GitHub Desktop.
Confusing behavior of Implicit Params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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