concept parseprefix in category idris
appears as: parsePrefix

This is an excerpt from Manning's book Type-Driven Development with Idris.
parsePrefix reads a prefix of the input according to the schema and returns the parsed input, if successful, paired with the remainder of the text. parseBySchema calls parsePrefix with some input and ensures that once it has parsed the input according to the schema, there’s no input remaining. The next listing shows the top-level implementation of parseBySchema and the type of the parsePrefix helper function.
Listing 6.19. Outline implementation of parseBySchema, using an undefined parsePrefix function to parse a prefix of an input according to a schema
parsePrefix : (schema : Schema) -> String -> Maybe (SchemaType schema, String) parseBySchema : (schema : Schema) -> String -> Maybe (SchemaType schema) parseBySchema schema input = case parsePrefix schema input of Just (res, "") => Just res #1 Just _ => Nothing #2 Nothing => Nothing #3Let’s take a look at the outline of parsePrefix, following the type-define-refine approach and see how the structure of the schema gives us hints about how to proceed with each part of the implementation: