
Dear list A v. newbie question. I found the following code on the web /-- Andrew Bromage / /-- If you're doing permutations, then I suppose you want this too: //-- (subLists might be a more suggestive name) /combinations *:: [a] -> [[a]] *combinations [] = [[]] combinations (x:xs) = combinations xs ++ [ x:xs' | xs' <- combinations xs ] What does ' (apostrophe) mean? I see no reference to it in Simon Thompson's book. Thanks Logesh

Logesh Pillay
Dear list
A v. newbie question.
I found the following code on the web
/-- Andrew Bromage / /-- If you're doing permutations, then I suppose you want this too: //-- (subLists might be a more suggestive name) /combinations *:: [a] -> [[a]] *combinations [] = [[]] combinations (x:xs) = combinations xs ++ [ x:xs' | xs' <- combinations xs ]
What does ' (apostrophe) mean? I see no reference to it in Simon Thompson's book.
In Haskell, ' following a letter or number in a variable name is considered a part of the variable name. So, xs' is just a variable name distinct from xs. Jon Cast

Logesh Pillay wrote:
I found the following code on the web
/-- Andrew Bromage / /-- If you're doing permutations, then I suppose you want this too: //-- (subLists might be a more suggestive name) /combinations *:: [a] -> [[a]] *combinations [] = [[]] combinations (x:xs) = combinations xs ++ [ x:xs' | xs' <- combinations xs ]
What does ' (apostrophe) mean? I see no reference to it in Simon Thompson's book.
' nothing. xs' does the same as xs_, or _xs, or xs2, but it's readable.

the xs' is just a variable as xs,xs_, _xs. perhaps imply some relations with the counterpart without apostrophe suffix,but this is not mandatory.
----- Original Message -----
From: "Logesh Pillay"
Dear list
A v. newbie question.
I found the following code on the web
/-- Andrew Bromage / /-- If you're doing permutations, then I suppose you want this too: //-- (subLists might be a more suggestive name) /combinations *:: [a] -> [[a]] *combinations [] = [[]] combinations (x:xs) = combinations xs ++ [ x:xs' | xs' <- combinations xs ]
What does ' (apostrophe) mean? I see no reference to it in Simon Thompson's book.
Thanks
Logesh
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi, Could anyone explain for me why its not possible to return a primitive type (such as Integer, String) while doing some IO actions ? e.g: foo :: IO() -> String What does it have to do with "lazy evalution" paradigm ? Cheers _________________________________________________________________ Want to block unwanted pop-ups? Download the free MSN Toolbar now! http://toolbar.msn.co.uk/

Hi, Could anyone explain for me why its not possible to return a primitive type (such as Integer, String) while doing some IO actions ?
e.g: foo :: IO() -> String
What does it have to do with "lazy evalution" paradigm ?
As there are people who can explain it better than me, just take a look at this Hawiki page: http://haskell.org/hawiki/UsingIo Regards, Jens

Dinh Tien Tuan Anh wrote:
Hi, Could anyone explain for me why its not possible to return a primitive type (such as Integer, String) while doing some IO actions ?
e.g: foo :: IO() -> String
What does it have to do with "lazy evalution" paradigm ?
In short, to not break functional aproach. Non-IO functions can't call IO functions, because IO functions are evaluated every time you call them. Matej 'Yin' Gagyi

On Wed, 2005-07-20 at 00:21 +0200, yin wrote:
Dinh Tien Tuan Anh wrote:
Hi, Could anyone explain for me why its not possible to return a primitive type (such as Integer, String) while doing some IO actions ?
e.g: foo :: IO() -> String
What does it have to do with "lazy evalution" paradigm ?
In short, to not break functional aproach. Non-IO functions can't call IO functions, because IO functions are evaluated every time you call them.
I prefer to say it another way. I think you asking for a function like this: f :: IO a -> a If so, with this you could write: someChar :: Handle -> Char someChar handle = f (hGetChar handle) where hGetChar :: Handle -> IO Char and Handle represents the interface to a file. This is a big problem for a purely functional language, because it means someChar is not a function! Given the same Handle argument, successive calls to someChar might return different results. Functions, by definition, are not allowed to have this kind of behaviour. Therefore f is not allowed. Cheers, Bernie.
participants (7)
-
Bernard Pope
-
Dinh Tien Tuan Anh
-
Jens Fisseler
-
Jonathan Cast
-
Logesh Pillay
-
Sun Yi Ming
-
yin