This is due to the restriction of monomorphism. When the compiler checks the top-level binding without annotating the type, it will not assign a polymorphic type if that type has a constraint and the function does not have a syntactic argument, which is the case for both of your functions.
However, if you do not include the type signature, it still does not compile. In your case, you provided him with additional information (part of foo = [app, _] ) and for some reason decided to choose a monomorphic type - I do not know what has changed in your environment, but this is not standard behavior.
Here is a simple file that redirects the problem you are having:
{-
If you comment out either a type signature, or both, you will encounter an error. However, comment out any signature of the top-level type, but run it with ghc -XNoMonomorphismRestriction Test.hs and it will be successfully compiled in each configuration. Here are a few tests ,
user2407038
source share