6 ms·
fact n = do let n' = n - 1 if n <= 1 then 1 else n * fact n' Here you go. Not sure about Haskell but in PureScript it compiles. Use "<-" for functions
by bPspGiJT8Y 3y ago
fact n = do
let n' = n - 1
if n <= 1 then 1 else n * fact n'
Here you go. Not sure about Haskell but in PureScript it compiles. Use "<-" for functions which return a value in IO type constructor, otherwise use "let".
- itishappy 3y agoThat's kinda the point though, right? There's something different about this `IO` thing that uses special syntax. You might be able to guess something and get it to compile, but should you? fact n = do let n' = do n - 1 if do n <= 1 then do 1 else do n * fact n'
- deleted 3y ago[deleted]