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.
_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
http://www.haskell.org/tutorial/patterns.html - Section lazy patterns
Regards
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...)
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...
Of course, Hoogle and Hayoo could be modified to show the docs
when such symbols are searched as a special condition.
--
Felipe.
> 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
--
Searching for "haskell tilde" produces a lot of results and they're
all relevant (on the first page at least).
D
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
?
!! 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 16:02, Henk-Jan van Tuyl <hjg...@chello.nl> wrote:
>> Finally, it is the array subscript operator:
>>
>> let x = arr ! 10
>
> Shouldn't this be
>
> let x = arr !! 10
(!) is for arrays, (!!) is for lists.
~d
Oops, thanks.
That is a really useful page (http://www.haskell.org/haskellwiki/Keywords).
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.
--
Tony Morris
http://tmorris.net/
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.
> 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
> 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
>> 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
This isn't Haskell 98 only, is it? :) *Adds type families, fundeps and the
arcane arrow notation*
--
Daniel