[Haskell-cafe] explicit type for "local" functions

Jean-Marc Alliot jm at alliot.org
Wed Jan 27 10:48:10 UTC 2021


Just a short and probably simple question.

Let's consider the following function:
collatz n =
   let coll (n,cpt)
         | n==1 = (1,cpt)
         | even n = coll (div n 2,cpt+1)
         | odd n = coll (div (n*3+1) 2,cpt+1) in
     snd (coll (n,0))

It is easy to set explicitly the type of "collatz" by writing before the 
function definition:
collatz ::  Integer->Int

But can I set explicitly the type of the "local" function "coll" ?

Thanks



More information about the Haskell-Cafe mailing list