Re: [Haskell-cafe] bitSize

2011-08-25 Thread Gabor Greif


Am 25.08.2011 um 19:57 schrieb Andrew Coppin:


Is there a way to actually determine how many bits are in an Integer?



occupiedBits :: Integer - Int
occupiedBits = (+1) . truncate . logBase 2 . (+1)

Caveat: untested :-)

Cheers,

Gabor
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] pthread_kill missing?

2009-11-18 Thread Gabor Greif
Hi all,

I'd like to send a signal from the main thread to a forkOS-ed thread in
GHC. The former should use raiseSignal and the second should sit in
awaitSignal.

I figured that the posix functionality in the unix-2.3 library does not
cover this case.

I would have expected that blocking/sending/receiving signals would
utilize the pthread_* routines. This does not seem to be the case.

Any idea when these will be available?

Thanks in advance,

cheers,

Gabor


PS: I guess some of you will say, use condition variables.
But that won't answer my question :-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] pthread_kill missing?

2009-11-18 Thread Gabor Greif


Am 18.11.2009 um 14:15 schrieb Svein Ove Aas:


On Wed, Nov 18, 2009 at 2:03 PM, Gabor Greif ga...@mac.com wrote:

PS: I guess some of you will say, use condition variables.
But that won't answer my question :-)


Actually, I was going to say use throwTo.

Is there som reason you have to use the POSIX routines directly
instead of using native haskell exceptions?


Because I'd like to eventually send signals from outside (e.g. a shell)
too. This is in fact a stripped-down version of a real program  
written in C
mainly to demonstrate how much easier it is to get the same  
functionality

in Haskell.

How much work would it be to add the pthread signal blocking/sending
facility to the unix library?

Cheers,

Gabor





--
Svein Ove Aas
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parameterisations of Monads

2008-02-05 Thread Gabor Greif


Am 05.02.2008 um 21:27 schrieb Dan Weston:


Matthew,

Your SuperMonad seems remarkably similar to Gabor Greif's Thrist  
datatype [1,2] reported only six days ago on this list [3].


Can you compare/contrast your class approach with his polymorphic  
type approach? Or have I completely confused the two because of the  
similar kind of their arguments?


data Thrist :: (* - * - *) - * - * - * where
Nil :: Thrist p a a
Cons :: p a b - Thrist p b c - Thrist p a c

data Arrow' :: (* - * - *) - * - * - * where
Arr :: Arrow a = a b c - Arrow' a b c
First :: Arrow a = Arrow' a b c - Arrow' a (b, d) (c, d)



For the record, I have done the monad into thrist embedding now:

http://heisenbug.blogspot.com/2008/02/embeddings-part-two-monad- 
thrist.html


Will start pondering about mfix and restricted monads now.

Cheers,

Gabor

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Relevance and applicability of category theory

2008-01-31 Thread Gabor Greif


Am 31.01.2008 um 01:23 schrieb [EMAIL PROTECTED]:

3. I believe the documentation stating that Haskell arrows are a  
generalization of Haskell monads, but arrows are a categorical  
thing too and in that context bear a much more distant relationship  
to monads.  Does a Haskell arrow have Hask as domain and codomain?   
Or is one particular element in Hask its domain and possibly  
another its codomain?  Those are not at all the same thing.



Without being able to dive into this matter now,
I just want to say that both the Haskell monads
and arrows can be generalized to something
I call a thrist, which appears to be the moral
equivalent of a free category. The underlying
category is obtained by a two-parameter GADT
(defining the morphisms) and the domains and
codomains of its members (which are Haskell types)
being the objects.

Here is my blog entry that motivates the concept
a bit:

http://heisenbug.blogspot.com/2007/11/trendy-topics.html

Cheers,

Gabor

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Relevance and applicability of category theory

2008-01-31 Thread Gabor Greif

Am 31.01.2008 um 18:13 schrieb Dan Weston:

Even though you cannot dive into this matter now, maybe when you  
get time you can update your blog with an explicit embedding of  
Haskell monads and arrows in your Thrist construction. Concrete  
examples will help me (and probably others) more quickly see the  
novelty, increased generality, and usefulness of a Thrist.


Okay, I took my time and came up with:

http://heisenbug.blogspot.com/2008/01/embeddings-part-one-arrow- 
thrist.html


Comments welcome.




Also, although you say that thrists are the moral equivalent of a  
free category, it appears (at least to me) possible that the first  
Thrist argument enables the construction of a restricted domain  
monad, e.g. (Eq a = Set a) monad. Is this so?


Hmmm, not sure what you asking for. If you have a monad instance Set  
a that has Eq a attached, this
already would do what you want, no? An example would help me to  
understand...





Dan


Cheers,

Gabor






___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Editor

2007-05-22 Thread Gabor Greif

Am 23.05.2007 um 00:20 schrieb Ashley Yakeley:

I don't suppose you're familiar with the Dylan programming  
language, or more to the point, have looked at the IDE that Apple  
included in their original implementation of the language (around  
1993 or so)? Characteristic of Apple of that time, the UI was both  
highly innovative and a joy to use. It was based around browsers,  
where each browser had a subject (such as a project, module,  
definition etc.) and an aspect (such as contents of, errors  
in, references to, direct methods of etc.). Browsers could be  
linked so that the selection in one browser became the subject in  
another. This made it very easy to navigate your project.


All code was stored in a database rather than as text files, and  
individual code definitions were separate objects in the browsers  
rather than pieces of text in a big file.


Info w/ screenshots: http://osteele.com/museum/apple-dylan
http://wiki.opendylan.org/wiki/view.dsp?title=Apple%20Dylan
Needless to say, this goes in rather the opposite UI direction to  
the Ctrl-M Ctrl-Meta-Z esc :edit qx approach to editors that  
some people prefer.


Dylan's not a bad language, and there are open source  
implementations available for Gnu/Linux. But if you want to check  
out Apple's IDE, you'll really need a 68K Mac, as the PPC version  
is very buggy and I don't think the 68K version will run in PPC.


Michael's blog:

http://snakeratpig.blogspot.com/2007/02/road-to-haskell.html

Dylan and Haskell are very similar in the multiple-dispatch (a  
haskeller would call that

pattern matching on several arguments) respect.

Cheers,

Gabor

PS: Btw, the Apple Dylan IDE works well on PPC if you apply a patch  
that was issued by

Digitool shortly after the initial port of the IDE to PPC.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Any Haskellers anywhere?

2007-05-05 Thread Gabor Greif

Am 06.05.2007 um 03:52 schrieb Rob Hoelz:


Sounds like a good idea to me.  I'd like to see if any Haskellers are
in Madison.


Doesn't Google have a service for visualizing locations on a map?
The wiki could point there, for example...

Gabor


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe