parametric types for typescript
This commit is contained in:
		
							parent
							
								
									55c03ed520
								
							
						
					
					
						commit
						868f9f428a
					
				| 
						 | 
				
			
			@ -9,7 +9,7 @@ open Expect.Operators
 | 
			
		|||
 | 
			
		||||
describe("ReducerProject Tutorial", () => {
 | 
			
		||||
  describe("Single source", () => {
 | 
			
		||||
/*
 | 
			
		||||
    /*
 | 
			
		||||
Case "Running a single source". 
 | 
			
		||||
*/
 | 
			
		||||
    test("run", () => {
 | 
			
		||||
| 
						 | 
				
			
			@ -98,7 +98,7 @@ Case "Running a single source".
 | 
			
		|||
//TODO multiple sources
 | 
			
		||||
//TODO multiple sources with includes. Introduction to includes
 | 
			
		||||
//TODO multiple sources with multi level includes. Cycle detection
 | 
			
		||||
//TODO 
 | 
			
		||||
//TODO
 | 
			
		||||
//TODO: Implement a runOrder consideration - clean results based on run order.
 | 
			
		||||
//TODO: runOrder vs setSource/touchSource
 | 
			
		||||
//TODO: Advanced details: (below)
 | 
			
		||||
| 
						 | 
				
			
			@ -106,4 +106,4 @@ Case "Running a single source".
 | 
			
		|||
//TODO: dependents and reexecution
 | 
			
		||||
//TODO: dependencies and reexecution
 | 
			
		||||
//TODO: cleanAllResults clean
 | 
			
		||||
//TODO: cleanAll clean 
 | 
			
		||||
//TODO: cleanAll clean 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
open ForTS_Types
 | 
			
		||||
 | 
			
		||||
@genType
 | 
			
		||||
let getResult = (_p: myProject): option<result_internalValue> => My_ErrorValue.EError->Error->Some
 | 
			
		||||
let getResult = (_p: myProject): option<result_<internalValue, errorValue>> =>
 | 
			
		||||
  My_ErrorValue.EError->Error->Some
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
open ForTS_Types
 | 
			
		||||
 | 
			
		||||
@genType let isError = (r: result_<'a, 'e>): bool => Belt.Result.isError(r)
 | 
			
		||||
@genType let isOk = (r: result_<'a, 'e>): bool => Belt.Result.isOk(r)
 | 
			
		||||
 | 
			
		||||
@genType
 | 
			
		||||
let getError = (r: result_<'a, 'e>): option<'e> =>
 | 
			
		||||
  switch r {
 | 
			
		||||
  | Ok(_) => None
 | 
			
		||||
  | Error(e) => Some(e)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@genType
 | 
			
		||||
let getValue = (r: result_<'a, 'e>): option<'a> =>
 | 
			
		||||
  switch r {
 | 
			
		||||
  | Ok(v) => Some(v)
 | 
			
		||||
  | Error(_) => None
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -1,18 +0,0 @@
 | 
			
		|||
open ForTS_Types
 | 
			
		||||
 | 
			
		||||
@genType let isError = (r: result_internalValue): bool => Belt.Result.isError(r)
 | 
			
		||||
@genType let isOk = (r: result_internalValue): bool => Belt.Result.isOk(r)
 | 
			
		||||
 | 
			
		||||
@genType
 | 
			
		||||
let getError = (r: result_internalValue): option<errorValue> =>
 | 
			
		||||
  switch r {
 | 
			
		||||
  | Ok(_) => None
 | 
			
		||||
  | Error(e) => Some(e)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@genType
 | 
			
		||||
let getValue = (r: result_internalValue): option<internalValue> =>
 | 
			
		||||
  switch r {
 | 
			
		||||
  | Ok(v) => Some(v)
 | 
			
		||||
  | Error(_) => None
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
@genType.opaque type recordLike = MyInterface_InternalValue_RecordLike.t
 | 
			
		||||
@genType.opaque type internalVoid = int
 | 
			
		||||
@genType.opaque type errorValue = My_ErrorValue.t
 | 
			
		||||
@genType.opaque type result_internalValue = result<internalValue, errorValue> // There has to be a type for each result permutation
 | 
			
		||||
@genType.opaque type result_<'a, 'e> = result<'a, 'e> // There has to be a type for each result permutation
 | 
			
		||||
@genType.opaque type myProject = {name: string}
 | 
			
		||||
 | 
			
		||||
//There is no need to map option<> as it becomes nullable
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user