Re: [Haskell-cafe] Re: AT solution: rebinding = for restricted monads

2007-02-27 Thread Pepe Iborra


Did anyone with knowledge of Associated Types pursue this solution?


Where did you get this from.  My haskell-cafe mail folder doesn't seem
to have the thread you are replying to.



Sorry I replied from gmane; I should have included a link to the  
original thread, but I really expected gmane to do that. The thread  
is at:


http://www.haskell.org/pipermail/haskell-cafe/2006-December/020615.html


It doesn't work with GHC head, and I can't really do anything  
about that.

Mostly curiosity.


The main reason this doesn't work with the head is because the
implementation of associated type *synonyms* (as opposed to associated
data types) is still incomplete.  (See also
http://haskell.org/haskellwiki/GHC/Indexed_types.)  We are  
working at
the implementation, but I just relocated from New York to Sydney,  
which

is why not much happened in the last two months.

But I also don't quite understand the intention of this code:



I will try to fill in the details, but surely it is all expanded in  
the original thread.


The idea is that we have an indexed/effectful monad where bind and  
return have a parameterized type:


class WitnessMonad m where
  (=) :: m a b x - (x - m b c y) - m a c y
  return :: x - m a a x

We can produce instances of WitnessMonad from an existing Monad using  
an adaptor


newtype WitnessAdaptor m a b x = W {unW::m x}
instance Monad m = WitnessMonad (WitnessAdaptor m)

And rebind the do syntax to our WitnessMonad.
But using vanilla Monads via this trick requires to lift and unlift  
every monadic action with the adaptor. An example in the IO monad:


test1 :: IO String
test1 = unW$ do
  msg - W getLine
  W$ putStrLn Thanks!
  return msg

From here on the intent was on producing a solution using ATs that  
hides this explicit wrapping. I don't really know the details of the  
proposed solution.


Thanks
pepe

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


Re[2]: [Haskell-cafe] FFI basics

2007-02-27 Thread Bulat Ziganshin
Hello Evan,

Tuesday, February 27, 2007, 12:02:57 AM, you wrote:

 Unfortunately, ghc doesn't seem relink the target if cfile.o changed,
 so as a hack I put 'rm target' before the ghc line to make it link
 every time.

it's a bug. i don't know whether it's already fixed, try it with the
latest 6.6 snapshot

 #2 is structs.  What's a good way to marshal structs?

this depends on your actual task. in particular, you can write
instances of Storable for your structures:

instance (Storable a, Storable b) = Storable (a,b) where
  sizeOf (x,y) = sizeOf x + sizeOf y
  ..

hsc2hs translator allows you to use offsets in C structures, see
http://therning.org/magnus/archives/238 
  
-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


[Haskell-cafe] Re: [Haskell] [Fwd: Re: Computer Language Shootout]

2007-02-27 Thread Fawzi Mohamed


On Feb 27, 2007, at 1:59 PM, Sven Panne wrote:


On Tuesday 27 February 2007 13:44, Andrzej Jaworski wrote:

I have learned logic from much deeper sources;-)
My statement was:
Guys started in Haskell and got to conclusion that for performance  
reasons

it is better to move to C.  The guys know what they are doing.

I hope that helps;-)


Hmmm, is there any paper/blog/etc. describing exactly what the  
performance

problems were? If something is too slow, usually either the language
implementor or the language user can learn something. Furthermore,  
when
moving from programming language X to Y and seeing performance  
improvements,
it is more often than not the case that the reason for this is not  
that Y is

faster than X, but that one has learned a lot about the problem when
implementing in X. So in general you see an improvement even when X  
== Y,

i.e. dump your old Haskell code and start from scratch.


I could not find references for the other stuff, but for Algebraic  
Dynamic Programming I found this


http://bibiserv.techfak.uni-bielefeld.de/adp/adplit.html

and citing my previous message ;)

they went from an embedded haskell implementation to a direct  
compiler implementation.


From what I understood I believe that mis-performance in that  
case came from the embedded nature of the DSL
1) not having a specialized parsing step (making the usage more  
difficult)
2) no abstract representation of the program that could be  
optimized with special transformations relative to the DSL

3) not fully optimized kernel methods

writing a real compiler for that language made sense, and also  
the choice of c as language for it, but I think that it would  
have been possible to write it in haskell without a big  
performance hit. I haven't seen that haskell compiler  
significantly worse than others except in really low level
computational code, which (with more effort than with C) can be  
optimized so that it is not really so terribly worse.



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


[Haskell-cafe] Logic programming using lazy evaluation

2007-02-27 Thread Henning Thielemann

I suspect that someone has already done this: A Haskell library which
solves a system of simple equations, where it is only necessary to derive
a value from an equation where all but one variables are determined. Say

1+2=x  -- add 1 2 x
y*z=20 -- times y z 20
x+y=5  -- add x y 5

should be solved as

x=3
y=2
z=10

Of course, it is easy to do this for a finite number of variables and
equations by assigning integer identifiers to the variables, then scanning
the equations repeatedly until all determinable variables are determined.

However, imagine I have an infinite number of equations and an infinite
number of variables, say

1=x0-- equal 1 x0
2*x0=x1 -- times 2 x0 x1
2*x1=x2 -- times 2 x1 x2
2*x2=x3 -- times 2 x2 x3
...

Accessing variable values by integer identifiers means that the garbage
collector cannot free values that are no longer needed.

Thus I thought about how to solve the equations by lazy evaluation. Maybe
it is possible to ty the knot this way

let (_,_,x0)  = add 1 2 x
(y0,z0,_) = times y z 20
(x1,y1,_) = add x y 5
x = alternatives [x0,x1]
y = alternatives [y0,y1]
z = alternatives [z0]
in  (solve x, solve y, solve z)

Independent from the question of how to implement 'alternatives' and
'solve' I wonder if there is a less cumbersome way to do this kind of
logic programming in Haskell.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] [Fwd: Re: Computer Language Shootout]

2007-02-27 Thread Fawzi Mohamed

On Feb 27, 2007, at 3:51 PM, Andrzej Jaworski wrote:


[...]
Nevertheless my point is still valid: when on compiler side the  
heap is
stretched and on program side you need Ockham's Razor in action  
Haskell
chokes. I hoped at least to stimulate interest in repeating GP  
experiment
with latest GHC version.  This could make a hot publication and  
save nice

people from reappearance of this thread:-)

(the experiment:
http://www.dcs.ed.ac.uk/home/stg/sfpw/book/Garmendia-Doval/ 
cameraready.ps)


Thanks for the link! I had not found it.
An interesting read.
Indeed it would be very interesting to repeat the experiment with the  
actual GHC...


Sincerely
Fawzi


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


Re: [Haskell-cafe] Trouble with record syntax and classes

2007-02-27 Thread Andreas Rossberg

[EMAIL PROTECTED] wrote:


When you type class Foo in Java or C++, it does three things:

1. It declares a new type called Foo.

2. It declares a _set_ of types (i.e. a class).

3. It declares that the type Foo (and all of its subtypes) is a member
of the set of types Foo.


I would add:

4. Define a namespace, also called Foo, for a set of values (and 
probably nested classes).



In Haskell, these three operations are distinct.

1. You declare a new type using data or newtype.

2. You declare a new set of types using class.

3. You declare that a type is a member of a class using instance.


4. You define a new namespace using module.

Cheers,
- Andreas

--
Andreas Rossberg, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: problems installing ghc 6.6 with extralibs (bad interface file)

2007-02-27 Thread Thomas Hartman

Thanks. I incorporated these changes, and it cranks longer now before
failing. But still fails, now with a seg fault.

Does this just mean I don't have enough ram, or cpu, or ... Any ideas?

thomas.

*

[EMAIL PROTECTED]:~/haskellInstalls$ tail -n13 out.txt
../compiler/ghc-inplace -H16m -O  -istage2/utils  -istage2/basicTypes
-istage2/types  -istage2/hsSyn  -istage2/prelude  -istage2/rename
-istage2/typecheck  -istage2/deSugar  -istage2/coreSyn
-istage2/specialise  -istage2/simplCore  -istage2/stranal
-istage2/stgSyn  -istage2/simplStg  -istage2/codeGen  -istage2/main
-istage2/profiling  -istage2/parser  -istage2/cprAnalysis
-istage2/ndpFlatten  -istage2/iface  -istage2/cmm  -istage2/nativeGen
-istage2/ghci -Istage2 -DGHCI -DBREAKPOINT -package template-haskell
-threaded -package readline -DUSE_READLINE -cpp -fglasgow-exts
-fno-generics -Rghc-timing -I. -Iparser -package unix -package Cabal
-package regex-compat -ignore-package lang -recomp -Rghc-timing  -H16M
'-#include cutils.h' -package-name  ghc-6.6   -fgenerics  -fno-cse
-c main/DriverPipeline.hs -o stage2/main/DriverPipeline.o  -ohi
stage2/main/DriverPipeline.hi
ghc: 489718944 bytes, 1371 GCs, 11780600/23325480 avg/max bytes
residency (7 samples), 59M in use, 0.00 INIT (0.00 elapsed), 3.40 MUT
(18.69 elapsed), 3.69 GC (3.91 elapsed) :ghc
../compiler/ghc-inplace -H16m -O  -istage2/utils  -istage2/basicTypes
-istage2/types  -istage2/hsSyn  -istage2/prelude  -istage2/rename
-istage2/typecheck  -istage2/deSugar  -istage2/coreSyn
-istage2/specialise  -istage2/simplCore  -istage2/stranal
-istage2/stgSyn  -istage2/simplStg  -istage2/codeGen  -istage2/main
-istage2/profiling  -istage2/parser  -istage2/cprAnalysis
-istage2/ndpFlatten  -istage2/iface  -istage2/cmm  -istage2/nativeGen
-istage2/ghci -Istage2 -DGHCI -DBREAKPOINT -package template-haskell
-threaded -package readline -DUSE_READLINE -cpp -fglasgow-exts
-fno-generics -Rghc-timing -I. -Iparser -package unix -package Cabal
-package regex-compat -ignore-package lang -recomp -Rghc-timing  -H16M
'-#include cutils.h' -package-name  ghc-6.6   -fgenerics-c
main/GHC.hs -o stage2/main/GHC.o  -ohi stage2/main/GHC.hi
gcc: Internal error: Segmentation fault (program cc1)
Please submit a full bug report.
See URL:http://gcc.gnu.org/bugs.html for instructions.
For Debian GNU/Linux specific bug reporting instructions, see
URL:file:///usr/share/doc/gcc-4.0/README.Bugs.

