Simple ships with a command-line utility,
smpl, that helps bootstrap applications as well as run then in development mode.
smpl [server] [OPTIONS]
smpl create [OPTIONS] <app_name>
-? --help Display help message
-V --version Print version information
Creating an application
<span class="kw">smpl</span> create [OPTIONS] <span class="kw"><</span>app_name<span class="kw">></span>
app_name. The Haskell module for the new application is the CamelCase derivation of
app_name. For example, an app with the name
test_appwould be created with the module name
By default, only minimal functionality is included in generated apps. The following options add additional functionality:
--templatesincludes support for rendering templates taken from the “views” subdirectory.
--postgresqladds support for creating models that serialize to PostgreSQL, as well as convenience methods for accessing a global PostgreSQL connection.
--sessionsadds the ability to interact with a cookie-based session map.
--allincludes all of the above.
All of these options modify the
[AppName].Common module by adding various instances for
AppSettings type, as well as add dependencies on necessary packages in the app’s cabal file. The
--templates flag also changes the default app handler to use render a placeholder view instead of a simple string.
Running an application
<span class="kw">smpl</span> server
wai-handler-develto run an application in development mode. In particular, it expects
appfunction from the
Applicationmodule to have the type signature
(Application -> IO()) -> IO ()and passes in a continuation to run the
Application. The server will watch for changed files, and recompile and reload the application as necessary.
By default, the server runs on port 3000, but this can be changed with
--port=PORT. If your
app function resides in a different module, use
--module=MODULE to specify it.
The server sets the
ENV environment variable to
development. This can be used by the application that it is running in development mode. For example,
simple-postgresql-orm uses this to start a PostgreSQL server in a subdirectory of the app as well as run all migrations when in development mode.