Vagif Verdi | 1 Nov 06:17 2011
Picon

Re: Adding custom application-specific config settings

Bump on this. It looks like putting AppConfig into a library was a
mistake. AppConfig often will be custom for every application.

On Oct 29, 6:01 am, Luite Stegeman <stege...@...> wrote:
> hi all,
>
> We just got a question in #yesod from a user (alistra) who wants to
> add extra configuration settings to a Yesod application, the values of
> which should be read from a .yml file at startup.
>
> In the old scaffold I'd just add a field toAppConfig, but it looks
> like that would require a lot of code duplication with the new one.
> Maybe I'm missing something, since I'm not that familiar with the new
> scaffold yet.
>
> What's the best way to do this with the new scaffold? I couldn't find
> any documentation on this, so I'd like to make it a cookbook example.
>
> luite

Ilya Portnov | 1 Nov 07:34 2011
Picon

Announce: persistent-hssqlppp 0.1

Hello Yesod world.

I'm glad to announce «Persistent-HsSqlPpp», a small package which
should simplify using complex SQL queries from Persistent (and Yesod).
As it name says, it uses HsSqlPpp package for SQL parsing and
manipulations with SQL AST.

persistent-hssqlppp on hackage: http://hackage.haskell.org/package/persistent-hssqlppp
git repo: http://gitorious.org/persistent-hssqlppp/
hssqlppp: http://hackage.haskell.org/package/hssqlppp

Main idea is that you describe your queries in usual SQL syntax and
use persistent-hssqlppp to generate EntityDef and QueryExpr
declarations from them. Then you pass that EntityDef to usual
Persistent's functions (like `share') to declare PersistEntity
instance. QueryExpr represents AST (abstract syntax tree) of your
query and is passed to selectFromQuery function, which returns list of
entities, selected by query.

Column types declarations (passed after delimiter ------ line) are
used to construct valid EntityDef (and then declare a valid
PersistEntity instance). Some types are inferred automatically, for
example, COUNT(…) is always Int. But for most columns you need to
specify types.

Note that usual Persistent selectList, insert, update etc functions
will not work with declared-from-query entities. For example, let's
consider you have

