Re: [Haskell-cafe] Re: [Haskell] Mailing List Archive: Search Broken?

2008-02-15 Thread Janis Voigtlaender

apfelmus wrote:

Janis Voigtlaender wrote:

when searching through gmane, and selecting a single message with a 
hit, one gets only to see that message without its context thread. At 
least I could not find out a way to switch from the found message to 
the thread in which it occurred.



The subject line is a hyperlink that points to the context thread of the 
message (which is displayed with frames).


... only in the case of haskell.cafe, but not for haskell.general. (see 
my response to Calvin Smith on the cafe list)


Actually, in the case of haskell.general, it seems to work if and only 
if the current message is the first one in a thread.


Ciao, Janis.

--
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:[EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] set terminology

2008-02-15 Thread PR Stanley

Hi
domain, source --- are the two different things? I'm sure I read 
somewhere that the source \subseteq domain in mappings. The same was 
said about range and target -- target \subseteq range.

Any ideas?
Thanks, Paul

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


[Haskell-cafe] Re: [Haskell] Mailing List Archive: Search Broken?

2008-02-15 Thread apfelmus

Janis Voigtlaender wrote:

apfelmus wrote:
The subject line is a hyperlink that points to the context thread of 
the message (which is displayed with frames).


 only in the case of haskell.cafe, but not for haskell.general. (see 
my response to Calvin Smith on the cafe list)


Actually, in the case of haskell.general, it seems to work if and only 
if the current message is the first one in a thread.


Oh! That used to work in haskell.general, too. Hm, it does seem to work 
for messages after August 2007. Looks like the search homunculus is on 
strike...



Regards,
apfelmus

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


Re: [Haskell-cafe] Mutable arrays

2008-02-15 Thread Andrew Butterfield

Stefan O'Rear wrote:

On Wed, Feb 06, 2008 at 08:57:43PM +, Andrew Butterfield wrote:
  

In Clean, we not only have explicit access to the world, but
we can partition it. Simplifying somewhat, we could open up
pairs of file-handle (f1.in,f1.out), (f2.in,f2,out) ... (fn.in,fn.out),
which does have to be done sequentially, since each file opening modifies 
the (global) filesystem. However, once this is done,

we could, in principle, execute the fn in any order,
and indeed in such a way that the implementation could choose to
do them in parallel - this potential for (admittedly limited)
deterministic parallel execution of I/O actions is possible with
uniqueness types, but not epxressible in the monadic world as
currently formulated.



What if f1.out is a symlink to f2.out?  I don't think Clean satisfies
the evaluation order independance that is so treasured here.
  

Sorry for lateness in getting back - it's been one of those fortnights..

The case you mention won't arise simply because during the process
of opening these file-handles (which cannot be done in parallel, because 
they all
modify the filesystem), the write conflict will be detected, and the 
opening of the

second one will fail.

Once the file-handle pairs are all opened we have a guarantee that all
writes are to distinct files.


--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
Course Director, B.A. (Mod.) in CS and ICT degrees, Year 4.
Department of Computer Science, Room F.13, O'Reilly Institute,
Trinity College, University of Dublin, Ireland.
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


[Haskell-cafe] *** JOB OFFER *** related to realtime 3D graphics, animation and reactive content

2008-02-15 Thread Peter Verswyvelen
 http://www.anygma.com/ Anygma is a startup company focusing on generating
easy-to-use tools for creating audio-visual 2D/3D content, in the area of
entertainment, media, corporate communication and the internet. 

 http://www.anygma.com/ Anygma has recently raised new capital in order to
fund the development of a new platform targeted towards artists and
designers for generating procedural and reactive geometry, animations and
games.

We are looking for talented and passionate computer scientists and software
engineers to help us design and implement a prototype of this platform.

If you are interested in applying Haskell, OpenGL, and some C/C++, to create
such a platform, feel free to apply for the job by sending an email to
mailto://peter%3CAT%3Enazooka%3CDOT%3Ecom peter AT nazooka DOT com.

More information about the job offer can be found
http://www.anygma.com/JobOfferA.html here.

Thank you,
Peter Verswyvelen,
Software Architect,
www.anygma.com http://www.anygma.com/ 

 

PS: This job offer was already placed in the Haskell Café a while ago, but
apparently many Haskellers did not notice it, so here’s take#2

 

 

 

 

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


Re: [Haskell-cafe] ANN: two new packages: carray, fft

2008-02-15 Thread Jed Brown
On 15 Feb 2008, [EMAIL PROTECTED] wrote:

On Thu, 14 Feb 2008, Jed Brown wrote:

 Hopefully these are mature enough to be generally useful.  I would
 appreciate any comments regarding the interface.  The FFTW API is not
 particularly nice for building a pure interface on.

 because FFTW stores global data (called 'plan's)

Yes.  In the Haskell interface, the existence of these plans is hidden
From the user.  In the advanced interface, you can influence the quality
of the plan which may effect how long a transform takes to compute, but
it will not effect the result.  If FFTW added the ability to query the
plan cache, or if we kept a mirror Haskell-side, then we could make
better use of memory which would improve performance.  Fortunately, we
have a really fast malloc.

 Some of the transforms could be made slightly faster at the expense of
 a much nastier interface, but unless someone needs the extra few
 percent, or is pushing the memory limits on their machine, I'm not
 inclined to expose the underlying nastiness.

 I want to mention once again that there is already a Fast Fourier
 transform for arbitrary length that is coded entirely in Haskell.
 http://hackage.haskell.org/packages/archive/dsp/0.2/doc/html/Numeric-Transform-Fourier-FFT.html

Indeed, this package does exist, but it is lacking compared to FFTW with
regard to multi-dimensional transforms, real to real transforms, and
performance (particularly for large sizes).

The transforms in the dsp package are only a few times slower than FFTW
for small sizes, but it quickly becomes orders of magnitude slower,
especially when the size is not a power of two.  It also uses several
times more memory, due in part to always using boxed arrays.  Modifying
dsp to allow use of unboxed arrays would be nice.

Jed


pgpnaE0VrMOn7.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] fast integer base-2 log function?

2008-02-15 Thread Uwe Hollerbach
Yes, I suspect you are right. I didn't look into that in much detail,
although I did try exchanging (2 ^ 5000) with (1 `shiftL` 5000);
but that didn't make any difference.

Uwe

On Fri, Feb 15, 2008 at 9:21 AM, Ryan Ingram [EMAIL PROTECTED] wrote:

 On Thu, Feb 14, 2008 at 8:23 PM, Uwe Hollerbach [EMAIL PROTECTED]
 wrote:
   Stefan's routine is, as expected, much much faster still: I tested the
   first two routines on numbers with 5 million or so bits and they took
   ~20 seconds of CPU time, whereas I tested Stefan's routine with
   numbers with 50 million bits, and it took ~11 seconds of CPU time.

 This seems wrong to me; that routine should take a small constant
 amount of time.  I suspect you are measuring the time to construct the
 50-million bit numbers as well.  If you constructed a single number
 and called this routine on it several times I am sure you would get
 far different results, with the first routines taking ~7-11s each and
 Stefan's GHC/GMP-magic taking almost nothing.

  -- ryan

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


Re: [Haskell-cafe] fast integer base-2 log function?

2008-02-15 Thread Ryan Ingram
On Thu, Feb 14, 2008 at 8:23 PM, Uwe Hollerbach [EMAIL PROTECTED] wrote:
  Stefan's routine is, as expected, much much faster still: I tested the
  first two routines on numbers with 5 million or so bits and they took
  ~20 seconds of CPU time, whereas I tested Stefan's routine with
  numbers with 50 million bits, and it took ~11 seconds of CPU time.

This seems wrong to me; that routine should take a small constant
amount of time.  I suspect you are measuring the time to construct the
50-million bit numbers as well.  If you constructed a single number
and called this routine on it several times I am sure you would get
far different results, with the first routines taking ~7-11s each and
Stefan's GHC/GMP-magic taking almost nothing.

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


Re: [Haskell-cafe] set terminology

2008-02-15 Thread Dan Weston
Since no one else has replied, I will take a stab. This is the 
terminology I have seen/heard:


A mapping in a category is typed. It can map only from a source object 
to a target object. There may be zero, one, or multiple such mappings 
(functions) from a given source to a given target (but at least one if 
source and target are the same, namely the identity map).


For a particular source and target, where the source and target happen 
not just to be opaque objects but have internal structure (with subset 
operations), mappings are called functions, the source is called the 
domain, and the target is called the codomain.


Elements X in the domain are mapped to some element Y in the codomain. 
The set of all such Y is the range, and the set of all such X is the 
corange. (Wikipedia [1] suggests that there is ambiguity with the word 
domain, but I have never heard that elsewhere).


Any given subset S of the corange (called a preimage) maps to the 
corresponding image of S, which is a subset of the range. Preimage and 
image apply to singleton sets as well, so (by trivial isomorphism) these 
words apply to mapped elements themselves. In this case, the usual arrow 
symbol gets a little vertical cap on the left end.


In any case, I would not get too hung up on the terminology. It is much 
more important to understand what is meant in any given setting.


[1] http://en.wikipedia.org/wiki/Function_%28mathematics%29

Dan

PR Stanley wrote:

Hi
domain, source --- are the two different things? I'm sure I read 
somewhere that the source \subseteq domain in mappings. The same was 
said about range and target -- target \subseteq range.

Any ideas?
Thanks, Paul

___
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] Designing DSL with explicit sharing [was: I love purity, but it's killing me]

2008-02-15 Thread Tony Finch
On Thu, 14 Feb 2008, [EMAIL PROTECTED] wrote:

 As I understand the original problem had less to do with the number of
 comparison but more to do with the cost of a single comparison. In an
 impure language, we can use constant-time physical equality. It is
 usually provided natively as pointer comparison, and can be trivially
 emulated via mutation.

In Haskell you can (with care) use System.Mem.StableName.
http://research.microsoft.com/~simonpj/Papers/weak.htm

Tony.
-- 
f.a.n.finch  [EMAIL PROTECTED]  http://dotat.at/
VIKING NORTH UTSIRE: SOUTHERLY 5 OR 6, OCCASIONALLY 7 LATER IN NORTH. MODERATE
OR ROUGH. FAIR. GOOD.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: two new packages: carray, fft

2008-02-15 Thread Jed Brown
On 15 Feb 2008, [EMAIL PROTECTED] wrote:

 On Fri, 15 Feb 2008, Jed Brown wrote:
 
  On 15 Feb 2008, [EMAIL PROTECTED] wrote:
 
  On Thu, 14 Feb 2008, Jed Brown wrote:
 
   Hopefully these are mature enough to be generally useful.  I would
   appreciate any comments regarding the interface.  The FFTW API is not
   particularly nice for building a pure interface on.
  
   because FFTW stores global data (called 'plan's)
 
  Yes.  In the Haskell interface, the existence of these plans is hidden
  From the user.
 
 With locks for threaded use?

In FFTW, planning is not thread-safe, but execution of plans is.  The
Haskell library takes a lock during planning, but releases it before
execution.  Planning can be time-consuming if you want a high quality
plan, and unfortunately this phase is single threaded.  It would be nice
if FFTW would expose slightly more of its internal interface, or take
its own lock when modifying it's cache so that planning would be
thread-safe.  Once a plan for your transform size is created (or
imported through the wisdom interface) the call to the planner will
return immediately and everything else can run in parallel.

In the Haskell interface, the default planner is 'estimate' which just
employs heuristics rather than actually computing some transforms.  If
you have imported the correct wisdom, this will still do an optimized
transform.  If not, it will be less than optimal, but there will be no
time-consuming planning phase.  If you are concerned about getting the
absolute best performance, you can use the advanced interface (which
still hides locking, memory allocation, and internals of
multi-dimensional transforms) for more control over planning.

Jed


pgp6d1Tx1XsiD.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Designing DSL with explicit sharing [was: I love purity, but it's killing me]

2008-02-15 Thread Jan-Willem Maessen


On Feb 15, 2008, at 1:15 PM, Tony Finch wrote:


On Thu, 14 Feb 2008, [EMAIL PROTECTED] wrote:


As I understand the original problem had less to do with the number  
of

comparison but more to do with the cost of a single comparison. In an
impure language, we can use constant-time physical equality. It is
usually provided natively as pointer comparison, and can be trivially
emulated via mutation.


In Haskell you can (with care) use System.Mem.StableName.
http://research.microsoft.com/~simonpj/Papers/weak.htm


Extra points to anyone who can demonstrate this actually in use for  
caching.


-Jan-Willem Maessen

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


Re: [Haskell-cafe] ANN: two new packages: carray, fft

2008-02-15 Thread Henning Thielemann

On Fri, 15 Feb 2008, Jed Brown wrote:

 On 15 Feb 2008, [EMAIL PROTECTED] wrote:

 On Thu, 14 Feb 2008, Jed Brown wrote:

  Hopefully these are mature enough to be generally useful.  I would
  appreciate any comments regarding the interface.  The FFTW API is not
  particularly nice for building a pure interface on.
 
  because FFTW stores global data (called 'plan's)

 Yes.  In the Haskell interface, the existence of these plans is hidden
 From the user.

With locks for threaded use?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] set terminology

2008-02-15 Thread Dan Weston
To clarify the distinction between domain/corange as I understand common 
usage:


For a total function, the domain and corange are equal. In the category 
of sets, all functions are total (by definition of a function). If we 
generalize to the category of CPOs by associating with every set an 
extra value called bottom (as well as appropriate sums and products 
containing bottom), and by expanding the concept of function to make use 
of these bottoms for otherwise undefined mappings, then the domain 
refers to the thing with the bottoms in it and the corange refers to the 
largest set (i.e. no bottoms) in the domain whose image contains no 
bottoms in it. So the corange may not be equal to the domain.


So, domain and codomain in Haskell are types (i.e. that include bottom). 
Range, corange, preimage, and image are only sets that don't include a 
bottom.


Also, a minor correction (after consulting Wikipedia [1]): For any given 
subset of the range (called an image), there may be multiple subsets of 
the corange that have this image (the corresponding inverse image). The 
preimage (or complete inverse image) is the exactly one largest such 
subset of the corange to have the given image.


[1] http://en.wikipedia.org/wiki/Function_%28mathematics%29

Dan

Dan Weston wrote:
Since no one else has replied, I will take a stab. This is the 
terminology I have seen/heard:


A mapping in a category is typed. It can map only from a source object 
to a target object. There may be zero, one, or multiple such mappings 
(functions) from a given source to a given target (but at least one if 
source and target are the same, namely the identity map).


For a particular source and target, where the source and target happen 
not just to be opaque objects but have internal structure (with subset 
operations), mappings are called functions, the source is called the 
domain, and the target is called the codomain.


Elements X in the domain are mapped to some element Y in the codomain. 
The set of all such Y is the range, and the set of all such X is the 
corange. (Wikipedia [1] suggests that there is ambiguity with the word 
domain, but I have never heard that elsewhere).


Any given subset S of the corange (called a preimage) maps to the 
corresponding image of S, which is a subset of the range. Preimage and 
image apply to singleton sets as well, so (by trivial isomorphism) these 
words apply to mapped elements themselves. In this case, the usual arrow 
symbol gets a little vertical cap on the left end.


In any case, I would not get too hung up on the terminology. It is much 
more important to understand what is meant in any given setting.


[1] http://en.wikipedia.org/wiki/Function_%28mathematics%29

Dan

PR Stanley wrote:

Hi
domain, source --- are the two different things? I'm sure I read 
somewhere that the source \subseteq domain in mappings. The same was 
said about range and target -- target \subseteq range.

Any ideas?
Thanks, Paul

___
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] Re: [Haskell] Lemmas about type functions

2008-02-15 Thread Ryan Ingram
[moved to haskell-cafe]

Hmm, there's a problem here.  Since type functions are open, it's not
actually true that (forall ts. Cat ts () = ts), because someone could
add, for example

type instance Cat [a] () = [(a,a)]

which makes the lemma no longer true.

What you are doing in cat_nil is not proving that Cat ts () = ts, but
rather that the form of ts is a particular form which makes that
theorem hold, in particular, for all types ts of the form

ts = (t1, (t2, ..., (tN, ()) ... ))
Cat ts () = ts

So for your lemma to hold, you need a new judgement Valid ts:

class Valid ts where
cat_nil :: Equiv (Cat ts ()) ts
-- other lemmas here

instance Valid () where
cat_nil = Equiv

instance Valid x = Valid (a, x) where
cat_nil = case (cat_nil :: Equiv (Cat x ()) x) of Equiv - Equiv

coerce :: forall f ts. Valid ts = f (Cat ts ()) - f ts
coerce x = case (cat_nil :: Equiv (Cat ts ()) ts) of Equiv - x

Also, I'm not sure if GHC can currently optimize away cat_nil; it's
clear by construction that cat_nil is total, but if the compiler can't
detect that it needs to run and make sure it returns Equiv and not
_|_.  Otherwise you get an unsound result:

