Henning Thielemann | 1 Aug 2008 01:29
Picon

Re: array fusion interface


On Tue, 22 Jul 2008, Evan Laforge wrote:

> With all the noise lately about high performance array libraries with
> list-like interfaces, such as bytestring, storablevector, uvector, and
> vector, I thought I would try to make use of one in a project of mine,
> and I'm either bumping up against the limits of its expressiveness, or
> am missing out on how to express my problem.
>
> I have streams of samples with irregular sampling rates, so they look
> like [(Time, SampleVal)].  In practice, this means [(Double, Double)].

Maybe I have already mentioned my eventlist package on Hackage which
supports such resampling operations - but is based on lists.
   http://hackage.haskell.org/cgi-bin/hackage-scripts/package/event-list
Henning Thielemann | 1 Aug 2008 01:37
Picon

Re: Point-free style in guards


On Tue, 22 Jul 2008, L29Ah wrote:

> outStanza | (isMessage) = outMessage
>             | (isPresence) = outPresence
>             | (isIQ) = outIQ
>
> Why such a style doesn't work, so I must write ugly code like that:
>
> outStanza a | (isMessage a) = outMessage a
>             | (isPresence a) = outPresence a
>             | (isIQ a) = outIQ a
>
> so, guards can't be useful in point-free function definitions in any way

It's sad that syntactic sugar makes people want even more syntactic sugar
(some people thus call it syntactic heroin).

You can easily achieve the wanted effect by a function like 'select'
  http://www.haskell.org/haskellwiki/Case
 and that way you can also avoid guards in many cases.
Henning Thielemann | 1 Aug 2008 01:51
Picon

Re: Exceptions


On Sun, 27 Jul 2008, Adrian Neumann wrote:

> Hello,
>
> I think it'd be nice if the compiler could warn me if there are any
> exceptions which I'm not catching, similar to checked exceptions in
> Java. Does anyone know of a possibility to do that in Haskell?

Please refer to the long "extensible extension" thread:
   http://www.haskell.org/pipermail/libraries/2008-July/010095.html
  In my posts I sketched possibilities to do that.
Galchin, Vasili | 1 Aug 2008 07:08
Picon

an array of pointers in FFI?

Hello,

     Is a (Ptr (Ptr a)) a polymorphic representation of an array of pointers of type "a"? I want to pass an array of pointers to a C function.

Kind regards, Vasili
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Galchin, Vasili | 1 Aug 2008 07:52
Picon

category theory tutorial pdfs .....

Hello,

    Prof. Harold Simmons' tutorial IMO are like a Russian matroshka doll ... first layer is for newbie ... inner layers require more sophistication. IMO a very subtle writer ... I have every book imaginable on cat theory and topos theory so I think can compare a little.

       1) http://www.cs.man.ac.uk/~hsimmons/BOOKS/books.html  ... an earlier version ... "An Intro to Category Theory in Four Easy Movements" ... this version delves a little into Topos Theory ... pretty subtle .. cool

       2) http://www.cs.man.ac.uk/~hsimmons/MAGIC-CATS/magic-cats.html  ... newer version which also has its cool merits IMO!

Regards, Vasili
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Bulat Ziganshin | 1 Aug 2008 07:53
Picon

Re: an array of pointers in FFI?

Hello Vasili,

Friday, August 1, 2008, 9:08:05 AM, you wrote:

>      Is a (Ptr (Ptr a)) a polymorphic representation of an array of
> pointers of type "a"? I want to pass an array of pointers to a C function.

use Ptr (Ptr ())

Ptr ()  in haskell is like void* in C, it's used to represent pointer
to arbitrary type. you can use castPtr to cast pointers between different
types

--

-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin <at> gmail.com
Galchin, Vasili | 1 Aug 2008 07:59
Picon

Re: an array of pointers in FFI?

Thanks Bulat! So since we are "talking" ;^) .... is there a function already in Foreign that will allow me to ...

[a] -> Ptr (Ptr ()) i.e. map a list of type "a" to an array of ptrs of type "a"?

Kind regards, Vasili

On Fri, Aug 1, 2008 at 12:53 AM, Bulat Ziganshin <bulat.ziganshin <at> gmail.com> wrote:
Hello Vasili,

Friday, August 1, 2008, 9:08:05 AM, you wrote:

>      Is a (Ptr (Ptr a)) a polymorphic representation of an array of
> pointers of type "a"? I want to pass an array of pointers to a C function.

