LK@f      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde Trustworthy35<CINTPointers can be linear, nonlinear, or focused. There are the following tradeoffs:SLinear pointers support strong update, but can only be split under focusing.BNonlinear pointers can be split, but do not support strong update.~Placeholders classify pointers that either point to junk or to data that is not allowed to be used (to maintain linearity). EWith the Fix constructor, I can build data structures of linear data.PLinear computations are arrows over linear data, but monads over nonlinear data.#Values representing the real world."Monadic bind (for nonlinear data).Monadic returnThis setup is from 5http://cs.ioc.ee/~tarmo/tsem11/jeltsch1602-slides.pdfIt implements some of Nhttp://pauillac.inria.fr/~fpottier/slides/fpottier-2007-05-linear-bestiary.pdf<3Allocate a new linear block (containing junk), Use C to initialize it.=Use B@ to take ownership of the contents of a block before freeing it.>3Split a pointer to a pair, into a pair of pointers.@Focusing on a pointer.Temporarily turns a linear pointer into a focused pointer. I get the linear pointer back after all copies have been surrendered (with ).AFocusing on a handle.B6Take the data out of a block, making it a placeholder.CThe reverse operation.D(A placeholder block can change its type.EAllocate a nonlinear pointer.HDDuplicate the world state. This is interpreted as creating a thread.ISync together two world states.mf g hi jklmnop !"#$%&q'()*+,-./01234567r8stuv9:w;<=>?@ABCDEFGHIJKLxyz{|}~M  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLM !"#$%& '()*+,-./012345678   9:;<=>?@ABCDEFGHIJKL^f g  hi jklmnop !"#$%&q'()*+,-./01234567r8stuv9:w;<=>?@ABCDEFGHIJKLxyz{|}~Safe-35IKLNM Example of an IO-performing ADT.N>An extended distributive law allows one to permute two layers. Laws are:)join . T dist = dist . join :: TTS -> TST)TS join . dist . dist = dist :: TS -> TSTP~The following construction on two monads is a monad provided the two monads have extended distributive laws, defined below.RLeft and right maps...TInjections into the P type.VIf you have a P5 over a monad, you can extract the underlying action.WP is commutative..MNOPQRSTUVWXYZ[MNOPQRSTUVWXYZ[QPNORSTUVWXYMZ[*MNOPQRSTUVWXYZ[Unsafe3457KL\HAn automatic lifter. The idea of automatic lifting is due to Dan Piponi.\]^_`abc\]\]cba`_^\]^_`abc Trustworthy<INdAn IO monad transformer.df cannot be unwrapped in the usual way -- the monad inside it has to be unwrapped. This is done using e, and  from mmorph.Most of the safety of the IO monad is ensured statically. However, to ensure that the same RealWorld token is not used multiple times, a runtime check is necessary. Among the alternatives that perform I/O, the first alternative forced by a concatenation of Es will contain a result, and subsequent alternatives will be errors.Therefore, a concatenation of hoistsr out of a monad defines at most one path of RealWorld token use. Here is an example using the binary tree monad:Hlet io :: IOT Tree () = lift (Node (Leaf 1) (Leaf 2)) >>= liftIO . print1run $ hoist (\(Node (Leaf x) _) -> Identity x) io11run $ hoist (\(Node _ (Leaf x)) -> Identity x) io28run $ hoist (\(Node (Leaf _) (Leaf x)) -> Identity x) io1(*** Exception: IOT: double RealWorld usee+Run an IOT yielding an IO computation. The & monad is a trivial wrapper around IO.de@dede de        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef ghijklmnopqrstuvwxyz{|}NR~eiMonad_5oPW4QxniIw0D6twXN8U06Control.LinearControl.Monad.PlusMonadControl.Monad.LifterControl.Monad.IOT Weakening weakening Placeholder NonlinearFocusedLinearPointerFixInOpen Semiclosed ExclusivePairBlankFnASt>>==rtnrunbimapassoc1assoc2drop1drop2undrop1undrop2swapapplycurrydistrassoc3assoc4void'bimap'opengetStdin getStdout getStderrcloseclose1fileSize setFileSizeeofseektellcharline lookaheadcontentsputCputSrandomfixInj1fixInj2 contractionnewfreesplitptrSwapfocusfocusHdlpeek'poke' changeType newNonlinearpeek1poke1forkjoin' helloWorld printStuff concurrentFileDistdist::+ CompositionleftMaprightMapinlinrsymcommutemapPlusreflrunFilereadLineLifterlf $fLiftermm $fLiftermn$fLifterIdentityIdentity $fLifterSTST $fLifterIOIO $fLifterSTIOIOT Splittable OpenhandlegetHdllift setBinaryalignfrstsecndcoercedummy$fWeakeningOpen$fWeakeningPointer$fWeakeningPointer0$fSplittableFocused$fSplittableNonlinear$fStorablePointer$fStorableHandle$fStorablePair$fStorableBlank$fOpenhandleOpen$fOpenhandleExclusive$fArrowChoiceA$fArrowA $fCategory*ARtn_hoist_leftMap _rightMap distributive1 distributive2 distributive bringDown_sym_commute $fDistFile$fApplicativeFile $fMonadFile$fMonadIOComposition$fMonadTransComposition$fAlternativeComposition$fApplicativeComposition$fMonadPlusComposition$fMonadComposition $fDistYoneda$fDistComposition $fDistErrorT $fDistEither $fDistMaybe$fDistIdentity$fDistIO$fDist[] $fDistWriterT $fDistStateTmmorp_42KUkOfzC6q3qCtAMiSHamControl.Monad.MorphhoistbaseData.Functor.IdentityIdentityStateerr_squash $fMMonadIOT $fMFunctorIOT$fMonadTransIOT $fMonadIOIOT $fFunctorIOT$fApplicativeIOT $fMonadIOTGHC.Basefail>>=>>fmapreturnControl.Monad.Fixmfix Control.MonadguardjoinMonadFunctorMonadFixliftM runIdentitymfilter<$!>unless replicateM_ replicateMfoldM_foldM zipWithM_zipWithM mapAndUnzipMforever<=<>=>filterMData.TraversableforMsequencemapM Data.Foldablemsum sequence_forM_mapM_ Data.Functionfix Data.FunctorvoidapliftM5liftM4liftM3liftM2when=<<mplusmzero MonadPlustrans_GZTjP9K5WFq01xC9BAGQpFControl.Monad.Trans.Class|>==<|<|<>|>squash generalizeMFunctorembedMMonad MonadTransControl.Monad.IO.ClassMonadIOliftIO