fay-text (empty) → 0.1.0.0
raw patch · 4 files changed
+96/−0 lines, 4 filesdep +faydep +fay-basedep +textsetup-changed
Dependencies added: fay, fay-base, text
Files
- LICENSE +20/−0
- Setup.hs +2/−0
- fay-text.cabal +27/−0
- src/Fay/Text.hs +47/−0
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2012 Michael Snoyman, Adam Bergmark++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
+ fay-text.cabal view
@@ -0,0 +1,27 @@+name: fay-text+version: 0.1.0.0+synopsis: Fay Text type represented as JavaScript strings+description: Text type represented as JavaScript strings for Fay and Data.Text for GHC. Use with OverloadedStrings and RebindableSyntax to have Fay treat string literals as Text.+homepage: https://github.com/faylang/fay-text+bug-reports: https://github.com/faylang/fay-text/issues+license: MIT+license-file: LICENSE+author: Michael Snoyman, Adam Bergmark+maintainer: adam@edea.se+copyright: 2013 Michael Snoyman, Adam Bergmark+category: Data, Fay, Text+build-type: Simple+cabal-version: >=1.8+data-files: src/Fay/Text.hs++source-repository head+ type: git+ location: https://github.com/faylang/fay-text.git++library+ exposed: False+ hs-source-dirs: src+ exposed-modules: Fay.Text+ build-depends: text+ , fay >= 0.17+ , fay-base >= 0.17
+ src/Fay/Text.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveDataTypeable #-}+-- | Module to be shared between server and client.+--+-- This module must be valid for both GHC and Fay.+--+-- For GHC this is an alias for Data.Text, for Fay it's an opaque data type represented by JavaScript strings.+--+module Fay.Text where++import Prelude+#ifdef FAY+import FFI+#else+import Fay.FFI+#endif+import Data.Data++#ifdef FAY++data Text = Text+ deriving (Show, Read, Eq, Typeable, Data)++pack :: String -> Text+pack = ffi "%1"++unpack :: Text -> String+unpack = ffi "%1"++#else++import qualified Data.Text as T++type Text = T.Text++pack :: String -> Text+pack = T.pack++unpack :: Text -> String+unpack = T.unpack++#endif++-- | Have this in scope with the OverloadedStrings and BindableSyntax extensions+-- and Fay will replace all string literals with Text.+fromString :: String -> Text+fromString = pack