packages feed

text-render (empty) → 0.1.0.0

raw patch · 4 files changed

+91/−0 lines, 4 filesdep +basedep +mtldep +parsecsetup-changed

Dependencies added: base, mtl, parsec, text

Files

+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2014 Allen Nelson++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Text/Render.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE OverloadedStrings #-}+module Text.Render (+    Render(..),+    renderTicks+  ) where++import qualified Prelude as P+import Prelude (($), (.), map, Int, Double, Functor(..), Show(..),+                Eq(..), Bool, Integer, Double, Monad(..))+import Control.Monad.Trans (MonadIO(..))+import Data.Monoid+import Data.Text (Text)+import qualified Data.Text as T+import Text.Parsec (ParseError)++type Name = Text++-- | A class for pretty printing, and in general, for "showing" as a `Text`.+class Show a => Render a where+  -- | Render the object as a `Text`.+  render :: a -> Text+  render = T.pack . P.show+  -- | Many types of objects need to be rendered in parentheses.+  renderParens :: a -> Text+  renderParens = render+  -- | Render in the `IO` monad. Useful for objects containing IORefs.+  renderIO :: MonadIO m => a -> m Text+  renderIO = return . render++instance Render Int+instance Render Bool+instance Render Integer+instance Render Double+instance Render Text+instance Render ParseError+instance (Render a, Render b) => Render (a, b) where+  render (a, b) = "(" <> render a <> ", " <> render b <> ")"+instance Render a => Render [a] where+  render list = "[" <> T.intercalate ", " (map render list) <> "]"++-- | Renders and surrounds in backticks. Useful for printing user input.+renderTicks :: Render a => a -> Text+renderTicks x = "`" <> render x <> "`"
+ text-render.cabal view
@@ -0,0 +1,26 @@+-- Initial text-render.cabal generated by cabal init.  For further+-- documentation, see http://haskell.org/cabal/users-guide/++name:                text-render+version:             0.1.0.0+synopsis:            A type class for rendering objects as text, pretty-printing, etc.+-- description:+homepage:            http://github.com/thinkpad20/text-render+license:             MIT+license-file:        LICENSE+author:              Allen Nelson+maintainer:          ithinkican@gmail.com+-- copyright:+category:            Text+build-type:          Simple+-- extra-source-files:+cabal-version:       >=1.10++library+  exposed-modules:     Text.Render+  hs-source-dirs:      src+-- other-modules:+  -- other-extensions:+  build-depends:       base ==4.8, text, parsec, mtl+  -- hs-source-dirs:+  default-language:    Haskell2010