{-# LANGUAGE UndecidableInstances #-}moduleFacebook.Monad(FacebookT,Auth,NoAuth,FbTier(..),runFacebookT,runNoAuthFacebookT,beta_runFacebookT,beta_runNoAuthFacebookT,getCreds,getManager,getTier,withTier,runResourceInFb-- * Re-export,lift)whereimportControl.Applicative(Applicative,Alternative)importControl.Monad(MonadPlus,liftM)importControl.Monad.Base(MonadBase(..))importControl.Monad.Fix(MonadFix)importControl.Monad.IO.Class(MonadIO)importControl.Monad.Trans.Class(MonadTrans(lift))importControl.Monad.Trans.Control(MonadTransControl(..),MonadBaseControl(..),ComposeSt,defaultLiftBaseWith,defaultRestoreM)importControl.Monad.Trans.Reader(ReaderT(..),ask)importData.Typeable(Typeable)importqualifiedData.ConduitasCimportqualifiedNetwork.HTTP.ConduitasHimportFacebook.Types-- | @FacebookT auth m a@ is this library's monad transformer.-- Contains information needed to issue commands and queries to-- Facebook. The phantom type @auth@ may be either 'Auth' (you-- have supplied your 'Credentials') or 'NoAuth' (you have not-- supplied any 'Credentials').newtypeFacebookTauthma=F{unF::ReaderTFbDatama}deriving(Functor,Applicative,Alternative,Monad,MonadFix,MonadPlus,MonadIO,MonadTrans)instanceMonadBasebm=>MonadBaseb(FacebookTauthm)whereliftBase=lift.liftBaseinstanceMonadTransControl(FacebookTauth)wherenewtypeStT(FacebookTauth)a=FbStT{unFbStT::StT(ReaderTFbData)a}liftWithf=F$liftWith(\run->f(liftMFbStT.run.unF))restoreT=F.restoreT.liftMunFbStTinstanceMonadBaseControlbm=>MonadBaseControlb(FacebookTauthm)wherenewtypeStM(FacebookTauthm)a=StMT{unStMT::ComposeSt(FacebookTauth)ma}liftBaseWith=defaultLiftBaseWithStMTrestoreM=defaultRestoreMunStMT-- | Phantom type stating that you have provided your-- 'Credentials' and thus have access to the whole API.dataAuthderiving(Typeable)-- | Phantom type stating that you have /not/ provided your-- 'Credentials'. This means that you'll be limited about which-- APIs you'll be able use.dataNoAuthderiving(Typeable)-- | Internal data kept inside 'FacebookT'.dataFbData=FbData{fbdCreds::Credentials-- ^ Can be 'undefined'!,fbdManager::!H.Manager,fbdTier::!FbTier}deriving(Typeable)-- | Which Facebook tier should be used (see-- <https://developers.facebook.com/support/beta-tier/>).dataFbTier=Production|Betaderiving(Eq,Ord,Show,Read,Enum,Typeable)-- | Run a computation in the 'FacebookT' monad transformer with-- your credentials.runFacebookT::Credentials-- ^ Your app's credentials.->H.Manager-- ^ Connection manager (see 'H.withManager').->FacebookTAuthma->marunFacebookTcredsmanager(Fact)=runReaderTact(FbDatacredsmanagerProduction)-- | Run a computation in the 'FacebookT' monad without-- credentials.runNoAuthFacebookT::H.Manager->FacebookTNoAuthma->marunNoAuthFacebookTmanager(Fact)=letcreds=error"runNoAuthFacebookT: never here, serious bug"inrunReaderTact(FbDatacredsmanagerProduction)-- | Same as 'runFacebookT', but uses Facebook's beta tier (see-- <https://developers.facebook.com/support/beta-tier/>).beta_runFacebookT::Credentials->H.Manager->FacebookTAuthma->mabeta_runFacebookTcredsmanager(Fact)=runReaderTact(FbDatacredsmanagerBeta)-- | Same as 'runNoAuthFacebookT', but uses Facebook's beta tier-- (see <https://developers.facebook.com/support/beta-tier/>).beta_runNoAuthFacebookT::H.Manager->FacebookTNoAuthma->mabeta_runNoAuthFacebookTmanager(Fact)=letcreds=error"beta_runNoAuthFacebookT: never here, serious bug"inrunReaderTact(FbDatacredsmanagerBeta)-- | Get the user's credentials.getCreds::Monadm=>FacebookTAuthmCredentialsgetCreds=fbdCreds`liftM`Fask-- | Get the 'H.Manager'.getManager::Monadm=>FacebookTanyAuthmH.ManagergetManager=fbdManager`liftM`Fask-- | Get the 'FbTier'.getTier::Monadm=>FacebookTanyAuthmFbTiergetTier=fbdTier`liftM`Fask-- | Run a pure function that depends on the 'FbTier' being used.withTier::Monadm=>(FbTier->a)->FacebookTanyAuthmawithTier=flipliftMgetTier-- | Run a 'ResourceT' inside a 'FacebookT'.runResourceInFb::C.Resourcem=>FacebookTanyAuth(C.ResourceTm)a->FacebookTanyAuthmarunResourceInFb(Finner)=F$ask>>=lift.C.runResourceT.runReaderTinner