dovin-0.2: A proof assistant for Magic: The Gathering puzzles.

Safe HaskellNone
LanguageHaskell2010

Dovin.V2

Description

V2 makes the following changes from V1:

  • withLocation now only takes a Location, using the current actor for player.
  • Flips argument order for validate functions to be consistent with rest of API.
  • activate and trigger use the stack.
  • Fork has a saner API and reports properly.
  • formatter now takes a Step rather than an Int. view is re-exported since it will virtually always be required for normal formatters.
Synopsis

Documentation

run :: (Step -> Formatter) -> GameMonad () -> IO () Source #

view :: MonadReader s m => Getting a s a -> m a #

View the value pointed to by a Getter, Iso or Lens or the result of folding over all the results of a Fold or Traversal that points at a monoidal value.

view . toid
>>> view (to f) a
f a
>>> view _2 (1,"hello")
"hello"
>>> view (to succ) 5
6
>>> view (_2._1) ("hello",("world","!!!"))
"world"

As view is commonly used to access the target of a Getter or obtain a monoidal summary of the targets of a Fold, It may be useful to think of it as having one of these more restricted signatures:

view ::             Getter s a     -> s -> a
view :: Monoid m => Fold s m       -> s -> m
view ::             Iso' s a       -> s -> a
view ::             Lens' s a      -> s -> a
view :: Monoid m => Traversal' s m -> s -> m

In a more general setting, such as when working with a Monad transformer stack you can use:

view :: MonadReader s m             => Getter s a     -> m a
view :: (MonadReader s m, Monoid a) => Fold s a       -> m a
view :: MonadReader s m             => Iso' s a       -> m a
view :: MonadReader s m             => Lens' s a      -> m a
view :: (MonadReader s m, Monoid a) => Traversal' s a -> m a