Type problem

57 views
Skip to first unread message

Magicloud Magiclouds

unread,
Jul 5, 2013, 3:52:02 AM7/5/13
to yeso...@googlegroups.com
I have a function as:

hsNames ::
      forall (m :: * -> *). (PersistQuery m,
                             PersistMonadBackend m ~ SqlBackend) =>
      [(String,
        [String],
        Text -> Text -> UTCTime -> UTCTime -> m [[Value]])]

Then I was using it in a handler:

let (_, fs, _) = head hsNames

I got:

    Couldn't match expected type `persistent-1.2.1:Database.Persist.Sql.Types.SqlBackend'
                with actual type `PersistMonadBackend m0'
    The type variable `m0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    In the second argument of `head', namely `hsNames'
-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.

Michael Snoyman

unread,
Jul 5, 2013, 6:27:18 AM7/5/13
to yeso...@googlegroups.com
It's saying that you're not using the third element in the tuple, and therefore it doesn't know what the type variable `m` means. I've written up a short example on SoH to better demonstrate:



--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Magicloud Magiclouds

unread,
Jul 5, 2013, 9:10:15 AM7/5/13
to yeso...@googlegroups.com
I tried to give it a type signature, but failed. Last time I met this issue with exactly the same types, was because I missed calling runDB. But here, how to resolve?

Michael Snoyman

unread,
Jul 7, 2013, 4:03:18 AM7/7/13
to yeso...@googlegroups.com
I don't know, you haven't told us what type signature you tried to provide.

Magicloud Magiclouds

unread,
Jul 7, 2013, 9:18:17 PM7/7/13
to yeso...@googlegroups.com
Ah, sorry, it was the type signature for the third one.

let (_, fs, (_ :: What should be here)) = head hsNames

Michael Snoyman

unread,
Jul 8, 2013, 1:08:00 AM7/8/13
to yeso...@googlegroups.com
OK... what type signature did you try to put in there?

Magicloud Magiclouds

unread,
Jul 8, 2013, 5:16:54 AM7/8/13
to yeso...@googlegroups.com
I have no idea, because it was not used, so anything compilable is fine.
Reply all
Reply to author
Forward
0 new messages