Get rid of Render
monad; make components look more like JS components
This commit is contained in:
parent
aa5d40a625
commit
141b482739
@ -9,15 +9,14 @@ import React.JSaddle
|
||||
import React.Types
|
||||
|
||||
--TODO: The Hook section shouldn't have any control flow to it; probably it also shouldn't depend on props except in specific ways
|
||||
component :: Hook (JSVal -> Render Element) -> ReaderT React JSM (Component JSVal ())
|
||||
component (Hook hook) = do
|
||||
component :: (JSVal -> Hook Element) -> ReaderT React JSM (Component JSVal ())
|
||||
component hook = do
|
||||
react <- ask
|
||||
f <- lift $ function' $ \_ _ args -> flip runReaderT react $ do
|
||||
render <- hook
|
||||
let props = case args of
|
||||
[] -> jsUndefined
|
||||
arg0 : _ -> arg0
|
||||
e <- unRender $ render props
|
||||
e <- unHook $ hook props
|
||||
unElement e
|
||||
pure $ Component f
|
||||
|
||||
|
@ -31,16 +31,6 @@ newtype Hook a = Hook { unHook :: ReaderT React JSM a }
|
||||
#endif
|
||||
)
|
||||
|
||||
newtype Render a = Render { unRender :: ReaderT React JSM a }
|
||||
deriving ( Functor
|
||||
, Applicative
|
||||
, Monad
|
||||
, MonadJSM
|
||||
#ifndef ghcjs_HOST_OS
|
||||
, MonadIO
|
||||
#endif
|
||||
)
|
||||
|
||||
newtype Element = Element { unElement :: ReaderT React JSM JSVal }
|
||||
|
||||
instance IsString Element where
|
||||
|
Loading…
Reference in New Issue
Block a user