[Haskell-beginners] [web-devel] yesod database select all rows?

Michael Snoyman michael at snoyman.com
Mon Jun 27 05:52:47 CEST 2011


On Mon, Jun 27, 2011 at 2:20 AM, Eric Schug <schugschug at gmail.com> wrote:
> Hello,
> It does not seem obvious to me how to perform the equivalent of
>
> SELECT * FROM table_name
> SELECT field1,field2 FROM table_name
>
> examples show something of the form
> rows <- runDB $ selectList [ Field1Eq value1, Field2Gt value2] [ ] 0 0
> But I don't see how the name of the table is determined nor how to select
> additional fields to extract.
>
> What would this do?
> rows <- runDB $ selectList [ ] [ ] 0 0

This all has to do with Haskell type trickery. If GHC can determine
the expected type of rows based on how you use it, it will work. If it
can't, it will complain about ambiguous types. If you want to select
from the Person entity, you can do something like:

    rows <- runDB $ selectList ([] :: [Filter Person]) [] 0 0

Michael



More information about the Beginners mailing list