reflex-frp / reflex-dom-contrib Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
In the docs for Reflex.Dom.Contrib.Router, the routeSite
function has a pretty scary type signature.
routeSite :: (String -> Widget Spider (Gui Spider (WithWebView SpiderHost) SpiderHostFrame) (Event Spider String)) -> IO ()
That overly specific type could be turned into an abstract one.
routeSite :: (forall t m. MonadWidget t m => String -> m (Event t String)) -> IO ()
The version on hackage is too old and does not build with newer GHC. It would be great if a new release is make and uploaded to hackage. Thanks.
I was trying to port our app using previous version of reflex-dom-contrib
which was using just Text
for URIs and now in Reflex.Dom.Contrib.Router
I see
type URI = U.URIRef U.Absolute
At the same time we use servant-router
and Link
from Servant.Utils.Links
supports only relative links because Servant
knows nothing about the current scheme/authority/host/port. And actually history.pushState
can't use URLs outside of the current domain.
Shouldn't we switch to relative URis or I miss something here?
Right now it seems to be the functor-dynamic
branch, but it took a while for me to figure that out :)
Sorry in advance for asking probably basic question, but I am new to nix and to reflex.
So I have a package created using the method suggested in reflex-platform, and I clone the directory, workon and built it.
Now, how do I use this? The closest I can find is some cryptic pkgs.fetchFromGitHub stuff.. Is that how we are supposed to use it?
I see that the github repo successfully compiles with webkit
, but the 0.4.1
release on Hackage does not. This is a pretty big program for those who use stack, and don't want to depend on a git repo.
How to use routeApp
to add routing to my webpage.
testApp :: MonadWidget t m => m ()
testApp = do
routeApp "app" $ do
withPathSegment go
pure ()
where
go :: (MonadWidget t m, MonadRouted t m) => Dynamic t (Maybe PathSegment) -> m ()
go dPathSeg = do
(dyn . ffor dPathSeg) $ \ps -> do
case maybe "a" id ps of
"a" -> do
evt <- button "switch to View B"
redirectInternal $ ("b" <$ evt)
text "View A"
"b" -> do
evt <- button "switch to View A"
redirectInternal $ ("a" <$ evt)
text "View B"
pure ()
I get this error while running the code:
Could not deduce (NotReady t (RouteT t m))
arising from a use of ‘go’
from the context: MonadWidget t m
bound by the type signature for:
testApp :: MonadWidget t m => m ()
this function will take a -> [String] instead of a -> String, and for ever String it create, it will popup a dialog sequentially (that is, after one is closed). I am planning to use it as some kind of user manual.
I couldn't figure out how to use route
to create a simple SPA webapp. (I've just started out using reflex). Any help appreciated. :)
Lets say I have the following views:
viewA :: MonadWidget t m => m (Event t Text)
viewA = do
el "div" $ text "view A"
gotoB <- button "GoTo B"
return $ fmap (const "B") gotoB
viewB :: MonadWidget t m => m (Event t Text)
viewB = do
el "div" $ text "view B"
gotoC <- button "GoTo C"
return $ fmap (const "C") gotoC
viewC :: MonadWidget t m => m (Event t Text)
viewC = do
el "div" $ text "view C"
gotoA <- button "GoTo A"
return $ fmap (const "A") gotoA
Say my page starts at viewA, how do I use route
to switch between these views?
The current default.nix
is out of date (as far as I can tell) and it's unlikely to stay up to-date over time. With nixpkgs.callCabal2nix
and reflex-platform.cabal2nixResult
, it's not difficult to generate the correct default.nix
automatically as part of a larger nix derivation. This will always be more reliable. Should we just delete the file?
I wanted to checkout Router
but from the haddock page it's not quite clear how it's supposed to be used.
Are there any projects maybe which use reflex-dom-contrib
which could be checked out to get the idea?
I was trying to create routable reflex app using servant-router
and reflex-dom-contrib
but it appears that routeSite
does routing only once so I couldn't do SPA and every route change will lead to complete page reload.
Is there any way to make routeSite
to use a Dynamic for routes?
Adding this because the reflex-platform
is mentioned in the README as the preferred way to build.
To repro:
./try-reflex
reflex-dom-contrib
to the 'general packages' section of packages.nix./try-reflex
expected: successful build and reflex shell
actual: dependency failure
output:
Configuring reflex-dom-contrib-0.4.1...
Setup: Encountered missing dependencies:
aeson >=0.8 && <0.11,
base >=4.6 && <4.9,
bifunctors >=4.0 && <5.3,
data-default ==0.5.*,
ghcjs-dom ==0.2.*,
lens >=4.9 && <4.14,
reflex >=0.2 && <0.5,
reflex-dom >=0.2 && <0.4
builder for ‘/nix/store/5m2wdc60i8hr4wvyngn3nlx1h7i4jwlm-reflex-dom-contrib-0.4.1.drv’ failed with exit code 1
cannot build derivation ‘/nix/store/ndjmzi9jy6cr5yzbmnc639pdwbgbcqxw-ghc-8.0.2-with-packages.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/ndjmzi9jy6cr5yzbmnc639pdwbgbcqxw-ghc-8.0.2-with-packages.drv’ failed
/run/current-system/sw/bin/nix-shell: failed to build all dependencies
It appears that the library doesn't work with reflex-dom-0.3
anymore:
/home/qrilka/ws/some/project/.stack-work/downloaded/MaRcALGDSgMN/src/Reflex/Dom/Contrib/Widgets/Svg.hs:34:15: error:
• Couldn't match type ‘Text’ with ‘[Char]’
Expected type: Text
-> Dynamic t (Map Text Text) -> m a -> m (El t, a)
Actual type: String
-> Dynamic t (Map String String) -> m a -> m (El t, a)
• In the expression:
elDynAttrNS' (Just "http://www.w3.org/2000/svg")
In an equation for ‘svgDynAttr'’:
svgDynAttr' = elDynAttrNS' (Just "http://www.w3.org/2000/svg")
and yet cabal file says:
reflex-dom >= 0.2 && < 0.5,
Documentation is missing. Why Either e a instead of a?
I've run into this while building reflex-dom-contrib with GHC 8.4.3:
src/Reflex/Dom/Contrib/CssClass.hs:50:22: error:
• No instance for (Semigroup CssClass)
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (Monoid CssClass)
|
50 | deriving (Eq, Ord, Monoid, Show)
|
I'll try to come up with a fix that works with a variety of GHCs if I get time in the next few days.
Can we get a release that uses the latest reflex
and improved-base
?
I am new user. I do not understand it at all.
after I run
~/reflex-platform/scripts/work-on ghcjs ./.
it shows
error: anonymous function at /Users/sxw/reflex-platform/reflex-dom-contrib/default.nix:4:1 called with unexpected argument 'mkDerivation', at /nix/store/7p1v9hfkiwa4ymxfjx5kwbz1k63rx66p-source/pkgs/development/haskell-modules/make-package-set.nix:87:27
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.