| Safe Haskell | None | 
|---|
Data.Puzzles.Compose
Contents
Description
Helpers to string together parser and renderer by puzzle type.
- type PuzzleHandler b a = forall p q. ParsePuzzle p q -> RenderPuzzle b p q -> a
- handle :: (Backend b R2, Renderable (Path R2) b) => PuzzleHandler b a -> PuzzleType -> a
- drawPuzzle :: PuzzleHandler b (Value -> Parser (Diagram b R2))
- drawPuzzleSol :: PuzzleHandler b ((Value, Value) -> Parser (Diagram b R2, Diagram b R2))
- drawPuzzleMaybeSol :: PuzzleHandler b ((Value, Maybe Value) -> Parser (Diagram b R2, Maybe (Diagram b R2)))
- drawPuzzle' :: PuzzleHandler b ((Value, Maybe Value) -> Parser (Diagram b R2))
- drawSolution' :: PuzzleHandler b ((Value, Maybe Value) -> Parser (Diagram b R2))
- drawExample' :: (Backend b R2, Renderable (Path R2) b) => PuzzleHandler b ((Value, Maybe Value) -> Parser (Diagram b R2))
Documentation
type PuzzleHandler b a = forall p q. ParsePuzzle p q -> RenderPuzzle b p q -> aSource
A function to compose an arbitrary matching pair of parser and renderer.
   In PuzzleHandler b a, b is the rendering backend type, while a is
   the result type of the composition.
handle :: (Backend b R2, Renderable (Path R2) b) => PuzzleHandler b a -> PuzzleType -> aSource
handle h t composes the parser and renderer for the puzzle
   type t with the handler h.
Handlers
drawPuzzle :: PuzzleHandler b (Value -> Parser (Diagram b R2))Source
Handler that parses a puzzle from a YAML value, and renders.
drawPuzzleSol :: PuzzleHandler b ((Value, Value) -> Parser (Diagram b R2, Diagram b R2))Source
Handler that parses puzzle and solution from a pair of corresponding YAML values, and renders both individually.
drawPuzzleMaybeSol :: PuzzleHandler b ((Value, Maybe Value) -> Parser (Diagram b R2, Maybe (Diagram b R2)))Source
Handler that parses puzzle and an optional solution from a pair of corresponding YAML values, and renders both individually, optionally for the solution.
drawPuzzle' :: PuzzleHandler b ((Value, Maybe Value) -> Parser (Diagram b R2))Source
Variant of drawPuzzle that accepts a pair of puzzle YAML value and
   optional solution YAML value.
drawSolution' :: PuzzleHandler b ((Value, Maybe Value) -> Parser (Diagram b R2))Source
Handler that accepts a pair of puzzle YAML value and optional solution YAML value, and renders the solution, failing if the solution is not provided.
drawExample' :: (Backend b R2, Renderable (Path R2) b) => PuzzleHandler b ((Value, Maybe Value) -> Parser (Diagram b R2))Source
Like drawSolution', but renders puzzle and solution in example layout.