
Felipe Almeida Lessa wrote:
You may just return countRows as Gaƫl said. However, there's a catch: GHC won't have enough information to typecheck the code and infer which table you're talking about. You'll probably need something such as:
count <- select $ from \(foo :: SqlExpr (Entity Foo)) -> return countRows
Alternatively, you could constraint the type via an unused expression:
count <- select $ from \foo -> let _ = foo ^. FooId -- constraint the type of foo return countRows
Both code snippets are untested. Have fun =).
There are still some problems typing all these and they all still return a list instead of a value whereas the SQL statement returns a single value. Looks like I'll need to dig into the Esqueleto sources. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/