packages feed

scotty-form 0.1.0.0 → 0.2.0.0

raw patch · 2 files changed

+13/−19 lines, 2 filesdep ~dittodep ~ditto-lucidPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: ditto, ditto-lucid

API changes (from Hackage documentation)

- Web.Scotty.Form: instance Ditto.Backend.FormError Data.Text.Internal.Text
+ Web.Scotty.Form: instance Ditto.Core.Environment Web.Scotty.ActionM Data.Text.Internal.Text

Files

scotty-form.cabal view
@@ -4,7 +4,7 @@ -- http://haskell.org/cabal/users-guide/  name: scotty-form-version: 0.1.0.0+version: 0.2.0.0 synopsis: Html form validation using `ditto` description: Formlet library for `scotty` using `lucid` and `ditto` -- bug-reports:@@ -30,8 +30,8 @@       base >=4.12 && <4.14     , scotty     , text-    , ditto     , lucid-    , ditto-lucid+    , ditto >= 0.4 && <= 0.5+    , ditto-lucid >= 0.4 && <= 0.5   hs-source-dirs: src   default-language: Haskell2010
src/Web/Scotty/Form.hs view
@@ -1,23 +1,25 @@ {-# language OverloadedStrings #-}-{-# language TypeFamilies #-}+{-# language MultiParamTypeClasses #-}+{-# language FlexibleInstances #-}  {-# OPTIONS_GHC -fno-warn-orphans #-}  module Web.Scotty.Form where  import Data.Text (Text)-import Ditto.Backend import Ditto.Core hiding (view) import Ditto.Lucid-import Ditto.Result+import Ditto.Types import Lucid (HtmlT, Html) import Web.Scotty-import qualified Data.Text as T import qualified Data.Text.Lazy as TL -instance FormError Text where-  type ErrorInputType Text = Text-  commonFormError = T.pack . (commonFormErrorStr T.unpack)+instance Environment ActionM Text where+  environment formId = do+    qp <- params+    case lookup (TL.pack $ show formId) qp of+      Nothing -> pure Missing+      Just x -> pure (Found $ TL.toStrict x)  type ScottyForm a = Form ActionM Text Text (Html ()) a @@ -37,18 +39,10 @@   -> Form ActionM Text err view a   -> ActionM (Result err a, view) reformSingle toForm prefix formlet = do-  qp <- params-  (View viewf, res') <- runForm (Environment $ env qp) (TL.fromStrict prefix) formlet-  res <- res'+  (View viewf, res) <- runForm prefix formlet   case res of     Error errs -> pure (Error errs, toForm [] $ viewf errs)     Ok (Proved _ unProved') -> pure (Ok unProved', toForm [] $ viewf [])-  where-  env :: [Param] -> FormId -> ActionM (Value Text)-  env qp' formId = do-    case lookup (TL.pack $ show formId) qp' of-      Nothing -> pure Missing-      Just x -> pure (Found $ TL.toStrict x)  simpleReformGET :: (Show b, Applicative f)    => Text