sqrt $2 p
This calls sqrt
with the function $2
as its argument and then applies the resulting function to the argument p
. This would only makes sense if sqrt
could take a function and produce a function as a result, which would be the case if and only if there was a Floating
instance for functions, which there is not. Thus the error message.
What you doubtlessly intended to do was to apply the function $2
to the argument p
and then apply sqrt
to the result, for which you'd write:
sqrt ($2 p)