As a naive implementation of "all" and "any", one of my students coped with
these definitions:
any' p xs = [x | x <- xs, p x] /= []
all' p xs = [x | x <- xs, p x] == xs
As expected, the type for any' is Eq a => (a -> Bool) -> [a] -> Bool because
of the use of ==. Nevertheless, the definition of all' does not type check:
a b is not an instance of class "Eq" (hugs 1.4)
No instance for: `Eq (aaKb taKd)'
arising from use of `==' at kk.hs:10 (ghc 2.10)
but it does in ghc 0.29... However, if you include the type annotation for all'
it works fine.
all' :: Eq a => (a -> Bool) -> [a] -> Bool
all' p xs = [x | x <- xs, p x] == xs
Any (simple) answer? (I'm afraid monad stuff, aggh)... I have many ML-minded
students
blaming at hugs because is not able to print the result of evaluating [] without
a type
annotation 8( ...
Thanks in advance,
Victor M. Gulias