-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Two-column database server.
--   
--   A server that stores a database with two columns, where the elements
--   in each column are of the same type. Operations are fast, although
--   memory usage increases with the number of rows. The implementation is
--   based in bimaps.
@package bimap-server
@version 0.1.0.1


-- | A bimap server is basically a server that stores a one-to-one
--   correspondence between two sets of values. You can think of it as a
--   table with two columns, where each column has elements of the same
--   type. You can lookup the table and update it using JSON based HTTP
--   requests.
--   
--   This is how you run the server:
--   
--   <pre>
--   bimapServer (Proxy :: Proxy Int) -- This proxy specifies the type of the values in the left column
--               (Proxy :: Proxy String) -- This proxy specifies the type of the values in the right column
--                5000 -- Server will be running in port 5000
--                60 -- This is the number of seconds between saves
--   </pre>
--   
--   In this example, the server will save in the file
--   <tt>"saved.bimap"</tt> the table every 60 seconds. Keep in mind that
--   <a>bimapServer</a> will install a handle for SIGTERM signals, meaning
--   that a <tt>kill</tt> signal will be catched by the process, triggering
--   a save of the table. After saving the table, the server will stop
--   running. However, the port that the server was using may still not be
--   available until the program using <a>bimapServer</a> is closed.
--   
--   The interface of the server is as follows:
--   
--   <ul>
--   <li>[GET] <tt>/list</tt>: Returns the list of rows in the table. The
--   format is <tt>[[a1,b1],...,[aN,bN]]</tt>. You can use the aeson's
--   encoding of the type <tt>[(a,b)]</tt> for decoding it.</li>
--   <li>[GET] <tt>/left-lookup</tt>: Lookup an element in the table by
--   searching in the left column. It returns the element in the right
--   column (if any) in JSON format as described by the <a>ToJSON</a>
--   instance. The element to lookup is specified using its JSON encoded
--   form as the body of the HTTP request.</li>
--   <li>[GET] <tt>/right-lookup</tt>: Just as <tt>/left-lookup</tt>,
--   except that using the right column for searching, and returning the
--   element in the left column (if any).</li>
--   <li>[POST] <tt>/insert</tt>: Insert a pair of values in the table,
--   replacing any occurences. The pair is sent in the body of the HTTP
--   request, in JSON format, using the aeson's encoding of pairs (tuples
--   of size 2).</li>
--   <li>[DELETE] <tt>/left-delete</tt>: Delete a row by searching in the
--   left column. The value to look for in the left column is passed
--   JSON-encoded as the body of the HTTP request.</li>
--   <li>[DELETE] <tt>/right-delete</tt>: Just as <tt>/left-delete</tt>,
--   but searching in the right column.</li>
--   </ul>
module Data.Bimap.Server

-- | Function to start a bimap server. The <a>Binary</a> instances are used
--   for saving the table to file. <a>FromJSON</a> and <a>ToJSON</a>
--   instances are used for the HTTP interface. The <a>Ord</a> instances
--   are used to implement fast lookups.
bimapServer :: forall a b. (Binary a, Binary b, FromJSON a, FromJSON b, ToJSON a, ToJSON b, Ord a, Ord b) => Proxy a -> Proxy b -> Int -> Int -> IO ()

-- | A concrete, poly-kinded proxy type
data Proxy k (t :: k) :: forall k. () => k -> *
Proxy :: Proxy k