(given the type instance above)
instance Valid [a] where cat_nil = cat_nil

Oleg has pointed out this problem with GADTs as type witnesses here:
http://okmij.org/ftp/Haskell/GADT-problem.hs

  -- ryan


On 2/15/08, Ryan Ingram [EMAIL PROTECTED] wrote:
 I am pretty sure that this doesn't exist, but it's quite interesting.
 I've submitted a feature request here:

 http://hackage.haskell.org/trac/ghc/ticket/2101

 On 2/15/08, Louis-Julien Guillemette [EMAIL PROTECTED] wrote:
  Hi all,
 
  I've been using GHC's type families somewhat extensively in my
  type-preserving compiler (BTW, they work great), and quite often I
  come across the need to prove lemmas about those functions.  As far as
  I understand there's currently no way to handle such lemmas purely at
  the type level, and I have to encode them as term-level functions.
 
  I wonder if I'm missing something, or otherwise if there are plans to
  provide some way to do this kind of type-level reasoning.
 
  Here's a simple example.
 
  I encode (de Bruijn) type contexts as lists of types of this form:
 
(t0, (t1, (... , ()...)))
 
  I sometimes concatenate type contexts, and need a lemma stating that
  appending an empty context leaves it unchanged (ts ++ [] == ts).
 
type family Cat ts0 ts
type instance Cat ()  ts' = ts'
type instance Cat (s, ts) ts' = (s, Cat ts ts')
 
  That is, I need to coerce:
 
Exp (Cat ts ())
 
  into:
 
Exp ts
 
  The way I presently do it is through a term-level function that
  produces a witness that the two types are equivalent, like this:
 
  data Equiv s t where
   Equiv :: (s ~ t) = Equiv s t
 
  cat_nil :: EnvRep ts - Equiv (Cat ts ()) ts
  cat_nil R0 = Equiv
  cat_nil (Rs _ ts_r) = case cat_nil ts_r of Equiv - Equiv
 
  coerce :: EnvRep ts - Exp (Cat ts ()) - Exp ts
  coerce ts_r e = case cat_nil ts_r of Equiv - e
 
 
  Louis
 
  ___
  Haskell mailing list
  [EMAIL PROTECTED]
  http://www.haskell.org/mailman/listinfo/haskell
 

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


Re: [Haskell-cafe] *** JOB OFFER *** related to realtime 3D graphics, animation and reactive content

2008-02-15 Thread Joshua Ball
How unfortunate that I didn't see your announcement before, as I have
just accepted a job with another company.

However, I have added your company to the Haskell in Industry page on
the Haskell wiki.

http://haskell.org/haskellwiki/Haskell_in_industry

Please add a paragraph describing your company.

I have also added this announcement to the Haskell jobs page

http://haskell.org/haskellwiki/Jobs

which is the #1 Google result for a search of haskell jobs.

2008/2/15 Peter Verswyvelen [EMAIL PROTECTED]:




 Anygma is a startup company focusing on generating easy-to-use tools for
 creating audio-visual 2D/3D content, in the area of entertainment, media,
 corporate communication and the internet.

  Anygma has recently raised new capital in order to fund the development of
 a new platform targeted towards artists and designers for generating
 procedural and reactive geometry, animations and games.

  We are looking for talented and passionate computer scientists and software
 engineers to help us design and implement a prototype of this platform.

  If you are interested in applying Haskell, OpenGL, and some C/C++, to
 create such a platform, feel free to apply for the job by sending an email
 to peter AT nazooka DOT com.

  More information about the job offer can be found here.

  Thank you,
  Peter Verswyvelen,
  Software Architect,
  www.anygma.com



 PS: This job offer was already placed in the Haskell Café a while ago, but
 apparently many Haskellers did not notice it, so here's take#2








 ___
 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] Help with error

2008-02-15 Thread Jeff φ
Hello,

I get an error message on the code below with GHC.  I can't figure out how
to get rid of the error.  I'd appreciate suggestions on how to fix this.
(BTW, the code may look overly combersome because I stripped out anything
unnecessary to demonstrate the error.)

