puzzle-draw-0.1.0.0: Creating graphics for pencil puzzles.

Safe HaskellNone
LanguageHaskell98

Data.Puzzles.Compose

Contents

Description

Helpers to string together parser and renderer by puzzle type.

Synopsis

Documentation

type PuzzleHandler b a = forall p q. ParsePuzzle p q -> RenderPuzzle b p q -> a Source

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 -> a Source

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.