title: Elegant way to combine multiple filtering functions in Haskell
body: <p>Given the following filtering functions as unary predicates,</p>
  <pre class="lang-hs prettyprint-override"><code>f1 :: Int -&gt; Bool
  f1 x = x &gt; 30
  
  f2 :: Int -&gt; Bool
  f2 x = x &lt; 60
  
  f3 :: Int -&gt; Bool
  f3 x = x `mod` 3 == 0
  </code></pre>
  <p>I'd like to filter a list of integers through all of them. Currently I'm doing something along the lines of:</p>
  <pre class="lang-hs prettyprint-override"><code>filtered = filter f1 $ filter f2 $ filter f3 [1..90]
  -- [33,36,39,42,45,48,51,54,57]
  </code></pre>
  <p>but it hardly feels like this is the most elegant solution possible; especially I don't like the multiple repetitions of <code>filter</code> and the lack of composability.</p>
  <p>Would there be a way to compose all these predicates into one, let's name it <code>&lt;?&gt;</code>, so that a possible syntax would resemble something like the following?</p>
  <pre class="lang-hs prettyprint-override"><code>filtered = filter (f1 &lt;?&gt; f2 &lt;?&gt; f3) [1..90]
  -- [33,36,39,42,45,48,51,54,57]
  </code></pre>
  <p>The type signature of this hypothetical <code>&lt;?&gt;</code> operator would then be <code>(a -&gt; Bool) -&gt; (a -&gt; Bool) -&gt; (a -&gt; Bool)</code> but <a href="https://hoogle.haskell.org/?hoogle=(a%20-%3E%20Bool)%20-%3E%20(a%20-%3E%20Bool)%20-%3E%20(a%20-%3E%20Bool)" rel="noreferrer">I wasn't able to find any such thing</a> on Hoogle.</p>