diff --git a/ChangeLog.md b/ChangeLog.md
new file mode 100644
--- /dev/null
+++ b/ChangeLog.md
@@ -0,0 +1,5 @@
+# Revision history for yeamer
+
+## 0.1.0.0  -- YYYY-mm-dd
+
+* First version. Released on an unsuspecting world.
diff --git a/Control/Monad/Trans/Writer/JSONable.hs b/Control/Monad/Trans/Writer/JSONable.hs
new file mode 100644
--- /dev/null
+++ b/Control/Monad/Trans/Writer/JSONable.hs
@@ -0,0 +1,34 @@
+-- |
+-- Module      : Control.Monad.Trans.Writer.JSONable
+-- Copyright   : (c) Justus Sagemüller 2017
+-- License     : GPL v3
+-- 
+-- Maintainer  : (@) jsagemue $ uni-koeln.de
+-- Stability   : experimental
+-- Portability : portable
+-- 
+
+{-# LANGUAGE DeriveFunctor         #-}
+{-# LANGUAGE DeriveFoldable        #-}
+{-# LANGUAGE DeriveTraversable     #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE UndecidableInstances  #-}
+
+module Control.Monad.Trans.Writer.JSONable where
+
+import Data.Aeson
+import Data.Flat
+import GHC.Generics
+import Data.Semigroup
+
+
+data WriterT l m a = WriterT { runWriterT :: m (a, l) }
+  deriving (Functor, Foldable, Traversable, Generic)
+instance (ToJSON (m (a,l))) => ToJSON (WriterT l m a)
+instance (FromJSON (m (a,l))) => FromJSON (WriterT l m a)
+instance (Flat (m (a,l))) => Flat (WriterT l m a)
+instance (Semigroup (m (a,l))) => Semigroup (WriterT l m a) where
+  WriterT x <> WriterT y = WriterT $ x<>y
+instance (Semigroup (m (a,l)), Monoid (m (a,l))) => Monoid (WriterT l m a) where
+  mempty = WriterT mempty
+  mappend = (<>)
diff --git a/Data/Traversable/Redundancy.hs b/Data/Traversable/Redundancy.hs
new file mode 100644
--- /dev/null
+++ b/Data/Traversable/Redundancy.hs
@@ -0,0 +1,37 @@
+-- |
+-- Module      : Data.Traversable.Redundancy
+-- Copyright   : (c) Justus Sagemüller 2017
+-- License     : GPL v3
+-- 
+-- Maintainer  : (@) jsagemue $ uni-koeln.de
+-- Stability   : experimental
+-- Portability : portable
+-- 
+
+module Data.Traversable.Redundancy where
+
+
+import Data.Foldable (toList)
+import Data.Traversable
+
+import Data.Vector (Vector)
+import qualified Data.Vector as Arr
+
+import qualified Data.Map as Map
+import Data.List (sortBy)
+import Data.Ord (comparing)
+
+import Control.Monad.Trans.State
+
+
+rmRedundancy :: (Ord a, Traversable t) => t a -> (t Int, Vector a)
+rmRedundancy q = ( (`evalState`indices) . forM q . const . state $ \((_,j):js) -> (j, js)
+                 , resource )
+ where backIxed = fmap ($ []) . Map.fromListWith (.) . zip (toList q) $ (:)<$>[0..]
+       histogram = sortBy (comparing $ negate . length . snd)
+                    $ Map.toList backIxed
+       indices = sortBy (comparing fst)
+                 [ (j,i)
+                 | (i,js) <- zip [0..] $ snd<$>histogram
+                 , j <- js ]
+       resource = Arr.fromList $ fst<$>histogram
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+              GNU GENERAL PUBLIC LICENSE
+                Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                     Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+              END OF TERMS AND CONDITIONS
+
+     How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/Presentation/Yeamer.hs b/Presentation/Yeamer.hs
new file mode 100644
--- /dev/null
+++ b/Presentation/Yeamer.hs
@@ -0,0 +1,933 @@
+-- |
+-- Module      : Presentation.Yeamer
+-- Copyright   : (c) Justus Sagemüller 2017
+-- License     : GPL v3
+-- 
+-- Maintainer  : (@) jsagemue $ uni-koeln.de
+-- Stability   : experimental
+-- Portability : portable
+-- 
+{-# LANGUAGE CPP                    #-}
+{-# LANGUAGE DeriveGeneric          #-}
+{-# LANGUAGE StandaloneDeriving     #-}
+{-# LANGUAGE TemplateHaskell        #-}
+{-# LANGUAGE QuasiQuotes            #-}
+{-# LANGUAGE TypeFamilies           #-}
+{-# LANGUAGE MultiParamTypeClasses  #-}
+{-# LANGUAGE DataKinds              #-}
+{-# LANGUAGE FlexibleInstances      #-}
+{-# LANGUAGE FlexibleContexts       #-}
+{-# LANGUAGE OverloadedStrings      #-}
+{-# LANGUAGE GADTs                  #-}
+{-# LANGUAGE ScopedTypeVariables    #-}
+{-# LANGUAGE UnicodeSyntax          #-}
+{-# LANGUAGE TupleSections          #-}
+{-# LANGUAGE ConstraintKinds        #-}
+{-# LANGUAGE ViewPatterns           #-}
+
+module Presentation.Yeamer ( Presentation
+                           -- * Running a presentation
+                           , yeamer
+                           -- * Primitives
+                           , staticContent, tweakContent, serverSide
+                           -- ** Maths
+                           , ($<>), maths
+                           -- ** Media content
+                           , imageFromFile, mediaFromFile, imageFromFileSupplier
+                           -- ** Arbitrary file serving
+                           , useFile, useFileSupplier
+                           -- ** Code / plaintext
+                           , verbatim, plaintext, verbatimWithin
+                           -- * Structure / composition
+                           , addHeading, (======), discardResult
+                           -- * CSS
+                           , divClass, spanClass, (#%), styling
+                           -- * Server configuration
+                           , yeamer'
+                           , YeamerServerConfig
+                           -- | Default port is 14910
+                           , yeamerTcpPort
+                           ) where
+
+import Yesod hiding (get)
+import Yesod.Form.Jquery
+
+import qualified Data.Text as Txt
+import qualified Data.Text.Lazy as Txt (toStrict)
+import qualified Data.Text.Encoding as Txt
+import Data.Text (Text)
+import Data.String (IsString (..))
+import Data.ByteString (ByteString)
+import qualified Data.ByteString.Lazy as BSL
+import qualified Data.ByteString.Char8 as BC8
+import Data.Flat (Flat, flat, unflat)
+import qualified Data.Aeson as JSON
+import qualified Text.Blaze.Html5 as HTM
+import qualified Text.Blaze.Html5.Attributes as HTM
+import qualified Text.Blaze.Html.Renderer.Text as HTMText
+import Presentation.Yeamer.Internal.Progress
+import Presentation.Yeamer.Internal.PrPathStepCompression
+import Data.Map (Map)
+import qualified Data.Map as Map
+import qualified Data.Vector as Arr
+import Presentation.Yeamer.Internal.Grid
+
+import Text.Cassius (Css)
+import Text.Julius (rawJS)
+
+import Yesod.Static (Static, static, base64md5)
+import Yesod.EmbeddedStatic
+import qualified Language.Javascript.JQuery as JQuery
+import Language.Haskell.TH.Syntax ( Exp(LitE, AppE, VarE, ConE)
+                                  , Lit(StringL), Name, runIO )
+import Language.Haskell.TH.Quote
+
+import qualified CAS.Dumb.Symbols as TMM
+import qualified CAS.Dumb.Tree as TMM
+import qualified Math.LaTeX.Prelude as TMM
+import Text.LaTeX (LaTeX)
+import qualified Text.LaTeX as LaTeX
+import qualified Text.TeXMath as MathML
+import qualified Text.XML.Light as XML
+
+import Data.List (intercalate)
+import Data.Foldable (fold)
+import Data.Traversable.Redundancy (rmRedundancy)
+import Control.Monad.Trans.Writer.JSONable
+import Control.Monad.Trans.List
+import Control.Monad.Trans.State
+import Control.Monad.Trans.Reader
+import Data.These
+import Data.These.Lens
+import qualified Data.Semigroup as SG
+import Data.Semigroup.Numbered
+import Data.Monoid
+import Data.Maybe
+import Data.Functor.Identity
+import Control.Monad
+import Control.Arrow (first, second, (&&&))
+import Control.Applicative
+
+import Data.Function ((&))
+import Data.Tuple (swap)
+import Data.Default.Class
+
+import System.FilePath ( takeFileName, takeExtension, takeBaseName, dropExtension
+                       , (<.>), (</>) )
+import System.Directory ( doesPathExist, makeAbsolute
+                        , createDirectoryIfMissing, renameFile
+#if MIN_VERSION_directory(1,3,1)
+                        , createFileLink, pathIsSymbolicLink, getSymbolicLinkTarget
+#endif
+                        )
+#if !MIN_VERSION_directory(1,3,1)
+import System.Posix.Files (createSymbolicLink, readSymbolicLink)
+#endif
+import System.IO.Temp
+
+import GHC.Generics
+import Lens.Micro
+import Lens.Micro.TH
+import Data.Bifunctor (bimap)
+
+#if !MIN_VERSION_directory(1,3,1)
+createFileLink = createSymbolicLink
+getSymbolicLinkTarget = readSymbolicLink
+pathIsSymbolicLink _ = pure True
+#endif
+
+#if !MIN_VERSION_flat(0,4,0)
+instance (Flat a) => Flat (Identity a)
+#endif
+
+data Container t where
+  WithHeading :: Html -> Container Identity
+  ManualCSSClasses :: Container (WriterT HTMChunkK [])
+  GriddedBlocks :: Container Gridded
+  CustomEncapsulation :: (t Html -> Html) -> Container t
+
+data HTMChunkK = HTMDiv {_hchunkCSSClass::Text} | HTMSpan {_hchunkCSSClass::Text}
+          deriving (Generic, Eq, Ord)
+instance JSON.FromJSON HTMChunkK
+instance JSON.ToJSON HTMChunkK
+instance Flat HTMChunkK
+makeLenses ''HTMChunkK
+
+type Sessionable = Flat
+
+data IPresentation m r where
+   StaticContent :: Html -> IPresentation m ()
+   Resultless :: IPresentation m r -> IPresentation m ()
+   Styling :: [Css] -> IPresentation m r -> IPresentation m r
+   Encaps :: (Traversable t, Sessionable r, Sessionable (t ()))
+               => Container t -> t (IPresentation m r) -> IPresentation m (t r)
+   Pure :: r -> IPresentation m r
+   Deterministic :: (r -> s) -> IPresentation m r -> IPresentation m s
+   Interactive :: Sessionable r
+          => IPresentation m () -> m r -> IPresentation m r
+   Dependent :: Sessionable x
+                   => IPresentation m x -> (x -> IPresentation m r) -> IPresentation m r
+instance (r ~ ()) => IsString (IPresentation m r) where
+  fromString = StaticContent . fromString
+
+type Presentation = IPresentation IO ()
+
+data PresentationServer = PresentationServer {
+      presentationToShow :: Presentation
+    , getStatic :: EmbeddedStatic
+    , getPseudostatic :: Static
+    }
+
+mkEmbeddedStatic False "myStatic" . pure . embedFileAt "jquery.js" =<< runIO JQuery.file
+
+pStatDir :: FilePath
+pStatDir = ".pseudo-static-content"
+
+mkYesod "PresentationServer" [parseRoutes|
+/ HomeR GET
+/p/#PresProgress ExactPositionR GET
+/changeposition/#PresProgress/#PositionChange ChPosR GET
+/reset ResetR GET
+/static StaticR EmbeddedStatic getStatic
+/pseudostatic PStaticR Static getPseudostatic
+|]
+instance Yesod PresentationServer where
+  addStaticContent = embedStaticContent getStatic StaticR Right
+  approot = ApprootRelative
+instance YesodJquery PresentationServer
+
+preprocPres :: IPresentation m r -> IPresentation m r
+preprocPres (StaticContent c) = StaticContent c
+preprocPres (Resultless p) = Resultless $ preprocPres p
+preprocPres (Styling s p) = Styling s $ preprocPres p
+preprocPres (Encaps (WithHeading h) p) = Encaps (WithHeading h) $ preprocPres<$>p
+preprocPres (Encaps ManualCSSClasses p) = Encaps ManualCSSClasses $ preprocPres<$>p
+preprocPres (Encaps (CustomEncapsulation f) p)
+                = Encaps (CustomEncapsulation f) $ preprocPres<$>p
+preprocPres (Encaps GriddedBlocks p)
+           = Styling grids
+           . divClass gridClass
+           . fmap (backonstruct . map (first (read . Txt.unpack . _hchunkCSSClass) . swap)
+                      . runWriterT)
+           . Encaps ManualCSSClasses
+           $ preprocPres <$> layouted
+ where (GridLayout w h prelayed, backonstruct) = layoutGridP p
+       layouted = WriterT $ swap . first (HTMDiv . ("autogrid-range_"<>) . idc)
+                      . snd <$> prelayed
+       gridRep :: [[Text]]
+       gridRep = foldr fill (replicate h $ replicate w ".") prelayed
+        where fill (GridRange xb xe yb ye, (i, _)) field
+                 = yPre ++ [ xPre ++ (idc i<$xRel) ++ xPost
+                           | xAll <- yRel
+                           , let (xPre, (xRel, xPost)) = splitAt xb xAll
+                                               & second (splitAt $ xe-xb) ] ++ yPost
+               where (yPre, (yRel, yPost)) = splitAt yb field
+                                   & second (splitAt $ ye-yb)
+       idc i
+        | c <- toEnum $ fromEnum 'a' + i
+        , c <= 'z'                        = Txt.singleton c
+       gridClass = "autogrid_"<>Txt.intercalate "-" (Txt.concat<$>gridRep)
+       grids = [lucius|
+                 div.#{gridClass} {
+                    display: grid;
+                    grid-template-areas: #{areas}
+                 }
+               |]()
+             : [ [lucius| div .#{divid} { grid-area: #{ist} } |]()
+               | (_, (i, _)) <- prelayed
+               , let ist = idc i
+                     divid = "autogrid-range_" <> ist ]
+        where areas = fold ["\""<>Txt.intercalate " " line<>"\" "
+                           | line <- gridRep ]
+
+preprocPres (Pure x) = Pure x
+preprocPres (Deterministic f p) = Deterministic f $ preprocPres p
+preprocPres (Interactive p a) = Interactive (preprocPres p) a
+preprocPres (Dependent d o) = Dependent (preprocPres d) (preprocPres<$>o)
+
+
+isInline :: IPresentation m a -> Bool
+isInline (StaticContent _) = True
+isInline (Encaps ManualCSSClasses (WriterT qs)) = all (\(_,i) -> case i of
+                   HTMSpan _ -> True
+                   HTMDiv _ -> False ) qs
+isInline (Encaps _ _) = False
+isInline (Styling _ q) = isInline q
+isInline (Interactive q _) = isInline q
+isInline (Resultless q) = isInline q
+isInline (Dependent q _) = isInline q
+isInline (Deterministic _ q) = isInline q
+isInline (Pure _) = True
+
+
+getHomeR :: Handler Html
+getHomeR = redirect . ExactPositionR $ assemblePresProgress mempty
+   
+
+getExactPositionR :: PresProgress -> Handler Html
+getExactPositionR pPosition = do
+   PresentationServer presentation _ _ <- getYesod
+   defaultLayout $ do
+      addScript $ StaticR jquery_js
+      slideChoice <- (`runReaderT`pPosition)
+            $ chooseSlide "" defaultChoiceName "" Nothing Nothing presentation
+      (`here`slideChoice) $ \slide -> do
+          let contents = go 0 slide
+          toWidget contents
+      return ()
+ where chooseSlide :: PrPath -> (Text->PrPath) -> Text -> Maybe PrPath -> Maybe PrPath
+                       -> IPresentation IO r
+                       -> ReaderT PresProgress
+                            (WidgetT PresentationServer IO) (These Presentation r)
+       chooseSlide _ _ "" Nothing Nothing (StaticContent conts)
+           = pure $ These (StaticContent conts) ()
+       chooseSlide path choiceName "" Nothing Nothing (Styling sty conts)
+                     = mapM_ toWidget sty
+                        >> chooseSlide path choiceName "" Nothing Nothing conts
+       chooseSlide path choiceName "" Nothing Nothing (Encaps f conts)
+                  = postGather <$> cellwise f
+        where postGather sq = case sequence sq of
+               That p's -> That p's
+               This _   -> This . discardResult $ Encaps f
+                                $ fmap (maybe mempty id . (^?here)) sq
+               These _ p's -> (`These`p's) . discardResult $ Encaps f
+                                $ fmap (maybe mempty id . (^?here)) sq
+              cellwise ManualCSSClasses
+                | WriterT contsL <- conts
+                     = WriterT <$> (`traverse`contsL) `id` \(cell,i) ->
+                 (,i) <$> chooseSlide (path<>case i of
+                                 HTMDiv c -> " div."<>c
+                                 HTMSpan c -> " span."<>c
+                              ) choiceName "" Nothing Nothing cell
+              cellwise _ = traverse (chooseSlide path choiceName "" Nothing Nothing) conts
+       chooseSlide path choiceName "" Nothing Nothing (Interactive conts followAction) = do
+           purity <- chooseSlide path choiceName "" Nothing Nothing conts
+           case purity ^? here of
+             Just pres -> pure . This $ discardResult pres
+             Nothing   -> That <$> liftIO followAction
+       chooseSlide path choiceName "" Nothing Nothing (Resultless conts) = do
+           purity <- chooseSlide path choiceName "" Nothing Nothing conts
+           case purity ^? here of
+             Just pres -> pure . (`These`()) $ discardResult pres
+             Nothing   -> pure $ That ()
+       chooseSlide path choiceName "" Nothing Nothing (Deterministic f conts) = do
+           purity <- chooseSlide path choiceName "" Nothing Nothing conts
+           pure $ bimap discardResult f purity
+       chooseSlide path choiceName pdiv bwd fwd (Dependent def opt) = do
+          let progPath = path<>" span."<>choiceName pdiv
+          positionCh <- lookupProgress progPath
+          case positionCh of
+            Nothing -> do
+              liftIO . putStrLn $ "Not enter '"++Txt.unpack progPath++"'"
+              purity <- chooseSlide path choiceName (pdiv<>"0") bwd (Just progPath) def
+              case preferThis purity of
+                 Left pres -> pure . This $ discardResult pres
+                 Right x -> do
+                   pPosition' <- setProgress progPath x `execStateT` pPosition
+                   redirect $ ExactPositionR pPosition'
+            Just x -> chooseSlide path choiceName (pdiv<>"1") (Just progPath) fwd $ opt x
+       chooseSlide path choiceName pdiv bwd fwd pres
+        | isJust bwd || isJust fwd  = do
+          let thisChoice = choiceName pdiv
+              newPath = (path<>" span."<>thisChoice)
+              [revertPossible, progressPossible]
+                 = maybe "false" (const "true") <$> [bwd,fwd] :: [Text]
+              [previous,next] = maybe "null" id <$> [bwd, fwd]
+          toWidget [julius|
+                 $("#{rawJS newPath}").click(function(e){
+                     if (e.ctrlKey && #{rawJS revertPossible}) {
+                         isRevert = true;
+                         pChanger = "@{ChPosR pPosition (PositionChange previous True)}";
+                     } else if (!(e.ctrlKey) && #{rawJS progressPossible}) {
+                         isRevert = false;
+                         pChanger = "@{ChPosR pPosition (PositionChange next False)}";
+                     } else {
+                         return;
+                     }
+                     e.stopPropagation();
+                     hasErrored = false;
+                     $.ajax({
+                           contentType: "application/json",
+                           processData: false,
+                           url: pChanger,
+                           type: "GET",
+                           dataType: "text",
+                           success: function(newURL, textStatus, jqXHR) {
+                              if (isRevert) {
+                                 window.location.replace(newURL);
+                              } else {
+                                 window.location.href = newURL;
+                              }
+                           },
+                           error: function(jqXHR, textStatus, errorThrown) {
+                              $("body").css("cursor","not-allowed");
+                              hasErrored = true;
+                              setTimeout(function() {
+                                 $("body").css("cursor","auto")}, 500);
+                           }
+                        });
+                     setTimeout(function() {
+                         if (!hasErrored) {$("body").css("cursor","wait")}
+                     }, 150);
+                 })
+               |]
+          (here %~ spanClass thisChoice)
+                  <$> chooseSlide newPath (disambiguateChoiceName choiceName)
+                           "" Nothing Nothing pres
+       chooseSlide _ _ _ _ _ (Pure x) = pure $ That x
+       chooseSlide _ _ _ _ _ pres
+          = error $ "Cannot display "++outerConstructorName pres
+       go :: Int -> IPresentation m r -> Html
+       go _ (StaticContent conts) = conts
+       go _ (Pure _) = error $ "Error: impossible to render a slide of an empty presentation."
+       go _ (Dependent _ _) = error $ "Internal error: un-selected Dependent option while rendering to HTML."
+       go lvl (Deterministic _ conts) = go lvl conts
+       go lvl (Resultless conts) = go lvl conts
+       go lvl (Interactive conts _) = go lvl conts
+       go lvl (Styling sty conts) = go lvl conts
+       go lvl (Encaps (WithHeading h) conts)
+           = let lvl' = min 6 $ lvl + 1
+                 hh = [HTM.h1, HTM.h2, HTM.h3, HTM.h4, HTM.h5, HTM.h6]!!lvl
+             in go lvl' $ Encaps (CustomEncapsulation $ \(Identity contsr)
+                                    -> HTM.div HTM.! HTM.class_ "headed-container"
+                                         $ hh h <> contsr
+                                 ) conts
+       go lvl (Encaps ManualCSSClasses conts)
+           = go lvl $ Encaps (CustomEncapsulation $ \(WriterT contsrs)
+                  -> foldMap (\(q,i) -> case i of
+                               HTMDiv c -> [hamlet| <div class=#{withSupclass c}> #{q} |]()
+                               HTMSpan c -> [hamlet| <span class=#{withSupclass c}> #{q} |]())
+                      $ contsrs
+                 ) conts
+        where withSupclass c
+               | Just _ <- Txt.stripPrefix "autogrid_" c
+                            = "autogrid "<>c
+               | otherwise  = c
+       go lvl (Encaps (CustomEncapsulation f) conts) = f $ go lvl <$> conts
+       go _ p = error $ outerConstructorName p <> " cannot be rendered."
+
+
+preferThis :: These a b -> Either a b
+preferThis (This a) = Left a
+preferThis (That b) = Right b
+preferThis (These a _) = Left a
+
+hchunkFor :: Text -> IPresentation m r -> HTMChunkK
+hchunkFor t p | isInline p  = HTMSpan t
+              | otherwise   = HTMDiv t
+
+instance (Monoid r, Sessionable r) => SG.Semigroup (IPresentation m r) where
+  StaticContent c <> StaticContent d = StaticContent $ c<>d
+  Encaps ManualCSSClasses (WriterT elems₀) <> Encaps ManualCSSClasses (WriterT elems₁)
+     = Encaps ManualCSSClasses . WriterT . disambiguate $ elems₀ ++ elems₁
+   where disambiguate = go 0 Map.empty
+          where go _ _ [] = []
+                go i occupied ((q,c):qs)
+                 | Txt.null (_hchunkCSSClass c) || c`Map.member`occupied
+                    = let c' = c & hchunkCSSClass .~ Txt.pack ("anonymousCell-"++show i)
+                      in go (i+1) occupied (( fmap (fst . head . runWriterT)
+                                             . Encaps ManualCSSClasses $ WriterT [(q,c)]
+                                            , c' ):qs)
+                 | otherwise
+                    = (q,c) : go (i+1) (Map.insert c () occupied) qs
+  Resultless (Encaps ManualCSSClasses ps) <> Resultless (Encaps ManualCSSClasses qs)
+      = Resultless $ Encaps ManualCSSClasses (discardResult<$>ps)
+               SG.<> Encaps ManualCSSClasses (discardResult<$>qs)
+  Resultless p@(Encaps ManualCSSClasses _) <> c
+      = Resultless p <> Resultless (Encaps ManualCSSClasses $ WriterT [(c,hchunkFor""c)])
+  c <> Resultless p@(Encaps ManualCSSClasses _)
+      = Resultless (Encaps ManualCSSClasses $ WriterT [(c,hchunkFor""c)]) <> Resultless p
+  p <> q = fmap fold . Encaps ManualCSSClasses $ WriterT
+             [(p, hchunkFor"anonymousCell-0"p), (q, hchunkFor"anonymousCell-1"q)]
+instance ∀ m . Monoid (IPresentation m ()) where
+  mappend = (SG.<>)
+  mempty = Resultless $ Encaps ManualCSSClasses
+                (WriterT [] :: WriterT HTMChunkK [] (IPresentation m ()))
+
+instance ∀ m . SemigroupNo 0 (IPresentation m ()) where
+  sappendN _ (Resultless (Encaps GriddedBlocks l))
+             (Resultless (Encaps GriddedBlocks r))
+           = Resultless . Encaps GriddedBlocks $ (discardResult<$>l) │ (discardResult<$>r)
+  sappendN _ l@(Resultless (Encaps GriddedBlocks _)) r
+           = l │ Resultless (Encaps GriddedBlocks $ pure r)
+  sappendN _ l r
+           = Resultless (Encaps GriddedBlocks $ pure l) │ r
+
+instance ∀ m . SemigroupNo 1 (IPresentation m ()) where
+  sappendN _ (Resultless (Encaps GriddedBlocks t))
+             (Resultless (Encaps GriddedBlocks b))
+           = Resultless . Encaps GriddedBlocks $ (discardResult<$>t) ── (discardResult<$>b)
+  sappendN _ t@(Resultless (Encaps GriddedBlocks _)) b
+           = t ── Resultless (Encaps GriddedBlocks $ pure b)
+  sappendN _ t b
+           = Resultless (Encaps GriddedBlocks $ pure t) ── b
+
+
+outerConstructorName :: IPresentation m r -> String
+outerConstructorName (StaticContent _) = "StaticContent"
+outerConstructorName (Resultless _) = "Resultless"
+outerConstructorName (Styling _ _) = "Styling"
+outerConstructorName (Encaps (WithHeading _) _) = "Encaps WithHeading"
+outerConstructorName (Encaps (CustomEncapsulation _) _) = "Encaps CustomEncapsulation"
+outerConstructorName (Encaps ManualCSSClasses _) = "Encaps ManualCSSClasses"
+outerConstructorName (Encaps GriddedBlocks _) = "Encaps GriddedBlocks"
+outerConstructorName (Pure _) = "Pure"
+outerConstructorName (Deterministic _ _) = "Deterministic"
+outerConstructorName (Interactive _ _) = "Interactive"
+outerConstructorName (Dependent _ _) = "Dependent"
+
+discardResult :: IPresentation m r -> IPresentation m ()
+discardResult (StaticContent c) = StaticContent c
+discardResult (Resultless p) = Resultless p
+discardResult p = Resultless p
+
+serverSide :: Sessionable a => m a -> IPresentation m a
+serverSide = Interactive (pure ())
+
+instance Functor (IPresentation m) where
+  fmap f (Deterministic g q) = Deterministic (f . g) q
+  fmap f (Pure x) = Pure $ f x
+  fmap f q = Deterministic f q
+instance Applicative (IPresentation m) where
+  pure = Pure
+  Pure f <*> x = fmap f x
+  f <*> Pure x = fmap ($ x) f
+  fs<*>xs = ap fs xs
+
+instance Monad (IPresentation m) where
+  return = pure
+  StaticContent c >>= f = Dependent (StaticContent c) f
+  Resultless p >>= f = Dependent (Resultless p) f
+  Styling _ (Pure x) >>= f = f x
+  Styling s (StaticContent c) >>= f = Dependent (Styling s (StaticContent c)) f
+  Styling s (Resultless c) >>= f = Dependent (Styling s (Resultless c)) f
+  Styling s (Styling s' x) >>= f = Styling (s++s') x >>= f
+  Styling s (Encaps (WithHeading h) x) >>= f
+      = Dependent (Styling s (Encaps (WithHeading h) x)) f
+  Styling s (Encaps ManualCSSClasses x) >>= f
+      = Dependent (Styling s (Encaps ManualCSSClasses x)) f
+  Styling s (Deterministic g x) >>= f = Styling s x >>= f . g
+  Styling s (Interactive p o) >>= f = Dependent (Interactive (Styling s p) o) f
+  Styling s (Dependent p g) >>= f = Dependent (Styling s p) $ Styling s . g >=> f
+  Encaps (WithHeading h) p >>= f = Dependent (Encaps (WithHeading h) p) f
+  Encaps ManualCSSClasses ps >>= f = Dependent (Encaps ManualCSSClasses ps) f
+  Pure x >>= f = f x
+  Deterministic g p >>= f = p >>= f . g
+  Interactive p q >>= f = Dependent (Interactive p q) f
+  Dependent p g >>= f = Dependent p $ g >=> f
+  o >> Interactive (Pure _) q = Interactive (discardResult o) q
+  o >> Pure x = fmap (const x) o
+  o >> n = o >>= const n
+    
+
+infixr 6 ======
+-- | Infix synonym of 'addHeading'. Intended to be used
+--   in @do@ blocks, for headings of presentation slides.
+(======) :: Sessionable r => Html -> IPresentation m r -> IPresentation m r
+(======) = addHeading
+
+addHeading :: Sessionable r => Html -> IPresentation m r -> IPresentation m r
+addHeading h = fmap runIdentity . Encaps (WithHeading h) . Identity
+
+divClass :: Sessionable r => Text -> IPresentation m r -> IPresentation m r
+divClass cn = fmap (fst . head . runWriterT)
+              . Encaps ManualCSSClasses . WriterT . pure . (,HTMDiv cn)
+
+spanClass :: Sessionable r => Text -> IPresentation m r -> IPresentation m r
+spanClass cn = fmap (fst . head . runWriterT)
+              . Encaps ManualCSSClasses . WriterT . pure . (,HTMSpan cn)
+
+infix 8 #%
+-- | Assign this content a CSS class attribute. If the content is inline, this will
+--   be a @<span>@, else a @<div>@.
+(#%) :: Sessionable r => Text -> IPresentation m r -> IPresentation m r
+c#%q
+ | isInline q  = spanClass c q
+ | otherwise   = divClass c q
+
+styling :: Css -> IPresentation m r -> IPresentation m r
+styling s (Styling s' a) = Styling (s:s') a
+styling s a = Styling [s] a
+
+staticContent :: Monoid r => Html -> IPresentation m r
+staticContent = fmap (const mempty) . StaticContent
+
+tweakContent :: Sessionable r => (Html -> Html) -> IPresentation m r -> IPresentation m r
+tweakContent f = fmap runIdentity
+               . Encaps (CustomEncapsulation $ f . runIdentity)
+               . Identity
+
+infixr 6 $<>
+($<>) :: (r ~ (), TMM.SymbolClass σ, TMM.SCConstraint σ LaTeX)
+         => TMM.CAS (TMM.Infix LaTeX) (TMM.Encapsulation LaTeX) (TMM.SymbolD σ LaTeX)
+           -> IPresentation m r -> IPresentation m r
+($<>) = (<>) . renderTeXMaths MathML.DisplayInline . TMM.toMathLaTeX
+
+maths :: (r ~ (), TMM.SymbolClass σ, TMM.SCConstraint σ LaTeX)
+        => [[TMM.CAS (TMM.Infix LaTeX) (TMM.Encapsulation LaTeX) (TMM.SymbolD σ LaTeX)]]
+          -> String -> IPresentation m r
+maths eqns = renderTeXMaths MathML.DisplayBlock . TMM.maths eqns
+
+renderTeXMaths :: MathML.DisplayType -> LaTeX -> IPresentation m ()
+renderTeXMaths dispSty tex = case MathML.readTeX . Txt.unpack $ LaTeX.render tex of
+         Right exps -> StaticContent . HTM.preEscapedText . Txt.pack . XML.showElement
+                        $ MathML.writeMathML dispSty exps
+         Left err -> error $ "Failed to re-parse generated LaTeX. "++err
+
+-- | Include a piece of plaintext, preserving all formatting. To be used in an
+--   oxford bracket.
+--
+--   In practice, you probably want to use this for monospace plaintext, which should
+--   appear in a @<pre>@ or @<textarea>@ tag. Use the specialised quoters for that.
+verbatim :: QuasiQuoter  -- ^ ≈ @'String' -> 'IPresentation' m ()@
+verbatim = verbatimWithin 'id
+
+-- | Convenience wrapper to generate quasi-quoters that will wrap code in any suitable
+--   HTML environment.
+verbatimWithin :: Name         -- ^ A function @'Html' -> 'Html'@ that should be
+                               --   used for presenting the (pre-escaped) plaintext.
+               -> QuasiQuoter  -- ^ A specialised version of 'verbatim' that will
+                               --   always use the wrapper.
+verbatimWithin env
+          = QuasiQuoter (pure . verbExp . preproc) undefined undefined undefined
+ where verbExp = AppE (ConE 'StaticContent)
+             . AppE (VarE env) . AppE (VarE 'HTM.preEscapedString) . LitE . StringL
+       preproc s
+         | (initL, '\n':posNewl) <- break (=='\n') s
+         , all (==' ') initL
+                      = preescapeBlock posNewl
+         | otherwise  = preescapeInline s
+       preescapeBlock s = intercalate "<br>" $ drop zeroIndent <$> sLines
+        where zeroIndent = minimum $ length . takeWhile (==' ') <$> sLines
+              sLines = lines s
+       preescapeInline = concatMap preescapeChar
+       preescapeChar '<' = "&lt;"
+       preescapeChar '>' = "&gt;"
+       preescapeChar '&' = "&amp;"
+       preescapeChar c = [c]
+
+-- | A simple version of 'verbatim' that gives the HTML wrapped in @<pre>@ tags, so
+--   it will (by default) appear in a monospace font.
+plaintext :: QuasiQuoter  -- ^ ≈ @'String' -> 'IPresentation' m ()@
+plaintext = verbatimWithin 'HTM.pre
+       
+-- | Display an image generated on-the-fly in the server. The image will be
+--   stored temporarily, in a content-indexed fashion.
+imageFromFileSupplier :: String               -- ^ File extension
+                      -> (FilePath -> IO ())  -- ^ File-writer function
+                      -> IPresentation IO ()
+imageFromFileSupplier ext = includeMediaFile SimpleImage ext . Left
+
+-- | Display an image that lies on the server as any ordinary static file.
+--   This is a special case of 'useFile', wrapping the file in an @<img>@ tag.
+imageFromFile :: FilePath -> IPresentation IO ()
+imageFromFile file = includeMediaFile SimpleImage (takeExtension file) $ Right file
+
+-- | More general form of 'imageFromFile'. Takes a guess based on the file
+--   extension, as to whether the media is a standing image or a video. In the
+--   latter case, simple HTML5 controls are added.
+mediaFromFile :: FilePath -> IPresentation IO ()
+mediaFromFile file = includeMediaFile (guessMediaFileSetup fileExt) fileExt $ Right file
+ where fileExt = takeExtension file
+
+guessMediaFileSetup :: String -> FileUsageSetup
+guessMediaFileSetup fileExt
+  | fileExt`elem`knownImgFormats    = SimpleImage
+  | fileExt`elem`knownVideoFormats  = SimpleVideo
+  | otherwise  = error $ "Unknow media format ‘"++fileExt++"’. Use one of "
+                            ++ show (knownImgFormats++knownVideoFormats)
+ where knownImgFormats = ('.':)<$>words "png gif jpg jpeg"
+       knownVideoFormats = ('.':)<$>words "webm ogg mp4"
+
+data FileUsageSetup
+      = SimpleImage
+      | SimpleVideo
+      | CustomFile (Url -> Html)
+
+type Url = FilePath
+
+useFile :: FilePath            -- ^ File that should be served to the client
+        -> (Url -> Html)       -- ^ How it should be used in the presentation
+        -> IPresentation IO ()
+useFile file use = includeMediaFile (CustomFile use) (takeExtension file) $ Right file
+
+useFileSupplier :: String               -- ^ File extension
+                -> (FilePath -> IO ())  -- ^ Server-side file-providing action
+                -> (Url -> Html)        -- ^ How to use the file client-side
+                -> IPresentation IO ()
+useFileSupplier ext supplier use = includeMediaFile (CustomFile use) ext $ Left supplier
+
+includeMediaFile :: FileUsageSetup -> FilePath
+             -> Either (FilePath -> IO ()) FilePath -> IPresentation IO ()
+includeMediaFile mediaSetup fileExt fileSupp = do
+   let prepareServing file hashLen completeHash = do
+         let linkPath = pStatDir</>take hashLen completeHash<.>takeExtension file
+         isOccupied <- doesPathExist linkPath
+         absOrig <- makeAbsolute file
+         let codedName = takeBaseName linkPath
+             makeThisLink = do
+               createFileLink absOrig linkPath
+               return codedName
+             disambiguate
+              | hashLen < length linkPath  = prepareServing file (hashLen+1) completeHash
+         if isOccupied
+            then do
+              isSymlk <- pathIsSymbolicLink linkPath
+              if isSymlk
+                then do
+                  existingTgt <- getSymbolicLinkTarget linkPath
+                  if existingTgt/=absOrig
+                   then disambiguate
+                   else return codedName
+                else disambiguate
+            else makeThisLink
+   imgCode <- case fileSupp of
+       Right file
+          -> serverSide . prepareServing file 4 . base64md5 . BSL.fromStrict . BC8.pack
+                 $ show file
+       Left supplier
+          -> serverSide $ do
+               tmpFile <- emptyTempFile pStatDir fileExt
+               supplier tmpFile
+               longHash <- base64md5 <$> BSL.readFile tmpFile
+               let file = pStatDir</>longHash<.>fileExt
+               renameFile tmpFile file
+               prepareServing file 4 (base64md5 . BSL.fromStrict $ BC8.pack file)
+               
+   let servableFile = "/pseudostatic"</>imgCode<.>fileExt
+    in StaticContent $ case mediaSetup of
+         SimpleImage -> [hamlet| <img src=#{servableFile}> |]()
+         SimpleVideo -> [hamlet| <video src=#{servableFile} controls> |]()
+         CustomFile use -> use servableFile
+
+
+getChPosR :: PresProgress -> PositionChange -> Handler Text
+getChPosR oldPosition posStep = do
+   newPosition <- execStateT (changePos_State posStep) oldPosition
+   toTextUrl $ ExactPositionR newPosition
+
+changePos_State :: PositionChange -> StateT PresProgress Handler ()
+changePos_State (PositionChange path isRevert) = do
+    PresentationServer presentation _ _ <- getYesod
+    go ("", defaultChoiceName, "") (finePath <$> Txt.words path) presentation
+    return ()
+
+ where -- | Traverse into the presentation tree structure to find a suitable
+       --   key to set at the relevant position.
+       --   'go'' will disambiguate path names of different branches.
+       go, go' :: ( PrPath            -- The path traversed already
+                  , Text->PrPath      -- How to use new path-chunks
+                  , Text )            -- Path-chunk being constructed
+               -> [String]            -- Path yet to traverse
+               -> IPresentation IO r  -- Presentation which to proceed
+               -> StateT PresProgress Handler
+                           ( Maybe r  -- Key value this branch yields
+                           , Bool )   -- Whether it contains displayable content
+       go _ [] (StaticContent _) = return $ (Just (), True)
+       go _ [] (Pure x) = return $ (Just x, False)
+       go _ [] (Interactive _ q)
+           = (,error "Don't know if interactive request actually shows something.")
+             . Just <$> liftIO q
+       go crumbs path (Encaps (WithHeading _) (Identity cont))
+           = (,True) . fmap Identity . fst <$> go crumbs path cont
+       go crumbs path (Encaps (CustomEncapsulation _) cont)
+           = (,True) . sequence
+              <$> traverse (\c -> fst <$> go crumbs path c) cont
+       go (crumbh,choiceName,crumbp) [] (Encaps ManualCSSClasses (WriterT conts))
+           = (,True) . sequence . WriterT <$> traverse
+                (\(c,ζ) -> (,ζ) . fst <$> go (crumbh<>case ζ of
+                                              HTMDiv i -> " div."<>i
+                                              HTMSpan i -> " span."<>i
+                                             , choiceName, crumbp) [] c)
+                conts
+       go crumbs path (Deterministic f c) = first (fmap f) <$> go crumbs path c
+       go crumbs [] (Resultless c) = (Just (),) <$> hasDisplayableContent crumbs c
+       go crumbs path (Resultless c) = first (const $ Just()) <$> go crumbs path c
+       go crumbs path (Interactive p _) = first (const Nothing) <$> go crumbs path p
+       go (crumbh, choiceName, crumbp) (('0':prog):path') (Dependent def _)
+           = first (const Nothing)
+                <$> go' (crumbh, choiceName, crumbp<>"0") (prog:path') def
+       go (crumbh, choiceName, crumbp) path' (Dependent def opt) = do
+          key <- lookupProgress $ crumbh <> " span."<>choiceName crumbp
+          case (key, path', isRevert) of
+            (Just k, ('1':prog):path'', _) -> do
+              (resKey, rHasContent)
+                   <- go' (crumbh, choiceName, crumbp<>"1") (prog:path'') $ opt k
+              if isRevert && not rHasContent then do
+                 revertProgress $ crumbh <> " span."<>choiceName crumbp
+                 return (Nothing, False)
+               else return (resKey, rHasContent)
+            (Nothing, ('1':prog):path'', _) -> do
+              (Just k, _) <- go' (crumbh, choiceName, crumbp<>"0") [] def
+              go' (crumbh, choiceName, crumbp<>"1") (prog:path'') $ opt k
+            (_, [[]], False) -> do
+              (key', _) <- go' (crumbh,choiceName,crumbp<>"0") [[]] def
+              case key' of
+               Just k -> do
+                 setProgress path k
+                 skipContentless (crumbh, choiceName, crumbp<>"1") $ opt k
+                 return (Nothing, True)
+               Nothing -> error $ outerConstructorName def ++ " refuses to yield a result value."
+            (_, [[]], True) -> do
+              revertProgress path
+              lHasContent
+                    <- hasDisplayableContent (crumbh, choiceName, crumbp<>"0") def
+              return (Nothing, lHasContent)
+            (Just k, [], False)
+             -> go' (crumbh, choiceName, crumbp<>"1") [] $ opt k
+            (Nothing, [], False)
+             -> return (Nothing, False)
+            (_, dir:_, _)
+             -> error $ "Div-ID "++dir++" not suitable for making a Dependent choice."
+       go crumbs path (Styling _ cont) = go crumbs path cont
+       go (crumbh, choiceName, _) (divid:path) (Encaps ManualCSSClasses (WriterT conts))
+         | Just dividt <-  HTMDiv<$>Txt.stripPrefix "div." (Txt.pack divid)
+                       <|> HTMSpan<$>Txt.stripPrefix "span." (Txt.pack divid)
+         , Just subSel <- lookup dividt $ swap<$>conts
+              = first (fmap $ WriterT . pure . (,dividt))
+                  <$> go (crumbh<>case dividt of
+                                 HTMDiv i -> " div."<>i
+                                 HTMSpan i -> " span."<>i
+                                , choiceName, "") path subSel
+       go _ [] pres
+          = error $ "Need further path information to extract value from a "++outerConstructorName pres
+       go _ (dir:_) pres
+          = error $ "Cannot index ("++dir++") further into a "++outerConstructorName pres
+       go' crumbs path p@(Dependent _ _)  = go crumbs path p
+       go' (crumbh,choiceName,crumbp) ([]:t) p
+              = go ( crumbh<>" span."<>choiceName crumbp
+                   , disambiguateChoiceName choiceName
+                   , "" ) t p
+       go' (crumbh,choiceName,crumbp) [] p
+        | not $ Txt.null crumbp
+              = go ( crumbh<>" span."<>choiceName crumbp
+                   , disambiguateChoiceName choiceName
+                   , "" ) [] p
+       go' crumbs path p = go crumbs path p
+       
+       skipContentless :: (PrPath, Text->PrPath, Text)
+                              -> IPresentation IO r
+                              -> StateT PresProgress Handler (Maybe r)
+       skipContentless _ (Pure x) = return $ Just x
+       skipContentless crumbs (Interactive p a) = do
+          ll <- skipContentless crumbs p
+          case ll of
+            Just _ -> Just <$> liftIO a
+            Nothing -> return Nothing
+       skipContentless (crumbh,choiceName,crumbp) (Dependent def opt) = do
+          let thisDecision = crumbh <> " span."<>choiceName crumbp
+          key <- lookupProgress thisDecision
+          case key of
+            Just k -> skipContentless (crumbh, choiceName, crumbp<>"1") $ opt k
+            Nothing -> do
+               key' <- skipContentless (crumbh, choiceName, crumbp<>"0") def
+               case key' of
+                 Just k' -> do
+                   setProgress thisDecision k'
+                   skipContentless (crumbh, choiceName, crumbp<>"1") $ opt k'
+                 Nothing -> return Nothing
+       skipContentless crumbs (Styling _ c) = skipContentless crumbs c
+       skipContentless crumbs (Resultless c)
+           = fmap (const ()) <$> skipContentless crumbs c
+       skipContentless crumbs (Deterministic f c)
+           = fmap f <$> skipContentless crumbs c
+       skipContentless _ (StaticContent _) = return Nothing
+       skipContentless _ (Encaps _ _) = return Nothing
+       skipContentless _ p = error
+        $ "`skipContentless` does not support "++outerConstructorName p
+
+       hasDisplayableContent :: (PrPath, Text->PrPath, Text)
+                              -> IPresentation IO r
+                              -> StateT PresProgress Handler Bool
+       hasDisplayableContent _ (Pure _) = return False
+       hasDisplayableContent crumbs (Interactive p _) = hasDisplayableContent crumbs p
+       hasDisplayableContent (crumbh,choiceName,crumbp) (Dependent def opt) = do
+          let thisDecision = crumbh <> " span."<>choiceName crumbp
+          key <- lookupProgress thisDecision
+          case key of
+            Just k -> hasDisplayableContent (crumbh, choiceName, crumbp<>"1") $ opt k
+            Nothing -> do
+               hasDisplayableContent (crumbh, choiceName, crumbp<>"0") def
+       hasDisplayableContent crumbs (Styling _ c) = hasDisplayableContent crumbs c
+       hasDisplayableContent crumbs (Resultless c)
+           = hasDisplayableContent crumbs c
+       hasDisplayableContent crumbs (Deterministic f c)
+           = hasDisplayableContent crumbs c
+       hasDisplayableContent _ (StaticContent _) = return True
+       hasDisplayableContent _ (Encaps _ _) = return True
+       hasDisplayableContent _ p = error
+        $ "`hasDisplayableContent` does not support "++outerConstructorName p
+
+       finePath p
+        | Just prog <- fmap (Txt.dropWhile (=='n'))
+                    $ Txt.stripPrefix "span."
+                     =<< Txt.stripSuffix "slide" p
+           = Txt.unpack prog
+        | otherwise  = Txt.unpack p
+
+defaultChoiceName :: Text->PrPath
+defaultChoiceName pdiv = "n"<>pdiv<>"slide"
+
+disambiguateChoiceName :: (Text->PrPath) -> (Text->PrPath)
+disambiguateChoiceName = (.("n"<>))
+
+getResetR :: Handler Html
+getResetR = do
+    clearSession
+    redirect HomeR
+
+
+class (MonadHandler m) => KnowsProgressState m where
+  lookupProgress :: Flat x => PrPath -> m (Maybe x)
+
+instance MonadHandler m
+            => KnowsProgressState (StateT PresProgress m) where
+  lookupProgress path = get >>= lift . runReaderT (lookupProgress path)
+instance MonadHandler m
+            => KnowsProgressState (ReaderT PresProgress m) where
+  lookupProgress path = do
+   PresProgress progs <- ask
+   case Map.lookup (Txt.words path) progs of
+     Just bs
+        | Right decoded <- unflat bs  -> return $ Just decoded
+        | otherwise                   -> error $
+            "Internal error in `lookupProgress`: value "++show bs++" cannot be decoded."
+     Nothing -> return Nothing
+ 
+
+setProgress :: (MonadHandler m, Flat x) => PrPath -> x -> StateT PresProgress m ()
+setProgress path prog = do
+   PresProgress progs <- get
+   
+   let progs' = Map.insert (Txt.words path)
+                           (flat prog) progs
+
+   put $ PresProgress progs'
+
+revertProgress :: MonadHandler m => PrPath -> StateT PresProgress m Bool
+revertProgress path = do
+   PresProgress progs <- get
+   let progs' = Map.delete (Txt.words path) progs
+   put $ PresProgress progs'
+                  
+   return $ Txt.words path`Map.member`progs
+
+     
+
+data YeamerServerConfig = YeamerServerConfig
+   { _yeamerTcpPort :: Int }
+makeLenses ''YeamerServerConfig
+
+instance Default YeamerServerConfig where
+  def = YeamerServerConfig 14910
+     
+yeamer' :: YeamerServerConfig -> Presentation -> IO ()
+yeamer' (YeamerServerConfig port) presentation = do
+   createDirectoryIfMissing True pStatDir
+   pStat <- static pStatDir
+   warp port $ PresentationServer (preprocPres presentation) myStatic pStat
+
+-- | Run a Yesod/Warp web server that will allow the presentation to be viewed
+--   in a web browser, on port 14910. This is a shorthand for @'yeamer'' 'def'@.
+yeamer :: Presentation -> IO ()
+yeamer = yeamer' def
diff --git a/Presentation/Yeamer/Internal/Grid.hs b/Presentation/Yeamer/Internal/Grid.hs
new file mode 100644
--- /dev/null
+++ b/Presentation/Yeamer/Internal/Grid.hs
@@ -0,0 +1,140 @@
+-- |
+-- Module      : Presentation.Yeamer.Internal.Grid
+-- Copyright   : (c) Justus Sagemüller 2017
+-- License     : GPL v3
+-- 
+-- Maintainer  : (@) jsagemue $ uni-koeln.de
+-- Stability   : experimental
+-- Portability : portable
+-- 
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE DeriveFunctor         #-}
+{-# LANGUAGE DeriveFoldable        #-}
+{-# LANGUAGE DeriveTraversable     #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE DataKinds             #-}
+{-# LANGUAGE RankNTypes            #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TemplateHaskell       #-}
+
+module Presentation.Yeamer.Internal.Grid where
+
+import Data.Semigroup.Numbered
+
+import GHC.Generics
+
+import Data.Aeson (FromJSON, ToJSON)
+import Data.Flat (Flat)
+
+import Data.Ratio ((%))
+
+import Data.List (sortBy)
+import Data.Ord (comparing)
+
+import Control.Applicative (liftA2)
+import Control.Arrow (second)
+
+import Lens.Micro
+import Lens.Micro.TH
+
+data Gridded a = GridRegion a
+               | GridDivisions [[Gridded a]]
+  deriving (Generic, Functor, Eq, Show, Foldable, Traversable)
+instance FromJSON a => FromJSON (Gridded a)
+instance ToJSON a => ToJSON (Gridded a)
+instance Flat a => Flat (Gridded a)
+
+instance Applicative Gridded where
+  pure = GridRegion
+  fs <*> GridRegion x = ($ x) <$> fs
+  GridRegion f <*> xs = f <$> xs
+  GridDivisions fs <*> GridDivisions xs = GridDivisions $ liftA2 (<*>) <$> fs <*> xs
+instance Monad Gridded where
+  return = GridRegion
+  GridRegion x >>= f = f x
+  GridDivisions xs >>= f = GridDivisions $ map (>>=f) <$> xs
+
+instance SemigroupNo 0 (Gridded a) where
+  sappendN _ (GridDivisions g) (GridDivisions h) | length g == length h
+        = GridDivisions $ zipWith (++) g h
+  sappendN _ e (GridDivisions [r]) = GridDivisions [e:r]
+  sappendN _ (GridDivisions [r]) e = GridDivisions [r++[e]]
+  sappendN p a b = GridDivisions [[a,b]]
+
+instance SemigroupNo 1 (Gridded a) where
+  sappendN _ (GridDivisions g@(l:_)) (GridDivisions h@(m:_)) | length l == length m
+        = GridDivisions $ g++h
+  sappendN _ e (GridDivisions c@([r]:_)) = GridDivisions $ [e]:c
+  sappendN _ (GridDivisions c@([r]:_)) e = GridDivisions $ c++[[e]]
+  sappendN p a b = GridDivisions [[a],[b]]
+  
+
+data GridRange = GridRange {
+      _xBegin, _xEnd, _yBegin, _yEnd :: Int }
+   deriving (Eq, Show, Generic)
+makeLenses ''GridRange
+data GridLayout a = GridLayout {
+      _gridWidth, _gridHeight :: Int
+    , _gridContents :: [(GridRange, a)]
+    } deriving (Functor, Generic, Eq, Show)
+makeLenses ''GridLayout
+
+layoutGrid :: Gridded a -> GridLayout a
+-- layoutGrid = fmap snd . fst . layoutGridP
+
+type GridRegionId = Int
+
+layoutGridP :: Gridded a -> ( GridLayout (GridRegionId, a)
+                            , [(GridRegionId, b)] -> Gridded b )
+layoutGridP g = ( layoutGrid g & gridContents %~ zipWith (second . (,)) [0..]
+                , const undefined )
+
+layoutGrid (GridRegion a) = GridLayout 1 1 [(GridRange 0 1 0 1, a)]
+layoutGrid (GridDivisions []) = GridLayout 0 0 []
+layoutGrid (GridDivisions [row])
+    = alignLayoutDirectional gridWidth xBegin xEnd
+                             gridHeight yBegin yEnd
+                        $ layoutGrid <$> row
+layoutGrid (GridDivisions rows)
+    = alignLayoutDirectional gridHeight yBegin yEnd
+                             gridWidth xBegin xEnd
+                        $ layoutGrid . GridDivisions . pure <$> rows
+
+alignLayoutDirectional
+    :: Lens' (GridLayout a) Int -> Lens' GridRange Int -> Lens' GridRange Int
+    -> Lens' (GridLayout a) Int -> Lens' GridRange Int -> Lens' GridRange Int
+    -> [GridLayout a] -> GridLayout a
+alignLayoutDirectional gridLength sBegin sEnd
+                       gridThickness zBegin zEnd
+                           = align . map (\(ζ, h') -> ((0,h'), (h',(ζ,0))))
+                                                  . xcat 0
+ where align state = case sortBy (comparing $ snd . fst) state of
+           (headSnail@((_,ySnail), _) : others)
+             | ySnail < 1
+               -> case break ((>ySnail) . snd . fst) others of
+                    (snails, hares)
+                      -> align $
+                            [ ((ySnail, ySnail+h'), (h', (ζ,i+1)))
+                            | (_, (h', (ζ,i))) <- headSnail : snails ]
+                         ++ [ ((ySnail,yHare), (h', shiftup cH))
+                            | ((_,yHare), (h', cH)) <- hares ]
+           _   -> gather $ fst . snd . snd <$> state
+       shiftup (ζ, i)
+          = ( ζ & gridThickness %~ (+1)
+                & gridContents . mapped
+                         %~ \(range, a) -> (range & zBegin%~shift
+                                                  & zEnd%~shift  , a)
+            , i+1 )
+        where shift j | j>i        = j+1
+                      | otherwise  = j
+       xcat _ [] = []
+       xcat ix (ζ : cells)
+          = ( ζ & gridContents . mapped . _1 %~ (sBegin %~(+ix))
+                                              . (sEnd %~(+ix))
+            , 1%(ζ^.gridThickness) )
+              : xcat (ix + ζ^.gridLength) cells
+       gather [ζ] = ζ
+       gather (ζ₀ : others) = case gather others of
+               ζo | ζ₀^.gridThickness == ζo^.gridThickness
+                    -> ζo & gridLength %~ (ζ₀^.gridLength +)
+                          & gridContents %~ (ζ₀^.gridContents ++)
diff --git a/Presentation/Yeamer/Internal/PrPathStepCompression.hs b/Presentation/Yeamer/Internal/PrPathStepCompression.hs
new file mode 100644
--- /dev/null
+++ b/Presentation/Yeamer/Internal/PrPathStepCompression.hs
@@ -0,0 +1,27 @@
+-- |
+-- Module      : Presentation.Yeamer.Internal.PrPathStepCompression
+-- Copyright   : (c) Justus Sagemüller 2017
+-- License     : GPL v3
+-- 
+-- Maintainer  : (@) jsagemue $ uni-koeln.de
+-- Stability   : experimental
+-- Portability : portable
+-- 
+module Presentation.Yeamer.Internal.PrPathStepCompression where
+
+
+import qualified Codec.Compression.Zlib as Zlib
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Lazy as BSL
+import qualified Data.Text as Txt
+import qualified Data.Text.Encoding as Txt
+
+compressPrPathSteps :: [Txt.Text] -> BS.ByteString
+compressPrPathSteps
+    = BSL.toStrict . Zlib.compress . BSL.fromStrict . Txt.encodeUtf8 . Txt.unlines
+decompressPrPathSteps :: BS.ByteString -> [Txt.Text]
+decompressPrPathSteps
+    = Txt.lines . Txt.decodeUtf8 . BSL.toStrict . Zlib.decompress . BSL.fromStrict
+
+noProgressSteps :: BS.ByteString
+noProgressSteps = compressPrPathSteps []
diff --git a/Presentation/Yeamer/Internal/Progress.hs b/Presentation/Yeamer/Internal/Progress.hs
new file mode 100644
--- /dev/null
+++ b/Presentation/Yeamer/Internal/Progress.hs
@@ -0,0 +1,86 @@
+-- |
+-- Module      : Presentation.Yeamer.Internal.Progress
+-- Copyright   : (c) Justus Sagemüller 2018
+-- License     : GPL v3
+-- 
+-- Maintainer  : (@) jsagemue $ uni-koeln.de
+-- Stability   : experimental
+-- Portability : portable
+-- 
+{-# LANGUAGE DeriveGeneric              #-}
+module Presentation.Yeamer.Internal.Progress where
+
+
+import Presentation.Yeamer.Internal.PrPathStepCompression
+
+import Data.Map (Map)
+import qualified Data.Map as Map
+import qualified Data.Vector as Arr
+
+import Data.ByteString (ByteString)
+import Data.Text (Text)
+import qualified Data.Text.Encoding as Txt
+import qualified Data.ByteString.Base64.URL as URLBase64
+
+import Data.Flat (Flat, flat, unflat)
+import qualified Data.Aeson as JSON
+
+import Yesod (PathPiece(..))
+
+import Control.Arrow ((>>>), (<<<))
+import Control.Monad ((>=>))
+import Control.Monad.Trans.List
+import Control.Monad.Trans.Writer
+import Lens.Micro (_Right)
+import Lens.Micro.Extras (preview)
+
+import Data.Traversable.Redundancy (rmRedundancy)
+
+import GHC.Generics
+
+
+type PrPath = Text
+
+newtype PresProgress = PresProgress
+    { getPresentationProgress :: Map [PrPath] ByteString }
+    deriving (Eq, Show, Read)
+
+instance PathPiece PresProgress where
+  fromPathPiece = Txt.encodeUtf8
+              >>> preview _Right . URLBase64.decode
+              >=> preview _Right . fmap assemblePresProgress . unflat
+  toPathPiece   = Txt.decodeUtf8
+              <<<                  URLBase64.encode
+              <<<                  flat . disassemblePresProgress
+
+assemblePresProgress :: ((ByteString, [ByteString]), Map [Int] Int) -> PresProgress
+assemblePresProgress ((pSR_l_c, pKR_l), prog_c)
+          = PresProgress . Map.mapKeys (map (progStepRsr Arr.!))
+                          $ fmap (progKeyRsr Arr.!) prog_c
+ where progStepRsr = Arr.fromList $ decompressPrPathSteps pSR_l_c
+       progKeyRsr = Arr.fromList pKR_l
+
+disassemblePresProgress :: PresProgress -> ((ByteString, [ByteString]), Map [Int] Int)
+disassemblePresProgress (PresProgress progs)
+         = ( ( compressPrPathSteps $ Arr.toList progStepRsr
+             , Arr.toList progKeyRsr )
+           , compressedProgs )
+ where (ListT (WriterT keyCompressed), progStepRsr)
+                  = rmRedundancy . ListT . WriterT $ Map.toList progs
+       (compressedProgs,progKeyRsr) = rmRedundancy $ Map.fromList keyCompressed
+
+
+data PositionChange = PositionChange
+    { posChangeLevel :: PrPath
+    , posChangeIsRevert :: Bool
+    } deriving (Generic, Eq, Show, Read)
+instance JSON.FromJSON PositionChange
+
+instance PathPiece PositionChange where
+  fromPathPiece = Txt.encodeUtf8
+                 >>> preview _Right . URLBase64.decode
+                 >=> preview _Right . fmap (uncurry PositionChange) . unflat
+  toPathPiece (PositionChange lvl isRev)
+                = Txt.decodeUtf8
+                 <<< URLBase64.encode
+                   $ flat (lvl, isRev)
diff --git a/Presentation/Yeamer/Maths.hs b/Presentation/Yeamer/Maths.hs
new file mode 100644
--- /dev/null
+++ b/Presentation/Yeamer/Maths.hs
@@ -0,0 +1,32 @@
+-- |
+-- Module      : Presentation.Yeamer.Maths
+-- Copyright   : (c) Justus Sagemüller 2017
+-- License     : GPL v3
+-- 
+-- Maintainer  : (@) jsagemue $ uni-koeln.de
+-- Stability   : experimental
+-- Portability : portable
+-- 
+-- Convenience module, re-exporting the necessary LaTeX builders for writing maths
+-- in a Yeamer presentation.
+
+{-# LANGUAGE CPP #-}
+
+module Presentation.Yeamer.Maths
+                ( module Presentation.Yeamer
+                , module Math.LaTeX.Prelude
+                , module Math.LaTeX.StringLiterals
+                , Math
+                ) where
+
+
+import Presentation.Yeamer
+import Math.LaTeX.Prelude hiding ( maths
+#if MIN_VERSION_TeX_my_math(0,201,2)
+                                 , ($<>)
+#endif
+                                 )
+import Math.LaTeX.StringLiterals ()
+import Text.LaTeX (LaTeX)
+
+type Math = Expression LaTeX
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/demo/Main.hs b/demo/Main.hs
new file mode 100644
--- /dev/null
+++ b/demo/Main.hs
@@ -0,0 +1,143 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE QuasiQuotes       #-}
+
+import Presentation.Yeamer
+import Presentation.Yeamer.Maths
+
+import Text.Cassius
+
+import Data.Semigroup
+import Data.Semigroup.Numbered
+
+import qualified Diagrams.Prelude as Dia
+import qualified Diagrams.Backend.Cairo as Dia
+
+main :: IO ()
+main = yeamer . styling style $ do
+   ""
+    ──
+    "main-title"#%"The Yeamer Presentation Engine"
+    ──
+    "Click anywhere to start demo"
+   
+   "Idea"
+    ======
+    "Beamonad/Yeamer is a Haskell eDSL for writing screen presentations."
+     ── do
+     "It is based on a free-monad like data structure, with monad "<>verb">>"
+      <>" representing sequencing of slides in the presentation. Thus, if"
+      <>" you click "<>emph"here..."
+     "...the viewer will switch to the next item in the containing "<>verb"do"
+      <>"-block. Use "<>verb"ctrl+click"<>" to revert this."
+
+   "Slide content Ⅰ"
+    ====== do
+     "Yeamer uses your web browser for rendering the slides. Therefore you can"
+        <>" in principle insert any HTML code, e.g. though Hamlet quasi quotes."
+       ──"In most cases, it is however recommended to simply use the "
+        <>verb"OverloadedStrings"<>" extension so text can be written in ordinary"
+        <>" Haskell string literals, and to combine elements with monoid operators."
+     
+     "(You don't need to worry about <special> characters &other; HTML pitfalls"
+      <>" – anything you put in a string literal will appear as-is.)"
+
+     "For the layout, we don't re-invent the wheel: CSS does that job fine."
+      ──styling ([cassius|
+              .reddened
+                  color: #f88
+              .caps
+                  font-size: 85%
+                  text-transform: uppercase |]())
+         ("You can at any point add "<> "reddened"#%"rules" <>" for"
+         <>"caps"#%"css"<>" styling. Usually it's best to do it just once"
+         <>" globally, and define "<>emph"small helper functions"<>" for details.")
+
+   "Slide composition"
+    ====== do
+     "There are three different ways in which "<>verb"Presentation"
+                  <>" is a semigroup, allowing you to put together slides"
+                  <>" out of content chunks:"
+      ── do
+      "The standard Monoid operator "<>verb"<>"<>" simply concatenates"
+       <>" text elements, or else brings the content as close together as possible."
+      "The stacking operator "<>verb"──"
+       ──"puts one element on top"
+       ──"of another."
+      (verb"==="<>"is an ASCII alternative,")
+       ==="it does the same thing."
+       ━━"So does "<>verb"━━"<>", except it has lower precedence."
+      "The siding operator "<>verb"│"<>"puts one element beside another."
+       ┃ "Alternatives: "<>verb"|||"<>" and "<>verb"┃"<>"."
+     
+     "All of these operators can be used together," │ "in any nesting."
+                    ──
+       "This allows arranging elements on a slide in an almost “WYSiWYG-like” way."
+      ┃
+        "At the browser level, this is implemented with CSS3 grids, which"
+            <>" automatically negotiate suitable width, height, and word-wrap"
+            <>" for each cell."
+   
+   "Slide content Ⅱ"
+    ====== do
+     "Static images can be included with "<>verb"imageFromFile"<>"."
+      ──
+      imageFromFile "img/beamonad.svg"
+     
+     "Especially for mathematical or data plots, it can make sense to generate"
+       <>" the images on-the-fly right from the Haskell code. You can use"
+       <>" anything that's able to generate image files, most popular being the "
+       <>verb"diagrams"<>" library."
+      ── do
+       imageFromDiagram (let line = Dia.fromVertices [0 Dia.^& 0, 1 Dia.^& 0.1]
+                         in Dia.lc Dia.green . Dia.lwO 3 $ line Dia.=== line)
+       "It is "<>emph"not"<>" necessary to come up with filenames for such images."
+        <>small(" (Internally, "<>verb"yeamer"<>" will use automatic filenames based"
+                <>" on the hashed image content.)")
+     "Other content that can easily be included: videos, maths equations,"
+       <>" step-by-step animations..."
+      ──"You come up with the next idea!"
+   
+   return ()
+
+
+imageFromDiagram :: Dia.Diagram Dia.Cairo -> Presentation
+imageFromDiagram dia = imageFromFileSupplier "png"
+           $ \tgtFile -> Dia.renderCairo tgtFile
+                           (Dia.mkSizeSpec $ Just 400 Dia.^& Just 200) dia
+
+
+style = [cassius|
+   body
+     height: 100vh
+     color: #fc8
+     background-color: #205
+     font-size: 6vmin
+     font-family: "Linux libertine", "Times New Roman"
+   .main-title
+     font-size: 180%
+   h1
+     font-size: 150%
+   div
+     width: 95%
+     height: 95%
+     text-align: center
+     margin: auto
+   .headed-container
+     height: 80%
+   .vertical-concatenation
+     display: flex
+     flex-direction: column
+   .emph
+     font-style: italic
+   .small
+     font-size: 67%
+   .verb
+     display: inline-block
+     font-size: 86%
+     background-color: #227
+     font-family: "Ubuntu Mono", "Droid Sans mono", "Courier New"
+
+  |] ()
+emph = ("emph"#%)
+verb = ("verb"#%)
+small = ("small"#%)
diff --git a/test/Main.hs b/test/Main.hs
new file mode 100644
--- /dev/null
+++ b/test/Main.hs
@@ -0,0 +1,146 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE QuasiQuotes       #-}
+
+import Presentation.Yeamer
+import Presentation.Yeamer.Maths
+
+import Text.Lucius
+import Text.Hamlet
+
+import Data.Foldable
+import Data.Semigroup
+import Data.Semigroup.Numbered
+import Data.String (fromString)
+import Data.Function (fix)
+
+import Data.Time.Clock
+import Data.Time.Clock.POSIX
+
+import Data.Flat (Flat(..))
+
+import qualified Diagrams.Prelude as Dia
+import qualified Diagrams.Backend.Cairo as Dia
+
+import Data.Function
+
+main :: IO ()
+main = yeamer . styling ([lucius|
+                  body {
+                    height: 100vh;
+                  }
+                  body {
+                    color: white;
+                    background-color: black;
+                    font-size: 160%;
+                  }
+                  div {
+                    height: 100%;
+                    text-align: center;
+                  }
+                  pre {
+                    text-align: left;
+                  }
+                  .headed-container {
+                    height: 80%;
+                  }
+                  .vertical-concatenation {
+                    display: flex;
+                    flex-direction: column;
+                  }
+                 |] ()) $ do
+
+
+   "Heading"
+    ======
+    "Simple test “presentation”"
+
+
+   "Code block"
+    ====== [plaintext|
+       bla
+         blub
+           bli
+         blum
+          |]
+
+   "Some maths"
+    ======
+    "Let's consider "<> 𝑎*𝑏/(7-pi) $<>". This ensures"
+     <> maths[[ 𝑥 + 𝑦 ⩵ (-2*ζ,99+𝑢)∫d ρ 𝑧, ""∀:𝑎⪢9 ]
+             ,[ 𝑥 - 𝑦 ⩵ 2786126792567    , ""∀:𝑏⪢3 ]]"."
+     <>"Furthermore, "<> ( 3⊂19 ⩵ ω∩set 𝑚 ) $<>" implies that"
+     <> maths[[ 37◞∑"foo" ≥ 𝑦◞◝(3.79,"bla") ]]","
+     <>"and therefore "<> (-τ) $<>"."
+
+
+   "A slide with automatic grid layout"
+    ====== do
+      "bla" │ "bli" │ "blo"
+        ──
+       "blum"   │  "blubb"
+
+
+   "Image files"
+    ====== do
+    imageFromDiagram (
+        Dia.circle 1 & Dia.lc Dia.red
+      )
+     ──
+     "Plain circle"
+    imageFromFile "/usr/share/icons/HighContrast/256x256/apps/firefox.png"
+     ──
+     "(Firefox logo)"
+
+   
+   "Manual HTML, and cell-wise sequencing"
+    ======
+    staticContent ([hamlet|
+                 <i>Static</i> text
+                 <br>
+                 More <b>text</b>
+                 <br>
+                 <em>More</em> text
+               |]())
+     ──
+     do "Click me!"
+        "You've clicked."
+     ──
+     do "No, me!"
+        "You've clicked."
+
+   
+   "Styling of inline elements"
+    ====== styling ([lucius| .fattened {font-weight: bold; font-style: italic} |]())`id`
+    mconcat (zipWith ($)
+              (cycle [id, ("fattened"#%)])
+              (fromString<$>words"Click any of these words.") )
+   
+   
+   "The current time at the server"
+    ====== do
+     t <- serverSide getCurrentTime
+     fromString $ show t
+
+
+   ()<-"Hydra"
+    ======
+    fix (\h -> "head" >>= \() -> h │ h
+                                 ──
+                                 h │ h )
+
+
+   return ()
+
+
+imageFromDiagram :: Dia.Diagram Dia.Cairo -> Presentation
+imageFromDiagram dia = imageFromFileSupplier "png"
+           $ \tgtFile -> Dia.renderCairo tgtFile
+                           (Dia.mkSizeSpec $ Just 640 Dia.^& Just 480) dia
+
+filling :: Int -> String -> Presentation
+filling n = fromString . concat . replicate n . (++" ")
+
+instance Flat UTCTime where
+  decode = fmap (posixSecondsToUTCTime . realToFrac . (id::Double->Double)) decode
+  encode = encode . (id::Double->Double) . realToFrac . utcTimeToPOSIXSeconds
+  size = size . (id::Double->Double) . realToFrac . utcTimeToPOSIXSeconds
diff --git a/test/tasty/test.hs b/test/tasty/test.hs
new file mode 100644
--- /dev/null
+++ b/test/tasty/test.hs
@@ -0,0 +1,152 @@
+-- |
+-- Module      : Main
+-- Copyright   : (c) Justus Sagemüller 2017
+-- License     : GPL v3
+-- 
+-- Maintainer  : (@) jsag $ hvl.no
+-- Stability   : experimental
+-- Portability : portable
+-- 
+
+module Main where
+
+import Presentation.Yeamer.Internal.Grid
+import Data.Semigroup.Numbered
+
+import qualified Data.Aeson as JSON
+
+import Test.Tasty
+import Test.Tasty.HUnit
+import qualified Test.Tasty.QuickCheck as QC
+import Test.Tasty.QuickCheck (Arbitrary(..))
+
+import Control.Monad
+
+
+main = defaultMain tests
+
+tests :: TestTree
+tests = testGroup "Tests"
+ [ testGroup "Grids"
+   [ testGroup "Concatenation"
+     [ testCase "Singletons, horizontal"
+        $ pure 0 │ pure 1
+           =#?@= ( GridDivisions [ [pure 0, pure 1] ]
+                 , GridLayout 2 1 [(GridRange 0 1 0 1, 0), (GridRange 1 2 0 1, 1)] )
+     , testCase "Singletons, vertical"
+        $ pure 1
+            ──
+          pure 2
+           =#?@= ( GridDivisions [ [pure 1]
+                                 , [pure 2] ]
+                 , GridLayout 1 2 [(GridRange 0 1 0 1, 1), (GridRange 0 1 1 2, 2)] )
+     , testCase "Quadrat"
+        $ pure 0 │ pure 1
+           ──
+          pure 2 │ pure 3
+           =#?@= ( GridDivisions [ [pure 0, pure 1]
+                                 , [pure 2, pure 3] ]
+                 , GridLayout 2 2 [ (GridRange 0 1 0 1, 0), (GridRange 1 2 0 1, 1)
+                                  , (GridRange 0 1 1 2, 2), (GridRange 1 2 1 2, 3) ] )
+     , testCase "Rectangle, landscape"
+        $ pure 0 │ pure 1 │ pure 4
+           ──
+          pure 2 │ pure 3 │ pure 5
+           =#?@= ( GridDivisions [ [pure 0, pure 1, pure 4]
+                                 , [pure 2, pure 3, pure 5] ]
+                 , GridLayout 3 2
+                   [ (GridRange 0 1 0 1, 0), (GridRange 1 2 0 1, 1), (GridRange 2 3 0 1, 4)
+                   , (GridRange 0 1 1 2, 2), (GridRange 1 2 1 2, 3), (GridRange 2 3 1 2, 5) ] )
+     , testCase "Rectangle, portrait"
+        $ pure 0 │ pure 1
+           ──
+          pure 2 │ pure 3
+           ──
+          pure 4 │ pure 5
+           =#?@= ( GridDivisions [ [pure 0, pure 1]
+                                 , [pure 2, pure 3]
+                                 , [pure 4, pure 5] ]
+                 , GridLayout 2 3
+                   [ (GridRange 0 1 0 1, 0), (GridRange 1 2 0 1, 1)
+                   , (GridRange 0 1 1 2, 2), (GridRange 1 2 1 2, 3)
+                   , (GridRange 0 1 2 3, 4), (GridRange 1 2 2 3, 5) ] )
+     , testCase "Rectangle (built non-sequentially)"
+        $ pure 0 │ pure 1
+           ──
+          pure 2 │ pure 3  ┃  pure 4
+                               ──
+                              pure 5
+          @?= GridDivisions [ [pure 0, pure 1, pure 4]
+                            , [pure 2, pure 3, pure 5] ]
+     , testCase "Nonuniform last row"
+        $ pure 0 │ pure 1 │ pure 2
+           ──
+          pure 3 │ pure 4 │ pure 5
+           ──
+          pure 6     │      pure 7
+           =#?@= ( GridDivisions [ [GridDivisions [[pure 0,pure 1,pure 2]]]
+                                 , [GridDivisions [[pure 3,pure 4,pure 5]]]
+                                 , [GridDivisions [[pure 6   ,    pure 7]]] ]
+                 , GridLayout 4 3
+                   [ (GridRange 0 1 0 1, 0), (GridRange 1 3 0 1, 1), (GridRange 3 4 0 1, 2)
+                   , (GridRange 0 1 1 2, 3), (GridRange 1 3 1 2, 4), (GridRange 3 4 1 2, 5)
+                   ,        (GridRange 0 2 2 3, 6),         (GridRange 2 4 2 3, 7)          ] )
+     , testCase "Nonuniform first row"
+        $ pure 0 │ pure 1 │ pure 2
+           ──
+          pure 3     │      pure 5
+           ──
+          pure 6     │      pure 7
+           =#?@= (GridDivisions [[GridDivisions [[pure 0,pure 1,pure 2]]]
+                                ,[GridDivisions [[pure 3   ,    pure 5]
+                                                ,[pure 6   ,    pure 7]]]]
+                 , GridLayout 4 3
+                   [ (GridRange 0 1 0 1, 0), (GridRange 1 3 0 1, 1), (GridRange 3 4 0 1, 2)
+                   ,        (GridRange 0 2 1 2, 3),         (GridRange 2 4 1 2, 5)
+                   ,        (GridRange 0 2 2 3, 6),         (GridRange 2 4 2 3, 7)          ] )
+     ]
+   , testGroup "JSON consistency"
+     [ QC.testProperty "Parsing back structure"
+        $ \g -> JSON.decode (JSON.encode g)
+                == Just (g :: Gridded ())
+     , QC.testProperty "Parsing back structure and values"
+        $ \g -> JSON.decode (JSON.encode g)
+                == Just (g :: Gridded Int)
+     ]
+   ]
+ ]
+
+
+instance (Arbitrary a) => Arbitrary (Gridded a) where
+  arbitrary = do
+    values <- arbitrary
+    arbGrid values
+   where arbGrid [] = do
+           emptyDir <- arbitrary
+           return . GridDivisions $ if emptyDir then [] else [[]]
+         arbGrid [v] = return $ GridRegion v
+         arbGrid values = GridDivisions <$> do
+           [width,height] <- replicateM 2
+                    $ (+1) . (`mod`maxSize) . QC.getNonNegative <$> arbitrary
+           let portionSize = fromIntegral n / fromIntegral (width*height)
+               portions = splitPortns portionSize 0 0 values
+               rows = splitEach width portions
+           forM rows $ mapM arbGrid
+          where n = length values
+                maxSize = floor $ fromIntegral n
+                splitPortns _ _ _ [] = []
+                splitPortns pnSize pos ideal l
+                    = case splitAt thisSize l of
+                        (portion, rest) ->
+                          portion : splitPortns pnSize (pos+thisSize) (ideal+pnSize) rest
+                 where thisSize
+                        | fromIntegral pos > ideal  = floor pnSize
+                        | otherwise                 = ceiling pnSize
+                splitEach _ [] = []
+                splitEach n l = case splitAt n l of
+                   (portion,rest) -> portion : splitEach n rest
+
+
+infix 1 =#?@=
+(=#?@=) :: (Eq a, Show a) => Gridded a -> (Gridded a, GridLayout a) -> Assertion
+a =#?@= b = (a, layoutGrid a) @?= b
diff --git a/yeamer.cabal b/yeamer.cabal
new file mode 100644
--- /dev/null
+++ b/yeamer.cabal
@@ -0,0 +1,118 @@
+-- Initial yeamer.cabal generated by cabal init.  For further 
+-- documentation, see http://haskell.org/cabal/users-guide/
+
+name:                yeamer
+version:             0.1.0.0
+synopsis:            Yesod-based server for interactive presentation slides
+-- description:         
+homepage:            https://github.com/leftaroundabout/yeamer
+license:             GPL-3
+license-file:        LICENSE
+author:              Justus Sagemüller
+maintainer:          (@) jsag $ hvl.no
+-- copyright:           
+category:            Keynote, Presentation, Graphics
+build-type:          Simple
+extra-source-files:  ChangeLog.md
+cabal-version:       >=1.10
+
+library
+  exposed-modules:     Presentation.Yeamer
+                       Presentation.Yeamer.Maths
+                       Presentation.Yeamer.Internal.Grid
+  other-modules:       Control.Monad.Trans.Writer.JSONable
+                       Presentation.Yeamer.Internal.PrPathStepCompression
+                       Presentation.Yeamer.Internal.Progress
+                       Data.Traversable.Redundancy
+  -- other-extensions:    
+  build-depends:       base >=4.8 && <4.11
+                       , yesod >=1.4 && <1.7
+                       , yesod-form
+                       , yesod-static
+                       , js-jquery
+                       , shakespeare
+                       , blaze-html
+                       , semigroups
+                       , data-default-class
+                       , numbered-semigroups >=0.1 && <0.2
+                       , transformers
+                       , TeX-my-math >=0.201.0.0 && < 0.202
+                       , dumb-cas
+                       , HaTeX
+                       , texmath >=0.9 && <0.10
+                       , xml
+                       , containers
+                       , microlens >=0.4 && <0.6
+                       , microlens-th
+                       , these >=0.7 && <1.1
+                       , these-lens
+                       , text 
+                       , bytestring 
+                       , base64-bytestring 
+                       , flat >0.3.1 && <0.4
+                       , aeson 
+                       , zlib
+                       , filepath
+                       , temporary
+                       , template-haskell
+                       , vector
+  if os(windows)
+     build-depends:    directory >= 1.3.1.0
+  else
+     build-depends:    directory
+                       , unix
+  -- hs-source-dirs:      
+--  ghc-options:         -ddump-splices
+  default-language:    Haskell2010
+
+executable test-presentation
+  main-is:             Main.hs
+  -- other-modules:       
+  -- other-extensions:
+  build-depends:       base >=4.8 && <4.11
+                       , yeamer
+                       , shakespeare
+                       , TeX-my-math
+                       , semigroups
+                       , numbered-semigroups
+                       , time
+                       , diagrams-lib, diagrams-cairo
+                       , flat
+  hs-source-dirs:      test
+  ghc-options:         -rtsopts "-with-rtsopts=-M2G"
+  default-language:    Haskell2010
+
+executable yeamer-demo
+  main-is:             Main.hs
+  -- other-modules:       
+  -- other-extensions:
+  build-depends:       base >=4.8 && <4.11
+                       , yeamer
+                       , shakespeare
+                       , TeX-my-math
+                       , semigroups
+                       , numbered-semigroups
+                       , diagrams-lib, diagrams-cairo
+  hs-source-dirs:      demo
+  ghc-options:         -rtsopts "-with-rtsopts=-M2G"
+  default-language:    Haskell2010
+
+test-suite test
+  default-language:
+    Haskell2010
+  type:
+    exitcode-stdio-1.0
+  hs-source-dirs:
+    test/tasty
+  main-is:
+    test.hs
+  ghc-options: "-with-rtsopts=-M500M"
+  build-depends:
+      base >= 4 && < 5
+    , tasty >= 0.7
+    , tasty-hunit
+    , tasty-quickcheck
+    , yeamer
+    , numbered-semigroups
+    , aeson
+
