on develop help sign in
Use ReaderT to derive more instances for UnrunnableT
commitbaeb5586f7d2b48c95e5ecd16a6f3e089144209c authorKen Micklas <kmicklas@gmail.com> dateFri 26 Apr 2019, 13:19 (7 years ago) parent8cd0e2d
1 file changed+24−31
reflex-dom-core/src/Reflex/Dom/Prerender.hs+24−31
reflex-dom-core/src/Reflex/Dom/Prerender.hs+24−31
@@ -4,6 +4,7 @@
44{-# LANGUAGE FlexibleContexts #-}
55{-# LANGUAGE FlexibleInstances #-}
66{-# LANGUAGE FunctionalDependencies #-}
7+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
78{-# LANGUAGE LambdaCase #-}
89{-# LANGUAGE OverloadedStrings #-}
910{-# LANGUAGE MultiParamTypeClasses #-}
@@ -134,21 +135,13 @@ instance (Adjustable t m, PrerenderBaseConstraints js t m, ReflexHost t) => Prer
134135 insertBefore df =<< deleteToPrerenderEnd doc
135136 holdDyn a0 a'
136137
137−newtype UnrunnableT js t m a = UnrunnableT { runUnrunnableT :: Void -> m a }
138+newtype UnrunnableT js t m a = UnrunnableT (ReaderT Void m a)
139+ deriving (Functor, Applicative, Monad, MonadTrans)
138140
139141unrunnable :: UnrunnableT js t m a
140−unrunnable = UnrunnableT $ \case
142+unrunnable = UnrunnableT $ ReaderT $ \case
141143
142−instance Functor (UnrunnableT js t m) where
143− fmap _ _ = unrunnable
144−instance Applicative (UnrunnableT js t m) where
145− pure _ = unrunnable
146− _ <*> _ = unrunnable
147−instance Monad (UnrunnableT js t m) where
148− _ >>= _ = unrunnable
149−instance MonadTrans (UnrunnableT js t) where
150− lift _ = unrunnable
151−instance Reflex t => DomBuilder t (UnrunnableT js t m) where
144+instance (Reflex t, Monad m) => DomBuilder t (UnrunnableT js t m) where
152145 type DomBuilderSpace (UnrunnableT js t m) = GhcjsDomSpace
153146 textNode _ = unrunnable
154147 commentNode _ = unrunnable
@@ -158,53 +151,53 @@ instance Reflex t => DomBuilder t (UnrunnableT js t m) where
158151 selectElement _ _ = unrunnable
159152 placeRawElement _ = unrunnable
160153 wrapRawElement _ _ = unrunnable
161−instance NotReady t (UnrunnableT js t m) where
154+instance (Reflex t, Monad m) => NotReady t (UnrunnableT js t m) where
162155 notReadyUntil _ = unrunnable
163156 notReady = unrunnable
164−instance Reflex t => Adjustable t (UnrunnableT js t m) where
157+instance (Reflex t, Monad m) => Adjustable t (UnrunnableT js t m) where
165158 runWithReplace _ _ = unrunnable
166159 traverseIntMapWithKeyWithAdjust _ _ _ = unrunnable
167160 traverseDMapWithKeyWithAdjust _ _ _ = unrunnable
168161 traverseDMapWithKeyWithAdjustWithMove _ _ _ = unrunnable
169−instance Reflex t => PerformEvent t (UnrunnableT js t m) where
162+instance (Reflex t, Monad m) => PerformEvent t (UnrunnableT js t m) where
170163 type Performable (UnrunnableT js t m) = UnrunnableT js t m
171164 performEvent _ = unrunnable
172165 performEvent_ _ = unrunnable
173−instance MonadRef (UnrunnableT js t m) where
166+instance Monad m => MonadRef (UnrunnableT js t m) where
174167 type Ref (UnrunnableT js t m) = Ref IO
175168 newRef _ = unrunnable
176169 readRef _ = unrunnable
177170 writeRef _ _ = unrunnable
178−instance HasDocument (UnrunnableT js t m) where
171+instance Monad m => HasDocument (UnrunnableT js t m) where
179172 askDocument = unrunnable
180−instance HasJSContext (UnrunnableT js t m) where
173+instance Monad m => HasJSContext (UnrunnableT js t m) where
181174 --type JsContextPhantom (UnrunnableT js t m) = ()
182−instance HasJS JS' (UnrunnableT js t m) where
175+instance Monad m => HasJS JS' (UnrunnableT js t m) where
183176 type JSX (UnrunnableT js t m) = UnrunnableT js t m
184−instance MonadJS JS' (UnrunnableT js t m) where
185−instance TriggerEvent t (UnrunnableT js t m) where
186−instance MonadReflexCreateTrigger t (UnrunnableT js t m) where
177+instance Monad m => MonadJS JS' (UnrunnableT js t m) where
178+instance Monad m => TriggerEvent t (UnrunnableT js t m) where
179+instance Monad m => MonadReflexCreateTrigger t (UnrunnableT js t m) where
187180 newEventWithTrigger _ = unrunnable
188−instance MonadFix (UnrunnableT js t m) where
181+instance Monad m => MonadFix (UnrunnableT js t m) where
189182 mfix _ = unrunnable
190−instance MonadHold t (UnrunnableT js t m) where
183+instance Monad m => MonadHold t (UnrunnableT js t m) where
191184 hold _ _ = unrunnable
192185 holdDyn _ _ = unrunnable
193186 holdIncremental _ _ = unrunnable
194−instance MonadSample t (UnrunnableT js t m)
195−instance MonadIO (UnrunnableT js t m)
196−instance MonadJSM (UnrunnableT js t m) where
187+instance Monad m => MonadSample t (UnrunnableT js t m)
188+instance Monad m => MonadIO (UnrunnableT js t m)
189+instance Monad m => MonadJSM (UnrunnableT js t m) where
197190 liftJSM' _ = unrunnable
198−instance Reflex t => PostBuild t (UnrunnableT js t m)
199−instance PrimMonad (UnrunnableT js t m) where
191+instance (Reflex t, Monad m) => PostBuild t (UnrunnableT js t m)
192+instance Monad m => PrimMonad (UnrunnableT js t m) where
200193-- type RawDocument (UnrunnableT js t m) = DOM.Document
201194--instance HasJSContext (UnrunnableT js t m)
202195--instance MonadJSM (UnrunnableT js t m)
203−instance Reflex t => DomRenderHook t (UnrunnableT js t m) where
196+instance (Reflex t, Monad m) => DomRenderHook t (UnrunnableT js t m) where
204197 withRenderHook _ _ = unrunnable
205198 requestDomAction _ = unrunnable
206199 requestDomAction_ _ = unrunnable
207−instance Reflex t => Prerender JS' t (UnrunnableT js t m) where
200+instance (Reflex t, Monad m) => Prerender JS' t (UnrunnableT js t m) where
208201 type Client (UnrunnableT js t m) = UnrunnableT js t m
209202 prerender _ _ = unrunnable
210203