concept small part in category idris
appears as: small part

This is an excerpt from Manning's book Type-Driven Development with Idris.
Refine— The type of ?parsePrefix_rhs_3 shows that you need to parse two subschemas and combine the results: It’s a good idea to give x and y more-meaningful names before proceeding:x : Schema y : Schema input : String -------------------------------------- parsePrefix_rhs_3 : Maybe ((SchemaType x, SchemaType y), String)To refine parsePrefix_rhs_3, you can recursively parse the first portion of the input according to schemal, and if that succeeds, parse the rest of the input according to schemar. Parse the first portion:parsePrefix (schemal .+. schemar) input = ?parsePrefix_rhs_3If parsePrefix on the first part of the schema fails, the whole thing will fail. Otherwise, you have a new hole:parsePrefix (schemal .+. schemar) input = case parsePrefix schemal input of Nothing => Nothing Just (l_val, input') => ?parsePrefix_rhs_2schemal : Schema l_val : SchemaType schemal input' : String schemar : Schema input : String -------------------------------------- parsePrefix_rhs_2 : Maybe ((SchemaType schemal, SchemaType schemar), String)
Keep reloading!
While following this type-driven approach, you always have a file that type-checks as far as possible. Here, rather than filling the hole completely, you’ve written a small part of it with a new hole, and checked that what you have type-checks before proceeding.
While following this type-driven approach, you always have a file that type-checks as far as possible. Here, rather than filling the hole completely, you’ve written a small part of it with a new hole, and checked that what you have type-checks before proceeding.