@@ -8,7 +8,6 @@ import Data.Lazy (force) as Lazy
8
8
import Data.Map (Map )
9
9
import Data.Maybe (fromMaybe )
10
10
import Data.Validation.Semigroup (toEither )
11
- import Effect (Effect )
12
11
import Effect.Ref (Ref )
13
12
import HTTPure (empty ) as Headers
14
13
import Polyform.Validator.Dual.Pure (Dual , runSerializer , runValidator ) as Pure
@@ -70,38 +69,29 @@ cookieName = "session"
70
69
71
70
runInStore ∷
72
71
∀ eff session .
73
- Effect ( SessionStore (Run (Cookies + EffRow + eff )) session ) →
72
+ SessionStore (Run (Cookies + EffRow + eff )) session →
74
73
Run (Cookies + EffRow + Session session + eff )
75
74
~> Run (Cookies + EffRow + eff )
76
- runInStore store = runInRunStore (Run .liftEffect store)
77
-
78
- runInRunStore ∷
79
- ∀ eff session .
80
- Run (Cookies + EffRow + eff ) (SessionStore (Run (Cookies + EffRow + eff )) session ) →
81
- Run (Cookies + EffRow + Session session + eff )
82
- ~> Run (Cookies + EffRow + eff )
83
- runInRunStore store action = do
84
- s ← store
75
+ runInStore store action = do
85
76
let
86
77
handleSession ∷
87
78
SessionF session ~> Run (Cookies + EffRow + eff )
88
79
handleSession (DeleteF next) = do
89
80
void $ Cookies .delete cookieName
90
- s .delete >>= next >>> pure
81
+ store .delete >>= next >>> pure
91
82
92
83
handleSession (FetchF next) = do
93
84
-- | TODO:
94
85
-- | * Handle custom cookie attributes (expiration etc.).
95
86
-- | * Should we raise here internalServerError when `set` returns `false`?
96
87
-- | * Should we run testing cycle of test cookie setup?
97
- void $ Cookies .set cookieName { value: s .key, attributes: Cookies .defaultAttributes }
98
- s .fetch >>= next >>> pure
88
+ void $ Cookies .set cookieName { value: store .key, attributes: Cookies .defaultAttributes }
89
+ store .fetch >>= next >>> pure
99
90
100
91
handleSession (SaveF v next) = do
101
- void $ Cookies .set cookieName { value: s .key, attributes: Cookies .defaultAttributes }
102
- a ← s .save v
92
+ void $ Cookies .set cookieName { value: store .key, attributes: Cookies .defaultAttributes }
93
+ a ← store .save v
103
94
pure (next a)
104
-
105
95
Run .interpret (Run .on _session handleSession Run .send) action
106
96
107
97
runInMemoryStore ∷
@@ -113,9 +103,9 @@ runInMemoryStore ∷
113
103
runInMemoryStore ref defaultSession action = do
114
104
-- | This laziness is a myth let's drop this all together
115
105
lazySessionKey ← Cookies .lookup cookieName
116
- let
117
- effSessionStore = SessionStore.InMemory .new ref defaultSession (Lazy .force lazySessionKey)
118
- runInStore (SessionStore .hoist Run .liftEffect <$> effSessionStore) action
106
+ effSessionStore ← Run .liftEffect $
107
+ SessionStore.InMemory .new ref defaultSession (Lazy .force lazySessionKey)
108
+ runInStore (SessionStore .hoist Run .liftEffect $ effSessionStore) action
119
109
120
110
-- | The whole session is stored in a cookie value so visible in the browser.
121
111
-- | We don't need any key-value session store.
0 commit comments