> (query, entity) = [persistSql|
(Continue reading)

Max Cantor | 1 Nov 08:58 2011
Picon

Prepopulated email field in email login (AuthR LoginR)

it would be nice if we could send a login link in the form:
http://myserver/auth/login?e=max-PmGiQ3U1+UDQT0dZR+AlfA <at> public.gmane.org and have the email
field repopulated.

any other interest?

max

Greg Weber | 1 Nov 08:57 2011

Re: Re: Adding custom application-specific config settings

Personally I had mixed feelings about moving AppConfig out of the scaffolded code and am open to the idea of putting it back in by default. However, it should now be in yesod-default. yesod-default is meant to be about the same code as the scaffolding. One can achieve the same effect of customizeable scaffold code by simply copy and pasting the definitions out of yesod-default. Perhaps in this case that won't work as well and multiple functions that use AppConfig will also need to be copied in?

On Mon, Oct 31, 2011 at 10:17 PM, Vagif Verdi <vagif.verdi <at> gmail.com> wrote:
Bump on this. It looks like putting AppConfig into a library was a
mistake. AppConfig often will be custom for every application.

On Oct 29, 6:01 am, Luite Stegeman <stege...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> hi all,
>
> We just got a question in #yesod from a user (alistra) who wants to
> add extra configuration settings to a Yesod application, the values of
> which should be read from a .yml file at startup.
>
> In the old scaffold I'd just add a field toAppConfig, but it looks
> like that would require a lot of code duplication with the new one.
> Maybe I'm missing something, since I'm not that familiar with the new
> scaffold yet.
>
> What's the best way to do this with the new scaffold? I couldn't find
> any documentation on this, so I'd like to make it a cookbook example.
>
> luite

Michael Snoyman | 1 Nov 14:18 2011

Re: Announce: persistent-hssqlppp 0.1

On Mon, Oct 31, 2011 at 11:34 PM, Ilya Portnov
<ilya.portnov@...> wrote:
> Hello Yesod world.
>
> I'm glad to announce «Persistent-HsSqlPpp», a small package which
> should simplify using complex SQL queries from Persistent (and Yesod).
> As it name says, it uses HsSqlPpp package for SQL parsing and
> manipulations with SQL AST.
>
> persistent-hssqlppp on hackage: http://hackage.haskell.org/package/persistent-hssqlppp
> git repo: http://gitorious.org/persistent-hssqlppp/
> hssqlppp: http://hackage.haskell.org/package/hssqlppp
>
> Main idea is that you describe your queries in usual SQL syntax and
> use persistent-hssqlppp to generate EntityDef and QueryExpr
> declarations from them. Then you pass that EntityDef to usual
> Persistent's functions (like `share') to declare PersistEntity
> instance. QueryExpr represents AST (abstract syntax tree) of your
> query and is passed to selectFromQuery function, which returns list of
> entities, selected by query.
>
> Column types declarations (passed after delimiter ------ line) are
> used to construct valid EntityDef (and then declare a valid
> PersistEntity instance). Some types are inferred automatically, for
> example, COUNT(…) is always Int. But for most columns you need to
> specify types.
>
> Note that usual Persistent selectList, insert, update etc functions
> will not work with declared-from-query entities. For example, let's
> consider you have
>
>> (query, entity) = [persistSql|
>>     SELECT d.name AS dept,
>>            COUNT(e.id),
>>            AVG(e.salary)
>>     FROM Employee e, Department d
>>     WHERE e.dept = d.id
>>     GROUP BY d.name
>>     ORDER BY d.name
>>     -----------------
>>     dept String
>>     salary Double
>>     |]
>
> …
>
>> share [mkPersist sqlSettings] [entity {entityName = "Stats"}]
>
> Then you can do, for example,
>
>> selectFromQuery query [] :: SqlPersist IO (Either String [Stats])
>
> but you cannot do `selectList [] [] :: SqlPersist IO [Stats]', because
> there is no "Stats" table in the database.
>
> Another limitation is that `persistSql' function (quasiquoter) should
> be called in separate module, in order to pass generated EntityDef to
> `share' function. This is because of GHC stage restriction.
>
> Third limitation is SQL-specific. There is some… hm… feature in SQL:
> if you do, for example, "SELECT table.column AS alias FROM table…",
> then you cannot continue with "… WHERE alias = 25", instead you need
> to write "WHERE table.column = 25". But Persistent (and persistent-
> template) cannot work with qualified column names (you cannot get
> «table.column» and «Table.column» as Haskell identifiers). So, in
> order to work with qualified column names in SELECT queries, you need
> to use column aliases (AS clause). Then persistent-hssqlppp will use
> that aliases as column names (for example, you can get smth like
> «queryAlias» and «QueryAlias»). And then, if you'll use last
> selectFromQuery's argument to add WHERE clause, for example,
>
>> selectFromQuery query [QueryAlias ==. 25]
>
> persistent will generate «SELECT table.column AS alias FROM table
> WHERE alias = 25», which is not valid SQL query :/
>
> So, currently you cannot use aliased columns when adding conditions
> using second argument of selectFromQuery function. But you off cause
> can use any valid WHERE clauses in your SQL queries directly.
>
> WBR, Ilya Portnov.

This looks like a very cool solution for creating complex SQL queries.
Does this work for SQLite, or only PostgreSQL?

Michael

Ilya Portnov | 1 Nov 15:39 2011
Picon

Re: Announce: persistent-hssqlppp 0.1

Hello.

>
> This looks like a very cool solution for creating complex SQL queries.
> Does this work for SQLite, or only PostgreSQL?

I didn't test it with SQLite. It does not content any rdbm-specific 
code, but I'm not sure if sqlite will parse all queries, created by 
hssqlppp (hssqlppp package aims to be generic, but is developed firstly 
for postgresql, afaik). So, one needs to test it with sqlite.

WBR, Ilya Portnov.

Picon

Yesod installation problem

Hi

I am trying to install yesod without succesfull.
MAC OS X 10.6.8
ghc version 7.03 32 bits

I did the following commands:
rm -rf .ghc .cabal
cabal update
cabal install yesod

but Cabal gives me the following messages:

Resolving dependencies...
cabal: cannot configure tls-extra-0.4.1. It requires certificate >=1.0.0 &&
<1.1.0 and cryptocipher >=0.3.0
For the dependency on certificate >=1.0.0 && <1.1.0 there are these 
packages:
certificate-1.0.0. However none of them are available.
certificate-1.0.0 was excluded because http-enumerator-0.7.1.3 requires
certificate >=0.7 && <0.10
For the dependency on cryptocipher >=0.3.0 there are these packages:
cryptocipher-0.3.0. However none of them are available.
cryptocipher-0.3.0 was excluded because clientsession-0.7.3.2 requires
cryptocipher >=0.2.5 && <0.3

Thanks
Francisco

Michael Snoyman | 1 Nov 16:00 2011

Re: Yesod installation problem

As a temporary fix, try running "cabal install tls-extra-0.4.0 &&
cabal install yesod". I'm going to write a separate email to the list
describing the problem.

On Tue, Nov 1, 2011 at 7:31 AM, Francisco José CHAVES ALONSO
<pachopepe@...> wrote:
> Hi
>
> I am trying to install yesod without succesfull.
> MAC OS X 10.6.8
> ghc version 7.03 32 bits
>
> I did the following commands:
> rm -rf .ghc .cabal
> cabal update
> cabal install yesod
>
> but Cabal gives me the following messages:
>
> Resolving dependencies...
> cabal: cannot configure tls-extra-0.4.1. It requires certificate >=1.0.0 &&
> <1.1.0 and cryptocipher >=0.3.0
> For the dependency on certificate >=1.0.0 && <1.1.0 there are these
> packages:
> certificate-1.0.0. However none of them are available.
> certificate-1.0.0 was excluded because http-enumerator-0.7.1.3 requires
> certificate >=0.7 && <0.10
> For the dependency on cryptocipher >=0.3.0 there are these packages:
> cryptocipher-0.3.0. However none of them are available.
> cryptocipher-0.3.0 was excluded because clientsession-0.7.3.2 requires
> cryptocipher >=0.2.5 && <0.3
>
> Thanks
> Francisco
>
>

Michael Snoyman | 1 Nov 16:15 2011

Yesod and the Package Version Policy

Hi all,

I need some input from the rest of the community on an annoying
package management issue. The PVP[1] is a system that- in theory-
ensures that packages will continue to build even if breaking versions
of their dependencies are released. For example, if foo-0.1.0 uses the
bar function from baz-0.2.0, and version 0.3.0 of baz is released
without the bar function, a simple dependency list means that foo
would break. By following the PVP, we specify that foo requires baz <
0.3, and therefore the bar function is available. I have strictly
adhered to the PVP for almost all packages.

However, I'm beginning to think this was a mistake. The following
issues are coming up:

* The majority of the time, breaking releases don't actually break
anything. For example, the text and time packages have both had a few
breaking revisions without any effect on the buildability[2] of our
code. Instead, I just had to spend half an hour updating cabal files
and releasing new versions to Hackage.
* Some packages, like containers, are built into GHC (bootlibs), and
therefore there is no choices about what version is available. Placing
an upper bound simply prevents code from compiling at all on newer
GHCs.
* The biggest issue right now: cabal-install is broken.

Let me explain that last point. http-enumerator-0.7.1.3 depends on
both tls-extra and certificate. Being a good follower of the PVP, it
specifies to use a version of certificate < 0.10, and tls-extra < 0.5.
Since I release http-enumerator-0.7.1.3, new versions of certificate
(1.0.0) and tls-extra (0.4.1) were released, with tls-extra now
requiring certificate-1.0.*. Since the version bound on certificate
between tls-extra-0.4.1 and http-enumerator-0.7.1.3 do not intersect,
you would expect cabal-install to use tls-extra-0.4.0. Instead, it
simply throws up its hands and walks away.

There are still times when strictly following the PVP is important.
For example, aeson broke a few weeks ago because of a week upper bound
on deepseq. But it's impossible to predict which times a strict upper
bound will *break* a build, and which time it will *save* a build.

So here's my proposal: let's start gradually relaxing upper bounds in
our dependencies. I'll start with this http-enumerator issue, and move
on from there as issues arise. If we start getting issues in the
opposite direction, we'll need to reconsider. And hopefully
cabal-install will get fixed one day, but I'm not holding my breath
right now.

Michael

[1] http://www.haskell.org/haskellwiki/Package_versioning_policy
[2] I think I just made up that word.

Greg Weber | 1 Nov 16:28 2011

Re: Yesod installation problem

I had to go one level deeper and start with


cabal install tls-0.8.2

then I could install tls-extra-0.4.1
However, the yesod install still fails. I think this gets closer to the heart of the problem:

cabal install clientsession-0.7.3.2 tls-extra-0.4.1 yesod
Resolving dependencies...
cabal: cannot configure tls-extra-0.4.1. It requires cryptocipher >=0.3.0
For the dependency on cryptocipher >=0.3.0 there are these packages:
cryptocipher-0.3.0. However none of them are available.
cryptocipher-0.3.0 was excluded because clientsession-0.7.3.2 requires
cryptocipher >=0.2.5 && <0.3





On Tue, Nov 1, 2011 at 8:00 AM, Michael Snoyman <michael-cq0OxgmGHj5BDgjK7y7TUQ@public.gmane.org> wrote:
As a temporary fix, try running "cabal install tls-extra-0.4.0 &&
cabal install yesod". I'm going to write a separate email to the list
describing the problem.

On Tue, Nov 1, 2011 at 7:31 AM, Francisco José CHAVES ALONSO
<pachopepe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hi
>
> I am trying to install yesod without succesfull.
> MAC OS X 10.6.8
> ghc version 7.03 32 bits
>
> I did the following commands:
> rm -rf .ghc .cabal
> cabal update
> cabal install yesod
>
> but Cabal gives me the following messages:
>
> Resolving dependencies...
> cabal: cannot configure tls-extra-0.4.1. It requires certificate >=1.0.0 &&
> <1.1.0 and cryptocipher >=0.3.0
> For the dependency on certificate >=1.0.0 && <1.1.0 there are these
> packages:
> certificate-1.0.0. However none of them are available.
> certificate-1.0.0 was excluded because http-enumerator-0.7.1.3 requires
> certificate >=0.7 && <0.10
> For the dependency on cryptocipher >=0.3.0 there are these packages:
> cryptocipher-0.3.0. However none of them are available.
> cryptocipher-0.3.0 was excluded because clientsession-0.7.3.2 requires
> cryptocipher >=0.2.5 && <0.3
>
> Thanks
> Francisco
>
>


Gmane