File: AuthProfileURL.hs

package info (click to toggle)
haskell-happstack-authenticate 0.10.12-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 192 kB
  • sloc: haskell: 1,512; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE DeriveDataTypeable, OverloadedStrings #-}
module Happstack.Auth.Core.AuthProfileURL where

import Control.Applicative ((<$>))
import Control.Monad       (msum)
import Data.Data           (Data, Typeable)
import Happstack.Auth.Core.AuthURL (AuthURL(..))
import Happstack.Auth.Core.ProfileURL (ProfileURL(..))
import Web.Routes          (PathInfo(..), segment)
import Test.QuickCheck     (Arbitrary(..), oneof)

data AuthProfileURL 
    = AuthURL AuthURL
    | ProfileURL ProfileURL
    deriving (Eq, Ord, Read, Show, Data, Typeable)

instance PathInfo AuthProfileURL where
    toPathSegments (AuthURL authURL)       = "auth"    : toPathSegments authURL
    toPathSegments (ProfileURL profileURL) = "profile" : toPathSegments profileURL
    fromPathSegments = 
        msum [ do segment "auth"
                  AuthURL <$> fromPathSegments
             , do segment "profile"
                  ProfileURL <$> fromPathSegments
             ]

instance Arbitrary AuthProfileURL where
    arbitrary = oneof [ AuthURL <$> arbitrary 
                      , ProfileURL <$> arbitrary
                      ]