title: Why does unsafePartial not work with a simple functor in PureScript?
body: <p>Unless I've made some simple error, the following pieces of code should be functionally identical:</p>
  
  <pre><code>-- This code does not compile
  pg :: forall a. PG a -&gt; Route a
  pg sql = connect $ apply (runPG sql) (unsafePartial &lt;&lt;&lt; fromJust &lt;$&gt; getConnection)
  
  -- This code does not compile
  pg sql = connect $ do
      connection &lt;- unsafePartial &lt;&lt;&lt; fromJust &lt;$&gt; getConnection
      runPG sql connection
  
  -- This code does work
  pg sql = connect $ do
     connection &lt;- getConnection
     runPG sql $ unsafePartial $ fromJust connection
  </code></pre>
  
  <p>To help understand this, here are the relevant types:</p>
  
  <pre><code>-- Route has a MonadAff instance and all the usual stuff
  newtype Route a = Route (ReaderT RouteState Aff a)
  
  -- `connect` makes a connection to Postgres and injects it into the environment.
  connect :: forall a. Route a -&gt; Route a 
  
  getConnection :: Route (Maybe Connection)
  
  -- PG has a MonadAff instance and all the usual stuff
  newtype PG a = PG (ReaderT Connection Aff a)
  
  runPG :: forall m a. MonadAff m =&gt; PG a -&gt; Connection -&gt; m a
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>Error found:
      in module AWS.Lambda.Router
      at src/AWS/Lambda/Router.purs:176:70 - 176:83 (line 176, column 70 - line 176, column 83)
  
        Could not match constrained type
  
          Partial =&gt; t1
  
        with type
  
          { client :: Client
          , pool :: Pool    
          }                 
  
  
      while trying to match type { client :: Client
                                 , pool :: Pool    
                                 }                 
        with type Partial =&gt; t1
      while checking that expression getConnection
        has type t0 (Maybe (Partial =&gt; t1))
      in value declaration pg
  
      where t0 is an unknown type
            t1 is an unknown type
  
      See https://github.com/purescript/documentation/blob/master/errors/ConstrainedTypeUnified.md for more information,
      or to contribute content related to this error.
  
  
      spago: Failed to build.
  </code></pre>
  
  <p>I think one of two things is going on here. Either I'm making some dumb syntax error or I don't understand <code>Partial</code> as I thought I did, although it seems pretty straightforward.</p>