Skip to content

Problem with type inference caused by ! defaults #15

@Unisay

Description

@Unisay

I have the following function declared in my typeclass:
https://github.com/DSTOQ/haskell-stellar-client/blob/master/src/Control/Monad/Stellar.hs#L26

When calling it in this way:

lastAccountTransaction :: MonadStellar m => AccountId -> m Transaction
lastAccountTransaction accountId = do
  let txs = accountTransactions accountId
          ! #cursor Nothing
          ! #limit Nothing
          ! #order Nothing

all compiles well,
but if only I try to use ! defaults, I get the following error:

      • Could not deduce (MonadStellar m0)
            arising from a use of ‘accountTransactions’
          from the context: MonadStellar m
            bound by the type signature for:
                       lastAccountTransaction :: forall (m :: * -> *).
                                                 MonadStellar m =>
                                                 AccountId -> m Transaction
            at src/Service/Domain/Offer.hs:40:1-70
          The type variable ‘m0’ is ambiguous
          These potential instances exist:
            instance Control.Monad.Rest.MonadRest m =>
                     MonadStellar (StellarT m)
              -- Defined in ‘Control.Monad.Trans.Stellar’
            instance MonadStellar m => MonadStellar (ExceptT e m)
              -- Defined in ‘Control.Monad.Stellar’
            instance MonadStellar m => MonadStellar (StateT s m)
              -- Defined in ‘Control.Monad.Stellar’
            ...plus four instances involving out-of-scope types
            (use -fprint-potential-instances to see them all)
        • In the first argument of ‘(!)’, namely
            ‘accountTransactions accountId’
          In the expression: accountTransactions accountId ! defaults
          In an equation for ‘txs’:
              txs = accountTransactions accountId ! defaults

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions