This commit is contained in:
Joeri Exelmans 2025-03-22 10:33:35 +01:00
parent 33c156fc5c
commit afd78c3b3e
5 changed files with 54 additions and 8 deletions

View file

@ -16,13 +16,14 @@ const squareFnType = makeGeneric(a =>
}),
}));
// should be: Int -> Int
console.log("should be: Int -> Int");
console.log(assign(squareFnType, makeGeneric(() => numDictType(Int))));
// should be: Double -> Double
console.log("should be: Double -> Double");
console.log(assign(squareFnType, makeGeneric(() => numDictType(Double))));
// to call 'square' we need:
// - access to a mapping from types to their typeclass instantiation
// - to know that our argument is 'Int'
console.log("");
console.log(square(NumInstances.get(Int))(42n)); // 1764n