
Greetings from a lurker
I thought that it would be an interesting idea to generate URLs from plain old Haskell record data types using Data.Data/Typeable.
Repo: https://github.com/chrisdone/url-generic
Docs: http://hackage.haskell.org/packages/archive/url-generic/0.1/doc/html/Web-URL...
Seems like a success. Whether it's a good idea I'm still considering. [snip] Let me know your thoughts.
I like it. Sorry, that is an understatement. Is it a good idea, definitely yes. A very similar approach for URLs is used in Drupal, sans the automatic generation of the url schemes. The benefit is the mapping between urls and type constructors. It makes all kinds of interesting URL expressions possible. For example having a compound page with several different posts in it, expressed in the url. This language gives control to the user to express exactly what content they want combined and how. This power is often under estimated. The scenarios are too many to mention.
From experience, it is good to combine this with named abstractions, both compile time and data driven ones.
The compile time ones are useful for abbreviations. They could probably be done using web-routes even now, but not sure how well that will work in practice. The data/value driven names are no more but a map from user specified paths to expessions in some data store. Both of the above can be used to provide clean, human readable urls, which are good both for usablility and SEO. In short - the url DSLs this package makes easy to create makes gives me a warm fuzzy feeling. You have a beer or a drink of your choice, or chocolate, on me if we meet somewhere. And a question: data Event = Event { eventId :: Maybe Integer -- ^ The event id. , eventScope :: Bool -- ^ Show the scope? , eventLayout :: Layout -- ^ Layout for the page. , eventRec :: Rec } deriving (Data,Typeable,Show) data Rec = Rec { one :: Int, two :: Int } deriving (Data,Typeable,Show) Would it be possible to express the above in a URL? I understand that at the moment it is not, but what are your thoughts on how far it would be reasonable to push the encoding. Cheers, Vlado