ghc: 595874452 bytes, 1818 GCs, 14564135/30202688 avg/max bytes
residency (8 samples), 74M in use, 0.00 INIT (0.00 elapsed), 5.10 MUT
(17.37 elapsed), 5.80 GC (12.08 elapsed) :ghc
make[1]: *** [stage2/main/GHC.o] Error 1
make: *** [install] Error 1
~/haskellInstalls



[EMAIL PROTECTED]:~/haskellInstalls$ sudo ./install-ghc-6.6.sh 21
| tee out.txt


[EMAIL PROTECTED]:~/haskellInstalls$ cat install-ghc-6.6.sh
if [ ! -f ghc-6.6-src.tar.bz2 ]; then
 wget http://www.haskell.org/ghc/dist/6.6/ghc-6.6-src.tar.bz2
fi

if [ ! -f ghc-6.6-src-extralibs.tar.bz2 ]; then
 wget http://www.haskell.org/ghc/dist/6.6/ghc-6.6-src-extralibs.tar.bz2
fi


tar -tvjf ghc-6.6-src.tar.bz2
tar -tvjf ghc-6.6-src-extralibs.tar.bz2
pushd ghc-6.6
 (cd compat  make clean  make UseStage1=YES)
 (cd utils  make clean  make UseStage1=YES)
 ./configure
 make
 make install
popd
[EMAIL PROTECTED]:~/haskellInstalls$


2007/2/27, Thomas Hartman [EMAIL PROTECTED]:

I incorporated these changes to my install script, and now it cranks
longer before failing, but still fails. Now with a seg fault.

For some odd reason the final crash snipped below didn't get written
to out.txt, otherwise I would have attached it.

Any ideas to get it working?

Thanks, thomas.

**

[EMAIL PROTECTED]:~/haskellInstalls$ cat install-ghc-6.6.sh
if [ ! -f ghc-6.6-src.tar.bz2 ]; then
  wget http://www.haskell.org/ghc/dist/6.6/ghc-6.6-src.tar.bz2
fi

if [ ! -f ghc-6.6-src-extralibs.tar.bz2 ]; then
  wget http://www.haskell.org/ghc/dist/6.6/ghc-6.6-src-extralibs.tar.bz2
fi


tar -tvjf ghc-6.6-src.tar.bz2
tar -tvjf ghc-6.6-src-extralibs.tar.bz2
pushd ghc-6.6
  (cd compat  make clean  make UseStage1=YES)
  (cd utils  make clean  make UseStage1=YES)
  ./configure
  make
  make install
popd
[EMAIL PROTECTED]:~/haskellInstalls$

[EMAIL PROTECTED]:~/haskellInstalls$ sudo ./install-ghc-6.6.sh 21
| tee out.txt



../compiler/ghc-inplace -H16m -O  -istage2/utils  -istage2/basicTypes
-istage2/types  -istage2/hsSyn  -istage2/prelude  -istage2/rename  -
istage2/typecheck  -istage2/deSugar  -istage2/coreSyn
-istage2/specialise  -istage2/simplCore  -istage2/stranal
-istage2/stgSyn  -istage2
/simplStg  -istage2/codeGen  -istage2/main  -istage2/profiling
-istage2/parser  -istage2/cprAnalysis  -istage2/ndpFlatten
-istage2/iface
 -istage2/cmm  -istage2/nativeGen  -istage2/ghci -Istage2 -DGHCI
-DBREAKPOINT -package template-haskell -threaded -package readline
-DUSE_R
EADLINE -cpp -fglasgow-exts -fno-generics -Rghc-timing -I. -Iparser
-package unix -package Cabal -package regex-compat 

Re: [Haskell-cafe] Logic programming using lazy evaluation

2007-02-27 Thread Ulf Norell

On 2/27/07, Henning Thielemann [EMAIL PROTECTED] wrote:


I suspect that someone has already done this: A Haskell library which
solves a system of simple equations, where it is only necessary to derive
a value from an equation where all but one variables are determined. Say


You might want to check out the following paper:

http://www.cs.chalmers.se/~koen/pubs/entry-haskell00-typedlp.html

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


[Haskell-cafe] Re: [Haskell] [Fwd: Re: Computer Language Shootout]

2007-02-27 Thread Claus Reinke
I hoped at least to stimulate interest in repeating GP experiment with latest GHC version. 


