<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Well, there obviously is a problem in
your example code. The argument "tableName" does not live in the
world of types, so <i>SqlExpr (Entity tableName)</i> is
meaningless (this barrier is getting fuzzier with each version of
GHC, but well...).<br>
<br>
Perhaps something can be done with existential types ?<br>
<br>
Le 24/11/12 12:07, Erik de Castro Lopo a écrit :<br>
</div>
<blockquote
cite="mid:20121124220731.b1a0260f0410cf1518cf07e1@mega-nerd.com"
type="cite">
<pre wrap="">Hi all,
Below my .sig is a little Persist/Esqueleto program that works correctly.
The getUserCount function does thr right thing and returns the number of
rows in the User table. However, what I'd like is a generic function
that returns the row count of any table, something vaguely like this:
queryRowCount :: tableType -> SqlPersist IO Int64
queryRowCount tableName = do
[Value x] <- select . from $ \(_ :: SqlExpr (Entity tableName)) ->
return countRows
return x
Is there any way to do this? Its probably possible in Agda, but can it
be made to work with GHC?
Cheers,
Erik
</pre>
</blockquote>
<br>
</body>
</html>