Help us understand the problem. What is going on with this article?

AOJ day 13: Type-level annotated string templates

More than 1 year has passed since last update.

Previously, I covered my post about well-typed paths using Symbols with formatting parameters, such that we can derive a parsing function from a Symbol proxy like so:

-- inferred type:
parseHelloURL :: String -> Either String { name :: String, age :: String }
parseHelloURL = parseURL (SProxy :: SProxy "/hello/{name}/{age}")

But really, we might like to read age here as an Int, and we could provide this information as a type annotation. And we can!

"Parsing type-level strings to extract types"

In this post, I go through how we can modify the previous implementation to conditionally parse out a type annotation from our Symbol, by using the same techniques for parsing piecewise with instance chain groups as done in Record-Format and other libraries.

https://qiita.com/kimagure/items/6729a5d55ab99bcee8ec

This way, we can instead work with URLs that have their types annotated like so:

parseHelloURL :: String -> Either String { name :: String, age :: Int }
parseHelloURL = parseURL (SProxy :: SProxy "/hello/{name:String}/{age:Int}")

"Simple Routing based on parsing type-level strings"

There's also a follow-up post to this that applies classic RowToList techniques to allow for a row of these routes to be tried to product an Either of no matches and a Variant of the routes:

https://qiita.com/kimagure/items/5c3f3fcb898e480c56be

kimagure
my new posts are on github.com/justinwoo/my-blog-posts
https://twitter.com/jusrin00
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした