<div dir="ltr"><div>Foreign.Ptr provides nullPtr. It would make some of my code more terse if this was additionally provided as a pattern synonym. The pattern synonym can be defined as:</div><div><br></div><div>    {-# language ViewPatterns #-}<br>    {-# language PatternSynonyms #-}<br>    module NullPointerPattern<br>      ( pattern Null<br>      ) where<br>    import Foreign.Ptr (Ptr,nullPtr)<br>    pattern Null :: Ptr a<br>    pattern Null <- ((\x -> x == nullPtr) -> True)<br>      where Null = nullPtr</div><div><br></div><div>Any here is example of code that becomes more terse once this is available:</div><div><br></div><div>    foo :: IO (Either Error (Ptr Foo))</div><div>    foo = do</div><div>      p <- initialize mySettings</div><div>      if p == nullPtr</div><div>        then pure (Left InitializeFailure)<br></div><div>        else pure (Right p)</div><div><br></div><div>With the pattern synonym, we are able to take advantage of LambdaCase:</div><div><br></div><div><div>    foo :: IO (Either Error (Ptr Foo))</div><div>    foo = initialize mySettings >>= \case</div><div>      Null -> pure (Left InitializeFailure)<br></div><div>      p -> pure (Right p)</div></div><div><div><br></div><div>I'm curious what others think.<br></div><div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">-Andrew Thaddeus Martin</div></div></div></div>