-
Notifications
You must be signed in to change notification settings - Fork 0
/
DesignHeuristicsSrp.hs
51 lines (32 loc) · 1.39 KB
/
DesignHeuristicsSrp.hs
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{-# LANGUAGE TemplateHaskell #-}
module DesignHeuristicsSrp where
import Data.Kind
import Polysemy
data UserInfo
data Password
data SignUpError
data ConfirmationInfo
data EmailAddress
data SignInError
data UserToken
data AuthenticateUserError
data AuthenticatedUser
data UserEffect (m :: Type -> Type) (a :: Type) where
SignUp :: UserInfo -> Password -> UserEffect m (Either SignUpError ())
ConfirmSignUp :: ConfirmationInfo -> UserEffect m Bool
SignIn :: EmailAddress -> Password -> UserEffect m (Either SignInError ())
SignOut :: UserToken -> UserEffect m ()
AuthenticateUser :: UserToken -> UserEffect m (Either AuthenticateUserError AuthenticatedUser)
makeSem ''UserEffect
-- Cleaner
data UserRegistration (m :: Type -> Type) (a :: Type) where
SignUp' :: UserInfo -> Password -> UserRegistration m (Either SignUpError ())
ConfirmSignUp' :: ConfirmationInfo -> UserRegistration m Bool
makeSem ''UserRegistration
data UserAuthenticationManagement (m :: Type -> Type) (a :: Type) where
SignIn' :: EmailAddress -> Password -> UserAuthenticationManagement m (Either SignInError ())
SignOut' :: UserToken -> UserAuthenticationManagement m ()
makeSem ''UserAuthenticationManagement
data UserAuthenticationCheck (m :: Type -> Type) (a :: Type) where
AuthenticateUser' :: UserToken -> UserAuthenticationCheck m (Either AuthenticateUserError AuthenticatedUser)
makeSem ''UserAuthenticationCheck