
Thanks for the explanations - fully understood. Tony Morris http://tmorris.net/ Jonathan Cast wrote:
On Tuesday 10 July 2007, Tony Morris wrote:
Thanks Don, Is your explanation specific to maybe? Or does that apply to all functions?
Suppose the following function for lists:
f :: [a] -> b -> (a -> [a] -> b) -> b
...instead of pattern matching [] and (x:xs)
Of course. GHC doesn't know anything about maybe; all it sees is:
1. One-liner:
maybe f x mb = case mb of { Just x' -> f x'; Nothing -> x }
2. Non-recursive
And it inlines like crazy. If you had quite a large data type, the number of case alternatives /might/ put you over GHC's inlining threshold, but that (ridiculous) scenario is the only thing that'll keep the argument from generalizing to your use case.
<snip>
Jonathan Cast http://sourceforge.net/projects/fid-core http://sourceforge.net/projects/fid-emacs _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe