servant-lucid (empty) → 0.4.0.0
raw patch · 4 files changed
+103/−0 lines, 4 filesdep +basedep +http-mediadep +lucidsetup-changed
Dependencies added: base, http-media, lucid, servant
Files
- LICENSE +30/−0
- Setup.hs +2/−0
- servant-lucid.cabal +28/−0
- src/Servant/HTML/Lucid.hs +43/−0
+ 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-lucid.cabal view
@@ -0,0 +1,28 @@+-- Initial servant-lucid.cabal generated by cabal init. For further+-- documentation, see http://haskell.org/cabal/users-guide/++name: servant-lucid+version: 0.4.0.0+synopsis: Servant support for lucid+-- 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.Lucid+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.7 && <5+ , http-media+ , lucid+ , servant == 0.4.*+ hs-source-dirs: src+ default-language: Haskell2010
+ src/Servant/HTML/Lucid.hs view
@@ -0,0 +1,43 @@+{-# 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 @lucid@'s+-- `ToHtml` 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 `ToHtml` instance, or is `Html`.+module Servant.HTML.Lucid where++import Data.Typeable (Typeable)+import Lucid (Html, ToHtml (..), renderBS)+import qualified Network.HTTP.Media as M+import Servant.API (Accept (..), MimeRender (..))++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+ ToHtml a => MimeRender HTML a where+ mimeRender _ = renderBS . toHtml++instance+#if MIN_VERSION_base(4,8,0)+ {-# OVERLAPPING #-}+#endif+ MimeRender HTML (Html a) where+ mimeRender _ = renderBS