packages feed

servant-blaze (empty) → 0.4.0.0

raw patch · 4 files changed

+105/−0 lines, 4 filesdep +basedep +blaze-htmldep +http-mediasetup-changed

Dependencies added: base, blaze-html, http-media, servant

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Julian K. Arni++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 Julian K. Arni 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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ servant-blaze.cabal view
@@ -0,0 +1,28 @@+-- Initial servant-blaze.cabal generated by cabal init.  For further+-- documentation, see http://haskell.org/cabal/users-guide/++name:                servant-blaze+version:             0.4.0.0+synopsis:            Blaze-html support for servant+-- description:+homepage:            http://haskell-servant.github.io/+license:             BSD3+license-file:        LICENSE+author:              Julian K. Arni+maintainer:          jkarni@gmail.com+-- copyright:+category:            Web+build-type:          Simple+-- extra-source-files:+cabal-version:       >=1.10++library+  exposed-modules:     Servant.HTML.Blaze+  -- other-modules:+  -- other-extensions:+  build-depends:       base >=4.7 && <5+                     , servant == 0.4.*+                     , http-media+                     , blaze-html+  hs-source-dirs:      src+  default-language:    Haskell2010
+ src/Servant/HTML/Blaze.hs view
@@ -0,0 +1,45 @@+{-# LANGUAGE CPP                   #-}+{-# LANGUAGE DeriveDataTypeable    #-}+{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings     #-}+#if !MIN_VERSION_base(4,8,0)+{-# LANGUAGE OverlappingInstances  #-}+#endif++-- | An @HTML@ empty data type with `MimeRender` instances for @blaze-html@'s+-- `ToMarkup` class and `Html` datatype.+-- You should only need to import this module for it's instances and the+-- `HTML` datatype.:+--+-- >>> type Eg = Get '[HTML] a+--+-- Will then check that @a@ has a `ToMarkup` instance, or is `Html`.+module Servant.HTML.Blaze where++import           Data.Typeable                 (Typeable)+import qualified Network.HTTP.Media            as M+import           Servant.API                   (Accept (..), MimeRender (..))+import           Text.Blaze.Html               (Html, ToMarkup, toHtml)+import           Text.Blaze.Html.Renderer.Utf8 (renderHtml)++data HTML deriving Typeable++-- | @text/plain;charset=utf-8@+instance Accept HTML where+    contentType _ = "text" M.// "html" M./: ("charset", "utf-8")++instance+#if MIN_VERSION_base(4,8,0)+         {-# OVERLAPPABLE #-}+#endif+         ToMarkup a => MimeRender HTML a where+    mimeRender _ = renderHtml . toHtml++instance+#if MIN_VERSION_base(4,8,0)+         {-# OVERLAPPING #-}+#endif+         MimeRender HTML Html where+    mimeRender _ = renderHtml+