{-# OPTIONS_GHC
-fglasgow-exts
-fbreak-on-exception
-fallow-undecidable-instances
#-}

import qualified Prelude
import Prelude
import Data.Array.IArray

class Sequence seq where
slength :: (seq e) - Int
snull :: (seq e) - Bool
shead :: (seq e) - e
stail :: (seq e) - (seq e)

instance Sequence [] where
slength = length
snull = null
shead = head
stail = tail

class From_seq t where
from_seq :: (Sequence seq) = (seq e) - (t e)

instance From_seq [] where
from_seq seq
| snull seq  = []
| otherwise = (shead seq) : (from_seq (stail seq))

from_seq' seq
| snull seq = (listArray (0,-1) [])
| otherwise = listArray (0,fromIntegral (slength seq) -1) (from_seq seq)

{-
When I uncomment this out, I get the error messages:

Error.hs:41:19:
Could not deduce (IArray a e)
  from the context (From_seq (a i),
Ix i,
Num i,
IArray a e1,
Sequence seq)
  arising from a use of `from_seq'' at Error.hs:41:19-31


instance (Ix i, Num i, IArray a e) = From_seq (a i) where
from_seq seq = from_seq' seq
-}


When I load the module above, I can evaluate the folloing in GHCI

*Main from_seq' [0..5] :: Array Int Double
array (0,5) [(0,0.0),(1,1.0),(2,2.0),(3,3.0),(4,4.0),(5,5.0)]

But, I'd like to do this with the From_seq class.  If anyone has
suggestions, I'd be grateful.

Thanks,

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


Re: [Haskell-cafe] Help with error

2008-02-15 Thread Antoine Latter
(sent to the list this time)

The problem is in the type-signature for from_seq:

from_seq :: (Sequence seq) = (seq e) - (t e)

Neither the From_seq class or the type signature of the from_seq
function place any restrictions on the type of e, so the type can be
rewritten as:

from_seq :: forall e seq . Sequence seq = (seq e) - (t e)

That is, the class explicitly defines from_seq has having norestrictions on e.

Your from_seq' function requires the type e (in the error, e1) to
inhabit IArray a e.

The IArray constraint isn't compatible with the From_seq class
definition.  You may need to explore multi-parameter type classes:
http://en.wikibooks.org/wiki/Haskell/Advanced_type_classes

Does this help?

-Antoine

2008/2/15 Jeff φ [EMAIL PROTECTED]:
 Hello,

 I get an error message on the code below with GHC.  I can't figure out how
 to get rid of the error.  I'd appreciate suggestions on how to fix this.
 (BTW, the code may look overly combersome because I stripped out anything
 unnecessary to demonstrate the error.)

 {-# OPTIONS_GHC
 -fglasgow-exts
  -fbreak-on-exception
 -fallow-undecidable-instances
  #-}

 import qualified Prelude
  import Prelude
 import Data.Array.IArray

 class Sequence seq where
 slength :: (seq e) - Int
  snull :: (seq e) - Bool
 shead :: (seq e) - e
  stail :: (seq e) - (seq e)

 instance Sequence [] where
  slength = length
 snull = null
  shead = head
 stail = tail

 class From_seq t where
 from_seq :: (Sequence seq) = (seq e) - (t e)

 instance From_seq [] where
 from_seq seq
  | snull seq  = []
 | otherwise = (shead seq) : (from_seq (stail seq))

 from_seq' seq
 | snull seq = (listArray (0,-1) [])
  | otherwise = listArray (0,fromIntegral (slength seq) -1) (from_seq
 seq)

  {-
 When I uncomment this out, I get the error messages:

 Error.hs:41:19:
 Could not deduce (IArray a e)
from the context (From_seq (a i),
 Ix i,
  Num i,
 IArray a e1,
  Sequence seq)
   arising from a use of `from_seq'' at Error.hs:41:19-31


 instance (Ix i, Num i, IArray a e) = From_seq (a i) where
  from_seq seq = from_seq' seq
 -}


 When I load the module above, I can evaluate the folloing in GHCI

 *Main from_seq' [0..5] :: Array Int Double
  array (0,5) [(0,0.0),(1,1.0),(2,2.0),(3,3.0),(4,4.0),(5,5.0)]

 But, I'd like to do this with the From_seq class.  If anyone has
 suggestions, I'd be grateful.

 Thanks,

 Jeff

 ___
 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