JavaScript to Haskell

06: Routed Params


Listen Later

tackling route params
  • This is really nice that it’s a lot like express
    • We can add route parameters with :xxx in the url, just like Sinatra and express. To read it in our handler, we use the param function. Edit the /hello route to be this
    • get "/hello/:name" $ do
      name <- param "name"
      text ("hello " <> name <> "!")
      • Tried this, got some errors. realized that Haskell has a ton of ideas about strings. Like Text.
      • Text errors

        ‘Text’ is defined in ‘Data.Text.Internal’
        ‘Data.Text.Internal.Lazy.Text’
        is defined in ‘Data.Text.Internal.Lazy’
        Resources
        • Guide
        • Text Types
        • Follow
          • JavaScript to Haskell
            • Twitter: @jstoHaskell()
            • Site: JSToHaskell
            • microblog: @jtomchak
            • Jesse Tomchak
              • Twitter: @jtomchak
              • ...more
                View all episodesView all episodes
                Download on the App Store

                JavaScript to HaskellBy Jesse Tomchak