packages feed

cased (empty) → 0.1.0.0

raw patch · 4 files changed

+119/−0 lines, 4 filesdep +basedep +textsetup-changed

Dependencies added: base, text

Files

+ Data/Cased.hs view
@@ -0,0 +1,68 @@++{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE EmptyDataDecls #-}++module Data.Cased (+  Lower, Upper, Mixed, Yes, No,+  IsUpperCased, IsLowerCased,+  Cased(..),+  Casing(..),++  upperCased, lowerCased, mixedCased,+  force+) where++import qualified Data.Text.Lazy as LT+import qualified Data.Text as ST+import qualified Data.Char as C++data Lower+data Upper+data Mixed+data Yes+data No++newtype Cased a b = Cased { fromCased :: b }+                  deriving (Show, Eq, Ord)++class Casing a where+  toUpper :: a -> a+  toLower :: a -> a++instance Casing ST.Text where+  toUpper = ST.toUpper+  toLower = ST.toLower++instance Casing LT.Text where+  toUpper = LT.toUpper+  toLower = LT.toLower++instance Casing String where+  toUpper = map C.toUpper+  toLower = map C.toLower++type family IsLowerCased a :: *+type family IsUpperCased a :: *++type instance IsUpperCased Upper = Yes+type instance IsUpperCased Lower = No+type instance IsUpperCased Mixed = No++type instance IsLowerCased Lower = Yes+type instance IsLowerCased Upper = No+type instance IsLowerCased Mixed = No++force :: (Cased Mixed b -> c) -> b -> c+force f = f . mixedCased++mixedCased :: a -> Cased Mixed a+mixedCased = Cased++upperCased :: (Casing b, IsUpperCased a ~ No) => Cased a b -> Cased Upper b+upperCased = Cased . toUpper . fromCased++lowerCased :: (Casing b, IsLowerCased a ~ No) => Cased a b -> Cased Lower b+lowerCased = Cased . toLower . fromCased
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2015 William Casarin++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
+ cased.cabal view
@@ -0,0 +1,29 @@+-- Initial cased.cabal generated by cabal init.  For further documentation,+--  see http://haskell.org/cabal/users-guide/++name:                cased+version:             0.1.0.0+synopsis:            Track string casing in its type+description:         Track string casing in its type+homepage:            https://github.com/jb55/cased+license:             MIT+license-file:        LICENSE+author:              William Casarin+maintainer:          bill@casarin.me+-- copyright:           +category:            Text+build-type:          Simple+-- extra-source-files:  +cabal-version:       >= 1.8++source-repository head+  type: git+  location: https://github.com/jb55/cased++library+  exposed-modules:     Data.Cased+  -- other-modules:       +  other-extensions:    FlexibleInstances, TypeSynonymInstances, TypeFamilies, EmptyDataDecls+  build-depends: base >=4.7 && <5+               , text+  -- hs-source-dirs: