@@ -491,37 +491,53 @@ let ErrorD err = ErrorResult([],err)
491491let WarnD err = OkResult([ err],())
492492let CompleteD = OkResult([],())
493493let ResultD x = OkResult([], x)
494- let CheckNoErrorsAndGetWarnings res = match reswith OkResult( warns,_) -> Some warns| ErrorResult_ -> None
494+ let CheckNoErrorsAndGetWarnings res =
495+ match reswith
496+ | OkResult( warns,_) -> Some warns
497+ | ErrorResult_ -> None
495498
496499/// The bind in the monad. Stop on first error. Accumulate warnings and continue.
497500let (++) res f =
498501match reswith
499502| OkResult([], res) -> (* tailcall*) f res
500503| OkResult( warns, res) ->
501- begin match f reswith
504+ match f reswith
502505| OkResult( warns2, res2) -> OkResult( warns@ warns2, res2)
503506| ErrorResult( warns2, err) -> ErrorResult( warns@ warns2, err)
504- end
505507| ErrorResult( warns, err) ->
506508 ErrorResult( warns, err)
507509
508510/// Stop on first error. Accumulate warnings and continue.
509- let rec IterateD f xs = match xswith [] -> CompleteD| h:: t-> f h++ ( fun () -> IterateD f t)
511+ let rec IterateD f xs =
512+ match xswith
513+ | [] -> CompleteD
514+ | h:: t-> f h++ ( fun () -> IterateD f t)
515+
510516let rec WhileD gd body = if gd() then body() ++ ( fun () -> WhileD gd body) else CompleteD
511- let MapD f xs = let rec loop acc xs = match xswith [] -> ResultD( List.rev acc) | h:: t-> f h++ ( fun x -> loop( x:: acc) t) in loop[] xs
517+
518+ let MapD f xs =
519+ let rec loop acc xs =
520+ match xswith
521+ | [] -> ResultD( List.rev acc)
522+ | h:: t-> f h++ ( fun x -> loop( x:: acc) t)
523+
524+ loop[] xs
512525
513526type TrackErrorsBuilder () =
514527member x.Bind ( res , k ) = res++ k
515- member x.Return ( res ) = ResultD( res)
516- member x.ReturnFrom ( res ) = res
528+ member x.Return res= ResultD res
529+ member x.ReturnFrom res= res
517530member x.For ( seq , k ) = IterateD k seq
518531member x.While ( gd , k ) = WhileD gd k
519532member x.Zero () = CompleteD
520533
521534let trackErrors = TrackErrorsBuilder()
522535
523536/// Stop on first error. Accumulate warnings and continue.
524- let OptionD f xs = match xswith None-> CompleteD| Some( h) -> f h
537+ let OptionD f xs =
538+ match xswith
539+ | None-> CompleteD
540+ | Some h-> f h
525541
526542/// Stop on first error. Report index
527543let IterateIdxD f xs =
@@ -540,13 +556,13 @@ let TryD f g =
540556| ErrorResult( warns, err) -> ( OkResult( warns,())) ++ ( fun () -> g err)
541557| res-> res
542558
543- let rec RepeatWhileD ndeep body = body ndeep++ ( function true -> RepeatWhileD( ndeep+ 1 ) body| false -> CompleteD)
559+ let rec RepeatWhileD ndeep body = body ndeep++ ( fun x -> if x then RepeatWhileD( ndeep+ 1 ) bodyelse CompleteD)
544560let AtLeastOneD f l = MapD f l++ ( fun res -> ResultD( List.exists id res))
545561
546562
547563// Code below is for --flaterrors flag that is only used by the IDE
548564
549- let stringThatIsAProxyForANewlineInFlatErrors = new System.String[| char29 |]
565+ let stringThatIsAProxyForANewlineInFlatErrors = new System.String[| char29 |]
550566
551567let NewlineifyErrorString ( message : string ) = message.Replace( stringThatIsAProxyForANewlineInFlatErrors, Environment.NewLine)
552568