This is my first Stack Overflow question so if I forgot any crucial information please just let me know and I will add it!
So I am new to Haskell and just learning about types and classes. Now I've got 1 type and 2 functions declared:
data Nat = Zero | Succ Nat
add :: Nat -> Nat -> Nat
add Zero n = n
add (Succ m) n = Succ (add m n)
mult :: Nat -> Nat -> Nat
mult Zero _ = Zero
mult (Succ m) n = add n (mult m n);
When calling the first function I can fully evaluate it and understand how Haskell processes it. Like this:
> 2 + 1 = 3
>
> add (Succ (Succ Zero)) (Succ Zero)
>
> Succ (add (Succ zero)) (Succ Zero))
>
> Succ (Succ (add Zero (Succ Zero))
>
> Succ (Succ (Succ Zero))
But I can't understand how this would be for the mult function. For me it looks like that will be an infinite loop of adding.
Anyone who can explain me how the mult function would be evaluated?