From 9729cd9d153b51cfed7c05d66422e69f65ce204c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20G=C3=B3mez?= Date: Fri, 12 Sep 2014 13:18:51 +0000 Subject: [PATCH] Default type instance for AuthEntity `AuthEntity` is now a type family associated to the `YesodAuthPersist` class, so its old type alias definition has now become its default type instance, which allows recovering the old behavior with minimal boilerplate: an empty instance declaration for `YesodAuthPersist` makes a Yesod application written with Persistent work just like before. Unfortunately, this requires enabling `UndecidableInstances` in the `Yesod.Auth` module since there is now a nested type family application (as `AuthEntity` is now itself a type family). This was tested with the scaffolded application with PostgreSQL, and it works (given another small change to make it work with Persistent 2 due to how `SqlPersistT` is now defined). --- yesod-auth/Yesod/Auth.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/yesod-auth/Yesod/Auth.hs b/yesod-auth/Yesod/Auth.hs index f2ea0ab0..78b2d734 100644 --- a/yesod-auth/Yesod/Auth.hs +++ b/yesod-auth/Yesod/Auth.hs @@ -9,6 +9,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Yesod.Auth ( -- * Subsite @@ -392,6 +393,7 @@ class (YesodAuth master, YesodPersist master) => YesodAuthPersist master where -- -- Since 1.2.0 type AuthEntity master :: * + type instance AuthEntity master = KeyEntity (AuthId master) getAuthEntity :: AuthId master -> HandlerT master IO (Maybe (AuthEntity master))