-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved traces to reduce circular deps in future
- Loading branch information
1 parent
f94549a
commit a7ad8ea
Showing
4 changed files
with
74 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { bool, delayed, str, TermType } from "../../type_system/types"; | ||
import { pdelay } from "../pdelay"; | ||
import { perror } from "../perror"; | ||
import { pfn } from "../pfn"; | ||
import { plam } from "../plam"; | ||
import { pforce } from "../pforce"; | ||
import { phoist } from "../phoist"; | ||
import { pBool } from "./bool"; | ||
import { pif } from "../builtins/bool"; | ||
import { ptrace } from "../builtins/ptrace"; | ||
import { TermFn } from "../../PTypes/PFn/PFn"; | ||
import { PString } from "../../PTypes/PString"; | ||
import { ToPType } from "../../type_system/ts-pluts-conversion"; | ||
|
||
export const ptraceIfTrue = phoist( | ||
pfn([ | ||
delayed( str ), | ||
bool, | ||
], bool) | ||
(( msg, boolean ) => | ||
pif( bool ).$( boolean ) | ||
.then( ptrace( bool ).$( pforce( msg ) ).$( pBool( true ) ) ) | ||
.else( pBool( false ) ) | ||
) | ||
); | ||
|
||
export const ptraceIfFalse = phoist( | ||
pfn([ | ||
delayed( str ), | ||
bool, | ||
], bool) | ||
(( msg, boolean ) => | ||
pif( bool ).$( boolean ) | ||
.then( pBool( true ) ) | ||
.else( ptrace( bool ).$( pforce( msg ) ).$( pBool( false ) ) ) | ||
) | ||
); | ||
|
||
export function ptraceError<T extends TermType>( t: T, somemsg?: string ) | ||
: TermFn<[ PString ], ToPType<T>> | ||
{ | ||
return phoist( | ||
plam( str, t ) | ||
( msg => pforce( | ||
ptrace( delayed( t ) ).$( msg ).$( pdelay( perror( t, somemsg ) ) ) | ||
) as any ) | ||
) as any; | ||
} |