Search code examples
scalahaskelllifthaskell-snap-frameworkheist

Form library suited for Snap and Heist


I am looking for a library that helps me create forms using Snap and Heist. There is no "blessed" form library for Snap that I know of, and none of the stray ones on Hackage seem to be particularly suited for the declarative nature of Heist templates.

Since Heist is so very similar to the template system used by the Lift web framework, I was wondering if there's something that would give me similar form support as is available there. If you aren't familiar with it, it would roughly look like this if translated to Heist:

<div class="some-div-in-a-heist-template">
  <my-form-splice>
    Name: <form-input field="name"/>
    <form-error field="name">Errors: <error-string/></form-error>
    Password: <form-input field="password"/>
    <!-- etc -->
    <form-submit/>
  </my-form-splice>
</div>

Are there any libraries available that can be glued together to get support for something like this?


Solution

  • There is a form handling library called digestive-functors. It lets you create a correspondence between forms and Haskell data structures in an applicative style. This might provide some of what you're looking for. Since Heist gives you arbitrary DOM manipulation, you should be able to implement the rest as a library of splices and related functions. To my knowledge no splice library like this exists today.