Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:28:48+00:00 2026-06-06T13:28:48+00:00

I am reading the web-routes tutorial in Happstack, and I have no idea what

  • 0

I am reading the web-routes tutorial in Happstack, and I have no idea what this is doing:

$(derivePathInfo ''Sitemap)

class PathInfo a where
  toPathSegments :: a -> [String]
  fromPathSegments :: URLParser a

The doc simply says:

we use template-haskell to derive an instance of PathInfo for the Sitemap type.

but where does it “store” it? I thought haskell had no state, and is PathInfo our own thing, or is it part of happstack?

If someone could explain this, for dummies? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:28:50+00:00Added an answer on June 6, 2026 at 1:28 pm

    It generates the code that defines an instance of the PathInfo class for the Sitemap type. This isn’t “state” as much as “type-global constants”. For example, toPathSegments (Article (ArticleId 5)) will return something like ["Article", "5"] which in turn will be used to generate a URL like "/Article/5". The other function, fromPathSegments, is the inverse operation, parsing "/Article/5" back into Article (ArticleId 5).

    You could write this instance manually:

    instance PathInfo Sitemap where
        toPathSegments Home = ["Home"]
        toPathSegments (Article (ArticleId x)) = ["Article", show x]
        fromPathSegments = ...
    

    Template Haskell is only used to reduce the need for this boilerplate code.

    You might like to read the chapter on type classes in the book Learn You a Haskell for Great Good! which is aimed at Haskell beginners.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading all over the web about this and still can't understand
I'm reading this nice tutorial about Node.js web servers: http://nodebeginner.org/ In this part of
I was reading Agile Web Development With Rails, when I saw this piece of
I'm reading about URL routing at How to: Define Routes for Web Forms Applications
I have been reading the web and trying out things for days looking for
After reading from web and forum done successfull installation of OAuth (pecl package) Doing
I have been reading up on web-site performance lately and along side lowering HTTP-Requests
I currently have a web-app where I have Servlets reading and writing to the
I'm reading a web page using HttpClient like this: httpclient = new DefaultHttpClient(); httpget
I am currently reading on Web Services. There is a SOAP tutorial at http://www.w3schools.com/soap/soap_intro.asp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.