Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4cd6ef9

Browse files
committed
Cleanup
1 parentae1380c commit4cd6ef9

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

‎src/fsharp/ConstraintSolver.fs‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,23 +305,29 @@ let BakedInTraitConstraintNames =
305305

306306
typeTrace=
307307
{mutable actions:((unit-> unit)*(unit-> unit)) list}
308+
308309
static memberNew()={ actions=[]}
310+
309311
membert.Undo()= List.iter(fun(_,a)-> a()) t.actions
310312
membert.Push f undo= t.actions<-(f, undo):: t.actions
311313

312314
typeOptionalTrace=
313315
| NoTrace
314316
| WithTraceofTrace
317+
315318
memberx.HasTrace=match xwith NoTrace->false| WithTrace_->true
319+
316320
membert.Exec f undo=
317321
match twith
318322
| WithTrace trace-> trace.Push f undo; f()
319323
| NoTrace-> f()
324+
320325
membert.AddFromReplay source=
321326
source.actions|> List.rev|>
322327
match twith
323328
| WithTrace trace-> List.iter(fun(action,undo)-> trace.Push action undo; action())
324329
| NoTrace-> List.iter(fun(action,_)-> action())
330+
325331
membert.CollectThenUndoOrCommit predicate f=
326332
letnewTrace= Trace.New()
327333
letres= f newTrace
@@ -334,15 +340,16 @@ type OptionalTrace =
334340
letCollectThenUndo f=
335341
lettrace= Trace.New()
336342
letres= f trace
337-
trace.Undo();
343+
trace.Undo()
338344
res
339345

340346
letFilterEachThenUndo f meths=
341-
meths|> List.choose(fun calledMeth->
347+
meths
348+
|> List.choose(fun calledMeth->
342349
lettrace= Trace.New()
343350
letres= f trace calledMeth
344351
trace.Undo()
345-
matchres|>CheckNoErrorsAndGetWarningswith
352+
match CheckNoErrorsAndGetWarnings reswith
346353
| None-> None
347354
| Some warns-> Some(calledMeth,warns.Length,trace))
348355

@@ -417,7 +424,7 @@ let FindPreferredTypar vs =
417424
|(v',e')::vs'->
418425
if PreferUnifyTypar v v'
419426
then(v, e):: vs
420-
else(v',e')::(v,e):: vs'
427+
else(v',e')::(v,e):: vs'
421428
find vs
422429

423430
letSubstMeasure(r:Typar)ms=

‎src/fsharp/ErrorLogger.fs‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -491,37 +491,53 @@ let ErrorD err = ErrorResult([],err)
491491
letWarnD err= OkResult([err],())
492492
letCompleteD= OkResult([],())
493493
letResultD x= OkResult([],x)
494-
letCheckNoErrorsAndGetWarnings res=match reswith OkResult(warns,_)-> Some warns| ErrorResult_-> None
494+
letCheckNoErrorsAndGetWarnings 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.
497500
let(++)res f=
498501
match reswith
499502
| OkResult([],res)->(* tailcall*) f res
500503
| OkResult(warns,res)->
501-
beginmatch 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 recIterateD f xs=match xswith[]-> CompleteD| h:: t-> f h++(fun()-> IterateD f t)
511+
let recIterateD f xs=
512+
match xswith
513+
|[]-> CompleteD
514+
| h:: t-> f h++(fun()-> IterateD f t)
515+
510516
let recWhileD gd body=if gd()then body()++(fun()-> WhileD gd body)else CompleteD
511-
letMapD f xs=let recloop acc xs=match xswith[]-> ResultD(List.rev acc)| h:: t-> f h++(fun x-> loop(x::acc) t)in loop[] xs
517+
518+
letMapD f xs=
519+
let recloop 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

513526
typeTrackErrorsBuilder()=
514527
memberx.Bind(res,k)= res++ k
515-
memberx.Return(res)= ResultD(res)
516-
memberx.ReturnFrom(res)= res
528+
memberx.Returnres= ResultDres
529+
memberx.ReturnFromres= res
517530
memberx.For(seq,k)= IterateD k seq
518531
memberx.While(gd,k)= WhileD gd k
519532
memberx.Zero()= CompleteD
520533

521534
lettrackErrors= TrackErrorsBuilder()
522535

523536
/// Stop on first error. Accumulate warnings and continue.
524-
letOptionD f xs=match xswith None-> CompleteD| Some(h)-> f h
537+
letOptionD f xs=
538+
match xswith
539+
| None-> CompleteD
540+
| Some h-> f h
525541

526542
/// Stop on first error. Report index
527543
letIterateIdxD 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 recRepeatWhileD ndeep body= body ndeep++(functiontrue-> RepeatWhileD(ndeep+1) body|false-> CompleteD)
559+
let recRepeatWhileD ndeep body= body ndeep++(fun x->if xthenRepeatWhileD(ndeep+1) bodyelse CompleteD)
544560
letAtLeastOneD 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-
letstringThatIsAProxyForANewlineInFlatErrors=new System.String[|char29|]
565+
letstringThatIsAProxyForANewlineInFlatErrors=new System.String[|char29|]
550566

551567
letNewlineifyErrorString(message:string)= message.Replace(stringThatIsAProxyForANewlineInFlatErrors, Environment.NewLine)
552568

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp