aiY       experimental6Sebastian Fischer <mailto:sebf@informatik.uni-kiel.de>"@Derives monadic datatypes and instances for explicit sharing as B well as conversion. Combines the other three derivations which > provide the same functionality split into different parts. DYou usually need the following preamble when deriving monadic code:   {-# LANGUAGE TemplateHaskell  , KindSignatures  , MultiParamTypeClasses  , FlexibleInstances  #-}  import Control.Monad.Sharing  import Data.Monadic.Derive  import Data.DeriveTH .If your types contain lists, you also need to   import Data.Monadic.List 2With this prerequisites, you can derive a monadic  type by  $(derive monadic ''Maybe) 8Generates a monadic datatype and corresponding con- and 1 destructor functions from a Haskell datatype. For example, the datatype  ! data Maybe a = Nothing | Just a 9can be translated into its monadic counterpart by typing   $(derive mdata ''Maybe) +This call generates the following datatype  * data MMaybe m a = MNothing | MJust (m a) ;and the following auxiliary functions for constructing and  matching monadic values:  ' mNothing :: Monad m => m (MMaybe m a)  mNothing = return MNothing  + mJust :: Monad m => m a -> m (MMaybe m a)  mJust a = return (MJust a) H matchMMaybe :: Monad m => m (MMaybe m a) -> m b -> (m a -> m b) -> m b M matchMMaybe x n j = x >>= \x -> case x of { MNothing -> n; MJust a -> j a }  Generates a  Shareable" instance for a monadic datatype. For example the call   $(derive shareable ''Maybe) "generates the following instance: B instance (Monad m, Shareable m a) => Shareable (Maybe m a) where - shareArgs fun MNothing = return MNothing 5 shareArgs fun (MJust a) = fun a >>= \a -> mJust a  Generates  Convertible* instances to convert between monadic and  non-monadic datatypes. For example, the call   $(derive convertible ''Maybe) #generates the following instances: ( instance (Monad m, Convertible m a a') 6 => Convertible m (Maybe a) (MMaybe m a') where $ convArgs fun Nothing = mNothing ) convArgs fun (Just a) = mJust (fun a)  ( instance (Monad m, Convertible m a' a) 6 => Convertible m (MMaybe m a') (Maybe a) where + convArgs fun MNothing = return Nothing B convArgs fun (MJust a) = (a >>= fun) >>= \a -> return (Just a) !"#$%&'()*+,-./0123456789 experimental6Sebastian Fischer <mailto:sebf@informatik.uni-kiel.de> ;Interface for convertible datatypes. The provided function  convArgs9 is supposed to map the given function on every argument B of the given value and combine the results to give the converted  value. We provide instances of the  class for some predefined , Haskell types. For flat types the function convArgs just returns A its argument which has no arguments to which the given function  could be applied.  ?Interface of shareable nested monadic data types. The provided  function  0 is supposed to map the given function on every  monadic argument. We provide instances of the   class for some predefined , Haskell types. For flat types the function   just returns A its argument which has no arguments to which the given function  could be applied. 3Interface of monads that support explicit sharing. <Yields an action that returns the same results as the given C action but whose effects are only executed once. Especially, when B the resulting action is duplicated it returns the same result at  every occurrence. :AAn instance to convert lists with monadic elements into ordinary  lists. ;>An instance to convert ordinary lists into lists with monadic  elements. <-An instance for lists with monadic elements.        experimental6Sebastian Fischer <mailto:sebf@informatik.uni-kiel.de>=>?@AB=Continuation-based, store-passing implementation of explicit & sharing. It is an inlined version of ContT (ReaderT Store m) 8 where the result type of continuations is polymorphic. CDRuns a computation of type Lazy m a with given continuation and  store. ALifts all monadic effects to the top-level and unwraps the monad # transformer for explicit sharing. EFGHIJK =>?EFGHIK =>>?EFGHIK experimental6Sebastian Fischer <mailto:sebf@informatik.uni-kiel.de>LMNOPAMonad transformer that adds explicit sharing capability to every  monad. QRALifts all monadic effects to the top-level and unwraps the monad # transformer for explicit sharing. STUVWXYZ experimental6Sebastian Fischer <mailto:sebf@informatik.uni-kiel.de>1[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   experimental0Sebastian Fischer (sebf\@informatik.uni-kiel.de) >Data type for lists where both the head and tail are monadic. The empty monadic list. %Constructs a non-empty monadic list. !Checks if monadic list is empty. -Yields the head of a monadic list. Relies on a instance ( to provide a failing implementation of [. -Yields the tail of a monadic list. Relies on a instance ( to provide a failing implementation of [. #This instance enables the function Control.Monad.Sharing.convert @ to transform nested monadic lists into ordinary Haskell lists. #This instance enables the function Control.Monad.Sharing.convert @ to transform ordinary Haskell lists into nested monadic lists. DThis instance allows to use nested monadic lists as argument to the  Control.Monad.Sharing.share combinator.     experimental6Sebastian Fischer <mailto:sebf@informatik.uni-kiel.de>2[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIIJJKLMNOPQRSTUUVWXMYZ[\]^_`)ab)ac)ad)ae)af)ag)hi)hj)hk)hl)hm)hn)ho)hp)hq)hr)hs)ht)hu)hv)hw)hx)hy)hz)h{)h|)h})h~)h)h)h)h)h)h)h)h)h)h)h)h)aKLS   M  N Sexplicit-sharing-0.8Data.Monadic.DeriveControl.Monad.Sharing.ClassesControl.Monad.Sharing Control.Monad.Sharing.FirstOrderData.Monadic.List(Control.Monad.Sharing.Implementation.CPS/Control.Monad.Sharing.Implementation.FirstOrder.Control.Monad.Sharing.Implementation.SlowState1Control.Monad.Sharing.Implementation.SlowStateCPS derive-2.4.1 Data.DeriveTHderivemonadicmdata shareable convertible ConvertibleconvertMBoolMCharMInt Shareable shareArgsSharingshareLazy runSharingevalLazyListConsNilnilconsisEmptyfirstrestConv typeParamName branchResName funArgNamebase Data.MaybeMaybeconvDataconvName convQConsconvCons convBTypeconvType makeCFunTmakeTypemakeCFun makeMatchFunT branchTypeC branchType makeMatchFunmakeAlt shareableInstmakeShareArgsRule convInsts makeConvToM makeConvFromMfromName isSymbolCharconsNameconsArgstVar isBangTypeconDecl$fConvertiblem[][]$fConvertiblem[][]0$fShareablem[]UntypedStore nextLabelheapfromLazyrunLazy emptyStore freshLabel lookupValue storeValuememotypedLabeled WithFreshLiftedSevalSgnfhnfrun labelArgs.:setLabelbindGHC.Basefail>>=>>returnMonadFunctor Control.Monad MonadPlusmfilterapliftM5liftM4liftM3liftM2liftMunlesswhen replicateM_ replicateMfoldM_foldM zipWithM_zipWithM mapAndUnzipMjoinvoidforever<=<>=>msumforM_forMfilterMguardmapM_mapM sequence_sequence=<<mplusmzerofmap$fConvertiblemList[]$fConvertiblem[]List$fShareablemListThunkEvalUneval ThunkStore emptyThunks getFreshKey lookupThunk insertThunk