Re: [Haskell-cafe] Non-termination due to context

2010-01-25 Thread Emil Axelsson
OK, I'll try to get to the SYB3 paper at some point. For now I'll just 
add to my knowledge that UndecidableInstances allows you to create 
non-terminating dictionaries in addition to the well-known risk of 
making the type checker loop.


Thanks!

/ Emil


Simon Peyton-Jones skrev:
It's a feature! 


You have
 * B is a superclass of A
 * Eq is a superclass of B

So every A dictionary has a B dictionary inside it, and every B dictionary has 
an Eq dictionary inside it.

Now, your instance declaration 
	instance (A a, Eq a) = B a

says if you give me an A dictionary and an Eq dictionary, I'll make you a B 
dictionary.

Now, 'test' needs a (B Int) dictionary.  To get one, we need an (A Int) dictionary and an (Eq Int) dictionary.  But 

	when solving these sub-problems, GHC assumes that you 
	have in hand a solution to the original problem, this case (B Int)


Why? Read the SYB3 paper.

OK so now you see the problem: we can solve the (A Int) and (Eq Int) 
sub-problems by selection from the (B Int) dictionary.


Still, I confess that I have not fully grokked the relationship between the 
SYB3-style recursion stuff and the question of superclasses.   So I will think 
about your example some more, thank you.

Meanwhile, it's clear that you are on thin ice.

Simon


| -Original Message-
| From: haskell-cafe-boun...@haskell.org 
[mailto:haskell-cafe-boun...@haskell.org] On
| Behalf Of Emil Axelsson
| Sent: 22 January 2010 11:25
| To: Haskell Cafe
| Subject: [Haskell-cafe] Non-termination due to context
| 
| Hello all!
| 
| Consider the following program:
| 
|  {-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-}

| 
|  class B a = A a
| 
|  instance A Int
| 
|  class Eq a = B a
| 
|  instance (A a, Eq a) = B a
| 
|  eq :: B a = a - a - Bool
|  eq = (==)
| 
|  test = 1 `eq` (2::Int)
| 
| (This is a condensed version of a much larger program that I've been

| debugging.)
| 
| It compiles just fine, but `test` doesn't terminate (GHCi 6.10.4). If I

| change the context `B a` to `Eq a` for the function `eq`, it terminates.
| 
| Although I don't know all the details of the class system, it seems

| unintuitive that I can make a program non-terminating just by changing
| the context of a function (regardless of UndecidableInstances etc.).
| 
| Is this a bug or a feature?
| 
| / Emil
| 
| ___

| 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


[Haskell-cafe] Failing to install hxt: tagsoup versioning

2010-01-25 Thread hask...@kudling.de
 Specifying one exact version is too restrictive, you'll end up with 
 everybody having umpteen versions of almost all packages installed.

I don't see this as a problem. Disk space is extremely cheap, but our time is
precious.
Aplications on Mac OS X provide necessary libraries in their .app folder.
That's some waste but it relieves you from dependency hell.

 Minor version bumps which leave the API unchanged shouldn't break anything,
 small additions to the API should rarely break things, so if people adhere 
 to http://www.haskell.org/haskellwiki/Package_versioning_policy ,

Indeed.

Neil, in this case i think, tagsoup's version shouldn't have changed from 0.6 to
minor 0.8
while exported definitions such as optLookupEntity were removed.

What do you think?

I'd be glad if we could find a general solution.
Currently everybody using ghc 6.10.4 and trying to install hxt will go through
this hassle.
Which would be almost everybody.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: ghc: unrecognised flags: -I

2010-01-25 Thread Christian Maeder
Lyndon Maydwell schrieb:
 For example, when I cabal install -v storable-complex I get the following:
 
 /usr/bin/ghc -package-name storable-complex-0.2.1 --make
 -hide-all-packages -i -idist/build -i. -idist/build/autogen
 -Idist/build/autogen -Idist/build -I -optP-include
 -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir
 dist/build -stubdir dist/build -package base-3.0.3.1 -O
 Foreign.Storable.Complex
 ghc: unrecognised flags: -I

For me this works (and does not have that single -I):

