anchor.diff:  open FSharpx
   open Eventful.Validation
   
  -type Validator<'TCmd,'TState> = 
  +type IStateValidatorRegistration<'TMetadata,'TKey> =
  +    abstract member Register<'TState> : IStateBuilder<'TState, 'TMetadata, 'TKey>  -> ('TState -> seq<ValidationFailure>) -> unit
  +
  +type Validator<'TCmd,'TState, 'TMetadata, 'TKey> = 
   | CommandValidator of ('TCmd -> seq<ValidationFailure>)
  -| StateValidator of ('TState -> seq<ValidationFailure>)
  +| StateValidator of (IStateValidatorRegistration<'TMetadata,'TKey> -> unit)
   | CombinedValidator of ('TCmd -> 'TState -> seq<ValidationFailure>)
   
   type SystemConfiguration<'TMetadata> = {
  
positive.code:         (handler: CommandHandler<'TCmd,'TCommandContext, 'TState, 'TId, 'TEvent,'TMetadata, 'TValidatedState>) = 
          { handler with Validators = validator::handler.Validators }
  
      // todo reinstate this
      // let ensureFirstCommand x = addValidator (StateValidator (isNone id (None, "Must be the first command"))) x 
  
      let buildSimpleCmdHandler<'TId,'TCmd,'TCmdState,'TEvent, 'TCommandContext,'TMetadata when 'TId : equality> emptyMetadata stateBuilder = 
          (simpleHandler<'TId,'TCmdState,'TCmd,'TEvent, 'TCommandContext,'TMetadata> emptyMetadata stateBuilder) >> buildCmd
  
negative.code:         validators
          |> List.map (function
                          | CommandValidator validator -> validator cmd |> (toChoiceValidator cmd)
                          | StateValidator validator -> 
                              let registration = 
                                  { new IStateValidatorRegistration<_,_> with 
                                      member x.Register
                                  }
                              validator state |> (toChoiceValidator cmd)
                          | CombinedValidator validator -> validator cmd state |> (toChoiceValidator cmd))
           |> List.map (fun x -> x)
           |> List.fold (fun s validator -> v.apl validator s) (Choice.returnM cmd) 
  