summaryrefslogtreecommitdiff
path: root/standalone/no-th/haskell-patches/yesod-core_expand_TH.patch
blob: f58fcb353e7d7d22f7fb973ba4a76a57e337ab08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
From f1feea61dcba0b16afed5ce8dd5d2433fe505461 Mon Sep 17 00:00:00 2001
From: dummy <dummy@example.com>
Date: Thu, 16 Oct 2014 02:15:23 +0000
Subject: [PATCH] hack TH

---
 Yesod/Core.hs              |  30 +++---
 Yesod/Core/Class/Yesod.hs  | 256 ++++++++++++++++++++++++++++++---------------
 Yesod/Core/Dispatch.hs     |  38 ++-----
 Yesod/Core/Handler.hs      |  25 ++---
 Yesod/Core/Internal/Run.hs |   6 +-
 Yesod/Core/Internal/TH.hs  | 111 --------------------
 Yesod/Core/Types.hs        |   3 +-
 Yesod/Core/Widget.hs       |  32 +-----
 8 files changed, 213 insertions(+), 288 deletions(-)

diff --git a/Yesod/Core.hs b/Yesod/Core.hs
index 9b29317..7c0792d 100644
--- a/Yesod/Core.hs
+++ b/Yesod/Core.hs
@@ -31,16 +31,16 @@ module Yesod.Core
     , unauthorizedI
       -- * Logging
     , LogLevel (..)
-    , logDebug
-    , logInfo
-    , logWarn
-    , logError
-    , logOther
-    , logDebugS
-    , logInfoS
-    , logWarnS
-    , logErrorS
-    , logOtherS
+    --, logDebug
+    --, logInfo
+    --, logWarn
+    --, logError
+    --, logOther
+    --, logDebugS
+    --, logInfoS
+    --, logWarnS
+    --, logErrorS
+    --, logOtherS
       -- * Sessions
     , SessionBackend (..)
     , customizeSessionCookies
@@ -87,17 +87,15 @@ module Yesod.Core
     , readIntegral
       -- * Shakespeare
       -- ** Hamlet
-    , hamlet
-    , shamlet
-    , xhamlet
+    --, hamlet
+    -- , shamlet
+    --, xhamlet
     , HtmlUrl
       -- ** Julius
-    , julius
+    --, julius
     , JavascriptUrl
     , renderJavascriptUrl
       -- ** Cassius/Lucius
-    , cassius
-    , lucius
     , CssUrl
     , renderCssUrl
     ) where
diff --git a/Yesod/Core/Class/Yesod.hs b/Yesod/Core/Class/Yesod.hs
index 8631d27..c40eb10 100644
--- a/Yesod/Core/Class/Yesod.hs
+++ b/Yesod/Core/Class/Yesod.hs
@@ -5,18 +5,22 @@
 {-# LANGUAGE CPP               #-}
 module Yesod.Core.Class.Yesod where
 
-import           Control.Monad.Logger               (logErrorS)
+--import           Control.Monad.Logger               (logErrorS)
 import           Yesod.Core.Content
 import           Yesod.Core.Handler
 
 import           Yesod.Routes.Class
+import qualified Text.Blaze.Internal
+import qualified Control.Monad.Logger
+import qualified Text.Hamlet
+import qualified Data.Foldable
 
 import           Blaze.ByteString.Builder           (Builder)
 import           Blaze.ByteString.Builder.Char.Utf8 (fromText)
 import           Control.Arrow                      ((***), second)
 import           Control.Monad                      (forM, when, void)
 import           Control.Monad.IO.Class             (MonadIO (liftIO))
-import           Control.Monad.Logger               (LogLevel (LevelInfo, LevelOther),
+import           Control.Monad.Logger               (Loc, LogLevel (LevelInfo, LevelOther),
                                                      LogSource)
 import qualified Data.ByteString.Char8              as S8
 import qualified Data.ByteString.Lazy               as L
@@ -33,7 +37,6 @@ import qualified Data.Text.Encoding.Error           as TEE
 import           Data.Text.Lazy.Builder             (toLazyText)
 import           Data.Text.Lazy.Encoding            (encodeUtf8)
 import           Data.Word                          (Word64)
-import           Language.Haskell.TH.Syntax         (Loc (..))
 import           Network.HTTP.Types                 (encodePath)
 import qualified Network.Wai                        as W
 import           Data.Default                       (def)
@@ -94,18 +97,26 @@ class RenderRoute site => Yesod site where
     defaultLayout w = do
         p <- widgetToPageContent w
         mmsg <- getMessage
-        withUrlRenderer [hamlet|
-            $newline never
-            $doctype 5
-            <html>
-                <head>
-                    <title>#{pageTitle p}
-                    ^{pageHead p}
-                <body>
-                    $maybe msg <- mmsg
-                        <p .message>#{msg}
-                    ^{pageBody p}
-            |]
+        withUrlRenderer  $         \ _render_aHra
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<!DOCTYPE html>\n<html><head><title>");
+                  id (TBH.toHtml (pageTitle p));
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</title>");
+                  Text.Hamlet.asHtmlUrl (pageHead p) _render_aHra;
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</head><body>");
+                  Text.Hamlet.maybeH
+                    mmsg
+                    (\ msg_aHrb
+                       -> do { id
+                                 ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                    "<p class=\"message\">");
+                               id (TBH.toHtml msg_aHrb);
+                               id ((Text.Blaze.Internal.preEscapedText . T.pack) "</p>") })
+                    Nothing;
+                  Text.Hamlet.asHtmlUrl (pageBody p) _render_aHra;
+                  id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack) "</body></html>") }
 
     -- | Override the rendering function for a particular URL. One use case for
     -- this is to offload static hosting to a different domain name to avoid
@@ -374,45 +385,103 @@ widgetToPageContent w = do
     -- modernizr should be at the end of the <head> http://www.modernizr.com/docs/#installing
     -- the asynchronous loader means your page doesn't have to wait for all the js to load
     let (mcomplete, asyncScripts) = asyncHelper render scripts jscript jsLoc
-        regularScriptLoad = [hamlet|
-            $newline never
-            $forall s <- scripts
-                ^{mkScriptTag s}
-            $maybe j <- jscript
-                $maybe s <- jsLoc
-                    <script src="#{s}">
-                $nothing
-                    <script>^{jelper j}
-        |]
-
-        headAll = [hamlet|
-            $newline never
-            \^{head'}
-            $forall s <- stylesheets
-                ^{mkLinkTag s}
-            $forall s <- css
-                $maybe t <- right $ snd s
-                    $maybe media <- fst s
-                        <link rel=stylesheet media=#{media} href=#{t}>
-                    $nothing
-                        <link rel=stylesheet href=#{t}>
-                $maybe content <- left $ snd s
-                    $maybe media <- fst s
-                        <style media=#{media}>#{content}
-                    $nothing
-                        <style>#{content}
-            $case jsLoader master
-              $of BottomOfBody
-              $of BottomOfHeadAsync asyncJsLoader
-                  ^{asyncJsLoader asyncScripts mcomplete}
-              $of BottomOfHeadBlocking
-                  ^{regularScriptLoad}
-        |]
-    let bodyScript = [hamlet|
-            $newline never
-            ^{body}
-            ^{regularScriptLoad}
-        |]
+        regularScriptLoad =         \ _render_aHsO
+          -> do { Data.Foldable.mapM_
+                    (\ s_aHsP
+                       -> Text.Hamlet.asHtmlUrl (mkScriptTag s_aHsP) _render_aHsO)
+                    scripts;
+                  Text.Hamlet.maybeH
+                    jscript
+                    (\ j_aHsQ
+                       -> Text.Hamlet.maybeH
+                            jsLoc
+                            (\ s_aHsR
+                               -> do { id
+                                         ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                            "<script src=\"");
+                                       id (TBH.toHtml s_aHsR);
+                                       id
+                                         ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                            "\"></script>") })
+                            (Just
+                               (do { id
+                                       ((Text.Blaze.Internal.preEscapedText . T.pack) "<script>");
+                                     Text.Hamlet.asHtmlUrl (jelper j_aHsQ) _render_aHsO;
+                                     id ((Text.Blaze.Internal.preEscapedText . T.pack) "</script>") })))
+                    Nothing }
+
+
+        headAll =         \ _render_aHsW
+          -> do { Text.Hamlet.asHtmlUrl head' _render_aHsW;
+                  Data.Foldable.mapM_
+                    (\ s_aHsX -> Text.Hamlet.asHtmlUrl (mkLinkTag s_aHsX) _render_aHsW)
+                    stylesheets;
+                  Data.Foldable.mapM_
+                    (\ s_aHsY
+                       -> do { Text.Hamlet.maybeH
+                                 (right (snd s_aHsY))
+                                 (\ t_aHsZ
+                                    -> Text.Hamlet.maybeH
+                                         (fst s_aHsY)
+                                         (\ media_aHt0
+                                            -> do { id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "<link rel=\"stylesheet\" media=\"");
+                                                    id (TBH.toHtml media_aHt0);
+                                                    id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "\" href=\"");
+                                                    id (TBH.toHtml t_aHsZ);
+                                                    id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "\">") })
+                                         (Just
+                                            (do { id
+                                                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                       "<link rel=\"stylesheet\" href=\"");
+                                                  id (TBH.toHtml t_aHsZ);
+                                                  id
+                                                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                       "\">") })))
+                                 Nothing;
+                               Text.Hamlet.maybeH
+                                 (left (snd s_aHsY))
+                                 (\ content_aHt1
+                                    -> Text.Hamlet.maybeH
+                                         (fst s_aHsY)
+                                         (\ media_aHt2
+                                            -> do { id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "<style media=\"");
+                                                    id (TBH.toHtml media_aHt2);
+                                                    id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "\">");
+                                                    id (TBH.toHtml content_aHt1);
+                                                    id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "</style>") })
+                                         (Just
+                                            (do { id
+                                                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                       "<style>");
+                                                  id (TBH.toHtml content_aHt1);
+                                                  id
+                                                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                       "</style>") })))
+                                 Nothing })
+                    css;
+                  case jsLoader master of {
+                    BottomOfBody -> return ()
+                    ; BottomOfHeadAsync asyncJsLoader_aHt3
+                      -> Text.Hamlet.asHtmlUrl
+                           (asyncJsLoader_aHt3 asyncScripts mcomplete) _render_aHsW
+                    ; BottomOfHeadBlocking
+                      -> Text.Hamlet.asHtmlUrl regularScriptLoad _render_aHsW } }
+
+    let bodyScript =     \ _render_aHt8 -> do { Text.Hamlet.asHtmlUrl body _render_aHt8;
+              Text.Hamlet.asHtmlUrl regularScriptLoad _render_aHt8 }
+
 
     return $ PageContent title headAll $
         case jsLoader master of
@@ -442,10 +511,13 @@ defaultErrorHandler NotFound = selectRep $ do
         r <- waiRequest
         let path' = TE.decodeUtf8With TEE.lenientDecode $ W.rawPathInfo r
         setTitle "Not Found"
-        toWidget [hamlet|
-            <h1>Not Found
-            <p>#{path'}
-        |]
+        toWidget  $         \ _render_aHte
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<h1>Not Found</h1>\n<p>");
+                  id (TBH.toHtml path');
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</p>") }
+
     provideRep $ return $ object ["message" .= ("Not Found" :: Text)]
 
 -- For API requests.
@@ -455,10 +527,11 @@ defaultErrorHandler NotFound = selectRep $ do
 defaultErrorHandler NotAuthenticated = selectRep $ do
     provideRep $ defaultLayout $ do
         setTitle "Not logged in"
-        toWidget [hamlet|
-            <h1>Not logged in
-            <p style="display:none;">Set the authRoute and the user will be redirected there.
-        |]
+        toWidget  $         \ _render_aHti
+          -> id
+               ((Text.Blaze.Internal.preEscapedText . T.pack)
+                  "<h1>Not logged in</h1>\n<p style=\"none;\">Set the authRoute and the user will be redirected there.</p>")
+
 
     provideRep $ do
         -- 401 *MUST* include a WWW-Authenticate header
@@ -480,10 +553,13 @@ defaultErrorHandler NotAuthenticated = selectRep $ do
 defaultErrorHandler (PermissionDenied msg) = selectRep $ do
     provideRep $ defaultLayout $ do
         setTitle "Permission Denied"
-        toWidget [hamlet|
-            <h1>Permission denied
-            <p>#{msg}
-        |]
+        toWidget  $         \ _render_aHtq
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<h1>Permission denied</h1>\n<p>");
+                  id (TBH.toHtml msg);
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</p>") }
+
     provideRep $
         return $ object $ [
           "message" .= ("Permission Denied. " <> msg)
@@ -492,30 +568,42 @@ defaultErrorHandler (PermissionDenied msg) = selectRep $ do
 defaultErrorHandler (InvalidArgs ia) = selectRep $ do
     provideRep $ defaultLayout $ do
         setTitle "Invalid Arguments"
-        toWidget [hamlet|
-            <h1>Invalid Arguments
-            <ul>
-                $forall msg <- ia
-                    <li>#{msg}
-        |]
+        toWidget  $         \ _render_aHtv
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<h1>Invalid Arguments</h1>\n<ul>");
+                  Data.Foldable.mapM_
+                    (\ msg_aHtw
+                       -> do { id ((Text.Blaze.Internal.preEscapedText . T.pack) "<li>");
+                               id (TBH.toHtml msg_aHtw);
+                               id ((Text.Blaze.Internal.preEscapedText . T.pack) "</li>") })
+                    ia;
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</ul>") }
+
     provideRep $ return $ object ["message" .= ("Invalid Arguments" :: Text), "errors" .= ia]
 defaultErrorHandler (InternalError e) = do
-    $logErrorS "yesod-core" e
     selectRep $ do
         provideRep $ defaultLayout $ do
             setTitle "Internal Server Error"
-            toWidget [hamlet|
-                <h1>Internal Server Error
-                <pre>#{e}
-            |]
+            toWidget  $             \ _render_aHtC
+              -> do { id
+                        ((Text.Blaze.Internal.preEscapedText . T.pack)
+                           "<h1>Internal Server Error</h1>\n<pre>");
+                      id (TBH.toHtml e);
+                      id ((Text.Blaze.Internal.preEscapedText . T.pack) "</pre>") }
+
         provideRep $ return $ object ["message" .= ("Internal Server Error" :: Text), "error" .= e]
 defaultErrorHandler (BadMethod m) = selectRep $ do
     provideRep $ defaultLayout $ do
         setTitle"Bad Method"
-        toWidget [hamlet|
-            <h1>Method Not Supported
-            <p>Method <code>#{S8.unpack m}</code> not supported
-        |]
+        toWidget  $         \ _render_aHtH
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<h1>Method Not Supported</h1>\n<p>Method <code>");
+                  id (TBH.toHtml (S8.unpack m));
+                  id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "</code> not supported</p>") }
     provideRep $ return $ object ["message" .= ("Bad method" :: Text), "method" .= TE.decodeUtf8With TEE.lenientDecode m]
 
 asyncHelper :: (url -> [x] -> Text)
@@ -682,8 +770,4 @@ loadClientSession key getCachedDate sessionName req = load
 -- turn the TH Loc loaction information into a human readable string
 -- leaving out the loc_end parameter
 fileLocationToString :: Loc -> String
-fileLocationToString loc = (loc_package loc) ++ ':' : (loc_module loc) ++
-  ' ' : (loc_filename loc) ++ ':' : (line loc) ++ ':' : (char loc)
-  where
-    line = show . fst . loc_start
-    char = show . snd . loc_start
+fileLocationToString loc = "unknown"
diff --git a/Yesod/Core/Dispatch.hs b/Yesod/Core/Dispatch.hs
index e0d1f0e..cc23fdd 100644
--- a/Yesod/Core/Dispatch.hs
+++ b/Yesod/Core/Dispatch.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE TypeFamilies #-}
 {-# LANGUAGE FlexibleInstances #-}
@@ -6,18 +5,18 @@
 {-# LANGUAGE CPP #-}
 module Yesod.Core.Dispatch
     ( -- * Quasi-quoted routing
-      parseRoutes
-    , parseRoutesNoCheck
-    , parseRoutesFile
-    , parseRoutesFileNoCheck
-    , mkYesod
+    --  parseRoutes
+    --, parseRoutesNoCheck
+    --, parseRoutesFile
+    --, parseRoutesFileNoCheck
+    --, mkYesod
       -- ** More fine-grained
-    , mkYesodData
-    , mkYesodSubData
-    , mkYesodDispatch
-    , mkYesodSubDispatch
+    --, mkYesodData
+    --, mkYesodSubData
+    --, mkYesodDispatch
+    --, mkYesodSubDispatch
       -- ** Path pieces
-    , PathPiece (..)
+      PathPiece (..)
     , PathMultiPiece (..)
     , Texts
       -- * Convert to WAI
@@ -135,13 +134,6 @@ toWaiAppLogger logger site = do
                 , yreSite = site
                 , yreSessionBackend = sb
                 }
-    messageLoggerSource
-        site
-        logger
-        $(qLocation >>= liftLoc)
-        "yesod-core"
-        LevelInfo
-        (toLogStr ("Application launched" :: S.ByteString))
     middleware <- mkDefaultMiddlewares logger
     return $ middleware $ toWaiAppYre yre
 
@@ -170,14 +162,7 @@ warp port site = do
                 ]
             -}
             , Network.Wai.Handler.Warp.settingsOnException = const $ \e ->
-                when (shouldLog' e) $
-                messageLoggerSource
-                    site
-                    logger
-                    $(qLocation >>= liftLoc)
-                    "yesod-core"
-                    LevelError
-                    (toLogStr $ "Exception from Warp: " ++ show e)
+                when (shouldLog' e) $ error (show e)
             }
   where
     shouldLog' =
@@ -211,7 +196,6 @@ defaultMiddlewaresNoLogging = acceptOverride . autohead . gzip def . methodOverr
 -- | Deprecated synonym for 'warp'.
 warpDebug :: YesodDispatch site => Int -> site -> IO ()
 warpDebug = warp
-{-# DEPRECATED warpDebug "Please use warp instead" #-}
 
 -- | Runs your application using default middlewares (i.e., via 'toWaiApp'). It
 -- reads port information from the PORT environment variable, as used by tools
diff --git a/Yesod/Core/Handler.hs b/Yesod/Core/Handler.hs
index d2b196b..13cac17 100644
--- a/Yesod/Core/Handler.hs
+++ b/Yesod/Core/Handler.hs
@@ -174,7 +174,7 @@ import           Data.Text.Encoding            (decodeUtf8With, encodeUtf8)
 import           Data.Text.Encoding.Error      (lenientDecode)
 import qualified Data.Text.Lazy                as TL
 import qualified Text.Blaze.Html.Renderer.Text as RenderText
-import           Text.Hamlet                   (Html, HtmlUrl, hamlet)
+import           Text.Hamlet                   (Html, HtmlUrl)
 
 import qualified Data.ByteString               as S
 import qualified Data.ByteString.Lazy          as L
@@ -203,6 +203,7 @@ import Control.Exception (throwIO)
 import Blaze.ByteString.Builder (Builder)
 import Safe (headMay)
 import Data.CaseInsensitive (CI)
+import qualified Text.Blaze.Internal
 import qualified Data.Conduit.List as CL
 import Control.Monad (unless)
 import           Control.Monad.Trans.Resource  (MonadResource, InternalState, runResourceT, withInternalState, getInternalState, liftResourceT, resourceForkIO
@@ -855,19 +856,15 @@ redirectToPost :: (MonadHandler m, RedirectUrl (HandlerSite m) url)
                -> m a
 redirectToPost url = do
     urlText <- toTextUrl url
-    withUrlRenderer [hamlet|
-$newline never
-$doctype 5
-
-<html>
-    <head>
-        <title>Redirecting...
-    <body onload="document.getElementById('form').submit()">
-        <form id="form" method="post" action=#{urlText}>
-            <noscript>
-                <p>Javascript has been disabled; please click on the button below to be redirected.
-            <input type="submit" value="Continue">
-|] >>= sendResponse
+    withUrlRenderer  $     \ _render_awps
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . T.pack)
+                   "<!DOCTYPE html>\n<html><head><title>Redirecting...</title></head><body onload=\"document.getElementById('form').submit()\"><form id=\"form\" method=\"post\" action=\"");
+              id (toHtml urlText);
+              id
+                ((Text.Blaze.Internal.preEscapedText . T.pack)
+                   "\"><noscript><p>Javascript has been disabled; please click on the button below to be redirected.</p></noscript><input type=\"submit\" value=\"Continue\"></form></body></html>") }
+ >>= sendResponse
 
 -- | Wraps the 'Content' generated by 'hamletToContent' in a 'RepHtml'.
 hamletToRepHtml :: MonadHandler m => HtmlUrl (Route (HandlerSite m)) -> m Html