/home/mac-bkb/bin/ghc -package-name storable-complex-0.2.1 --make
-hide-all-packages -i -idist/build -i. -idist/build/autogen
-Idist/build/autogen -Idist/build -optP-include
-optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir
dist/build -stubdir dist/build -package base-3.0.3.1 -O
Foreign.Storable.Complex

 Has anyone encountered this before, or more realistically, can anyone
 give me some advice on how to narrow this problem down further?

Sorry, no idea.

 I'm running cabal version 1.6.0.1, ghc 6.10.4 on OS X 10.5.

I've got Cabal-1.6.0.3, ghc 6.10.4 on OS X 10.5 (Intel)

cabal-install version 0.6.2
using version 1.6.0.3 of the Cabal library

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


Re: [Haskell-cafe] Failing to install hxt: tagsoup versioning

2010-01-25 Thread Malcolm Wallace
Minor version bumps which leave the API unchanged shouldn't break  
anything, http://www.haskell.org/haskellwiki/Package_versioning_policy


Neil, in this case i think, tagsoup's version shouldn't have changed  
from 0.6 to minor 0.8 while exported definitions such as  
optLookupEntity were removed.


Changing version number 0.6 - 0.8 is a major release increment, not a  
minor one, according the package versioning policy linked to.


Regards,
Malcolm




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


Re: [Haskell-cafe] Failing to install hxt: tagsoup versioning

2010-01-25 Thread Daniel Fischer
Am Montag 25 Januar 2010 14:31:07 schrieb Malcolm Wallace:
  Minor version bumps which leave the API unchanged shouldn't break
  anything, http://www.haskell.org/haskellwiki/Package_versioning_policy
 
  Neil, in this case i think, tagsoup's version shouldn't have changed
  from 0.6 to minor 0.8 while exported definitions such as
  optLookupEntity were removed.

 Changing version number 0.6 - 0.8 is a major release increment, not a
 minor one, according the package versioning policy linked to.

Which I found rather irritating initially.
I had 'learned' that version numbers go

Major.Minor.Patchlevel[.optionalLineNoise]

and then coming to terms with

Major.major.Minor[.optionalStuff]

took a couple of days.


 Regards,
  Malcolm

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


Re: [Haskell-cafe] Naive booleans and numbers - type-checking fails

2010-01-25 Thread Ryan Ingram
As other people have said, you need higher rank types for this.

