[clean-list] questions from a beginner

Markó Csaba marko_csaba at mail.tvnet.hu
Sat Apr 28 15:03:22 MEST 2007


Hello!

I'm new to Clean, and I have a few questions:
(they may be trivial for you :)


1. Is there a way to get the deducted type information?
For example:
myFunc n x
    | n==0    = 1.0
    | n>0    = x * myFunc (n-1) x
    | otherwise = abort("Error n<0")
Ok, it is a simple one, and the type must be myFunc :: Int Real -> Real
So I want to know what the compiler "thinks" about it...


2. What is wrong in my code?
*In CleanBookI.pdf, page 37 an example:
    Start = takeWhile ((<>) 0.0) (iterate (\x = x/10.0) 1.0)
In Exercise No 2:
    "Rewrite the program such that it only prints the smallest number 
that is different from
    zero using the function until."
*My first solution try:
    smallestRealv2 = until (\x = x/10.0 == 0.0 ) (\x = x/10.0) 1.0
    Start = smallestRealv2
It prints: 0
*Second try:
    smallestRealv3 = until (smrAux) (\x = x/10.0) 1.0
        where smrAux x       
                |  (x/10.0) <> 0.0   =   False       
                |  otherwise         =   True       
    Start = smallestRealv2
This one also prints: 0
The original example works, of course, and the last number in the list 
is about 9.8813E-324,
so I expected this result. What is wrong?


3. What is '.' (dot) in type definitions?
I know that ! is for strict, and * for unique.
(I don't really know yet what uniqueness means exactly, but it is an 
other story... I'm not there yet)
For example in CleanBookI.pdf, page 206:
    filter :: (a -> .Bool) !.[a] -> .[a]      // Drop all elements not 
satisfying pred
And if we are here, what is the 'u:' prefix? example: insertAt :: !Int 
.a u:[.a] -> u:[.a]


Thanks,
Markó Csaba



More information about the clean-list mailing list