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).
This commit is contained in:
parent
4fd20299c1
commit
9729cd9d15
@ -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))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user