Copyright | (c) Justin Le 2018 |
---|---|
License | BSD3 |
Maintainer | justin@jle.im |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Types to drive the challenge runner and help speed up/clean up solutions.
Synopsis
- data a :~> b = MkSol {}
- withSolver :: (String -> Maybe String) -> String :~> String
- withSolver' :: (String -> String) -> String :~> String
- data SomeSolution where
- MkSomeSol :: (a :~> b) -> SomeSolution
- data SolutionError
- runSolution :: (a :~> b) -> String -> Either SolutionError String
- runSomeSolution :: SomeSolution -> String -> Either SolutionError String
- runSolutionWith :: Map String Dynamic -> (a :~> b) -> String -> Either SolutionError String
- runSomeSolutionWith :: Map String Dynamic -> SomeSolution -> String -> Either SolutionError String
- dyno :: forall a. (Typeable a, ?dyno :: DynoMap) => String -> Maybe a
- dyno_ :: forall a. (Typeable a, ?dyno :: DynoMap) => String -> a -> a
Documentation
Abstracting over the type of a challenge solver to help with cleaner solutions.
A a
encapsulates something that solves a challenge with input
type :~>
ba
into a response of type b
.
Consists of a parser, a shower, and a solver. The solver solves
a general a ->
function, and the parser and shower are used
to handle the boilerplate of parsing and printing the solution.Maybe
b
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
and hide the type variables so we can put
different solutions in a container.:~>
b
MkSomeSol :: (a :~> b) -> SomeSolution |
data SolutionError Source #
Errors that might happen when running a :~>
on some input.
Instances
runSolution :: (a :~> b) -> String -> Either SolutionError String Source #
Run a :~>
on some input.
runSomeSolution :: SomeSolution -> String -> Either SolutionError String Source #
Run a SomeSolution
on some input.
DynoMap
:: Map String Dynamic | map of dynamic values for testing with |
-> (a :~> b) | |
-> String | |
-> Either SolutionError String |
Run a :~>
on some input, with a map of dynamic values for testing
:: Map String Dynamic | map of dynamic values for testing with |
-> 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.
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.