Elmish-UrlParser implements parser combinators for turning URLs into strongly-typed data.
For more information see the docs.
paket add Fable.Elmish.UrlParser
With .NET Core SDK v6:
fotnet fsi build.fsx
Turn URLs into statically-typed data
Home Page: https://elmish.github.io/urlParser
License: Other
Elmish-UrlParser implements parser combinators for turning URLs into strongly-typed data.
For more information see the docs.
paket add Fable.Elmish.UrlParser
With .NET Core SDK v6:
fotnet fsi build.fsx
Yall opposed to adding [<RequireQualifiedAccess>]
for functions like map
, oneOf
, parseHash
, etc?
Also, any reason as to why so conservative when naming functions like s
and i32
?
Please don't take this as crapping on the library (it's pretty awesome) but I wonder if adoption is not as big as Feliz.Router
... due to the cryptic nature of some of these function names...
And maybe placing </>
in a module that one must open kind of like fstoolkit-errorhandling
does it...
Again, just observations since I am comparing urlParser
(elmish.browser
) with Feliz.Router
I think I have suggested renaming s
and str
to something more userfriendly but got rejected =/
Can we instead provide documentation with ///
on each of the functions? I think the documentation in the Elmish.UrlParser
github page is very helpful, so maybe adding it to the function would also provide value...
* s combinator for a static string we expect to find in the URL,
* </> combinator to capture a slash in the URL,
* str combinator to extract a string,
* i32 combinator to attempt to parse an int.
* top combinator that takes nothing.
* remaining combinator to get the remaining parts of the URL
I tend to shadow like this to provide clarity:
// combinator for a static string we expect to find in the URL
let matchString = UrlParser.s
// combinator to extract a string
let parseString = UrlParser.str
// combinator to attempt to parse and Int32
let parseInt32 = UrlParser.i32
Before the Fable 4.0 update we did:
let urlParser location = parsePath pageParser location
but now we have to do
let urlParser (location:Browser.Types.Location) =
parse pageParser location.pathname (parseParams (location.search.Replace("?","")))
It looks like the ? is no longer handled automatically.
I am seeing this line throws when used via Navigation when query string is null. It assumes queryString has some value
Line 357 in 014ab69
It just looks wrong to me.
I recently had a case where I needed to consume the remaining elements of an url that might contain slashes. this is the parser I wrote :
let remaining: Parser<(string -> 'a), 'a> = (fun s ->
[
{ visited = List.concat [s.visited; s.unvisited]
unvisited = []
args = s.args
value = s.value (String.Join("/", s.unvisited))}
])
usage:
type Route =
| Home
| Graph of string
// #/graph/lorem/ipsum
oneOf [ map Route.Graph (s "graph" </> remaining)
map Route.Home top ]
that started with what looked like a bug in the parsing, but was due to the payload containing a /
. I thought that might be worth documenting at least, maybe adding to the lib ?
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.