Changes between Version 1 and Version 2 of Holes
 Timestamp:
 Feb 9, 2012 8:05:23 PM (6 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Holes
v1 v2 39 39 {{{ 40 40 test :: [Bool] 41 test = undefined : undefined : []41 test = undefined : (undefined ++ []) 42 42 }}} 43 43 … … 49 49 Same example: 50 50 {{{ 51 test = ?a : ?b : []51 test = ?a : (?b ++ []) 52 52 }}} 53 53 … … 55 55 56 56 {{{ 57 > :t let test = ?a : ?b : []in test :: [Bool]58 let test = ?a : ?b : []in test :: [Bool]59 :: (?a::Bool, ?b:: Bool) => [Bool]57 > :t let test = ?a : (?b ++ []) in test :: [Bool] 58 let test = ?a : (?b ++ []) in test :: [Bool] 59 :: (?a::Bool, ?b::[Bool]) => [Bool] 60 60 }}} 61 61 … … 63 63 64 64 {{{ 65 test.hs: 5:8:65 test.hs:4:8: 66 66 Unbound implicit parameter (?a::Bool) 67 67 arising from a use of implicit parameter `?a' 68 68 In the first argument of `(:)', namely `?a' 69 In the expression: ?a : ?b : []70 In an equation for `test': test = ?a : ?b : []69 In the expression: ?a : (?b ++ []) 70 In an equation for `test': test = ?a : (?b ++ []) 71 71 72 test.hs: 5:13:73 Unbound implicit parameter (?b:: Bool)72 test.hs:4:14: 73 Unbound implicit parameter (?b::[Bool]) 74 74 arising from a use of implicit parameter `?b' 75 In the first argument of `( :)', namely `?b'76 In the second argument of `(:)', namely ` ?b : []'77 In the expression: ?a : ?b : []75 In the first argument of `(++)', namely `?b' 76 In the second argument of `(:)', namely `(?b ++ [])' 77 In the expression: ?a : (?b ++ []) 78 78 Failed, modules loaded: none. 79 79 }}} 80 80 81 This will show you the type, however, it does consider it an error and fails, so there may be other problems you don't get to see because of it. It also will refuse to load and compile the module, so it's impossible to run the parts of it that are finished. So to correctly use it here, the function would have to be written as: 81 This will show you the type, however, it does consider it an error and fails, so there may be other problems you don't get to see because of it. It also will refuse to load and compile the module, so it's impossible to run the parts of it that are finished. 82 83 The reason is that the hole becomes a part of the type signature, as a constraint. So to correctly use it here, the function would have to be written as: 82 84 83 85 {{{ 84 test :: (?a::Bool, ?b:: Bool) => [Bool]85 test = ?a : ?b : []86 test :: (?a::Bool, ?b::[Bool]) => [Bool] 87 test = ?a : (?b ++ []) 86 88 }}} 87 89 88 This makes it very impractical to use them as holes, as you have to update this yourself to let the typechecker continue. If this wasn't bad enough, implicit parameters propagate upwards: if another function were to call {{{test}}}, it would show the same implicit parameters (and therefore, all of their type signatures have to be updated if you introduce a new hole). Another tricky problem with implicit parameters is that implicit parameters with the same name in different functions are not assumed to be the same parameter (i.e., required to be unifiable), ''except'' if some function has both implicit parameters in its constraints (so calls them both, possibly indirectly). Lastly, it's impossible to run code with unbound implicit parameters, even if the parameters are never actually used.90 This makes it very impractical to use them as holes, as all type signatures have to be updated to let the typechecker continue. Not only in the functions that use the implicit parameter itself, but they propagate upwards, just like class constraints: if another function were to call {{{test}}}, it would have the same implicit parameters (and therefore, all of these type signatures would have to be updated when a new hole is added). Another tricky problem with implicit parameters is that implicit parameters with the same name in different functions are not assumed to be the same parameter (i.e., required to be unifiable), ''except'' if some function has both implicit parameters in its constraints. Lastly, it's impossible to run code with unbound implicit parameters, even if the parameters are never actually used. 89 91 90 92 