title: State transformer: need a Nothing in a (Maybe Bool)
body: <p>This is from the nicta course (hence <code>List = [], Optional = Maybe, ...</code>), so I'm not looking for a full solution, but I am stuck on a State Transformer question. The aim is to filter duplicates from a List and completely fail if passed any number > 100.</p>
  
  <pre><code>-- filtering :: Applicative f =&gt; (a -&gt; f Bool) -&gt; List a -&gt; f (List a)
  
  distinctF :: (Ord a, Num a) =&gt; List a -&gt; Optional (List a)
  distinctF lst = case runStateT (filtering go lst) S.empty of
    Full (val, _) -&gt; Full val
    Empty         -&gt; Empty
    where
      --go :: a -&gt; StateT (S.Set a) Optional Bool
      go x = do
        s &lt;- getT
        if x &gt; 100 then do
          return *?*Empty / False*?*
  </code></pre>
  
  <p>This typechecks while <code>go = undefined</code>, but I'm struggling to put <code>Empty</code> into as <code>return</code> wraps e.g. <code>False</code> in a <code>Full/Just</code>. <code>fail</code> gets me someway forward but I don't think that is the solution.</p>
  
  <p>In practice I am probably missing a more important issue and would welcome enlightenment.</p>