Lets start with just pairs to get you headed in the right direction:

 {-# LANGUAGE RankNTypes #-}

(As an aside, almost all of my real programs require at least rank-2
types, so I usually turn on RankNTypes on principle)

 mpair :: a - b - (a - b - c) - c
 mpair f s k = k f s

 mfst p = p (\x y - x)
 msnd p = p (\x y - y)

Here is where it gets tricky.  GHC infers these types:

mfst :: ((a - b - a) - c) - c
msnd :: ((a - b - b) - c) - c

But these aren't the right types; if you try to use both mfst and msnd
on the same pair, you will unify a and b which is almost certainly
wrong; it says the first and second element of the pair are the same
type.

Now, lets look at the type signature for the partially-applied mpair;
given x :: A, and y :: B, we have
  mpair x y :: (A - B - c) - c

Notice this: a pair is a polymorphic function!  Lets make functions
that take pairs specify that explicitly:

 mfst :: (forall c. (a - b - c) - c) - a
 msnd :: (forall c. (a - b - c) - c) - b

Here we tell the typechecker that mfst and msnd are required to be
passed polymorphic functions; this makes us free to determine the
result type when we call p, and the same pair can be passed to both
of these functions successfully.  The placement of the parentheses
around the forall is very important, because that's how we specify
where the polymorphism is required.

Similar tricks generally need to be used when defining church
numerals, if you are headed in that direction.  These sort of objects
which work in untyped lambda calculus are just not expressible in the
simply typed lambda calculus, even with rank-1 polymorphism.  Once you
move to full System F, a lot more becomes possible.

  -- ryan

2010/1/24 Dušan Kolář ko...@fit.vutbr.cz:
 Dear cafe,

  I'm trying to prepare a naive definition of booleans, numbers and some
 helper functions such a way, so that definition in lambda-calculus can be
 used in a straightforward way in Haskell. I was caught in trouble quite soon
 during change of lambda-expressions to Haskell - defining prefn as a helper
 for prev. When using Haskell-ish if-then-else then there is no problem (the
 code commented out), while using defined if-then-else (mif), the
 type-checking fails, but just for this case! Other simple tests are OK for
 the mif. Do I need some extra option for type-checker, or is it a principal
 failure (infinite type is reported) - I'm running ghci 6.10.4.

 mtrue  x y = x
 mfalse x y = y

 m0 f n = n
 m1 f n = f n
 m2 f n = f (f n)

 msucc x g m = x g (g m)
 iszero m = m (\_ - mfalse) mtrue

 mif c t f = c t f
 mpair f s = \e - e f s
 mfst p = p mtrue
 msnd p = p mfalse

 -- mprefn f p = if mex True False then mth else mel
 mprefn f p = mif mex mth mel
   where
     mex = mfst p
     mth = mpair mfalse (msnd p)
     mel = mpair mfalse (f (msnd p))


 Please, change of definitions is not a solution, I'm trying to follow
 available resources, so using something else is not an option. :-(

 Thanks for any help

  Dusan

 ___
 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


[Haskell-cafe] HList darcs repo missing?

2010-01-25 Thread Jake Wheat
Hello all,

I was looking for the HList darcs repo at:

http://darcs.haskell.org/HList/

but it seems to be missing. Has it been moved somewhere else?

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


[Haskell-cafe] Re: Failing to install hxt: tagsoup versioning

2010-01-25 Thread Neil Mitchell
Hi

 Minor version bumps which leave the API unchanged shouldn't break
 anything,
 small additions to the API should rarely break things, so if people adhere
 to http://www.haskell.org/haskellwiki/Package_versioning_policy ,

 Neil, in this case i think, tagsoup's version shouldn't have changed from
 0.6 to minor 0.8
 while exported definitions such as optLookupEntity were removed.

As Malcolm says, the rule is that 0.6 - 0.8 I can do absolutely
anything. If it's any consolation, I'm intending 0.9 to be perfectly
compatible with 0.8.

If there's anything I can do to make the hxt thing a bit easier I'm
happy to do so. The change to remove optLookupEntity was necessary to
support HTML 5 correctly, so I didn't really have a choice. In general
I do try and keep the API as stable as possible.

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


[Haskell-cafe] Adopting hpodder?

2010-01-25 Thread John Goerzen
Hi folks,

I wrote hpodder a little while back.  I no longer listen to podcasts at
all (blame my Kindle for that).  Is anyone here interested in adopting
it and giving it some needed care?

Thanks,

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


Re: [Haskell-cafe] HList darcs repo missing?

2010-01-25 Thread Gwern Branwen
On Mon, Jan 25, 2010 at 3:47 PM, Jake Wheat
jakewheatm...@googlemail.com wrote:
 Hello all,

 I was looking for the HList darcs repo at:

 http://darcs.haskell.org/HList/

 but it seems to be missing. Has it been moved somewhere else?

 Thanks,
 Jake Wheat

It was there as of 15 September 2009 when I sent Oleg my last patch.
Maybe some of the server changes since messed around with it?

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


[Haskell-cafe] ANN: ftdi-0.1

2010-01-25 Thread Roel van Dijk
Hello,

I just released a very early version of my 'ftdi' library [1]. It
is a small layer on top of the usb package [2] that enables you
to communicate with FTDI [3] devices.

Its design is based on the C-library libftdi [4], but it
implemented completely in Haskell. Most functionality is
untested. I only have access to an FT2232C chip, so testing other
chips is not possible at the moment. Furthermore, the only thing
I do with that chip is perform bulk reads and the
occasional small (1 byte) bulk write. The good news is that it is
quite good a bulk reads. It outperformed both libftdi-0.16 and
the official driver [5] by about 40% for my use case. Although to
be fair, both C libraries used the old libusb-0.1 library. This
library is ultimately linked with libusb-1.0.* which is a complete
rewrite.


To play with the library either
  cabal install ftdi
or
  darcs get http://code.haskell.org/~roelvandijk/code/ftdi


Regards,
Roel van Dijk


1 - http://hackage.haskell.org/package/ftdi
2 - http://ftdichip.com/
3 - http://hackage.haskell.org/package/usb
4 - http://www.intra2net.com/en/developer/libftdi/
5 - http://www.ftdichip.com/Drivers/D2XX.htm
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HList darcs repo missing?

2010-01-25 Thread Ross Paterson
On Mon, Jan 25, 2010 at 05:27:57PM -0500, Gwern Branwen wrote:
 It was there as of 15 September 2009 when I sent Oleg my last patch.
 Maybe some of the server changes since messed around with it?

Most things that could be moved to community.haskell.org weren't moved
across to the new machine:

http://www.haskell.org/pipermail/haskell/2010-January/021861.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HList darcs repo missing?

2010-01-25 Thread Jake Wheat
2010/1/25 Ross Paterson r...@soi.city.ac.uk:
 Most things that could be moved to community.haskell.org weren't moved
 across to the new machine:

 http://www.haskell.org/pipermail/haskell/2010-January/021861.html

Thanks, I found what seems to be the latest version here (last update
14th Jan 2010):

http://old-darcs.well-typed.com/HList/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Codensity improvement of free monads

2010-01-25 Thread Luke Palmer
Hello haskell-cafe,

I have just read Asymptotic Improvement of Computations over Free
Monads by Janis Voigtlander, since I have been working with free
monads a lot recently and don't want to get hit by their quadratic
performance when I start to care about that.

But after reading the paper, I still don't really understand how
improve actually improves anything.  Can anyone provide a good
explanation for where the work is saved?

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


Re: [Haskell-cafe] Codensity improvement of free monads

2010-01-25 Thread Edward Kmett
On Mon, Jan 25, 2010 at 7:37 PM, Luke Palmer lrpal...@gmail.com wrote:

 Hello haskell-cafe,

 I have just read Asymptotic Improvement of Computations over Free
 Monads by Janis Voigtlander, since I have been working with free
 monads a lot recently and don't want to get hit by their quadratic
 performance when I start to care about that.

 But after reading the paper, I still don't really understand how
 improve actually improves anything.  Can anyone provide a good
 explanation for where the work is saved?


With a free monad, the structure keeps growing via substitution. This
requires you on each bind to re-traverse the common root of the free monad,
which isn't changing in each successive version.

Lets say the size of this accumulated detritus increases by one each time.
Then you will be traversing over 1, 2, 3, 4, ... items to get to the values
that you are substituting as you keep binding your free monadic computation.
The area near the root of your structure keeps getting walked over and over,
but there isn't any work do to there, the only thing bind can do is
substitution, and all the substitution is down by the leaves.

On the other hand, when you have CPS transformed it, at each layer you only
have to climb over the 1 item you just added to get to where you apply the
next computation.

This only gets better when you are dealing with free monads that provide
multiple points for extension: i.e. that grow in a treelike fashion like:

data Bin a = Bin a a
data Free f a = Return a | Free (f (Free f a))
data Codensity f a = Codensity (forall r. (a - f r) - f r)

If you build the free monad Free Bin, then you will wind up having to walk
all the way down to the leaves on each bind, well, modulo demand, that is.
But since it is a free monad, the 'body' of the tree will never change. Just
the data you are substituting at the leaves. Codensity (Free Bin) lets you
only generate the body of the tree once, while your substitutions just get
pushed down to the leaves in one pass.

An interesting exercise is to work out why Codensity can change the
asymptotics of certain operations over Free Bin, but Density doesn't change
the asymptotics of anything non-trivial over Cofree Bin for the better.

-Edward Kmett

Luke
 ___
 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


[Haskell-cafe] ANN: The Monad.Reader Issue 15

2010-01-25 Thread Brent Yorgey
I am very pleased to announce that Issue 15 of The Monad.Reader is now
available for your reading pleasure [1].

Issue 15 consists of the following four articles:

* The hp2any project by Gergely Patai
* Adventures in Three Monads by Edward Z. Yang
* The Operational Monad Tutorial by Heinrich Apfelmus
* Implementing STM in pure Haskell by Andrew Coppin

Feel free to browse the source files. You can check out the entire
repository using darcs:

  darcs get http://code.haskell.org/~byorgey/TMR/Issue15


If you'd like to write something for Issue 16, please get in
touch. The deadline will likely be sometime in mid-late April; more
details will be forthcoming.

-Brent

[1] http://themonadreader.files.wordpress.com/2010/01/issue15.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text?

2010-01-25 Thread Jeremy Shaw
On Sun, Jan 24, 2010 at 5:49 AM, Neil Mitchell ndmitch...@gmail.com wrote:

 Hi,

 The problem with Data for Text isn't that we have to write a new
 instance, but that you could argue that proper handling of Text with
 Data would not be using a type class, but have special knowledge baked
 in to Data. That's far worse than the Serialise problem mentioned
 above, and no one other than the Data authors could solve it. Of
 course, I don't believe that, but it is a possible interpretation.


Right.. that is the problem with Text. Do you think the correct thing to do
for gunfold and toConstr is to convert the Text to a String and then call
the gufold and toConstr for String? Or something else?


 The Serialise problem is a serious one. I can't think of any good
 solutions, but I recommend you give knowledge of your serialise class
 to Derive (http://community.haskell.org/~ndm/derive/) and then at
 least the instances can be auto-generated. Writing lots of boilerplate
 and regularly ripping it up is annoying, setting up something to
 generate it for you reduces the pain.


We currently use template haskell to generate the Serialize instances in
most cases (though some data types have more optimized encodings that were
written by hand). However, you must supply the Version and Migration
instances by hand (they are super classes of Serialize).

I am all for splitting the Serialize stuff out of happstack .. it is not
really happstack specific. Though I suspect pulling it out is not entirely
trivial either. I think the existing code depends on syb-with-class.

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


[Haskell-cafe] imaging textbooks?

2010-01-25 Thread Dan Mead
Hey all

Can anyone recommend a good textbook on computer vision or image processing?

I don't care if it favors Haskell or not, I'm just trying to find a good text.

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


Re: [Haskell-cafe] imaging textbooks?

2010-01-25 Thread Keith Sheppard
I have just started reading this so I don't know how good it is yet
but the draft is freely available:

http://research.microsoft.com/en-us/um/people/szeliski/Book/

Best
Keith

2010/1/25 Dan Mead d.w.m...@gmail.com:
 Hey all

 Can anyone recommend a good textbook on computer vision or image processing?

 I don't care if it favors Haskell or not, I'm just trying to find a good text.

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




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


[Haskell-cafe] scheduling an alarm

2010-01-25 Thread Brian Denheyer
I cobbled the following together from bits and pieces I found on
mailing lists.  Seems straightforward, but the code I've included
just sits there.

The awaitSignal seems to be causing a problem, in that if I remove it
(and don't call forever recursively) then I get my ALARM 5 sec later.

Otherwise nothing.  The problem is that if I don't include awaitSignal,
then, of course, forever is called just as fast as the CPU will go :-)

Brian


import System.Posix.Signals
import System.IO
import Control.Concurrent

alarm =
do putStrLn ALARM
   hFlush stdout
   return ()

forever =
do putStrLn foo
   scheduleAlarm 5
   awaitSignal Nothing
   yield
   forever

main =
do installHandler realTimeAlarm (Catch alarm) Nothing 
   forever

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


Re: [Haskell-cafe] imaging textbooks?

2010-01-25 Thread Thomas DuBuisson
Handbook of Computer Vision Algorithms in Image Algebra
I started to read it felt it was a solid text but just don't have the time.

Thomas

http://www.amazon.com/Handbook-Computer-Vision-Algorithms-Algebra/dp/0849300754/ref=sr_1_1?ie=UTF8s=booksqid=1264487502sr=8-1

2010/1/25 Keith Sheppard keiths...@gmail.com:
 I have just started reading this so I don't know how good it is yet
 but the draft is freely available:

 http://research.microsoft.com/en-us/um/people/szeliski/Book/

 Best
 Keith

 2010/1/25 Dan Mead d.w.m...@gmail.com:
 Hey all

 Can anyone recommend a good textbook on computer vision or image processing?

 I don't care if it favors Haskell or not, I'm just trying to find a good 
 text.

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




 --
 keithsheppard.name
 ___
 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] scheduling an alarm

2010-01-25 Thread Thomas DuBuisson
1) Don't use System.Posix.Signals
It isn't necessary and makes your code less portable

2) The POSIX SIGALRM is used/caught by the RTS and that is why you are
seeing strange behavior.