use Ptr (Ptr ())

Ptr ()  in haskell is like void* in C, it's used to represent pointer
to arbitrary type. you can use castPtr to cast pointers between different
types


--
Best regards,
 Bulat                            mailto:Bulat.Ziganshin <at> gmail.com


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Stuart Cook | 1 Aug 2008 10:25
Picon

Re: an array of pointers in FFI?

2008/8/1 Galchin, Vasili <vigalchin <at> gmail.com>:
> Thanks Bulat! So since we are "talking" ;^) .... is there a function already
> in Foreign that will allow me to ...
>
> [a] -> Ptr (Ptr ()) i.e. map a list of type "a" to an array of ptrs of type
> "a"?

I think this is going to be a two-part operation: first you'll need to
store those values somewhere, so that you can produce pointers to
them. Then, you create a (foreign) array and fill it with the pointers
you got from step one. Of course, you'll need to manage memory for the
two stages separately, ensuring that the pointers don't outlive the
things they point to, and that both memory regions are freed when no
longer needed.

For example, if you have a list (xs :: [Int]), you can probably
achieve the first step using (mapM new xs),* which should give you a
list (ps:: [Ptr Int]). Then, you can do (newArray ps), which will
allocate an array and store the pointers in it, giving you a pointer
of type (Ptr (Ptr Int)). Once you're done, use (free) to clean up the
array of pointers, and also each of the individual elements of (ps).
If you only need the pointer array in a particular scope, you should
be able to make your life a bit easier using the (alloca) or (with)
family of functions.

* This is probably a bit wasteful, since it makes a separate
allocation for each element, but it does make life easier.

Hope this helps.

Stuart
Chaddaï Fouché | 1 Aug 2008 10:48
Picon
Gravatar

Re: a really dumb posting question ;^(

2008/7/31 Galchin, Vasili <vigalchin <at> gmail.com>:
> Hello,
>
>     What do I do to do a followup haskell cafe posting? E.g. I want to put a
> posting on the category theory thread!

You respond to it. Sometimes it is not sufficient
(haskell-cafe <at> haskell.org isn't in the to or cc field), then you
probably have a "respond to all" action in your mailer, you should use
it. The best way is to use "respond to list" if you have it but
"respond to all" should work properly.

--

-- 
Jedaï
Benjamin L. Russell | 1 Aug 2008 14:44
Picon
Favicon

Re: category theory tutorial pdfs .....

On Fri, 1 Aug 2008 00:52:41 -0500, "Galchin, Vasili"
<vigalchin <at> gmail.com> wrote:

>Hello,
>
>    Prof. Harold Simmons' tutorial IMO are like a Russian matroshka doll ...
>first layer is for newbie ... inner layers require more sophistication. IMO
>a very subtle writer ... I have every book imaginable on cat theory and
>topos theory so I think can compare a little.
>
>       1) http://www.cs.man.ac.uk/~hsimmons/BOOKS/books.html  ... an earlier
>version ... "An Intro to Category Theory in Four Easy Movements" ... this
>version delves a little into Topos Theory ... pretty subtle .. cool

I have started reading _An introduction to category theory in four
easy movements_ (see
http://www.cs.man.ac.uk/~hsimmons/BOOKS/CatTheory.pdf).  The author's
style is very strange; in the first section, he states that he
highlights "subsidiary notions" to be defined later in small caps, and
even uses some of these in his exercises.  For example, he highlights
and uses "preset" and "monoid" as part of Exercise 1.1 before defining
them, so I then need to hunt around in the vicinity for definitions
(available several pages later).  However, the PDF file is not
text-searchable, so I need to hunt manually through the vicinity of
pages to find a definition.

This makes the book more interesting, at the expense of being harder
to use.  Do you know of a text-searchable version of this file?

He also has a rather peculiar sense of humor.  For instance, on page
6, he writes (regarding that in the original examples of categories,
"the arrows were morphisms which were then called homomorphism, and it
wasn't realized that this family could be very large"), 

> (Some out and out category theorists still don't realize the significance of this.  
> On the other hand, some off the wall set theorists don't realize the significance 
> of category theory.)

This reminds me of a lecture by David Gelernter in 1992 in a survey
course on cognitive science at Yale in which he said that some weak AI
cognitive scientists had said that other strong AI cognitive
scientists must have been "out to lunch."

Again, if you know of a text-searchable version of this book, please
post the reference in this thread.

-- Benjamin L. Russell

Gmane