Stream: beginners

Topic: math functions in new compiler


view this post on Zulip Guillaume Sarisson (Mar 03 2026 at 07:16):

Hi everyone! I'm playing a bit with the new compiler and I can't figure out how to call math functions. Does the Num module still exists ?

view this post on Zulip Luke Boswell (Mar 03 2026 at 07:19):

No it doesn't --- src/build/roc/Builtin.roc defines all the builtin functions

view this post on Zulip Luke Boswell (Mar 03 2026 at 07:19):

https://github.com/roc-lang/roc/blob/3fa8df31997e3e233d5bda63eec8737ccd3ce941/src/build/roc/Builtin.roc#L4

view this post on Zulip Luke Boswell (Mar 03 2026 at 07:21):

$ roc repl
Roc REPL
Type :help for help, :exit to quit

» U16.plus(12,32)
44
» 12 + 23
35
» U32.div_by(12,3)
4

view this post on Zulip Guillaume Sarisson (Mar 03 2026 at 07:24):

Cool, it works. Thanks !

view this post on Zulip Luke Boswell (Mar 03 2026 at 07:25):

It's a bit funky... but you can do

» 12.U64.plus(12)
24
» 12.plus(12)
24

view this post on Zulip Guillaume Sarisson (Mar 03 2026 at 13:13):

I’ll give it a try, thanks! I think I’ll try to implement a few more complex functions (cos, sin, exp, …) in pure roc since I don’t see them in the built in file, just for fun. Is it going to be added in the futur ?

view this post on Zulip Anton (Mar 03 2026 at 14:10):

I just made #9231 to make sure we add them :)


Last updated: Mar 20 2026 at 12:28 UTC