3) Consider using Haskell exceptions from Control.Concurrent (throwTo).
Not sure what you want to do but you can always myThreadId = \tid -
forkIO $ threadDelay someDelayTime  (throwTo tid someExceptionVal)

Thomas

On Mon, Jan 25, 2010 at 10:25 PM, Brian Denheyer bri...@aracnet.com wrote:

 I cobbled the following together from bits and pieces I found on
 mailing lists.  Seems straightforward, but the code I've included
 just sits there.

 The awaitSignal seems to be causing a problem, in that if I remove it
 (and don't call forever recursively) then I get my ALARM 5 sec later.

 Otherwise nothing.  The problem is that if I don't include awaitSignal,
 then, of course, forever is called just as fast as the CPU will go :-)

 Brian


 import System.Posix.Signals
 import System.IO
 import Control.Concurrent

 alarm =
do putStrLn ALARM
   hFlush stdout
   return ()

 forever =
do putStrLn foo
   scheduleAlarm 5
   awaitSignal Nothing
   yield
   forever

 main =
do installHandler realTimeAlarm (Catch alarm) Nothing
   forever

 ___
 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] Re: could we get a Data instance for Data.Text.Text?

2010-01-25 Thread José Pedro Magalhães
Hi Jeremy,

As Neil Mitchell said before, if you really don't want to expose the
internals of Text (by just using a derived instance) then you have no other
alternative than to use String conversion. If you've been using it already
and performance is not a big problem, then I guess it's ok.