diff --git a/Yesod/Core/Internal/Run.hs b/Yesod/Core/Internal/Run.hs
index 311f208..63f666f 100644
--- a/Yesod/Core/Internal/Run.hs
+++ b/Yesod/Core/Internal/Run.hs
@@ -16,7 +16,7 @@ import           Control.Exception.Lifted     (catch)
 import           Control.Monad                (mplus)
 import           Control.Monad.IO.Class       (MonadIO)
 import           Control.Monad.IO.Class       (liftIO)
-import           Control.Monad.Logger         (LogLevel (LevelError), LogSource,
+import           Control.Monad.Logger         (Loc, LogLevel (LevelError), LogSource,
                                                liftLoc)
 import           Control.Monad.Trans.Resource (runResourceT, withInternalState, runInternalState, createInternalState, closeInternalState)
 import qualified Data.ByteString              as S
@@ -31,7 +31,7 @@ import qualified Data.Text                    as T
 import           Data.Text.Encoding           (encodeUtf8)
 import           Data.Text.Encoding           (decodeUtf8With)
 import           Data.Text.Encoding.Error     (lenientDecode)
-import           Language.Haskell.TH.Syntax   (Loc, qLocation)
+import           Language.Haskell.TH.Syntax   (qLocation)
 import qualified Network.HTTP.Types           as H
 import           Network.Wai
 #if MIN_VERSION_wai(2, 0, 0)
@@ -158,8 +158,6 @@ safeEh :: (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
        -> ErrorResponse
        -> YesodApp
 safeEh log' er req = do
-    liftIO $ log' $(qLocation >>= liftLoc) "yesod-core" LevelError
-           $ toLogStr $ "Error handler errored out: " ++ show er
     return $ YRPlain
         H.status500
         []
diff --git a/Yesod/Core/Internal/TH.hs b/Yesod/Core/Internal/TH.hs
index 7e84c1c..a273c29 100644
--- a/Yesod/Core/Internal/TH.hs
+++ b/Yesod/Core/Internal/TH.hs
@@ -23,114 +23,3 @@ import Yesod.Core.Content
 import Yesod.Core.Class.Dispatch
 import Yesod.Core.Internal.Run
 
--- | Generates URL datatype and site function for the given 'Resource's. This
--- is used for creating sites, /not/ subsites. See 'mkYesodSub' for the latter.
--- Use 'parseRoutes' to create the 'Resource's.
-mkYesod :: String -- ^ name of the argument datatype
-        -> [ResourceTree String]
-        -> Q [Dec]
-mkYesod name = fmap (uncurry (++)) . mkYesodGeneral name [] False
-
--- | Sometimes, you will want to declare your routes in one file and define
--- your handlers elsewhere. For example, this is the only way to break up a
--- monolithic file into smaller parts. Use this function, paired with
--- 'mkYesodDispatch', to do just that.
-mkYesodData :: String -> [ResourceTree String] -> Q [Dec]
-mkYesodData name res = mkYesodDataGeneral name False res
-
-mkYesodSubData :: String -> [ResourceTree String] -> Q [Dec]
-mkYesodSubData name res = mkYesodDataGeneral name True res
-
-mkYesodDataGeneral :: String -> Bool -> [ResourceTree String] -> Q [Dec]
-mkYesodDataGeneral name isSub res = do
-    let (name':rest) = words name
-    fmap fst $ mkYesodGeneral name' rest isSub res
-
--- | See 'mkYesodData'.
-mkYesodDispatch :: String -> [ResourceTree String] -> Q [Dec]
-mkYesodDispatch name = fmap snd . mkYesodGeneral name [] False
-
--- | Get the Handler and Widget type synonyms for the given site.
-masterTypeSyns :: Type -> [Dec]
-masterTypeSyns site =
-    [ TySynD (mkName "Handler") []
-      $ ConT ''HandlerT `AppT` site `AppT` ConT ''IO
-    , TySynD (mkName "Widget")  []
-      $ ConT ''WidgetT `AppT` site `AppT` ConT ''IO `AppT` ConT ''()
-    ]
-
-mkYesodGeneral :: String                   -- ^ foundation type
-               -> [String]                 -- ^ arguments for the type
-               -> Bool                     -- ^ it this a subsite
-               -> [ResourceTree String]
-               -> Q([Dec],[Dec])
-mkYesodGeneral name args isSub resS = do
-    renderRouteDec <- mkRenderRouteInstance site res
-    routeAttrsDec  <- mkRouteAttrsInstance site res
-    dispatchDec    <- mkDispatchInstance site res
-    parse <- mkParseRouteInstance site res
-    let rname = mkName $ "resources" ++ name
-    eres <- lift resS
-    let resourcesDec =
-            [ SigD rname $ ListT `AppT` (ConT ''ResourceTree `AppT` ConT ''String)
-            , FunD rname [Clause [] (NormalB eres) []]
-            ]
-    let dataDec = concat
-            [ [parse]
-            , renderRouteDec
-            , [routeAttrsDec]
-            , resourcesDec
-            , if isSub then [] else masterTypeSyns site
-            ]
-    return (dataDec, dispatchDec)
-  where site    = foldl' AppT (ConT $ mkName name) (map (VarT . mkName) args)
-        res     = map (fmap parseType) resS
-
-mkMDS :: Q Exp -> MkDispatchSettings
-mkMDS rh = MkDispatchSettings
-    { mdsRunHandler = rh
-    , mdsSubDispatcher =
-        [|\parentRunner getSub toParent env -> yesodSubDispatch
-                                 YesodSubRunnerEnv
-                                    { ysreParentRunner = parentRunner
-                                    , ysreGetSub = getSub
-                                    , ysreToParentRoute = toParent
-                                    , ysreParentEnv = env
-                                    }
-                              |]
-    , mdsGetPathInfo = [|W.pathInfo|]
-    , mdsSetPathInfo = [|\p r -> r { W.pathInfo = p }|]
-    , mdsMethod = [|W.requestMethod|]
-    , mds404 = [|notFound >> return ()|]
-    , mds405 = [|badMethod >> return ()|]
-    , mdsGetHandler = defaultGetHandler
-    }
-
--- | If the generation of @'YesodDispatch'@ instance require finer
--- control of the types, contexts etc. using this combinator. You will
--- hardly need this generality. However, in certain situations, like
--- when writing library/plugin for yesod, this combinator becomes
--- handy.
-mkDispatchInstance :: Type                -- ^ The master site type
-                   -> [ResourceTree a]    -- ^ The resource
-                   -> DecsQ
-mkDispatchInstance master res = do
-    clause' <- mkDispatchClause (mkMDS [|yesodRunner|]) res
-    let thisDispatch = FunD 'yesodDispatch [clause']
-    return [InstanceD [] yDispatch [thisDispatch]]
-  where
-    yDispatch = ConT ''YesodDispatch `AppT` master
-
-mkYesodSubDispatch :: [ResourceTree a] -> Q Exp
-mkYesodSubDispatch res = do
-    clause' <- mkDispatchClause (mkMDS [|subHelper . fmap toTypedContent|]) res
-    inner <- newName "inner"
-    let innerFun = FunD inner [clause']
-    helper <- newName "helper"
-    let fun = FunD helper
-                [ Clause
-                    []
-                    (NormalB $ VarE inner)
-                    [innerFun]
-                ]
-    return $ LetE [fun] (VarE helper)
diff --git a/Yesod/Core/Types.hs b/Yesod/Core/Types.hs
index 388dfe3..b3fce0f 100644
--- a/Yesod/Core/Types.hs
+++ b/Yesod/Core/Types.hs
@@ -21,6 +21,7 @@ import           Control.Monad.Catch                (MonadCatch (..))
 import           Control.Monad.Catch                (MonadMask (..))
 #endif
 import           Control.Monad.IO.Class             (MonadIO (liftIO))
+import qualified Control.Monad.Logger
 import           Control.Monad.Logger               (LogLevel, LogSource,
                                                      MonadLogger (..))
 import           Control.Monad.Trans.Control        (MonadBaseControl (..))
@@ -191,7 +192,7 @@ data RunHandlerEnv site = RunHandlerEnv
     , rheRoute    :: !(Maybe (Route site))
     , rheSite     :: !site
     , rheUpload   :: !(RequestBodyLength -> FileUpload)
-    , rheLog      :: !(Loc -> LogSource -> LogLevel -> LogStr -> IO ())
+    , rheLog      :: !(Control.Monad.Logger.Loc -> LogSource -> LogLevel -> LogStr -> IO ())
     , rheOnError  :: !(ErrorResponse -> YesodApp)
       -- ^ How to respond when an error is thrown internally.
       --
diff --git a/Yesod/Core/Widget.hs b/Yesod/Core/Widget.hs
index 481199e..8489fbe 100644
--- a/Yesod/Core/Widget.hs
+++ b/Yesod/Core/Widget.hs
@@ -16,8 +16,8 @@ module Yesod.Core.Widget
       WidgetT
     , PageContent (..)
       -- * Special Hamlet quasiquoter/TH for Widgets
-    , whamlet
-    , whamletFile
+    --, whamlet
+    --, whamletFile
     , ihamletToRepHtml
     , ihamletToHtml
       -- * Convert to Widget
@@ -46,7 +46,7 @@ module Yesod.Core.Widget
     , widgetToParentWidget
     , handlerToWidget
       -- * Internal
-    , whamletFileWithSettings
+    --, whamletFileWithSettings
     , asWidgetT
     ) where
 
@@ -207,35 +207,9 @@ addScriptRemote = flip addScriptRemoteAttrs []
 addScriptRemoteAttrs :: MonadWidget m => Text -> [(Text, Text)] -> m ()
 addScriptRemoteAttrs x y = tell $ GWData mempty mempty (toUnique $ Script (Remote x) y) mempty mempty mempty mempty
 
-whamlet :: QuasiQuoter
-whamlet = NP.hamletWithSettings rules NP.defaultHamletSettings
-
-whamletFile :: FilePath -> Q Exp
-whamletFile = NP.hamletFileWithSettings rules NP.defaultHamletSettings
-
-whamletFileWithSettings :: NP.HamletSettings -> FilePath -> Q Exp
-whamletFileWithSettings = NP.hamletFileWithSettings rules
-
 asWidgetT :: WidgetT site m () -> WidgetT site m ()
 asWidgetT = id
 
-rules :: Q NP.HamletRules
-rules = do
-    ah <- [|asWidgetT . toWidget|]
-    let helper qg f = do
-            x <- newName "urender"
-            e <- f $ VarE x
-            let e' = LamE [VarP x] e
-            g <- qg
-            bind <- [|(>>=)|]
-            return $ InfixE (Just g) bind (Just e')
-    let ur f = do
-            let env = NP.Env
-                    (Just $ helper [|getUrlRenderParams|])
-                    (Just $ helper [|liftM (toHtml .) getMessageRender|])
-            f env
-    return $ NP.HamletRules ah ur $ \_ b -> return $ ah `AppE` b
-
 -- | Wraps the 'Content' generated by 'hamletToContent' in a 'RepHtml'.
 ihamletToRepHtml :: (MonadHandler m, RenderMessage (HandlerSite m) message)
                  => HtmlUrlI18n message (Route (HandlerSite m))
-- 
2.1.1