packages feed

hamlet 1.1.6.4 → 1.1.7

raw patch · 4 files changed

+28/−17 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Text/Hamlet.hs view
@@ -106,9 +106,12 @@     name <- newName s     (pattern, scope) <- bindingPattern b     return (AsP name pattern, (i, VarE name):scope)-bindingPattern (BindVar i@(Ident s)) = do-    name <- newName s-    return (VarP name, [(i, VarE name)])+bindingPattern (BindVar i@(Ident s))+    | all isDigit s = do+        return (LitP $ IntegerL $ read s, [])+    | otherwise = do+        name <- newName s+        return (VarP name, [(i, VarE name)]) bindingPattern (BindTuple is) = do     (patterns, scopes) <- fmap unzip $ mapM bindingPattern is     return (TupP patterns, concat scopes)@@ -217,14 +220,11 @@         case reads s of             (x, ""):_ -> Just x             _ -> Nothing+    toMatch :: (Binding, [Doc]) -> Q Match     toMatch (idents, inside) = do-        let pat = case map unIdent idents of-                    ["_"] -> WildP-                    [str]-                        | Just i <- readMay str -> LitP $ IntegerL i-                    strs -> let (constr:fields) = map mkName strs-                            in ConP constr (map VarP fields)-        insideExp <- docsToExp env hr scope inside+        (pat, extraScope) <- bindingPattern idents+        let scope' = extraScope ++ scope+        insideExp <- docsToExp env hr scope' inside         return $ Match pat (NormalB insideExp) [] docToExp env hr v (DocContent c) = contentToExp env hr v c 
Text/Hamlet/Parse.hs view
@@ -56,7 +56,7 @@           | LineMaybe Deref Binding           | LineNothing           | LineCase Deref-          | LineOf [Ident]+          | LineOf Binding           | LineTag             { _lineTagName :: String             , _lineAttr :: [(Maybe Deref, String, Maybe [Content])]@@ -224,10 +224,11 @@         return $ LineCase x     controlOf = do         _   <- try $ string "$of"-        pat <- many1 $ try $ spaces >> ident+        spaces+        x <- identPattern         _   <- spaceTabs         eol-        return $ LineOf pat+        return $ LineOf x     content cr = do         x <- many $ content' cr         case cr of@@ -418,7 +419,7 @@          | DocWith [(Deref, Binding)] [Doc]          | DocCond [(Deref, [Doc])] (Maybe [Doc])          | DocMaybe Deref Binding [Doc] (Maybe [Doc])-         | DocCase Deref [([Ident], [Doc])]+         | DocCase Deref [(Binding, [Doc])]          | DocContent Content     deriving (Show, Eq, Read, Data, Typeable) @@ -448,9 +449,9 @@     rest'' <- nestToDoc set rest'     Ok $ DocMaybe d i inside' nothing : rest'' nestToDoc set (Nest (LineCase d) inside:rest) = do-    let getOf (Nest (LineOf pat) insideC) = do+    let getOf (Nest (LineOf x) insideC) = do             insideC' <- nestToDoc set insideC-            Ok (pat, insideC')+            Ok (x, insideC')         getOf _ = Error "Inside a $case there may only be $of.  Use '$of _' for a wildcard."     cases <- mapM getOf inside     rest' <- nestToDoc set rest
hamlet.cabal view
@@ -1,5 +1,5 @@ name:            hamlet-version:         1.1.6.4+version:         1.1.7 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>
test/HamletTest.hs view
@@ -979,6 +979,16 @@         #{field1}
     |]
 
+caseCaseRecord :: Assertion
+caseCaseRecord = do
+  let z = ARecord 10 True
+  helper "10\nTrue" [hamlet|
+    $case z
+      $of ARecord { field1, field2 = x }
+        #{field1}
+        #{x}
+    |]
+
 data Msg = Hello | Goodbye
 
 ihelper :: String -> HtmlUrlI18n Msg Url -> Assertion