aoc2018-0.1.0.0: Advent of Code 2018 solutions and auto-runner

Copyright(c) Justin Le 2018
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

AOC.Solver

Contents

Description

Types to drive the challenge runner and help speed up/clean up solutions.

Synopsis

Documentation

data a :~> b Source #

Abstracting over the type of a challenge solver to help with cleaner solutions.

A a :~> b encapsulates something that solves a challenge with input type a into a response of type b.

Consists of a parser, a shower, and a solver. The solver solves a general a -> Maybe b function, and the parser and shower are used to handle the boilerplate of parsing and printing the solution.

Constructors

MkSol 

Fields

withSolver :: (String -> Maybe String) -> String :~> String Source #

Construct a :~> from a String -> Maybe String solver, which might fail. Does no parsing or special printing treatment.

withSolver' :: (String -> String) -> String :~> String Source #

Construct a :~> from just a normal String -> String solver. Does no parsing or special printing treatment.

data SomeSolution where Source #

Wrap an a :~> b and hide the type variables so we can put different solutions in a container.

Constructors

MkSomeSol :: (a :~> b) -> SomeSolution 

data SolutionError Source #

Errors that might happen when running a :~> on some input.

Constructors

SEParse 
SESolve 
Instances
Eq SolutionError Source # 
Instance details

Defined in AOC.Solver

Ord SolutionError Source # 
Instance details

Defined in AOC.Solver

Show SolutionError Source # 
Instance details

Defined in AOC.Solver

Generic SolutionError Source # 
Instance details

Defined in AOC.Solver

Associated Types

type Rep SolutionError :: Type -> Type #

NFData SolutionError Source # 
Instance details

Defined in AOC.Solver

Methods

rnf :: SolutionError -> () #

type Rep SolutionError Source # 
Instance details

Defined in AOC.Solver

type Rep SolutionError = D1 (MetaData "SolutionError" "AOC.Solver" "aoc2018-0.1.0.0-Hkhvhpmf68i25W661VmcCR" False) (C1 (MetaCons "SEParse" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "SESolve" PrefixI False) (U1 :: Type -> Type))

runSolution :: (a :~> b) -> String -> Either SolutionError String Source #

Run a :~> on some input.

DynoMap

runSolutionWith Source #

Arguments

:: Map String Dynamic

map of dynamic values for testing with lookupDyno.

-> (a :~> b) 
-> String 
-> Either SolutionError String 

Run a :~> on some input, with a map of dynamic values for testing

runSomeSolutionWith Source #

Arguments

:: Map String Dynamic

map of dynamic values for testing with lookupDyno.

-> SomeSolution 
-> String 
-> Either SolutionError String 

Run a SomeSolution on some input, with a map of dynamic values for testing

dyno :: forall a. (Typeable a, ?dyno :: DynoMap) => String -> Maybe a Source #

From a ?dyno Implicit Params, look up a value at a given key. Meant to be used with TypeApplications:

'dyno' @"hello"

This can be used within the body of sSolve, since it will always be called with the implicit parameter.

When called on actual puzzle input, result will always be Nothing. But, for some test inputs, there might be supplied values.

This is useful for when some problems have parameters that are different with test inputs than for actual inputs.

dyno_ Source #

Arguments

:: (Typeable a, ?dyno :: DynoMap) 
=> String 
-> a

default

-> a 

A version of dyno taking a default value in case the key is not in the map. When called on actual puzzle input, this is always id. However, for some test inputs, there might be supplied values.

Meant to be used with TypeApplications:

'dyno_' @"hello" 7

This is useful for when some problems have parameters that are different with test inputs than for actual inputs.