
13 Mar
2012
13 Mar
'12
4:24 a.m.
Kevin Clees
Now my function looks like this:
tmp:: [(Int, Int)] -> Int -> (Int, Int) tmp [] y = (0,0) ^^^^^ tmp xs y = xs !! (y-1)
If the function returns (0,0) it will blocked by another function.
Personally, I think using "special" values like this is a code smell, and indicates poor design. There are many implicit assumptions, for instance that (0,0) isn't already a member of the input list, and that this is correctly handled by surrounding functions. Generally, it's much more desirable to encode this in the types, so I would vastly prefer the Maybe solution in almost all cases, which makes these assumptions explicit. -k -- If I haven't seen further, it is by standing in the footprints of giants