------------------------------------------------------------------------------- |-- Module : Control.Concurrent.Speculation.Class-- Copyright : (C) 2011 Edward Kmett, Jake McArthur-- License : BSD-style (see the file LICENSE)---- Maintainer : Edward Kmett <ekmett@gmail.com>-- Stability : provisional-- Portability : portable---- Versions of the combinators from the 'speculation' package-- with the signature rearranged to enable them to be used-- directly as actions in the 'Cont' and 'ContT' monads-- or any other 'Codensity'-shaped monad.----------------------------------------------------------------------------moduleControl.Concurrent.Speculation.ClasswhereimportControl.Monad.Trans.ContimportControl.Concurrent.SpeculationimportData.Function(on)classMonadSpecmwhere-- | @spec@ with a user supplied comparison functionspecByM::(a->a->Bool)->a->a->ma-- | @spec'@ with a user supplied comparison functionspecByM'::(a->a->Bool)->a->a->ma-- | When a is unevaluated, @'spec' g a@ evaluates the current continuation -- with @g@ while testing if @g@ '==' @a@, if they differ, it re-evalutes the-- continuation with @a@. If @a@ was already evaluated, the continuation is-- just directly applied to @a@ instead.specM::(MonadSpecm,Eqa)=>a->a->maspecM=specByM(==)-- | As per 'spec', without the check for whether or not the second argument-- is already evaluated.specM'::(MonadSpecm,Eqa)=>a->a->maspecM'=specByM'(==)-- | @spec'@ with a user supplied comparison functionspecOnM::(MonadSpecm,Eqc)=>(a->c)->a->a->maspecOnM=specByM.on(==)-- | @spec'@ with a user supplied comparison functionspecOnM'::(MonadSpecm,Eqc)=>(a->c)->a->a->maspecOnM'=specByM.on(==)-- * Basic speculationinstanceMonadm=>MonadSpec(ContTrm)wherespecByMfga=ContT$\k->specByfgkaspecByM'fga=ContT$\k->specBy'fgka