until that happens, I'd be wary to draw too many conclusions for today's 
applications from this paper. two orders of magnitude difference would seem

to imply programming problems to me (though the authors did have the problem/
excuse of lack of profiling tools).


(the experiment:
http://www.dcs.ed.ac.uk/home/stg/sfpw/book/Garmendia-Doval/cameraready.ps)


not only is it old (ghc-4.08), it doesn't show much code, and what it shows,
looks suspiciously like a case of ML-mindset programming in Haskell (the kind
that people get help with on the various Haskell lists nearly every day, 
nowadays).

according to 3.5, the Haskell version came first, was used for experiments, and
errors in design were corrected, then came the ML version, which was at this 
point
already substantially faster (from which i would be tempted to conclude that the
coding style was a better fit for ML than for Haskell; cf also 3.5.1, third para). 
the ML version was then profiled and improved, after which these improvements 
were backported from the ML to the Haskell version! 

okay, profiling was not available for the Haskell version back then, but using ML 
profiling to improve a Haskell version sounds highly dangerous to me, even more 
so if the authors do not even mention any awareness of this danger. in 3.5.1, we 
see Alleles as a BoolVector, which sounds fine until we see it converted to its 
list of associations, which is then foldl-ed (!) over with a non-strict function (good 
that those chromosome lengths appear to be only 60..), for every evaluation. this 
is the main evaluation function for fitness, so it should be very much inner loop, 
with population sizes and generations ranging to 7500/700 and 50/15.

.
of course, the same function in the ML version just means running a loop over a
vector, with a strict accumulator..

that is just the code shown in the paper - and it is the only piece of code, 
apart
from structure declarations. perhaps inlining and strictness analysis caught 
this
particular problem, and perhaps calling out to C for random numbers didn't slow
down the program, either - the paper just doesn't give enough information to 
tell.

   So far, we have found the Standard ML version to out-perform the Haskell 
version by over two orders of magnitude. Despite extensive study of the Haskell 
version, no clear reason has emerged for this poor performance.


note that they do not say any Haskell version would have to be slow because 
of..,
they say they don't know.

well, enough of this fud!-) 


i hope it is fair to say that not just todays compilers are different, but also 
the user
communities. i cannot imagine anyone experiencing this level of performance
difference in a concrete application without asking questions about it on one of 
the Haskell lists, nor would i expect such questions to remain unanswered for 
long enough to merit a paper (at least not about the question; Data.ByteString

shows that there are still papers to be written about answers;-). and if it is 
too
complicated for a public discussion, the project in question could always hire
Haskell expertise, in the form of consulting (although i see that most entries 
have
disappeared from the Haskell consultants list, probably because they tend to
answer questions for free on the mailing lists?-).

claus

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


[Haskell-cafe] Re: overlapping instances, selecting if type a does not belong to class?

2007-02-27 Thread Marc Weber
 However, it seems that your particular problem can be solved with
 simpler means:
 
  instance (HList a) = HListAppendArbitrary a HNil a where
hAppendArbitrary a _ = a
  instance (HList a, HList b, HList c) 
  = HListAppendArbitrary a (HCons b d) c where
hAppendArbitrary a b = hAppend a b -- or use HCons with recursion
 
  -- overlapping instance HList + value (2)
  instance (HList a, HList c)
= HListAppendArbitrary a b c where
hAppendArbitrary a b = HCons b a

It looks like this, doesn't it ?
(Some class isntance declarations are still missing)
= code ===
class (HList c) = HListAppendArbitrary a b c | a b - c where
  hAppendArbitrary :: a - b - c

-- instances HList + HList
instance HListAppendArbitrary HNilHNilHNil where   -- line  134
  hAppendArbitrary _ _ = HNil
instance HListAppendArbitrary (HCons a b) HNil(HCons a b) where
  hAppendArbitrary a _ = a
instance HListAppendArbitrary HNil(HCons a b) (HCons a b) where
  hAppendArbitrary _ a = a
instance HListAppendArbitrary (HCons a b) (HCons b c) (HCons a l) where
  hAppendArbitrary a b = hAppend a b

-- instance HList + value
instance HListAppendArbitrary HNil b (HCons b HNil) where  -- line 143
  hAppendArbitrary _ b = HCons b HNil
instance HListAppendArbitrary (HCons a b)  c d where
  hAppendArbitrary a b = hAppend a (HCons b HNil)

-- instance value + HList
instance HListAppendArbitrary bHNil c where
  hAppendArbitrary b _ = HCons b HNil
instance HListAppendArbitrary a(HCons b c) d where
  hAppendArbitrary a b = hAppend (HCons a HNil) b
= end code ===

But I'm getting the same error twice:

hps-lib/HPS/Utils.hs|134| 0:
|| Functional dependencies conflict between instance declarations:
||   instance [incoherent] HListAppendArbitrary HNil HNil HNil
-- Defined at hps-lib/HPS/Utils.hs|134| 0
||   instance [incoherent] HListAppendArbitrary HNil b (HCons b HNil)
-- Defined at hps-lib/HPS/Utils.hs|143| 0

