What is the meaning of tilde ("~") symbol

Hi, I'm reading the following subject : http://www.haskell.org/pipermail/haskell-cafe/2007-July/028227.html In the sample code, we can see : instance ReadAsAnyOf () ex where readAsAnyOf ~() = mzero And, I've search the meaning of the symbol "~", but I've found nothing about this (note that's not easy to search "~" on google ...) Could you give me a link about this, or explain me it ? Thx in advance.

On Sat, 2010-02-13 at 14:03 +0100, kg wrote:
Hi,
I'm reading the following subject : http://www.haskell.org/pipermail/haskell-cafe/2007-July/028227.html
In the sample code, we can see :
instance ReadAsAnyOf () ex where readAsAnyOf ~() = mzero
And, I've search the meaning of the symbol "~", but I've found nothing about this (note that's not easy to search "~" on google ...)
Could you give me a link about this, or explain me it ?
Thx in advance.
http://www.haskell.org/tutorial/patterns.html - Section lazy patterns Regards

Here's an idea... maybe we should make a small page on the Wiki explaining what all the various symbols in Haskell mean? There are a couple which are rare enough that most tutorials don't mention them that often. And there are of course symbols which mean different things in different contexts. (I especially love how curly braces are used for overriding layout *and* for named fields...)

I like that idea. When I was first learning Haskell, I remember
spending a non-trivial amount of time trying to figure out what '$'
did. I incorrectly assumed that it was provided by some library. '!'
and '~' would certainly be other good candidates for this kind of a
page. These types of things can be pretty hard to google.
On Sun, Feb 14, 2010 at 8:24 AM, Andrew Coppin
Here's an idea... maybe we should make a small page on the Wiki explaining what all the various symbols in Haskell mean?
There are a couple which are rare enough that most tutorials don't mention them that often. And there are of course symbols which mean different things in different contexts. (I especially love how curly braces are used for overriding layout *and* for named fields...)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

MightyByte wrote:
I like that idea. When I was first learning Haskell, I remember spending a non-trivial amount of time trying to figure out what '$' did. I incorrectly assumed that it was provided by some library.
Technically, it is...
'!' and '~' would certainly be other good candidates for this kind of a page.
Every now and then somebody asks about "@" too.
These types of things can be pretty hard to google.
Well yes, there is that too... ;-) Of course, the next question is if we're going to do this, how to we make it so that all the newbies stumble across this page without having to spend 25 years tracking it down? A wiki page isn't much good if nobody finds it...

On Sun, Feb 14, 2010 at 8:39 AM, Andrew Coppin
MightyByte wrote:
I like that idea. When I was first learning Haskell, I remember spending a non-trivial amount of time trying to figure out what '$' did. I incorrectly assumed that it was provided by some library.
Technically, it is...
Hmmm, both Hoogle and Hayoo give me the right answer when I search for '$'. For some reason I thought I had tried that without success. However, I'm pretty sure that was before Hayoo came out; and maybe Hoogle wasn't as good in those days. At any rate, they still don't help for things like '~', so there's definitely a use for a wiki page like this.

On Sun, Feb 14, 2010 at 09:00:14AM -0500, MightyByte wrote:
At any rate, they still don't help for things like '~', so there's definitely a use for a wiki page like this.
Of course, Hoogle and Hayoo could be modified to show the docs when such symbols are searched as a special condition. -- Felipe.

On Sun, 14 Feb 2010 14:24:03 +0100, Andrew Coppin
Here's an idea... maybe we should make a small page on the Wiki explaining what all the various symbols in Haskell mean?
There are a couple which are rare enough that most tutorials don't mention them that often. And there are of course symbols which mean different things in different contexts. (I especially love how curly braces are used for overriding layout *and* for named fields...)
The symbols that are not specified in a library can be found here: http://www.haskell.org/haskellwiki/Keywords Hoogle used to show links to this page, when a keyword was searched, but not anymore. -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://functor.bamikanarie.com http://members.chello.nl/hjgtuyl/tourdemonad.html --

Henk-Jan van Tuyl wrote:
The symbols that are not specified in a library can be found here: http://www.haskell.org/haskellwiki/Keywords
Ah, nice. It seems somebody else has already thought of this. Also, I read this page and discovered something new within about 30 seconds. (Pattern guards...)
Hoogle used to show links to this page, when a keyword was searched, but not anymore.
Hmm, pitty. As I commented, documentation isn't much help if nobody finds it.

On 14 February 2010 16:02, Henk-Jan van Tuyl
The symbols that are not specified in a library can be found here: http://www.haskell.org/haskellwiki/Keywords Hoogle used to show links to this page, when a keyword was searched, but not anymore.
In section 5 ! on this page it says
Finally, it is the array subscript operator:
let x = arr ! 10
Shouldn't this be let x = arr !! 10 ?

Finally, it is the array subscript operator:
let x = arr ! 10
Shouldn't this be
let x = arr !! 10
!! is the list subscript. Look in Data.Array.IArray for (!). Or Data.Map. There's still no consensus on typeclasses for collections, so these are all separate functions. Has anyone taken a shot at a set of AT-using classes for the standard collections?

