Applying Function Passed as Argument to Different Types in Haskell
<p>Is there any way to apply a function passed as an argument to two different types? As a contrived example, I can create a <code>(Maybe Int, Maybe Bool)</code> with the expression <code>(Just 3, Just True)</code>, but if I try to make this behaviour more generic with the function</p>

<pre><code>generic :: (a -&gt; Maybe a) -&gt; (Maybe Int, Maybe Bool)
generic f = (f 3, f True)
</code></pre>

<p>so that I might be able to do something like <code>generic Just</code>, the compiler complains because the type variable <code>a</code> is constant.</p>

<p>The use case of this is applying a generic function to a tree structure where each node is parametrized by a type.</p>