If you compare those two lines g
instance HListAppendArbitrary HNilHNilHNil where   -- line  134
instance HListAppendArbitrary HNil b  (HCons b HNil) where  -- 
line 143

I see that HNil HNil - HNil 
doesn't fit
   HNil b (thus maybe HNil) - HCons b HNil

But I don't want to omit the funtcional dependency because the resulting
type should be determined by the first two parameters.

As I don't know how to solve this right now I'll use HLists anywhere.

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


[Haskell-cafe] Declaring variance of class parameters?

2007-02-27 Thread Jacques Carette

If I have a class, say
class Symantics repr where
 int:: Int - repr Int

and so on, I would like to *require* that 'repr' be covariant.  Is there 
any way to do that?


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


Re: [Haskell-cafe] Declaring variance of class parameters?

2007-02-27 Thread Ross Paterson
On Tue, Feb 27, 2007 at 02:00:29PM -0500, Jacques Carette wrote:
 If I have a class, say
 class Symantics repr where
  int:: Int - repr Int
 
 and so on, I would like to *require* that 'repr' be covariant.  Is there 
 any way to do that?

class Functor repr = Symantics repr

would be pretty close, and has the virtue of saying what you mean.

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


Re: [Haskell-cafe] Logic programming using lazy evaluation

2007-02-27 Thread Henning Thielemann

On Tue, 27 Feb 2007, Ulf Norell wrote:

 On 2/27/07, Henning Thielemann [EMAIL PROTECTED] wrote:
 
  I suspect that someone has already done this: A Haskell library which
  solves a system of simple equations, where it is only necessary to derive
  a value from an equation where all but one variables are determined. Say

 You might want to check out the following paper:

 http://www.cs.chalmers.se/~koen/pubs/entry-haskell00-typedlp.html

Thanks for the link!
It reminds me, that my problem differs from usual logic programming.
I'm not interested in multiple solutions, I expect only one.
If a variable is underdetermined, it shall be evaluated to undefined.
If a variable is overdetermined,
that is different rules lead to different values for that variable,
one of these values shall be returned.
Checking for consistency per variable would require processing the whole
(possibly infinite) list of rules.
Instead one could check consistency per rule.
That is, the solver should return a list of Bools
which indicate which rules could be satisfied.
In this setting it should be possible to solve the equations lazily.

In contrast to the paper
I assume that I can neither use Int variable identifiers nor STRefs
because they would prevent the garbage collector
from freeing unreferenced variable substitutions.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Trouble with record syntax and classes

2007-02-27 Thread Albert Y. C. Lai

Thomas Nelson wrote:

data ISine = Sine Integer Integer Integer String |
MetaSine Integer Integer Integer [ISine]


Having advised you to use different field names for different record 
types last time, I now confuse you by saying you can share field names 
in the different cases inside the same type!


data ISine = Sine {period, offset, threshold :: Int, letter :: String}
   | MetaSine {period, offset, threshold :: Int,
   sub_sines :: [ISine]}

If the same field name is used in both cases, both fields must be of the 
same type, e.g., period is Int throughout.


This only works within the same type, i.e., ISine. Other types still 
cannot have a field named period.


You no longer need to define a period function yourself, since the 
field period already does that. period blah works whether blah is 
a Sine or a MetaSine. letter blah works if blah is a Sine, aborts if 
blah is a MetaSine. (But you kind of want that anyway.) Dually for 
sub_sines.


Existing pattern-matching code still works, e.g.,

  act time (Sine p o t l) = ...

still works. (The order of p o t l follows the order of fields in the 
data declaraction.) You can also optionally write


  act time Sine{period=p, offset=o, threshold=t, letter=l} = ...

Either way it is up to you.

Record syntax in Haskell is a bit confusing and restrictive. Both in 
some sense it is also pervertedly convenient.

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


Re: [Haskell-cafe] Re: [Haskell] [Fwd: Re: Computer Language Shootout]

2007-02-27 Thread Duncan Coutts
On Tue, 2007-02-27 at 16:51 +, Claus Reinke wrote:

 okay, profiling was not available for the Haskell version back then, but 
 using ML 
 profiling to improve a Haskell version sounds highly dangerous to me, even 
 more 
 so if the authors do not even mention any awareness of this danger. in 3.5.1, 
 we 
 see Alleles as a BoolVector, which sounds fine until we see it converted to 
 its 
 list of associations, which is then foldl-ed (!) over with a non-strict 
 function (good 
 that those chromosome lengths appear to be only 60..), for every evaluation. 
 this 
 is the main evaluation function for fitness, so it should be very much inner 
 loop, 
 with population sizes and generations ranging to 7500/700 and 50/15.
  .
 of course, the same function in the ML version just means running a loop over 
 a
 vector, with a strict accumulator..

It'd be interesting to get the real code for this. Partly to just try
optimising it but more so as a real test case for list/array fusion.

As far as I see, there's no reason that consuming an assoc list of a
bool vector with a foldl' (the ' is probably essential) should be slow.
If it's fused properly no list cells should ever be allocated, we should
get the loop over the vector.

Duncan

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


[Haskell-cafe] Re: [Haskell] [Fwd: Re: Computer Language Shootout]

2007-02-27 Thread Andrzej Jaworski
On 2/26/07, Kirsten Chevalier honored me with his attention:

Can you clarify what you mean by this? How do you formally prove that
a programming language (rather than a specific implementation of one)
performs better for a given problem? (..)

It is about my saying:SML was exhaustively proved to predict this logic
much better.

Formal proof requires a theory. So you might use Copernicus model to
formally prove that Australia is on the other side of  Earth against Europe.
Exhaustive prove might require you to dig a very deep hole in the
ground;-)
In case of proving softspots of Haskell, a couple of very knowledgeable
people here and there dug through exhaustive set of alternatives. That's it.

In case of formal proves over programming languages aspirations are limited
to program correctness and probably will never address performance. (see
http://unit.aist.go.jp/cvs/Agda/)

Unfortunately I spend most of my time doing first kind of proofs, I am not
sure how it is with you;-)

I've read a few of your posts and I still don't understand what you
mean by a compiler address[ing] specific properties of a program.
Can you give an example of the kinds of program properties you're
talking about, and explain how C compilers exploit them in a way that
Haskell compilers currently fail to do?

My posts were intentionally motivational because I wanted to get feedback on
the problem.
As to address[ing] specific properties of a program.
In ADP a program deals with DNA and molecular structures. Because the
program is a sort of inference engine and simulator at the same time it is
desirable to introduce likelihood function as low as possible to avoid
blowing up search spaces when everything is constructed and reconstructed at
the same time. C is low so that's it. However that is done at a cost - the
routines that access the pre-calculated data are no longer identical to
those that access the routines that initially calculated the data. In Prolog
or Haskell they could remain the same.

Have a good time,
-Andrzej



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


Re: [Haskell-cafe] Logic programming using lazy evaluation

2007-02-27 Thread Chris Kuklewicz
Henning Thielemann wrote:
 I suspect that someone has already done this: A Haskell library which
 solves a system of simple equations, where it is only necessary to derive
 a value from an equation where all but one variables are determined. Say
 
 1+2=x  -- add 1 2 x
 y*z=20 -- times y z 20
 x+y=5  -- add x y 5
 
 should be solved as
 
 x=3
 y=2
 z=10
 
 Of course, it is easy to do this for a finite number of variables and
 equations by assigning integer identifiers to the variables, then scanning
 the equations repeatedly until all determinable variables are determined.
 
 However, imagine I have an infinite number of equations and an infinite
 number of variables, say
 
 1=x0-- equal 1 x0
 2*x0=x1 -- times 2 x0 x1
 2*x1=x2 -- times 2 x1 x2
 2*x2=x3 -- times 2 x2 x3
 ...
 
 Accessing variable values by integer identifiers means that the garbage
 collector cannot free values that are no longer needed.

That will always be true for potentially non-finite lists of equations.

 
 Thus I thought about how to solve the equations by lazy evaluation. Maybe
 it is possible to ty the knot this way
 
 let (_,_,x0)  = add 1 2 x
 (y0,z0,_) = times y z 20
 (x1,y1,_) = add x y 5
 x = alternatives [x0,x1]
 y = alternatives [y0,y1]
 z = alternatives [z0]
 in  (solve x, solve y, solve z)

 
 Independent from the question of how to implement 'alternatives' and
 'solve' I wonder if there is a less cumbersome way to do this kind of
 logic programming in Haskell.
 ___


For an infinite number of equations you have to generate them as data at run
time.  Your notation above only works for a finite set of equations known at
compile time.

So you have a stream of equations, and each equation depends on some subset of
the variables seen so far and may also introduce new variables for the first 
time.

As equations are read it will become possible to solve for variables, so there
is an evolving environment of solved variables as you read the equation stream.

You can never free up the old variables since you cannot prove that future
equations will not use them.

You can forget old equations once all their variables have been assigned.

In general the combinatorial trick is: after reading a new equation to then find
a subset of n equations with n still unassigned variables.  Then run a solver on
these n equations  variables.  Once all such subsets have been solved you
proceed to the next new equation.  Then one of the n equations will have to be
the freshly read equation.  Your only 1 undetermined variable means that n is
restricted to only be 1, which greatly simplified finding an equation to solve.
 After any variable is solved the whole list of unsolved equations is revisited.

After each step the environment of variables and equations will be updated, and
if solving a set of equations found no solution then the whole set is
inconsistent and you can abort.  If solving a set of equations gives multiple
answers (x*x==4) then you could have parallel sets of variable assignments, or a
heuristic to pick only one member of that set of sets.  If a solved variables
causes other equations to fail then that set of values is inconsistent.

I can now see this as a straightforward State-like monad, where the state holds
the current environment of solved variables and unsolved equations.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] What inhabits this type: (forall a. a - b) - (forall a. m a - m b)

2007-02-27 Thread Jacques Carette

Since my last query was answered so quickly, let's try another.

I have looked on Hoogle.  I would have asked Djinn, but I don't have it 
around.  So, can someone find a term that inhabits

(forall a. a - b) - (forall a. m a - m b)
?  I think of this as the type of functions that, given a function from 
any boxed-up a to a b, will give me a function from a boxed-up ma to a m 
b -- m does not have to be a Monad!.


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


Re: [Haskell-cafe] What inhabits this type: (forall a. a - b) - (forall a. m a - m b)

2007-02-27 Thread Stefan O'Rear
On Tue, Feb 27, 2007 at 06:01:44PM -0500, Jacques Carette wrote:
 Since my last query was answered so quickly, let's try another.
 
 I have looked on Hoogle.  I would have asked Djinn, but I don't have it 

No you couldn't.  Djinn doesn't support rank2 types.  (FWIW you can go to
#haskell at chat.freenode.org and /msg 'lambdabot' with '@djinn type')

 around.  So, can someone find a term that inhabits
 (forall a. a - b) - (forall a. m a - m b)
 ?  I think of this as the type of functions that, given a function from 
 any boxed-up a to a b, will give me a function from a boxed-up ma to a m 
 b -- m does not have to be a Monad!.

undefined (assuming impredicativity ...)

It doesn't exist without _|_.  Proof:

data Void a where
  Void :: Void Int

assumed :: (forall a. a - b) - (forall a. m a - m b)

(const True) :: forall a. a - Bool

assumed (const True) :: forall m a. m a - m Bool
assumed (const True) :: Void Int - Void Bool
assumed (const True) Void :: Void Bool

but there is no constructor of type Void Bool, so assumed (const True) Void
cannot evaluate to WHNF, contradicting our assumtion that assumed exists and
is total, QED.  (Go ahead mathematicians, I expect a good flaming here)

HTH

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


Re: [Haskell-cafe] Re: [Haskell] [Fwd: Re: Computer Language Shootout]

2007-02-27 Thread Claus Reinke

It'd be interesting to get the real code for this. Partly to just try
optimising it but more so as a real test case for list/array fusion.

As far as I see, there's no reason that consuming an assoc list of a
bool vector with a foldl' (the ' is probably essential) should be slow.
If it's fused properly no list cells should ever be allocated, we should
get the loop over the vector.


fooling around with a dummy framework (loop over evaluate population*generations
times) suggests that it is far easier to get order-of-magnitude slow-downs and 
space
leaks by not evaluating the fitness results to the end than it is by not 
evaluating a short
inner loop (provided that its result is forced at each outer iteration, ie 
making sure that
the next generation is computed from the fitness *before* the next iteration starts). 

that's why i mentioned that this might not have been the source of their trouble. but 
as they did have resource trouble, it worries me that they present this kind of code 
without even discussing possible implications, strictness or optimisations. 

yes, it would be interesting to see if the rest of the code follows the same pattern 
(in which case i wouldn't be surprised about resource issues), or whether there is 
anything more interesting going on. as it stands, guessing what the authors might
have wanted to say in this paper isn't helping anyone. 


claus

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


Re: [Haskell-cafe] What inhabits this type: (forall a. a - b) - (forall a. m a - m b)

2007-02-27 Thread Nicolas Frisby

The type doesn't actually indicate that the type m supports a return
operation. I introduced the qualifier that it was a functor. You
implicity introduced the constraint that it is a monad (actually a
pointed functor, but that's a Monad's return operator). With that
constraint, your thought process seems fine to me.

On 2/27/07, Bryan Burgers [EMAIL PROTECTED] wrote:

 Since my last query was answered so quickly, let's try another.

 I have looked on Hoogle.  I would have asked Djinn, but I don't have it
 around.  So, can someone find a term that inhabits
 (forall a. a - b) - (forall a. m a - m b)
 ?  I think of this as the type of functions that, given a function from
 any boxed-up a to a b, will give me a function from a boxed-up ma to a m
 b -- m does not have to be a Monad!.

 Jacques

(Jacques, sorry you got this twice--I forgot to send it to the list.)

How about this one?
f g x = return $ g x

Since 'g' can, by definition, take any type and return a 'b', then it
should be able to take some 'm a' and return something of type 'b',
which we just return.

I'm not really familiar with foralls, but the two explicit foralls
make the two a's different, right?

(After reading the other responses, I must be wrong, but can somebody
explain why?)

Bryan Burgers
___
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: problems installing ghc 6.6 with extralibs (bad interface file)

2007-02-27 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thomas Hartman wrote:
 Thanks. I incorporated these changes, and it cranks longer now before
 failing. But still fails, now with a seg fault.
 
 Does this just mean I don't have enough ram, or cpu, or ... Any ideas?
 [...]
 gcc: Internal error: Segmentation fault (program cc1)
 Please submit a full bug report.
 See URL:http://gcc.gnu.org/bugs.html for instructions.
 For Debian GNU/Linux specific bug reporting instructions, see
 URL:file:///usr/share/doc/gcc-4.0/README.Bugs.
 [...]

If you try again, does it work, or does it crash in the same place? My
own experience with most gcc internal errors is that gcc just crashes
randomly and it works fine when trying again, so it's worth a try if you
haven't already...

Isaac
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF5MgIHgcxvIWYTTURAmCLAKDJvX4DVFG5xoJR5nUqRT9qFLJ7VACguJ/K
wN8fybsNW/nBan7ZPfzwyjk=
=Lu7z
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: problems installing ghc 6.6 with extralibs (bad interface file)

2007-02-27 Thread Seth Gordon
Thomas Hartman wrote:
 Thanks. I incorporated these changes, and it cranks longer now before
 failing. But still fails, now with a seg fault.
 *
 gcc: Internal error: Segmentation fault (program cc1)
 Please submit a full bug report.
 See URL:http://gcc.gnu.org/bugs.html for instructions.
 For Debian GNU/Linux specific bug reporting instructions, see
 URL:file:///usr/share/doc/gcc-4.0/README.Bugs.

According to conventional wisdom, when gcc segfaults on a big
compilation job (e.g., the Linux kernel), it could be a sign of a
transient memory error; gcc exercises the RAM so much that the error
rate on a typical computer's memory chips can have a practical effect.

You can either buy more expensive RAM or run the build again and hope
for better luck.


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


Re: [Haskell-cafe] Plotting in Haskell

2007-02-27 Thread Tim Docker
Chirs Witte wrote:

 Are there any good libraries for drawing plots (2D and 3D) in Haskell
 (under Windows using GHC)?


Dons has already mentioned my charting library:

http://dockerz.net/software/chart.html

This is 2D only for now. good depends your perspective :-) It is
(intended to be) quite extensible. Russell O'Connor recently contributed
automatic scaling log axes.

The web-page + documentation is due for an update. Get the latest version
from darcs. Hopefully the haddock doco + examples is enough to get going.

Tim

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


Re: [Haskell-cafe] Re: problems installing ghc 6.6 with extralibs (bad interface file)

2007-02-27 Thread Paul Brown

On 2/27/07, Seth Gordon [EMAIL PROTECTED] wrote:

Thomas Hartman wrote:
 Thanks. I incorporated these changes, and it cranks longer now before
 failing. But still fails, now with a seg fault.
According to conventional wisdom, when gcc segfaults on a big
compilation job (e.g., the Linux kernel), it could be a sign of a
transient memory error; gcc exercises the RAM so much that the error
rate on a typical computer's memory chips can have a practical effect.


I believe that you're probably correct in this case: I was able to get
ghc 6.6 + optional packages built on a linode virtual host (guessing
from the original poster's prompt) but only after expanding the amount
of memory available.

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


[Haskell-cafe] Re: overlapping instances, selecting if type a does not belong to class?

2007-02-27 Thread oleg

The problem you report can be fixed with some trickery and local
functional dependencies. I'd like to show a different solution, which
follows a useful general pattern, of isolating overlapping instances
to one small part of the program that analyzes the type. The rest of
the type program just uses the results of the analysis.

 I wasn't able to find the definition of AllOf(But):
It is in the complete code
http://pobox.com/~oleg/ftp/Haskell/poly2.hs
It isn't that interesting:
 data AllOfBut x y


{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-undecidable-instances #-}
{-# OPTIONS -fallow-overlapping-instances #-}

module HAA where

import HListPrelude 

data HTrue
data HFalse

-- If two arguments are HList's, concatenate them. If only one of them
-- is HList, add the other to the head. We assume at least one is an HList.

class IsHList a b | a - b
instance IsHList HNil HTrue
instance IsHList (HCons a b) HTrue
instance TypeCast HFalse y = IsHList x y


-- The are no overlapping instances below
class (HList c) = HListAppendArbitrary a b c | a b - c where
hAppendArbitrary :: a - b - c

instance (IsHList a af, IsHList b bf, HAA af bf a b c) 
= HListAppendArbitrary a b c where
hAppendArbitrary = haa (undefined::af) (undefined::bf)


class (HList c) = HAA af bf a b c | af bf a b - c where
haa :: af - bf - a - b - c

-- Both are HLists
instance (HList c, HAppend a b c) = HAA HTrue HTrue a b c where
haa _ _ = hAppend

instance HList a = HAA HTrue HFalse a b (HCons b a) where
haa _ _ a b = HCons b a

instance HList b = HAA HFalse HTrue a b (HCons a b) where
haa _ _ a b = HCons a b

-- deliberately unimplemented: at least one must be an HList...
-- instance HList b = HAA HFalse HFalse a b c where

test1 = hAppendArbitrary HNil True
test2 = hAppendArbitrary True (HCons () HNil)
test3 = hAppendArbitrary (HCons () HNil) (HCons False HNil)
test4 = hAppendArbitrary (HCons () HNil) 'a'
-- testf = hAppendArbitrary 'n' ()


-- TypeCast is skipped

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