Regarding the Serialize issue, maybe I am not understanding the problem
correctly: isn't that just another generic function? There are generic
implementations of binary get and put for at least two generic programming
libraries in Hackage [1, 2], and writing one for SYB shouldn't be hard
either, I think. Then you could have a trivial way of generating instances
of Serialize, namely something like

 instance Serialize MyType where
   getCopy = gget
   putCopy = gput


and you could provide Template Haskell code for generating these. Or even
just do

 instance (Data a) = Serialize a where ...


if you are willing to use OverlappingInstances and UndecidableInstances...


Cheers,
Pedro

[1]
http://hackage.haskell.org/packages/archive/regular-extras/0.1.2/doc/html/Generics-Regular-Functions-Binary.html
[2]
http://hackage.haskell.org/packages/archive/multirec-binary/0.0.1/doc/html/Generics-MultiRec-Binary.html

On Tue, Jan 26, 2010 at 03:16, Jeremy Shaw jer...@n-heptane.com wrote:

 On Sun, Jan 24, 2010 at 5:49 AM, Neil Mitchell ndmitch...@gmail.comwrote:

 Hi,

 The problem with Data for Text isn't that we have to write a new
 instance, but that you could argue that proper handling of Text with
 Data would not be using a type class, but have special knowledge baked
 in to Data. That's far worse than the Serialise problem mentioned
 above, and no one other than the Data authors could solve it. Of
 course, I don't believe that, but it is a possible interpretation.


 Right.. that is the problem with Text. Do you think the correct thing to do
 for gunfold and toConstr is to convert the Text to a String and then call
 the gufold and toConstr for String? Or something else?


 The Serialise problem is a serious one. I can't think of any good
 solutions, but I recommend you give knowledge of your serialise class
 to Derive 
 (http://community.haskell.org/~ndm/derive/http://community.haskell.org/%7Endm/derive/)
 and then at
 least the instances can be auto-generated. Writing lots of boilerplate
 and regularly ripping it up is annoying, setting up something to
 generate it for you reduces the pain.


 We currently use template haskell to generate the Serialize instances in
 most cases (though some data types have more optimized encodings that were
 written by hand). However, you must supply the Version and Migration
 instances by hand (they are super classes of Serialize).

 I am all for splitting the Serialize stuff out of happstack .. it is not
 really happstack specific. Though I suspect pulling it out is not entirely
 trivial either. I think the existing code depends on syb-with-class.

 - jeremy

 ___
 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


[Haskell-cafe] list mail

2010-01-25 Thread 田 其雨

 
Sorry, for some reasons, I had to change my E-mail, so please don't send the 
list mail anymore, and I will get it with a new mail.
 
Best wishes.
  
_
Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe