{-# OPTIONS  -XDeriveDataTypeable
{-# OPTIONS -IData/Persistent/Queue       #-}
{- |
This module implements a persistent, transactional collection with Queue interface as well as
 indexed access by key

use this version if you store in the queue different versions of largue structures, for
example, documents and define a "Data.RefSerialize" instance. If not, use "Data.Persistent.Queue.Binary" Instead.

Here @QueueConstraints  w r a@ means  @Data.RefSerlialize.Serialize a@


module Data.Persistent.Queue.Text(
RefQueue(..), getQRef,
pop,popSTM,pick, flush, flushSTM,
pickAll, pickAllSTM, push,pushSTM,
pickElem, pickElemSTM,  readAll, readAllSTM,
deleteElem, deleteElemSTM,
) where
import Data.Typeable
import Control.Concurrent.STM(STM,atomically, retry)
import Control.Monad(when)
import Data.TCache.DefaultPersistence

import Data.TCache
import System.IO.Unsafe
import Data.RefSerialize
import Data.ByteString.Lazy.Char8
import Control.Workflow.GenSerializer

import Debug.Trace

a !> b= trace b a

instance SerialiserString ST ST where
    serialString = showp
    deserialString = readp

instance Indexable (Queue a) where
   key (Queue k  _ _)= queuePrefix ++ k
   defPath _= "WorkflowState/Text/"

#include "Queue.inc.hs"