title: Yesod route containing a `Maybe a` argument
body: <p>
  I've been trying to use a <code>Maybe a</code> in a route. So far I tried</p>
  
  <pre class="lang-hs prettyprint-override"><code>/u/#Maybe UserId
  /u/#(Maybe UserId)
  /u/#Maybe-UserId
  </code></pre>
  
  <p>and</p>
  
  <pre class="lang-hs prettyprint-override"><code>/u/#MaybeUserId
  </code></pre>
  
  <p>where</p>
  
  <pre class="lang-hs prettyprint-override"><code>type MaybeUserId = Maybe UserId
  </code></pre>
  
  <p>But without much success.</p>
  
  <p>Strangely enough, <code>#Maybe-UserId</code> compiles fine with an handler using <code>Maybe UserId</code> but, it's not able to find a match even with the new <code>PathPiece</code> instance below.</p>
  
  <pre class="lang-hs prettyprint-override"><code>instance (PathPiece a) =&gt; PathPiece (Maybe a) where
      fromPathPiece s = case s of
          "Nothing" -&gt; Nothing
          _ -&gt; Just $ fromPathPiece s
      toPathPiece m = case m of
          Just s -&gt; toPathPiece s
          _ -&gt; "Nothing"
  </code></pre>
  
  <p><del>What am I missing to create <code>Maybe</code> routes and not having to declare an a type and instance for each and every <code>Maybe a</code> that I want to use?</del></p>
  
  <p><del><strong>edit:</strong> The instance works fine when using anything other than <code>Ǹothing</code> for some reason.</del></p>
  
  <p><strong>edit2:</strong> <code>"Nothing" -&gt; Nothing</code> actualy indicates that the <code>PathPiece</code> failed parsing, which is not the desired outcome. <code>"Nothing" -&gt; Just Nothing</code> does the right thing.</p>