I'm trying to implement the isAdmin function in a similar fashion to these Yesod book examples. The problem is that I want to keep my 'admin' emails in the database, but when I make a database query, isAdmin loses its purity, so I have to return Handler-something IO Bool instead of just Bool. Now, this scraps the very nice syntax sugar in hamlet that allows to do so:
$if isAdmin
<p ...
Is there a way to still have a pure isAdmin function even if I make a call to the database (I seriously doubt that... by the way, I don't want to pass any parameters to isAdmin)? Or maybe I could still use the $if syntax with the impure function?
P.S.: Currently, I am using a hack in the handler module:
isadmin <- isAdmin
So, I can write in the hamlet corresponding to that handler:
$if isadmin
But it is not universal and I like the first method more.
isAdminfunction" -- Terminology nitpicking: something that doesn't take arguments isn't a function. A better wording would be "a pureisAdminvalue". If you were talking about the monadicisAdminyou actually have, you could also say "anisAdmincomputation". - duplode