packages feed

userid (empty) → 0.1.0.0

raw patch · 4 files changed

+86/−0 lines, 4 filesdep +aesondep +basedep +boomerangsetup-changed

Dependencies added: aeson, base, boomerang, lens, safecopy, web-routes, web-routes-th

Files

+ Data/UserId.hs view
@@ -0,0 +1,31 @@+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, GeneralizedNewtypeDeriving, TemplateHaskell #-}+{- | This module provides a `UserId` type plus some useful instances for web development. -}+module Data.UserId where++import Control.Lens      ((?=), (.=), (^.), (.~), makeLenses, view, set)+import Data.Aeson        (FromJSON(..), ToJSON(..), Result(..), fromJSON)+import Data.Data         (Data)+import Data.SafeCopy     (SafeCopy, base, deriveSafeCopy)+import Data.Typeable     (Typeable)+import GHC.Generics      (Generic)+import Text.Boomerang.TH (makeBoomerangs)+import Web.Routes        (PathInfo(..))+import Web.Routes.TH     (derivePathInfo)++-- | a 'UserId' uniquely identifies a user.+newtype UserId = UserId { _unUserId :: Integer }+    deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic)+deriveSafeCopy 1 'base ''UserId+makeLenses ''UserId+makeBoomerangs ''UserId++instance ToJSON   UserId where toJSON (UserId i) = toJSON i+instance FromJSON UserId where parseJSON v = UserId <$> parseJSON v++instance PathInfo UserId where+    toPathSegments (UserId i) = toPathSegments i+    fromPathSegments = UserId <$> fromPathSegments++-- | get the next `UserId`+succUserId :: UserId -> UserId+succUserId (UserId i) = UserId (succ i)
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Jeremy Shaw++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 Jeremy Shaw 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
+ userid.cabal view
@@ -0,0 +1,23 @@+name:                userid+version:             0.1.0.0+synopsis:            A library which provides the UserId type and useful instances for web development+description:         Includes instances for SafeCopy, Lens, Boomerang, PathInfo and more+homepage:            http://www.github.com/Happstack/userid+license:             BSD3+license-file:        LICENSE+author:              Jeremy Shaw+maintainer:          jeremy@n-heptane.com+category:            Data+build-type:          Simple+cabal-version:       >=1.10++library+  exposed-modules:     Data.UserId+  build-depends:       base          >=4.8   && < 4.9,+                       aeson         >= 0.9  && < 0.10,+                       boomerang     >= 1.4  && < 1.5,+                       lens          >= 4.9  && < 4.13,+                       safecopy      >= 0.8  && < 0.9,+                       web-routes    >= 0.27 && < 0.28,+                       web-routes-th >= 0.22 && < 0.23+  default-language:    Haskell2010