Skip to content

Commit aa00c75

Browse files
committed
Add integer.is to prelude
1 parent 7d0c8f0 commit aa00c75

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/language/semantics/prelude.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,24 @@ export const prelude: ObjectNode = makeObjectNode({
228228
),
229229
),
230230
),
231+
is: preludeFunction(
232+
['integer', 'is'],
233+
{
234+
parameter: types.something,
235+
return: types.boolean,
236+
},
237+
argument =>
238+
either.makeRight(
239+
typeof argument === 'string' &&
240+
types.integer.isAssignableFrom({
241+
name: '',
242+
kind: 'union',
243+
members: new Set([argument]),
244+
})
245+
? 'true'
246+
: 'false',
247+
),
248+
),
231249
less_than: preludeFunction(
232250
['integer', 'less_than'],
233251
{

0 commit comments

Comments
 (0)