On 14 February 2010 22:11, Evan Laforge
Finally, it is the array subscript operator:
let x = arr ! 10
Shouldn't this be
let x = arr !! 10
!! is the list subscript. Look in Data.Array.IArray for (!). Or Data.Map.
There's still no consensus on typeclasses for collections, so these are all separate functions. Has anyone taken a shot at a set of AT-using classes for the standard collections?
Oops, thanks. That is a really useful page (http://www.haskell.org/haskellwiki/Keywords).

On 14 February 2010 22:11, Evan Laforge
There's still no consensus on typeclasses for collections, so these are all separate functions. Has anyone taken a shot at a set of AT-using classes for the standard collections?
The standard collections have different shapes depending on what they represent (maps, trees, lists, sequences) so considering Functor, Traversable, Foldable perhaps the common operations are largely already covered. A unifying 'collection' class might be as problematic as good old Num is for numbers... Best wishes Stephen

On Sun, Feb 14, 2010 at 2:22 PM, Stephen Tetley
On 14 February 2010 22:11, Evan Laforge
wrote: There's still no consensus on typeclasses for collections, so these are all separate functions. Has anyone taken a shot at a set of AT-using classes for the standard collections?
The standard collections have different shapes depending on what they represent (maps, trees, lists, sequences) so considering Functor, Traversable, Foldable perhaps the common operations are largely already covered. A unifying 'collection' class might be as problematic as good old Num is for numbers...
But how about indexing? It would be nice to have universal operators like (!!) :: collection elt -> index -> elt lookup :: index -> collection elt -> Maybe elt member :: index -> collection elt -> Bool That way you can have nice short names for these common operations. Lists are very flexible but it's nothing Monoid hasn't already done with integers and newtype wrappers, and there are plenty of others which would be applicable (no pun intended): Map, Set, Bytestring, Sequence. I suppose we can get empty and concat with Monoid. What about singleton? The names and locations are all over the map (no really, not intended) too, symptomatic I suppose of the fact that they all evolved separately.

Hi Evan Singleton (aka wrap) would be nice - isn't it called Pointed in the typeclassopedia but not otherwise existent? I suppose its missing by historical accident rather than design. I frequently use Semigroup (append but no zero) - there is one on Hackage without any instances: http://hackage.haskell.org/package/algebra I'm no fan of (!!) on lists or other containers where it isn't O(1), but lookup/member are a bit more promising. However are there any useful derived operations or constructions that can be defined only in terms of a Lookup type class? For comparison, Monoid has mconcat as a derived op and e.g. the Writer monad can be usefully abstract by relying only on the Monoid interface as can Foldable. Excepting Data.Tree, Data.Graph and HashTable, 'containers' seems pretty regular now - it certainly has moved on with 0.3.0.0. Best wishes Stephen

Stephen Tetley wrote:
Hi Evan
Singleton (aka wrap) would be nice - isn't it called Pointed in the typeclassopedia but not otherwise existent? I suppose its missing by historical accident rather than design.
I frequently use Semigroup (append but no zero) - there is one on Hackage without any instances: http://hackage.haskell.org/package/algebra
I do too. I also wish there was an associative: class F f where k :: f a -> f a -> f a without the zero component. -- Tony Morris http://tmorris.net/

I'm no fan of (!!) on lists or other containers where it isn't O(1), but lookup/member are a bit more promising. However are there any useful derived operations or constructions that can be defined only in terms of a Lookup type class? For comparison, Monoid has mconcat as a derived op and e.g. the Writer monad can be usefully abstract by relying only on the Monoid interface as can Foldable.
I was thinking of (!!) as an unsafe lookup, where lookup is the safe one. Of course historically (!!) considers lists as (Int -> elt) while elem considers them a set, which is why you'd need some newtype wrappers. Anyway, I'd be happy to not include the unsafe variants at all. That would mean putting [] into Setlike with 'member' but not Maplike with 'lookup'. You'd have to come up with a better name or hide the Prelude alist lookup. I don't know about derived operations, I suppose you could come up with some sort of Evironment monad that required merely a (Maplike a) class constraint instead of a concrete data type like Map, but for me the prime motivation would be the short universal name. I could stick it in my "import unqualified" toolbox and type less.
Excepting Data.Tree, Data.Graph and HashTable, 'containers' seems pretty regular now - it certainly has moved on with 0.3.0.0.
Yes, and it's not a big deal to me. I use Map and Set and List and the overhead of separate functions for each is pretty minimal. If I used a wider variety of containers I'd probably want it more.

Hi
The symbols that are not specified in a library can be found here: http://www.haskell.org/haskellwiki/Keywords Hoogle used to show links to this page, when a keyword was searched, but not anymore.
And that's a bug: http://code.google.com/p/ndmitchell/issues/detail?id=280 (that I only just became aware of). I'll fix this up shortly. Thanks, Neil

Hi,
The symbols that are not specified in a library can be found here: http://www.haskell.org/haskellwiki/Keywords
I noticed that \ is not in that list, should it be? Patrick -- ===================== Patrick LeBoutillier Rosemère, Québec, Canada

Hi Patrick,
The symbols that are not specified in a library can be found here: http://www.haskell.org/haskellwiki/Keywords
I noticed that \ is not in that list, should it be?
Yes! Add it. If it would help a beginner understand what something means, it should be on that list. Thanks, Neil

On Sunday 14 February 2010 17:02:36 Henk-Jan van Tuyl wrote:
The symbols that are not specified in a library can be found here: http://www.haskell.org/haskellwiki/Keywords Hoogle used to show links to this page, when a keyword was searched, but not anymore.
This isn't Haskell 98 only, is it? :) *Adds type families, fundeps and the arcane arrow notation* -- Daniel
participants (15)
-
Andrew Coppin
-
Daniel Schüssler
-
Dougal Stanton
-
Evan Laforge
-
Felipe Lessa
-
Henk-Jan van Tuyl
-
Jake Wheat
-
kg
-
Maciej Piechotka
-
MightyByte
-
Neil Mitchell
-
Patrick LeBoutillier
-
Stephen Tetley
-
Tony Morris
-
wagnerdm@seas.upenn.edu