reform-hsp-0.2.7.1/ 0000755 0000000 0000000 00000000000 12776026215 012137 5 ustar 00 0000000 0000000 reform-hsp-0.2.7.1/LICENSE 0000644 0000000 0000000 00000002757 12776026215 013157 0 ustar 00 0000000 0000000 Copyright (c)2012, Jeremy Shaw
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Jeremy Shaw nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
reform-hsp-0.2.7.1/reform-hsp.cabal 0000644 0000000 0000000 00000002235 12776026215 015207 0 ustar 00 0000000 0000000 Name: reform-hsp
Version: 0.2.7.1
Synopsis: Add support for using HSP with Reform
Description: Reform is a library for building and validating forms using applicative functors. This package add support for using reform with HSP.
Homepage: http://www.happstack.com/
License: BSD3
License-file: LICENSE
Author: Jeremy Shaw
Maintainer: jeremy@n-heptane.com
Copyright: 2012 Jeremy Shaw, Jasper Van der Jeugt, SeeReason Partners LLC
Category: Web
Build-type: Simple
Cabal-version: >=1.6
tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1
source-repository head
type: git
location: https://github.com/Happstack/reform-hsp.git
Library
Exposed-modules: Text.Reform.HSP.Common
Text.Reform.HSP.String
Text.Reform.HSP.Text
Build-depends: base > 4 && <5,
hsp >= 0.9 && < 0.11,
hsx2hs >= 0.13 && < 0.15,
reform >= 0.2.1 && < 0.3,
text >= 0.11 && < 1.3
reform-hsp-0.2.7.1/Setup.hs 0000644 0000000 0000000 00000000056 12776026215 013574 0 ustar 00 0000000 0000000 import Distribution.Simple
main = defaultMain
reform-hsp-0.2.7.1/Text/ 0000755 0000000 0000000 00000000000 12776026215 013063 5 ustar 00 0000000 0000000 reform-hsp-0.2.7.1/Text/Reform/ 0000755 0000000 0000000 00000000000 12776026215 014315 5 ustar 00 0000000 0000000 reform-hsp-0.2.7.1/Text/Reform/HSP/ 0000755 0000000 0000000 00000000000 12776026215 014747 5 ustar 00 0000000 0000000 reform-hsp-0.2.7.1/Text/Reform/HSP/Common.hs 0000644 0000000 0000000 00000042146 12776026215 016542 0 ustar 00 0000000 0000000 {-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies, UndecidableInstances, ViewPatterns, OverloadedStrings, QuasiQuotes #-}
module Text.Reform.HSP.Common where
import Data.List (intercalate)
import Data.Monoid ((<>), mconcat)
import Data.Text.Lazy (Text, pack)
import qualified Data.Text as T
import Text.Reform.Backend
import Text.Reform.Core
import Text.Reform.Generalized as G
import Text.Reform.Result (FormId, Result(Ok), unitRange)
import Language.Haskell.HSX.QQ (hsx)
import HSP.XMLGenerator
import HSP.XML
instance (XMLGen m, EmbedAsAttr m (Attr Text Text)) => (EmbedAsAttr m (Attr Text FormId)) where
asAttr (n := v) = asAttr (n := (pack $ show v))
inputText :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text text)) =>
(input -> Either error text)
-> text
-> Form m input error [XMLGenT x (XMLType x)] () text
inputText getInput initialValue = G.input getInput inputField initialValue
where
inputField i a = [hsx| [] |]
inputEmail :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text text)) =>
(input -> Either error text)
-> text
-> Form m input error [XMLGenT x (XMLType x)] () text
inputEmail getInput initialValue = G.input getInput inputField initialValue
where
inputField i a = [hsx| [] |]
inputPassword :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text text)) =>
(input -> Either error text)
-> text
-> Form m input error [XMLGenT x (XMLType x)] () text
inputPassword getInput initialValue = G.input getInput inputField initialValue
where
inputField i a = [hsx| [] |]
inputSubmit :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text text)) =>
(input -> Either error text)
-> text
-> Form m input error [XMLGenT x (XMLType x)] () (Maybe text)
inputSubmit getInput initialValue = G.inputMaybe getInput inputField initialValue
where
inputField i a = [hsx| [] |]
inputReset :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text text)) =>
text
-> Form m input error [XMLGenT x (XMLType x)] () ()
inputReset lbl = G.inputNoData inputField lbl
where
inputField i a = [hsx| [] |]
inputHidden :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text text)) =>
(input -> Either error text)
-> text
-> Form m input error [XMLGenT x (XMLType x)] () text
inputHidden getInput initialValue = G.input getInput inputField initialValue
where
inputField i a = [hsx| [] |]
inputButton :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsAttr x (Attr Text text)) =>
text
-> Form m input error [XMLGenT x (XMLType x)] () ()
inputButton label = G.inputNoData inputField label
where
inputField i a = [hsx| [] |]
textarea :: (Monad m, FormError error, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId), EmbedAsChild x text) =>
(input -> Either error text)
-> Int -- ^ cols
-> Int -- ^ rows
-> text -- ^ initial text
-> Form m input error [XMLGenT x (XMLType x)] () text
textarea getInput cols rows initialValue = G.input getInput textareaView initialValue
where
textareaView i txt = [hsx| [] |]
-- | Create an @\@ element
--
-- This control may succeed even if the user does not actually select a file to upload. In that case the uploaded name will likely be "" and the file contents will be empty as well.
inputFile :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, XMLGenerator x, StringType x ~ Text, EmbedAsAttr x (Attr Text FormId)) =>
Form m input error [XMLGenT x (XMLType x)] () (FileType input)
inputFile = G.inputFile fileView
where
fileView i = [hsx| [] |]
-- | Create a @\