Re: [Haskell-cafe] monte carlo trouble

2007-08-15 Thread Thomas Hartman
have you looked at pfp, the haskell probabilistic functional programming 
library ?

http://web.engr.oregonstate.edu/~erwig/pfp/

the paper 

http://web.engr.oregonstate.edu/~erwig/papers/abstracts.html#JFP06a

describes modeling various statisticy things this way, like tree growth 
and the monty hall problem, I think it's likely this  is applicable to 
monte carlo processes as well.

thomas.




Paul Johnson [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/15/2007 02:38 PM

To
Chad Scherrer [EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] monte carlo trouble






Chad Scherrer wrote:
 There's a problem I've been struggling with for a long time...

 I need to build a function
 buildSample :: [A] - State StdGen [(A,B,C)]
 
 given lookup functions
 f :: A - [B]
 g :: A - [C]

 The idea is to first draw randomly form the [A], then apply each
 lookup function and draw randomly from the result of each.
 
I don't understand why this returns a list of triples instead of a 
single triple.  Your description below seems to imply the latter.

You should probably look at the Gen monad in Test.QuickCheck, which is 
basically a nice implementation of what you are doing with State 
StdGen below.  Its elements function gets a single random element, 
and you can combine it with replicateM to get a list of defined length.

(BTW, are you sure want multiple random samples rather than a shuffle? 
A shuffle has each element exactly once whereas multiple random samples 
can pick any element an arbitrary number of times.  I ask because 
shuffles are a more common requirement.  For the code below I'll assume 
you meant what you said.)

Using Test.QuickCheck I think you want something like this (which I have 
not tested):

   buildSample :: [A] - Gen (A,B,C)
   buildSample xs = do
  x - elements xs
  f1 - elements $ f x
  g1 - elements $ g x
  return

If you want n such samples then I would suggest

   samples - replicateM n $ buildSample xs
 It's actually slightly more complicated than this, since for the real
 problem I start with type [[A]], and want to map buildSample over
 these, and sample from the results.

 There seem to be so many ways to deal with random numbers in Haskell.
 
Indeed.
 After some false starts, I ended up doing something like

 sample :: [a] - State StdGen [a]
 sample [] = return []
 sample xs = do
   g - get
   let (g', g'') = split g
   bds = (1, length xs)
   xArr = listArray bds xs
   put g''
   return . map (xArr !) $ randomRs bds g'
 
Not bad, although you could instead have a sample function that returns 
a single element and then use replicateM to get a list.
 buildSample xs = sample $ do
   x - xs
   y - f x
   z - g x
   return (x,y,z)

 This is really bad, since it builds a huge array of all the
 possibilities and then draws from that. Memory is way leaky right now.
 I'd like to be able to just have it apply the lookup functions as
 needed.

 Also, I'm still using GHC 6.6, so I don't have
 Control.Monad.State.Strict. Not sure how much difference this makes,
 but I guess I could just copy the source for that module if I need to.
 
Strictness won't help.  In fact you would be better with laziness if 
that were possible (which it isn't here).  The entire array has to be 
constructed before you can look up any elements in it.  That forces the 
entire computation.   But compare your implementation of buildSample to 
mine.

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] monte carlo trouble

2007-08-15 Thread Thomas Hartman
 I've seen PFP, but I don't see where that would help here. I'd still 
end up with an enormous list of tuples. 

I'm not sure I understand what you need, but did you read the bits about 
replacing a pure state expansion (all the possibile states) with an 
approximation using random/io ? the approximation of course used much less 
resources (orders of orders of magnitude :) ) , the more time the random 
process had to evolve the better the approximation matched the pure 
calculation. very wonderful.

thomas.




Chad Scherrer [EMAIL PROTECTED] 
08/15/2007 03:05 PM

To
Paul Johnson [EMAIL PROTECTED], Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] monte carlo trouble






Thanks for your replies.

I actually starting out returning a single element instead. But a
given lookup might return [], and the only way I could think of to
handle it in (State StdGen a) would be to fail in the monad. But
that's not really the effect I want - I'd rather have it ignore that
element. Another option was to wrap with Maybe, but then since I
really want  a sequence of them anyway, I decided to just wrap in a
List instead. Is there a way Maybe would work out better?

I've seen PFP, but I don't see where that would help here. I'd still
end up with an enormous list of tuples. This could be generated
lazily, but sampling with replacement (yes I want this, not a shuffle)
would require forcing the whole list anyway, wouldn't it? Using my
approach, even asking ghci for the length of the list ran for 30+
minutes.

If there's a way to lazily sample with replacement from a list without
even requiring the length of the list to be known in advance, that
could lead to a solution.

Thanks,
Chad

On 8/15/07, Paul Johnson [EMAIL PROTECTED] wrote:
 Chad Scherrer wrote:
  There's a problem I've been struggling with for a long time...
 
  I need to build a function
  buildSample :: [A] - State StdGen [(A,B,C)]
 
  given lookup functions
  f :: A - [B]
  g :: A - [C]
 
  The idea is to first draw randomly form the [A], then apply each
  lookup function and draw randomly from the result of each.
 
 I don't understand why this returns a list of triples instead of a
 single triple.  Your description below seems to imply the latter.

 You should probably look at the Gen monad in Test.QuickCheck, which is
 basically a nice implementation of what you are doing with State
 StdGen below.  Its elements function gets a single random element,
 and you can combine it with replicateM to get a list of defined length.

 (BTW, are you sure want multiple random samples rather than a shuffle?
 A shuffle has each element exactly once whereas multiple random samples
 can pick any element an arbitrary number of times.  I ask because
 shuffles are a more common requirement.  For the code below I'll assume
 you meant what you said.)

 Using Test.QuickCheck I think you want something like this (which I have
 not tested):

buildSample :: [A] - Gen (A,B,C)
buildSample xs = do
   x - elements xs
   f1 - elements $ f x
   g1 - elements $ g x
   return

 If you want n such samples then I would suggest

samples - replicateM n $ buildSample xs
  It's actually slightly more complicated than this, since for the real
  problem I start with type [[A]], and want to map buildSample over
  these, and sample from the results.
 
  There seem to be so many ways to deal with random numbers in Haskell.
 
 Indeed.
  After some false starts, I ended up doing something like
 
  sample :: [a] - State StdGen [a]
  sample [] = return []
  sample xs = do
g - get
let (g', g'') = split g
bds = (1, length xs)
xArr = listArray bds xs
put g''
return . map (xArr !) $ randomRs bds g'
 
 Not bad, although you could instead have a sample function that returns
 a single element and then use replicateM to get a list.
  buildSample xs = sample $ do
x - xs
y - f x
z - g x
return (x,y,z)
 
  This is really bad, since it builds a huge array of all the
  possibilities and then draws from that. Memory is way leaky right now.
  I'd like to be able to just have it apply the lookup functions as
  needed.
 
  Also, I'm still using GHC 6.6, so I don't have
  Control.Monad.State.Strict. Not sure how much difference this makes,
  but I guess I could just copy the source for that module if I need to.
 
 Strictness won't help.  In fact you would be better with laziness if
 that were possible (which it isn't here).  The entire array has to be
 constructed before you can look up any elements in it.  That forces the
 entire computation.   But compare your implementation of buildSample to
 mine.

 Paul.



-- 

Chad Scherrer

Time flies like an arrow; fruit flies like a banana -- Groucho Marx



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail

[Haskell-cafe] trouble building 6.7 on ubuntu

2007-08-16 Thread Thomas Hartman
I have gotten ghc 6.7 to compile, but not with extra libs.  I'm on linux 
x86, ubuntu.

Can someone suggest a download date that worked for them, or how to fix 
one or more of the problems described below?

When I build from source (this is for august 2, unknown linux, as conal 
spoke well of it :) but I have tried with several other dates in august 
with the same result)

I get 

Linux linuxpt 2.6.15-23-386 #1 PREEMPT Tue May 23 13:49:40 UTC 2006 i686 
GNU/Linux

The programs included with the Ubuntu system are free software;
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
Which we'll further canonicalise into: i386-unknown-linux
checking for path to top of build tree... ./configure: line 1433: cd: 
utils/pwd:
 No such file or directory
./configure: line 1438: -v0: command not found
./configure: line 1441: utils/pwd/pwd: No such file or directory
configure: error: cannot determine current directory

when I try unzip src and extralibs I get 

(aug 15... tail of a large out file after 1.5 hours of configure; make  
out.txt)

..
make[1]: Leaving directory 
`/home/hartthoma/installs/ghc6.7/aug15/ghc-6.7.20070815/libraries'
make -C libraries all
make[1]: Entering directory 
`/home/hartthoma/installs/ghc6.7/aug15/ghc-6.7.20070815/libraries'
rm -f -f stamp/configure.library.*.base base/unbuildable
( cd base  setup/Setup configure \
--enable-library-profiling --enable-split-objs \
   --prefix='$topdir' \
   --datadir='$prefix/share/ghc' \
   --datasubdir='.' \
   --libsubdir='$compiler/lib/$pkgid' \
   --with-compiler=../../compiler/stage1/ghc-inplace\
   --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace\
   --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace \
   --with-ld=/usr/bin/ld \
   --haddock-args=--use-contents=../index.html \
   --use-index=../doc-index.html \
  \
   --configure-option=--with-cc=gcc ) \
   touch 
stamp/configure.library.build-profiling-splitting.base || touch 
base/unbuildable
Setup: Warning: Unknown fields: nhc98-options (line 173)
Fields allowed in this section:
buildable, cc-options, ld-options, frameworks, c-sources,
extensions, extra-libraries, extra-lib-dirs, includes,
install-includes, include-dirs, hs-source-dirs, other-modules,
ghc-prof-options, ghc-options, hugs-options, nhc-options,
jhc-options, exposed-modules
Setup: Warning: A package using section syntax should require
Cabal-Version: = 1.2 or equivalent.
HsColour 1.6
configure: Reading installed packages...
Configuring base-2.1...
configure: Flags chosen: isghc=True
configure: Dependency rts-any: using rts-1.0
Setup: executing external program failed (exit 1) : 
/usr/local/bin/HsColour -version
rm -f base/GNUmakefile
cp Makefile.local base
if ifBuildable/ifBuildable base; then \
   cd base  setup/Setup makefile -f GNUmakefile; \
fi
Setup: error reading dist/setup-config; run setup configure command?

make[1]: *** [base/GNUmakefile] Error 1
make[1]: Leaving directory 
`/home/hartthoma/installs/ghc6.7/aug15/ghc-6.7.20070815/libraries'
make: *** [stage1] Error 2

very weird error because when I execute /usr/local/bin/HsColour -version 
it doesn't fail but outputs 1.6.

Can somebody suggest a download date known to compile (with extralibs) for 
ubuntu? Or suggest a fix?

By the way I have also tried 

darcs get http://hackage.haskell.org/trac/ghc

but this dies about halfway through (in the patch 1s ) with libcurl 
error 18 or libcurl error 404 depending on the phase of the moon.

I'm currently trying a build from darcs checkout with get --partial. If 
this is the preferred way of doing a checkout due to crapping out 
halfway issues maybe it should be said in the readme. (to be honest I 
forget what the difference between a partial darcs get and a complete get 
is.)

Much obliged,

thomas.
 


Conal Elliott [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/15/2007 06:38 PM

To
[EMAIL PROTECTED]
cc

Subject
Fwd: how to get packages for HEAD snapshot ?






oops -- meant to cc cvs-ghc

btw, 20070802 does run and does have libs included. 

-- Forwarded message --
From: Conal Elliott  [EMAIL PROTECTED]
Date: Aug 15, 2007 2:56 PM
Subject: Re: how to get packages for HEAD snapshot ?
To: Stefan O'Rear [EMAIL PROTECTED]

Thank Stefan, 

The latest mingw32 snapshot I see is 20070811.  I installed it also, and 
when I run ghc, it just crashes (WinXP).  Happens when I run it inside of 
emacs and also in a cygwin bash window.

Is that a known problem? 

 - Conal

On 8/15/07, Stefan O'Rear  [EMAIL PROTECTED] wrote:
On Wed, Aug 15, 2007 at 02:20:53PM -0700, Conal Elliott wrote:
 I installed ghc-6.7.20070810-i386-unknown-mingw32.exe.  Though it runs, 
I
 don't know how to get other packages 

Re: [Haskell-cafe] Looking at program execution

2007-08-17 Thread Thomas Hartman
[EMAIL PROTECTED]:~cat test.hs
import Debug.Trace

foo = foldl (\first second -
  (trace ( first:  ++ ( show first) ) first)
  +
  (trace ( second:  ++ (show second) ) second) ) 0 [1,2,3]

bar = foldl (+)

traceIt x = trace (\nTraceIt:\n++show x++\n) x
[EMAIL PROTECTED]:~ghc -e foo test.hs
first: 0
second: 1
first: 1
second: 2
first: 3
second: 3
6
[EMAIL PROTECTED]:~

hope this helps.




Ian Duncan [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/16/2007 08:20 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] Looking at program execution






Is there any way to view the steps that a haskell program goes 
through step by step?
I'm thinking something similar to what I've seen in things I've been 
reading. For example:
foldl (+) 0 [1..10]
= (0+1)
= ((0+1)+2)
= (((0+1)+2)+3)
= etc.
I've seen these sorts of line-by-line execution steps, but I was 
curious if there was any way to simply type in a function and its 
arguments and have ghci or hugs or something print out this sort of 
visual representation of what's going on. Anyone know of something 
like this?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Looking at program execution

2007-08-17 Thread Thomas Hartman
or actually just...

[EMAIL PROTECTED]:~cat test.hs
import Debug.Trace

foo = foldl (\first second -
  trace ( ( show first) ++ (+) ++ (show second ) )
  ( first + second) ) 0 [1,2,3]

[EMAIL PROTECTED]:~ghc -e foo test.hs
0+1
1+2
3+3
6
[EMAIL PROTECTED]:~

is probably better




Thomas Hartman [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/17/2007 10:52 AM

To
haskell-cafe@haskell.org, [EMAIL PROTECTED]
cc

Subject
Re: [Haskell-cafe] Looking at program execution







[EMAIL PROTECTED]:~cat test.hs 
import Debug.Trace 

foo = foldl (\first second - 
  (trace ( first:  ++ ( show first) ) first) 
  + 
  (trace ( second:  ++ (show second) ) second) ) 0 [1,2,3] 

bar = foldl (+) 

traceIt x = trace (\nTraceIt:\n++show x++\n) x 
[EMAIL PROTECTED]:~ghc -e foo test.hs 
first: 0 
second: 1 
first: 1 
second: 2 
first: 3 
second: 3 
6 
[EMAIL PROTECTED]:~ 

hope this helps. 



Ian Duncan [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED] 
08/16/2007 08:20 PM 


To
haskell-cafe@haskell.org 
cc

Subject
[Haskell-cafe] Looking at program execution








Is there any way to view the steps that a haskell program goes 
through step by step?
I'm thinking something similar to what I've seen in things I've been 
reading. For example:
foldl (+) 0 [1..10]
= (0+1)
= ((0+1)+2)
= (((0+1)+2)+3)
= etc.
I've seen these sorts of line-by-line execution steps, but I was 
curious if there was any way to simply type in a function and its 
arguments and have ghci or hugs or something print out this sort of 
visual representation of what's going on. Anyone know of something 
like this?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


---

This e-mail may contain confidential and/or privileged information. If you 

are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] trouble building regex-base 0.91 on ghc 6.7

2007-08-17 Thread Thomas Hartman
I'm trying to build the latest regex base, which is required for the other 
regex packages under ghc 6.7

It complains that it can't find Data.Sequence, because it's in a hidden 
module containers. I added containers to the cabal depends as can be seen 
in the grep below.

And containers isn't hidden when I do ghc-pkg list.

What gives?

Still getting used to cabal...

thomas.


[EMAIL PROTECTED]:~/installs/regex-base-0.91runghc Setup.hs build
Preprocessing library regex-base-0.91...
Building regex-base-0.91...

Text/Regex/Base/RegexLike.hs:47:17:
Could not find module `Data.Sequence':
  it is a member of package containers-0.1, which is hidden

[EMAIL PROTECTED]:~/installs/regex-base-0.91grep -i containers 
regex-base.cabal
Build-Depends:  base = 2.0, mtl, containers 

[EMAIL PROTECTED]:~/installs/regex-base-0.91ghc-pkg list
/usr/local/lib/ghc-6.7.20070816/package.conf:
Cabal-1.1.7, HUnit-1.1.1, QuickCheck-1.0.1, array-0.1,
arrows-0.2.1, base-2.1, bytestring-0.1, cgi-3001.1.5,
containers-0.1, directory-1.0, fgl-5.4.1, filepath-1.0,
(ghc-6.7.20070816), haskell-src-1.0.1, haskell98-1.0, hpc-0.5,
html-1.0.1, mtl-1.0.1, network-2.0.1, old-locale-1.0, old-time-1.0,
packedstring-0.1, parallel-1.0, parsec-2.0, pretty-1.0,
process-1.0, random-1.0, readline-1.0, regex-base-0.72, rts-1.0,
stm-2.1, template-haskell-0.1, unix-2.0, xhtml-3000.0.2

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] trouble building regex-base 0.91 on ghc 6.7

2007-08-17 Thread Thomas Hartman
thanks stefan, I did remember that discussion (actually also an answer to 
a question I asked.)

I got from that that previous help that I had to edit the cabal file.

The problem here, as you say, is that I had not re-run runghc Setup.hs 
configure.

thanks,

thomas.



Stefan O'Rear [EMAIL PROTECTED] 
08/17/2007 03:00 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] trouble building regex-base 0.91 on ghc 6.7






On Fri, Aug 17, 2007 at 02:40:33PM -0400, Thomas Hartman wrote:
 I'm trying to build the latest regex base, which is required for the 
other 
 regex packages under ghc 6.7
 
 It complains that it can't find Data.Sequence, because it's in a hidden 
 module containers. I added containers to the cabal depends as can be 
seen 
 in the grep below.
 
 And containers isn't hidden when I do ghc-pkg list.
 
 What gives?
 
 Still getting used to cabal...

Did you re-run configure after changing the cabal file?

Also, what ghc-pkg says has absolutely nothing to do with this; the
options Cabal passes completely override the ghc-pkg exposure flags.I
can hardly fault you for not knowing the answer to a Cabal FAQ, since
Cabal doesn't actually have a FAQ list yet.

You are running into the same problem as
http://www.haskell.org/pipermail/haskell-cafe/2007-August/030276.html,
and most of my explanation there applies here.

Stefan
[attachment signature.asc deleted by Thomas Hartman/ext/dbcom] 


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] trouble compiling import GHC.Prim(MutableByteArray#, ..... (building regex-tdfa from darcs) -- what's that # sign doing?

2007-08-17 Thread Thomas Hartman
trying to compile regex-tdfa, I ran into another issue. (earlier I had a 
cabal problem but that's resolved.)

there's a line that won't compile, neither for ghc 6.6.1 nor 6.7 

import 
GHC.Prim(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,unsafeCoerce#)

so the fresh darcs regex tdfa package won't build.

This line (line 16 below) causes this error for 

  ghc -e '' RunMutState.hs

for both ghc 6.1 and 6.7 

Much obliged for any help,

Thomas.

*

[EMAIL PROTECTED]:~/installs/regex_darcs/regex-tdfarunghc Setup.hs build
Preprocessing library regex-tdfa-0.93...
Building regex-tdfa-0.93...

Text/Regex/TDFA/RunMutState.hs:16:32: parse error on input `#'
[EMAIL PROTECTED]:~/installs/regex_darcs/regex-tdfahead -n20 
Text/Regex/TDFA/RunMutState.hs | cat -n 
 1  {-# LANGUAGE CPP #-}
 2  module 
Text.Regex.TDFA.RunMutState(TagEngine(..),newTagEngine,newTagEngine2
 3,newScratch,tagsToGroupsST
 4 ,toInstructions,compareWith,resetScratch
 5,SScratch(..),MScratch,WScratch) 
where
 6 
 7  import Control.Monad(forM_,liftM,liftM2,liftM3,foldM)
 8  --import Control.Monad.ST.Strict as S (ST)
 9  --import qualified Control.Monad.ST.Lazy as L (ST)
10  import Control.Monad.State(MonadState(..),execState)
11 
12  import Data.Array.Base(unsafeRead,unsafeWrite,STUArray(..))
13  #ifdef __GLASGOW_HASKELL__
14  import GHC.Arr(STArray(..))
15  import GHC.ST(ST(..))
*** 16  import 
GHC.Prim(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,unsafeCoerce#)
17  #else
18  import Control.Monad(when)
19  import Control.Monad.ST(ST)
20  import Data.Array.ST(STArray)
[EMAIL PROTECTED]:~/installs/regex_darcs/regex-tdfa



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] trouble compiling import GHC.Prim(MutableByteArray#, ..... (building regex-tdfa from darcs) -- what's that # sign doing?

2007-08-17 Thread Thomas Hartman
Thanks Stefan. I got regex tdfa to compile on 6.7. FWIW, here's a patch, 
generated with darcs whatsnew against a fresh unzip of regex tdfa 0.92

I didn't patch against the darcs head because this uses a language 
progma in {-# options #-} in some file*, which ghc 6.7 didn't know what to 
do with, nor I.

*: Text/Regex/TDFA/RunMutState.hs: {-# LANGUAGE CPP #-} (in darcs head, 
which as I said, I did not patch against, rather I patched against 0.92 
downloaded and unzipped.)

If there is a better way than this to send patches please advise, as I 
don't do this terribly often. (Actually I have no idea how to apply the 
below patch... is there a way?)

{
hunk ./Data/IntMap/CharMap.hs 1
+{-# OPTIONS -XGeneralizedNewtypeDeriving #-}
hunk ./Data/IntMap/EnumMap.hs 1
+{-# OPTIONS -XGeneralizedNewtypeDeriving #-}
hunk ./Data/IntSet/EnumSet.hs 1
+{-# OPTIONS -XGeneralizedNewtypeDeriving #-}
hunk ./Text/Regex/TDFA/ByteString/Lazy.hs 1
-{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -fno-warn-orphans -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/Common.hs 1
-{-# OPTIONS -funbox-strict-fields #-}
+{-# OPTIONS -funbox-strict-fields -XGeneralizedNewtypeDeriving #-}
hunk ./Text/Regex/TDFA/CorePattern.hs 1
+{-# OPTIONS -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/CorePattern.hs 38
+import Data.Monoid
+import Control.Monad
hunk ./Text/Regex/TDFA/RunMutState.hs 1
+{-# OPTIONS -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/String.hs 1
-{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -fno-warn-orphans -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/TDFA.hs 1
+{-# OPTIONS -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/TDFA.hs 12
-import Control.Monad.RWS
+import Control.Monad (mplus)
+--import Control.Monad.RWS
hunk ./Text/Regex/TDFA/TDFA.hs 33
+import Data.Monoid
+
hunk ./Text/Regex/TDFA/TNFA.hs 1
-{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -fno-warn-orphans -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/Wrap.hs 1
-{-# OPTIONS -fno-warn-orphans #-}
+{-# OPTIONS -fno-warn-orphans -fglasgow-exts #-}
hunk ./Text/Regex/TDFA.hs 42
-  ,module Text.Regex.TDFA.String
-  ,module Text.Regex.TDFA.ByteString
-  ,module Text.Regex.TDFA.ByteString.Lazy
-  ,module Text.Regex.TDFA.Sequence
+  --,module Text.Regex.TDFA.String
+  --,module Text.Regex.TDFA.ByteString
+  --,module Text.Regex.TDFA.ByteString.Lazy
+  --,module Text.Regex.TDFA.Sequence
hunk ./regex-tdfa.cabal 16
-Build-Depends:  regex-base = 0.80, base = 2.0, parsec, mtl
+Build-Depends:  regex-base = 0.80, base = 2.0, parsec, mtl, 
containers, array, bytestring
}





Stefan O'Rear [EMAIL PROTECTED] 
08/17/2007 04:47 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] trouble compiling import GHC.Prim(MutableByteArray#, 
.  (building regex-tdfa from   darcs) -- what's that # sign 
doing?






On Fri, Aug 17, 2007 at 04:27:29PM -0400, Thomas Hartman wrote:
 trying to compile regex-tdfa, I ran into another issue. (earlier I had a 

 cabal problem but that's resolved.)
 
 there's a line that won't compile, neither for ghc 6.6.1 nor 6.7 
 
 import 
 
GHC.Prim(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,unsafeCoerce#)
 
 so the fresh darcs regex tdfa package won't build.
 
 This line (line 16 below) causes this error for 
 
   ghc -e '' RunMutState.hs
 
 for both ghc 6.1 and 6.7 

There are at least two things going on here.

1. GHC-specific unboxed identifiers have a # in the name.   I think this
   is a relic from back when the only reasonable way to namespace was to
   modify your compiler to add extra identifier characters, and use them
   in all non-portable identifiers.  In any case, you have to enable the
   -fglasgow-exts option (or -XMagicHash in recent 6.7) to allow imports
   of such identifiers.

2. Explicitly importing GHC.Prim has been discouraged for as long as I
   can remember, and GHC HQ has finally made good on the promise to make
   it impossible.  Code which imports it has a bug already, which can be
   fixed by switching to GHC.Exts.  (Why?  GHC.Prim is wired into the
   compiler, while GHC.Exts is a normal Haskell module, so by using
   GHC.Exts you are insulated from questions of what is primitive and
   what is derived but still unportable.  Yes, this does change.)

Stefan
[attachment signature.asc deleted by Thomas Hartman/ext/dbcom] 


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility?

2007-08-20 Thread Thomas Hartman
cafe, is there a way to patch the build-depends line of a cabal file 
without breaking backwards compatibility? 

I just patched HDBC head to compile under ghc 6.7. Unfortunately it now 
won't compile in 6.6.1. 

is there a way for build-depends to detect which version of ghc you're on?

also I seem to recall that -fglasgow-exts was deprecated under 6.7. is 
there a better way to beat back the error message below than this?

thanks,

thomas.

{
hunk ./Database/HDBC/Statement.hs 1
+{-# LANGUAGE TypeSynonymInstances #-}
hunk ./Database/HDBC/Types.hs 1
+{-# OPTIONS_GHC -fglasgow-exts #-}
+{-
+-- without -fglasgow-exts you get: [_$_]
+Database/HDBC/Types.hs:202:0:
+Illegal polymorphic or qualified type: forall conn.
+  (IConnection conn) =
+  conn - b
+In the type signature for `withWConn':
+  withWConn :: forall b.
+  ConnWrapper - (forall conn. (IConnection conn) = conn 
- b) - b
+-}
hunk ./HDBC.cabal 13
-Build-Depends: base, mtl
+
+Build-Depends: base, mtl, old-time, bytestring, containers
+-- breaks backwards compability with ghc 6.6.1
+
}


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] cabal install of HDBC-odbc fails on ghc 6.7, -I flag causes problems

2007-08-20 Thread Thomas Hartman
problemw with the -I flag to ghc are causing cabal install to fail for 
hdbc-odbc (darcs head).

man ghc still reports that -I is a valid flag after installing ghc 6.7 
from darcs head a couple days ago.

I think the problem might be the space after the -I flag (which is bad for 
both 6.6.1 and 6.7)

[EMAIL 
PROTECTED]:~/installs/HDBC-odbc-head/hdbc-odbc/usr/local/bin/ghc-6.7.20070816 
  -I. -e '' Setup.hs
[EMAIL 
PROTECTED]:~/installs/HDBC-odbc-head/hdbc-odbc/usr/local/bin/ghc-6.7.20070816 
  -I/ -e '' Setup.hs
[EMAIL 
PROTECTED]:~/installs/HDBC-odbc-head/hdbc-odbc/usr/local/bin/ghc-6.7.20070816 
  -I / -e '' Setup.hs
ghc-6.7.20070816: unrecognised flags: -I

just a guess... 

anothing thing is it seems like there's a new INCLUDE pragma in 6.7. 
perhaps this should be used in one of the source files to get it to 
compile. but which one? I couldn't figure out what was causing 

  ghc -c -I dist/build/Database/HDBC/ODBC/Connection_hsc_make.c -o 
dist/build/Database/HDBC/ODBC/Connection_hsc_make.o

to be run. (I did try grepping on ghc but no luck, below.)

Any tips on debugging this cabal install would be appreciated.

thanks,

thomas

*

$ runghc Setup.hs configure; runghc Setup.hs build

.

configure: Using tar found on system at: /bin/tar
Reading parameters from 
/home/hartthoma/installs/HDBC-odbc-head/hdbc-odbc/HDBC-odbc.buildinfo
Preprocessing library 
[EMAIL PROTECTED]:~/installs/HDBC-odbc-head/hdbc-odbcdarcs 
whatsnew.0...
ghc-6.7.20070816: unrecognised flags: -I
Usage: For basic information, try the `--help' option.
compiling dist/build/Database/HDBC/ODBC/Connection_hsc_make.c failed
command was: ghc -c -I dist/build/Database/HDBC/ODBC/Connection_hsc_make.c 
-o dist/build/Database/HDBC/ODBC/Connection_hsc_make.o




[EMAIL PROTECTED]:~/installs/HDBC-odbc-head/hdbc-odbcdarcs whatsnew
{
hunk ./Setup.hs 8
-main = defaultMainWithHooks defaultUserHooks{preConf = conf, postConf = 
ok}
-   where ok _ _ _ _ = return ExitSuccess
+--main = defaultMainWithHooks defaultUserHooks{preConf = conf, postConf = 
ok}
+--   where ok _ _ _ _ = return ExitSuccess
+main = do
+  let ok _ _ _ _ = do return ExitSuccess
+  return ()
+in defaultMainWithHooks defaultUserHooks{preConf = conf, postConf = 
ok}
+  return ()
+
}

.

[EMAIL PROTECTED]:~/installs/HDBC-odbc-head/hdbc-odbcgrep -i ghc *
HDBC-odbc.buildinfo:ghc-prof-options:
HDBC-odbc.buildinfo:ghc-options:
HDBC-odbc.cabal:GHC-Options: -O2
Makefile:GHCPARMS := -fglasgow-exts
Makefile:all: setup # GHC build
Makefile:   ghc -package Cabal Setup.hs -o setup
Makefile:   cd testsrc  ghc --make -package mtl -package HUnit 
-package MissingH -package HDBC -lodbc $(GHCPARMS) -o runtests 
-i../dist/build:.. ../d\
ist/build/hdbc-odbc-helper.o runtests.hs
Makefile:test-ghc6: testsrc/runtests
Makefile:interact-ghci: all
Makefile:   ghci -idist/build -Ldist/build $(GHCPARMS)
Makefile:test: test-ghc6 test-hugs
README.txt:You'll need either GHC 6.4.1 or above, or Hugs 2005xx or above. 
 If
README.txt:2) ghc --make -o setup Setup.lhs
README.txt:To use with GHC, you'll want to use:


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] can't build haxml under ghc 6.7, says HughesPJ is hidden... but ghc-pkg doesn't say it's hidden...

2007-08-20 Thread Thomas Hartman
so you get

$ runghc Setup.hs configure
Setup.hs: Multiple description files found.  Please use only one of : 
[HaXml.cabal,HaXml-darcs.cabal]

is there a way to specify which cabal file should be used, or do you just 
have to  move a file out out the way with eg

  mv HaXml.cabal HaXml.cabal.tmp ? 

Understanding this better is important to me because I am installing a 
number of packages on 6.7, and am reluctant to send a patch that breaks 
backwards compabitility with earlier versions.

It seems to me that if there is a way to specify the cabal file, you're a 
step closer to having something DWIM that works for either 6.6 or 6.7, as 
Claus wishlists elsewhere in this thread. 

thomas.




Malcolm Wallace [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/10/2007 08:31 AM

To
haskell-cafe@haskell.org
cc

Subject
Re: [Haskell-cafe] can't build haxml under ghc 6.7, says HughesPJ   is 
hidden... but ghc-pkg doesn't say it's hidden...






Stefan O'Rear [EMAIL PROTECTED] wrote:

 When you build a package, Cabal passess the -hide-all-packages option
 to GHC, which prevents the package from using any installed packages
 other than the ones explicitly listed in the Build-Depends: field.
 
 For now, we just edit .cabal files when transporting code between GHC
 versions...

Just for information, the HaXml darcs repo has recently adopted the
solution of containing two .cabal files, one for ghc-6.6.x, and the
other for the split-base packages (=ghc-6.7).  The only difference is
the build-depends line, which is now as follows:

build-depends: base, haskell98, polyparse, pretty, fps

But if you have collected the earlier release HaXml-1.13.2 from hackage,
then you can omit both 'polyparse' and 'fps' dependencies.  ('fps' will
shortly be changing to 'bytestring' in any case...)

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility?

2007-08-20 Thread Thomas Hartman
 Take a look at the Cabal.cabal file, how this is solved, atm.

where is this, how can I take a look at it?

 The next release of Cabal (and the current HEAD) supports  conditionals

I couldn't install head, but since I'm running 6.7, do I already have it?

[EMAIL PROTECTED]:~/installs/cabal-head/cabalrunghc Setup.lhs configure

Distribution/Simple/InstallDirs.hs:267:36:
Not in scope: `dropDrive'

[EMAIL PROTECTED]:~/installs/cabal-head/caballs -l `which ghc`
lrwxrwxrwx 1 root root 31 2007-08-20 11:08 /usr/local/bin/ghc - 
/usr/local/bin/ghc-6.7.20070816


[EMAIL PROTECTED]:~/installs/cabal-head/cabalghc-pkg list | grep -i cabal
Cabal-1.1.7

  Please also note that this might not be the 
 best way to use the new features;  as I suggested in another thread, 
 simulating base-1.0 on systems with base-2.0 is probably best handled 
 with a base.cabal file that imports base-2.0, old-time, etc. and re- 
 exports all imported modules to get a virtual base-1.0.

I'm interested in seeing how this works, but I couldn't find that other 
thread.

Where is the documentation for the new functionality in cabal head, or do 
you just have to read the source code for now?

thanks, t




Thomas Schilling [EMAIL PROTECTED] 
08/20/2007 01:37 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] is there a way to patch the build-depends line of a 
cabal file without breaking backwards compatibility?







On 20 aug 2007, at 18.37, Thomas Hartman wrote:


 cafe, is there a way to patch the build-depends line of a cabal 
 file without breaking backwards compatibility?

 I just patched HDBC head to compile under ghc 6.7. Unfortunately it 
 now won't compile in 6.6.1.

 is there a way for build-depends to detect which version of ghc 
 you're on?

 also I seem to recall that -fglasgow-exts was deprecated under 6.7. 
 is there a better way to beat back the error message below than this?


The next release of Cabal (and the current HEAD) supports 
conditionals to test for flags, os/arch, and implementation 
(+version).  Note that the problem isn't the GHC version, but the new 
base version, in which the old base was split up into smaller 
packages, so we have something roughly like:  base-1.0 = base-2.0 + 
bytestring + old-time + mtl.  Take a look at the Cabal.cabal file, 
how this is solved, atm.  Please also note that this might not be the 
best way to use the new features;  as I suggested in another thread, 
simulating base-1.0 on systems with base-2.0 is probably best handled 
with a base.cabal file that imports base-2.0, old-time, etc. and re- 
exports all imported modules to get a virtual base-1.0.

/ Thomas




---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] -f flag to runghc broken, or is it just me? (because trying switch elegantly between ghc 6.6 and ghc 6.7)

2007-08-22 Thread Thomas Hartman
I'm doing a lot of switching between ghc 6.6 and ghc 6.7 on the same 
computer. I install modules using

  $ runghc Setup.hs configure 
etc.

I would like to specify which version of ghc should be getting the package 
installed via the f flag to runghc

  $ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingrunghc
  runghc: syntax: runghc [-f GHCPATH] [GHC-ARGS] FILE ARG...

but this appears to be broken.

  $ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingrunghc
 
arghandling-nice.hs
  arghandling-nice.hs: args length does not equal 3. args: : []
  usage example: $ runghc arghandling-nice.hs firstarg secondarg thirdarg

without the flag works but 

  $ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingrunghc
 
-f /usr/local/bin/ghc-6.6.1  arghandling-nice.hs

does nothing.

$ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingls 
-l /usr/local/bin/ghc-6.6.1
-rwxr-xr-x 1 root root 151 2007-06-16 20:22 /usr/local/bin/ghc-6.6.1

In general I don't like using runghc because it doesn't appear to be 
documented anywhere except that (incorrect?) usage message. Is there a way 
to do a package install just using ghc -e? (Sure I could compile, but it 
helps me sometimes if I can not, a la runghc.) At any rate I couldn't 
figure out how to pass arguments to main via ghc -e.



  $ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingcat 
arghandling-nice.hs
  import System

  main = do args - getArgs
  let usagemsg = usage example: $ runghc arghandling-nice.hs 
firstarg secondarg thirdarg
  case args of
[first,second,third] - process first second third
_- error $ args length does not equal 3. 
args: :  ++ ( show args ) ++ \n ++ usagemsg

  process a b c = print $ unwords [a,b,c]

Thanks for anybody who can help me out with this.

Thomas.

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


workaround found, pipe it through ghci Re: [Haskell-cafe] -f flag to runghc broken, or is it just me? (because trying switch elegantly between ghc 6.6 and ghc 6.7)

2007-08-22 Thread Thomas Hartman
this works. now if only there were a quiet option for ghci...

well, for me, I guess this may be goodbye to poor sad undocumented 
malfunctioning runghc..

[EMAIL 
PROTECTED]:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingecho
 
:main 1 2 3 | /usr/local/bin/ghci-6.6.1 arghandling-nice.hs
   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |  GHC Interactive, version 6.6.1, for Haskell 98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Loading package base ... linking ... done.
[1 of 1] Compiling Main ( arghandling-nice.hs, interpreted )
Ok, modules loaded: Main.
*Main Loading package haskell98 ... linking ... done.
1 2 3
*Main Leaving GHCi.





Thomas Hartman [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/22/2007 01:38 PM

To
haskell-cafe@haskell.org haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] -f flag to runghc broken, or is it just me? (because trying 
switch elegantly between ghc 6.6 and ghc 6.7)







I'm doing a lot of switching between ghc 6.6 and ghc 6.7 on the same 
computer. I install modules using 

  $ runghc Setup.hs configure 
etc. 

I would like to specify which version of ghc should be getting the package 
installed via the f flag to runghc 

  $ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingrunghc
 

  runghc: syntax: runghc [-f GHCPATH] [GHC-ARGS] FILE ARG... 

but this appears to be broken. 

  $ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingrunghc
 
arghandling-nice.hs 
  arghandling-nice.hs: args length does not equal 3. args: : [] 
  usage example: $ runghc arghandling-nice.hs firstarg secondarg thirdarg 

without the flag works but 

  $ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingrunghc
 
-f /usr/local/bin/ghc-6.6.1  arghandling-nice.hs 

does nothing. 

$ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingls 
-l /usr/local/bin/ghc-6.6.1 
-rwxr-xr-x 1 root root 151 2007-06-16 20:22 /usr/local/bin/ghc-6.6.1 

In general I don't like using runghc because it doesn't appear to be 
documented anywhere except that (incorrect?) usage message. Is there a way 
to do a package install just using ghc -e? (Sure I could compile, but it 
helps me sometimes if I can not, a la runghc.) At any rate I couldn't 
figure out how to pass arguments to main via ghc -e. 



  $ 
:~/personal/PersonalRepos/pharchive/learning/haskell/UnixTools/arghandlingcat 
arghandling-nice.hs 
  import System 

  main = do args - getArgs 
  let usagemsg = usage example: $ runghc arghandling-nice.hs 
firstarg secondarg thirdarg 
  case args of 
[first,second,third] - process first second third 
_- error $ args length does not equal 3. 
args: :  ++ ( show args ) ++ \n ++ usagemsg 

  process a b c = print $ unwords [a,b,c] 

Thanks for anybody who can help me out with this. 

Thomas. 
---

This e-mail may contain confidential and/or privileged information. If you 

are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] runInteractiveCommand behaves differently on linux and windows

2007-08-28 Thread Thomas Hartman
Maybe this is by design, but I just thought I would point this behavior 
out and ask for comment.

test1 merely shows that runInteractiveCommand reacts differently to perl 
warnings than perl errors. Okay, maybe the inconsistency in that case is 
due to perl and not haskell.

test2 behaves the same on win and nix. This is pipe like in that the 
ouptut of a command (which could be the result of a shell call, but just 
as easily be the return of a haskell function) gets fed into a shell 
command. In this case, if the shell command is simply tail the behavior 
is consistent from win to nix.

test3 shows that the behavior stops being consistent if ssh enters the 
picture. (piping to tail via ssh). again, maybe this is due to ssh and not 
haskell.

however... note however that on windows

ghc -e 'mapM_ ( putStrLn . show ) [1..1000] ' | ssh [EMAIL PROTECTED] 
'tail -n2'

works fine.  so it's not *just* ssh, but ssh in conjuction with 
runInteractiveCommand which seems to cause problems

FWIW, using 10 lines instead of 1000 still hangs on windows.

Is there a way to code up shell pipelike behavior in a more portable way?

curious what the cafe thinks...

thomas.

import Test.HUnit
import Misc ( (=^) )
import System.Process
import System.IO
import System.Exit

-- works on linux, error on windows

test1 = do 
  res1 - test_shellrunStderrOk
  runTestTT $ TestCase ( assertEqual test1 made it  res1 )
  where test_shellrunStderrOk = do
  runprocessStdErrAllowed'  cmdPerlwarn
  return made it
cmdPerldie =   perl -e 'die \error\' 
cmdPerlwarn =  perl -e 'warn \blee\' 

-- works on linux, windows
test2 = pipeTo tail -n2

-- works on linux, hangs on windows
test3 = pipeTo ssh [EMAIL PROTECTED] 'tail -n2'

pipeTo cmd = do
  res2 - test_shellrunPipeinLike
  runTestTT $ TestCase ( assertEqual ( pipe to, cmd:  ++ cmd) (show l) 
res2 )
  where test_shellrunPipeinLike = do
  runprocessStdErrAllowed' (unlines $ map show [1..l]) ( cmd )
  =^ filter (not . ( == '\n') )
l = 1000

runprocessStdErrAllowed' inp s = do
(ih,oh,eh,pid) - runInteractiveCommand s
so - hGetContents oh
se - hGetContents eh
hPutStrLn ih inp
hClose ih
ex - waitForProcess pid
case ex of
ExitFailure e  - fail $ shell command  ++ s ++ \nFailed 
with status:  ++ show e
_   | otherwise - return so



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal install of HDBC-odbc fails on ghc 6.7, -I flag causes problems

2007-08-28 Thread Thomas Hartman
Well, I built with -v3 as suggested, but the ouptut doesn't seem that 
helpful to me. ghc compile commands, at any rate, do not appear to be 
outputted


$ echo :main build | /usr/local/bin/ghci-6.7.20070816 -v3 Setup.hs 
1build.out 2build.err

build.out: 

GHCi, version 6.7.20070816: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Ok, modules loaded: Main.
*Main Loading package array-0.1 ... linking ... done.
Loading package containers-0.1 ... linking ... done.
Loading package old-locale-1.0 ... linking ... done.
Loading package old-time-1.0 ... linking ... done.
Loading package filepath-1.0 ... linking ... done.
Loading package directory-1.0 ... linking ... done.
Loading package unix-2.0 ... linking ... done.
Loading package process-1.0 ... linking ... done.
Loading package pretty-1.0 ... linking ... done.
Loading package Cabal-1.1.7 ... linking ... done.
Reading parameters from 
/home/hartthoma/installs/HDBC-odbc-1.0.1.0/HDBC-odbc.buildinfo
Preprocessing library HDBC-odbc-1.0.1.0...
*** Exception: exit: ExitFailure 1
*Main Leaving GHCi.

build.err: 

Glasgow Haskell Compiler, Version 6.7.20070816, for Haskell 98, stage 2 
booted by GHC version 6.6.1
Using package config file: /usr/local/lib/ghc-6.7.20070816/package.conf
hiding package regex-base-0.72 to avoid conflict with later version 
regex-base-0.91
hiding package HDBC-1.0.1 to avoid conflict with later version HDBC-1.1.2
wired-in package base mapped to base-2.1
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0
wired-in package template-haskell mapped to template-haskell-0.1
wired-in package ndp not found.
Hsc static flags: -static
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
*** Chasing dependencies:
Chasing modules from: 
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep []
Upsweep completely successful.
*** Deleting temp files:
Deleting: 
*** Chasing dependencies:
Chasing modules from: Setup.hs
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep
  [NONREC
  ModSummary {
 ms_hs_date = Mon Aug 20 09:49:47 EDT 2007
 ms_mod = main:Main,
 ms_imps = [System.Exit, Distribution.PackageDescription,
Distribution.Simple.Utils, Data.List, System.Info,
Distribution.Simple]
 ms_srcimps = []
  }]
compile: input file Setup.hs
*** Checking old interface for main:Main:
[1 of 1] Compiling Main ( Setup.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size = 435
*** Simplify:
Result size = 464
Result size = 437
*** Tidy Core:
Result size = 437
*** CorePrep:
Result size = 491
*** ByteCodeGen:
*** Deleting temp files:
Deleting: 
Upsweep completely successful.
*** Deleting temp files:
Deleting: 
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
ghc-6.6.1: unrecognised flags: -I
Usage: For basic information, try the `--help' option.
compiling dist/build/Database/HDBC/ODBC/Connection_hsc_make.c failed
command was: ghc -c -I dist/build/Database/HDBC/ODBC/Connection_hsc_make.c 
-o dist/build/Database/HDBC/ODBC/Connection_hsc_make.o
*** Deleting temp files:
Deleting: 
*** Deleting temp dirs:
Deleting: 








Duncan Coutts [EMAIL PROTECTED] 
08/22/2007 04:53 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] cabal install of HDBC-odbc fails on ghc 6.7, -I flag 
causes problems






On Mon, 2007-08-20 at 13:10 -0400, Thomas Hartman wrote:
 
 problemw with the -I flag to ghc are causing cabal install to fail for
 hdbc-odbc (darcs head). 

 Any tips on debugging this cabal install would be appreciated. 

 $ runghc Setup.hs configure; runghc Setup.hs build 

Try with -v3 is:

runghc Setup.hs build -v3

this will give extremely verbose output. We'd like to see the last bit
to see what ghc command line exactly is failing. It'll show the command
line arguments in Haskell show format eg [-I, /]

Duncan





---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal install of HDBC-odbc fails on ghc 6.7, -I flag causes problems

2007-08-29 Thread Thomas Hartman
Ah ok, so I did 

echo :main build -v3 | /usr/local/bin/ghci-6.7.20070816 Setup.hs 
1build.out 2build.err 

and this does indeed seem more informative. advice?

build.err: 

[1 of 1] Compiling Main ( Setup.hs, interpreted )
ghc-6.6.1: unrecognised flags: -I
Usage: For basic information, try the `--help' option.
compiling dist/build/Database/HDBC/ODBC/Connection_hsc_make.c failed
command was: ghc -c -I dist/build/Database/HDBC/ODBC/Connection_hsc_make.c 
-o dist/build/Database/HDBC/ODBC/Connection_hsc_make.o

build.out: 

GHCi, version 6.7.20070816: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Ok, modules loaded: Main.
*Main Loading package array-0.1 ... linking ... done.
Loading package containers-0.1 ... linking ... done.
Loading package old-locale-1.0 ... linking ... done.
Loading package old-time-1.0 ... linking ... done.
Loading package filepath-1.0 ... linking ... done.
Loading package directory-1.0 ... linking ... done.
Loading package unix-2.0 ... linking ... done.
Loading package process-1.0 ... linking ... done.
Loading package pretty-1.0 ... linking ... done.
Loading package Cabal-1.1.7 ... linking ... done.
Reading parameters from 
/home/hartthoma/installs/HDBC-odbc-1.0.1.0/HDBC-odbc.buildinfo
Creating dist/build (and its parents)
Creating dist/build/autogen (and its parents)
Preprocessing library HDBC-odbc-1.0.1.0...
Creating dist/build/Database/HDBC/ODBC (and its parents)
(/usr/local/bin/hsc2hs,[-D__GLASGOW_HASKELL__=606,--cflag=-I,--lflag=-lodbc,-o,dist/build/Database/HDBC/ODBC/Connection.hs,Database/HDBC/ODBC/Connection.hsc])
*** Exception: exit: ExitFailure 1
*Main Leaving GHCi.







Duncan Coutts [EMAIL PROTECTED] 
08/28/2007 08:08 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] cabal install of HDBC-odbc fails on ghc 6.7, -I flag 
causes problems






On Tue, 2007-08-28 at 18:19 -0400, Thomas Hartman wrote:
 
 Well, I built with -v3 as suggested, but the ouptut doesn't seem that
 helpful to me. ghc compile commands, at any rate, do not appear to be
 outputted 

Sorry, I meant to pass -v3 to cabal, not to ghc compiling/running
Setup.hs

 $ echo :main build | /usr/local/bin/ghci-6.7.20070816 -v3 Setup.hs
 1build.out 2build.err 

like:

runghc Setup.hs build -v3


Duncan




---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] runInteractiveCommand behaves differently on linux and windows

2007-08-29 Thread Thomas Hartman
I probably should have also mentioned that the fail on windows is for me 
ssh-ed to that box remotely, where the sshd program is cygwin.





Thomas Hartman [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/28/2007 06:03 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] runInteractiveCommand behaves differently on linux and 
windows







Maybe this is by design, but I just thought I would point this behavior 
out and ask for comment. 

test1 merely shows that runInteractiveCommand reacts differently to perl 
warnings than perl errors. Okay, maybe the inconsistency in that case is 
due to perl and not haskell. 

test2 behaves the same on win and nix. This is pipe like in that the 
ouptut of a command (which could be the result of a shell call, but just 
as easily be the return of a haskell function) gets fed into a shell 
command. In this case, if the shell command is simply tail the behavior 
is consistent from win to nix. 

test3 shows that the behavior stops being consistent if ssh enters the 
picture. (piping to tail via ssh). again, maybe this is due to ssh and not 
haskell. 

however... note however that on windows 

ghc -e 'mapM_ ( putStrLn . show ) [1..1000] ' | ssh [EMAIL PROTECTED] 
'tail -n2' 

works fine.  so it's not *just* ssh, but ssh in conjuction with 
runInteractiveCommand which seems to cause problems 

FWIW, using 10 lines instead of 1000 still hangs on windows. 

Is there a way to code up shell pipelike behavior in a more portable way? 

curious what the cafe thinks... 

thomas. 

import Test.HUnit 
import Misc ( (=^) ) 
import System.Process 
import System.IO 
import System.Exit 

-- works on linux, error on windows 

test1 = do 
  res1 - test_shellrunStderrOk 
  runTestTT $ TestCase ( assertEqual test1 made it  res1 ) 
  where test_shellrunStderrOk = do 
  runprocessStdErrAllowed'  cmdPerlwarn 
  return made it 
cmdPerldie =   perl -e 'die \error\'  
cmdPerlwarn =  perl -e 'warn \blee\'  

-- works on linux, windows 
test2 = pipeTo tail -n2 

-- works on linux, hangs on windows 
test3 = pipeTo ssh [EMAIL PROTECTED] 'tail -n2' 

pipeTo cmd = do 
  res2 - test_shellrunPipeinLike 
  runTestTT $ TestCase ( assertEqual ( pipe to, cmd:  ++ cmd) (show l) 
res2 ) 
  where test_shellrunPipeinLike = do 
  runprocessStdErrAllowed' (unlines $ map show [1..l]) ( cmd ) 
  =^ filter (not . ( == '\n') ) 
l = 1000 

runprocessStdErrAllowed' inp s = do 
(ih,oh,eh,pid) - runInteractiveCommand s 
so - hGetContents oh 
se - hGetContents eh 
hPutStrLn ih inp 
hClose ih 
ex - waitForProcess pid 
case ex of 
ExitFailure e  - fail $ shell command  ++ s ++ \nFailed 
with status:  ++ show e 
_   | otherwise - return so 


---

This e-mail may contain confidential and/or privileged information. If you 

are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] trouble compiling regex posix head (I think 0.92) on ghc 6.7

2007-08-29 Thread Thomas Hartman
I'm trying to compile regex-posix on ghc 6.7. (Ultimate goal: happs on 
6.7).

First, I patched by changing the cabal file to be compatible with the new 
libraries broken out of base. I also had to add HsRegexPosixConfig.h to 
include/regex (I just copied it from somewhere else on my hard drive where 
I guess it had been put by an earlier regex-posix install, I don't know if 
it's compatible here but at least it permitted things to compile further.) 


Setup.hs build -v3 had a lot of warnigs but didn't seem to fail. However, 
Setup.hs install -v3 didn't work. 

the problem in build seems to occur around upsweep partially failed or 
main not exported...

[6 of 6] Compiling Text.Regex.Posix ( Text/Regex/Posix.hs, 
dist/build/Text/Regex/Posix.o )
*** Parser:
*** Renamer/typechecker:

Text/Regex/Posix.hs:57:2:
Warning: The export item `module Text.Regex.Posix.String' exports 
nothing

Text/Regex/Posix.hs:59:2:
Warning: The export item `module Text.Regex.Posix.Sequence' exports 
nothing

Text/Regex/Posix.hs:61:2:
Warning: The export item `module Text.Regex.Posix.ByteString' exports 
nothing

Text/Regex/Posix.hs:63:2:
Warning: The export item `module Text.Regex.Posix.ByteString.Lazy' 
exports nothing
*** Deleting temp files:
Deleting: /tmp/ghc9618_0/ghc9618_0.s
Warning: deleting non-existent /tmp/ghc9618_0/ghc9618_0.s
Upsweep partially successful.
*** Deleting temp files:
Deleting: 
link(batch): upsweep (partially) failed OR
   Main.main not exported; not linking.
*** Deleting temp files:
Deleting: 
*** Deleting temp dirs:
Deleting: /tmp/ghc9618_0

complete output (along with patch) is attached.

I'd appreciate any advice. 

best, thomas. 




---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.{
addfile ./include/regex/HsRegexPosixConfig.h
hunk ./include/regex/HsRegexPosixConfig.h 1
+/* include/HsRegexPosixConfig.h.  Generated by configure.  */
+/* include/HsRegexPosixConfig.h.in.  Generated from configure.ac by 
autoheader.  */
+
+/* Define to 1 if you have the inttypes.h header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the memory.h header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have a POSIX regex library installed */
+#define HAVE_POSIX_REGEX 1
+
+/* Define to 1 if you have the `regcomp' function. */
+#define HAVE_REGCOMP 1
+
+/* Define to 1 if you have the regex.h header file. */
+#define HAVE_REGEX_H 1
+
+/* Define to 1 if you have the stdint.h header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the stdlib.h header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the strings.h header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the string.h header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the sys/stat.h header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the sys/types.h header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the unistd.h header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT [EMAIL PROTECTED]
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME Haskell regex-posix package
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING Haskell regex-posix package 0.71
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME regex-posix
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION 0.71
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
hunk ./regex-posix.cabal 16
-Build-Depends:  regex-base = 0.80, base = 2.0
+Build-Depends:  regex-base = 0.80, base = 2.0, array, containers, 
bytestring
hunk ./regex-posix.cabal 43
-Include-Dirs:   include
+Include-Dirs:   include/regex
}


regex-posix-0.92-build
Description: Binary data


regex-posix-0.92-install
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] compiling happs under 6.7 (unbound implicit parameter error)

2007-08-29 Thread Thomas Hartman
After much progress and learning, I'm stuck again trying to get happs to 
compile under ghc 6.7. (Hoping that running happs under the new ghc 
debugger will help me understand it better.)

I was trying to compile from the stable 8.8 version, unzipped and with 
just a few modifications. (see attached zip).

The problem has to do with an unbound implicit parameter 

[53 of 72] Compiling HAppS.Protocols.MessageWrap.W ( 
src/HAppS/Protocols/MessageWrap/W.hs, 
dist/build/HAppS/Protocols/MessageWrap/W.o )

src/HAppS/Protocols/MessageWrap/W.hs:209:63:
Unbound implicit parameter (?style::Element - XML Element)
  arising from a use of `xmlWrapM'
   at src/HAppS/Protocols/MessageWrap/W.hs:209:63-72
In the expression: xmlWrapM v
In the definition of `ehShow'':
ehShow' (DynException e)
  | Just (DynErr' v) - fromDynamic e = xmlWrapM v


I'd appreciate any advice. 

thomas.



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

happs88.build
Description: Binary data


W.hs
Description: Binary data


happs8.8patchforghc67
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] darcs behind firewall

2007-08-30 Thread Thomas Hartman
If you are on linux (I'm on ubuntu) you should be able to set 

export http_proxy=http://proxyserver.com:1234
export https_proxy=http://proxyserver.com:123

vars, per what your sysadmin says. In my case, these are set to the same 
var that permits me to use firefox via the proxy, in firefox - edit- 
preferences - network tab - connection settings, http proxy.

and darcs should just work

thomas.





Sukit Tretriluxana [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/30/2007 03:54 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] darcs behind firewall






Hi all,

Does anyone know how to specify proxy server and port for darcs to use 
when it connects to servers? I am behind firewall most of the time and all 
requests have to go through a proxy.

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] happs on ghc 6.7 won't work because of dependency on Data.Binary (everything that depends on Data.Binary broken at present) ( unknown symbol `stg_uncheckedShiftRL64' )

2007-08-30 Thread Thomas Hartman
happs on ghc 6.7 won't work because of dependency on Data.Binary, since 
everything that depends on Data.Binary is broken at present.

This is for Data.Binary installed via cabal from darcs get --partial 
http://darcs.haskell.org/binary . Cabal installed without any errors, but 
perhaps there should have been one since it appears broke.

So I think my project of using the ghc debugger to help understand happs 
is on ice until this gets resolved.

Unless this has been fixed since August 16. (Anyone out there got a more 
recent version?)

$ cat UseDataBinary.hs
import Data.Binary

main = putStrLn hello world

$ /usr/local/bin/ghc-6.6.1 -e 'main' UseDataBinary.hs
hello world

$ /usr/local/bin/ghc-6.7.20070816 -e 'main' UseDataBinary.hs
interactive: /usr/local/lib/binary-0.3/ghc-6.7.20070816/HSbinary-0.3.o: 
unknown symbol `stg_uncheckedShiftRL64'
ghc-6.7.20070816: unable to load package `binary-0.3'

$ /usr/local/bin/ghc-6.7.20070816 -e '' UseDataBinary.hs




---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: trouble compiling regex posix head (I think 0.92) on ghc 6.7

2007-08-30 Thread Thomas Hartman
I darcs pulled cabal head to get latest cabal, removed -Werror from 
GHC-Options in the cabal file, removed HsRegexPosixConfig.h and tried 
again with the same result.

It seems to really want that file. With, it installs, without, no install.

$ darcs whatsnew
{
hunk ./regex-posix.cabal 16
-Build-Depends:  regex-base = 0.80, base = 2.0
+Build-Depends:  regex-base = 0.80, base = 2.0, array, 
containers, byt
estring
hunk ./regex-posix.cabal 32
-GHC-Options:-Wall -Werror -O2
+GHC-Options:-Wall -O2
hunk ./regex-posix.cabal 43
-Include-Dirs:   include
+Include-Dirs:   include/regex
}
 



Chris Kuklewicz [EMAIL PROTECTED] 
08/30/2007 12:34 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe@haskell.org, [EMAIL PROTECTED] [EMAIL PROTECTED]
Subject
Re: trouble compiling regex posix head (I think 0.92) on ghc 6.7






Thomas Hartman wrote:
 
 I'm trying to compile regex-posix on ghc 6.7. (Ultimate goal: happs on
 6.7).

I have not explored ghc 6.7.  You should also try posting on the
[EMAIL PROTECTED] mailing list.

 
 First, I patched by changing the cabal file to be compatible with the
 new libraries broken out of base. I also had to add HsRegexPosixConfig.h
 to include/regex (I just copied it from somewhere else on my hard drive
 where I guess it had been put by an earlier regex-posix install, I don't
 know if it's compatible here but at least it permitted things to compile
 further.)

I had no idea what HsRegexPosixConfig was, and I have no such file at all.
So I looked in Wrap.hsc and found:

 #ifdef HAVE_REGEX_H
 #define HAVE_REGCOMP 1
 #else
 #ifndef __NHC__
 #include HsRegexPosixConfig.h
 #else
 #define HAVE_REGEX_H 1
 #define HAVE_REGCOMP 1
 #endif
 #endif

Note that I did not write that section -- that was added by someone else.

So HsRegexPosixConfig.h should only matter if HAVE_REGEX_H is undefined. 
The
regex-base.cabal file says:
CC-Options: -DHAVE_REGEX_H
So unless Cabal is having a very very bad day, I assume that
HsRegexPosixConfig.h is never needed.

That it matters to your build to have that file seems _wrong_ to me.

The only header file it should need is regex.h

 Setup.hs build -v3 had a lot of warnings but didn't seem to fail.
 However, Setup.hs install -v3 didn't work.

You might try to change the cabal file.  Currently I think it is
GHC-Options:-Wall -Werror -O2
and remove -Werror
GHC-Options:-Wall -O2

And you can change the cabal Include-Dirs to point to wherever it will 
find
regex.h

 the problem in build seems to occur around upsweep partially failed or
 main not exported...

That means nothing to me.

 
 [6 of 6] Compiling Text.Regex.Posix ( Text/Regex/Posix.hs,
 dist/build/Text/Regex/Posix.o )
 *** Parser:
 *** Renamer/typechecker:
 
 Text/Regex/Posix.hs:57:2:
 Warning: The export item `module Text.Regex.Posix.String' exports
 nothing
 
 Text/Regex/Posix.hs:59:2:
 Warning: The export item `module Text.Regex.Posix.Sequence' exports
 nothing
 
 Text/Regex/Posix.hs:61:2:
 Warning: The export item `module Text.Regex.Posix.ByteString'
 exports nothing
 
 Text/Regex/Posix.hs:63:2:
 Warning: The export item `module Text.Regex.Posix.ByteString.Lazy'
 exports nothing

Those warning are slightly bogus.  Including the module should export the 
instances.

 *** Deleting temp files:
 Deleting: /tmp/ghc9618_0/ghc9618_0.s
 Warning: deleting non-existent /tmp/ghc9618_0/ghc9618_0.s
 Upsweep partially successful.
 *** Deleting temp files:
 Deleting:
 link(batch): upsweep (partially) failed OR
Main.main not exported; not linking.
 *** Deleting temp files:
 Deleting:
 *** Deleting temp dirs:
 Deleting: /tmp/ghc9618_0
 
 complete output (along with patch) is attached.

 
 I'd appreciate any advice.
 
 best, thomas.
 
 




---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC 6.6.1 binary package for Ubuntu available?

2007-08-31 Thread Thomas Hartman
you may find this helpful.




Sukit Tretriluxana [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/31/2007 12:19 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] GHC 6.6.1 binary package for Ubuntu available?






Hi,

I am wondering if there is the binary package for GHC 6.6.1 for Ubuntu. I 
searched in the package manager and I only see the version 6.6.

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC 6.6.1 binary package for Ubuntu available?

2007-08-31 Thread Thomas Hartman
you may find this helpful. (with link)

http://www.haskell.org/pipermail/haskell-cafe/2007-April/024137.html




Sukit Tretriluxana [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/31/2007 12:19 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] GHC 6.6.1 binary package for Ubuntu available?






Hi,

I am wondering if there is the binary package for GHC 6.6.1 for Ubuntu. I 
searched in the package manager and I only see the version 6.6.

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] trying to install gutsy's libghc6-mtl-dev from source on feisty

2007-08-31 Thread Thomas Hartman
you may want to generate the .deb rather than take the deb that was 
packaged for gutsy.

http://www.haskell.org/pipermail/haskell-cafe/2007-April/024137.html

pupeno's guide to do this: 

http://pupeno.com/2006/12/17/unstable-packages-on-ubuntu/





Anatoly Yakovenko [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/31/2007 01:42 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] trying to install gutsy's libghc6-mtl-dev from   source on 
feisty






i have ghc6_6.6.1-2ubuntu2_i386.deb and
ghc6-prof_6.6.1-2ubuntu2_i386.deb installed, but i cant seem to get
mtl to install, can someone tell me what this output means?   i just
switched to a debian based system from gentoo, so i dont grok dpkg
yet:

[EMAIL PROTECTED]:~$ sudo dpkg -i libghc6-mtl-dev_1.0.1-2_i386.deb
(Reading database ... 129709 files and directories currently installed.)
Preparing to replace libghc6-mtl-dev 1.0-3 (using
libghc6-mtl-dev_1.0.1-2_i386.deb) ...
ghc-pkg: cannot find package mtl-1.0
dpkg: warning - old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
ghc-pkg: cannot find package mtl-1.0
dpkg: error processing libghc6-mtl-dev_1.0.1-2_i386.deb (--install):
 subprocess new pre-removal script returned error exit status 1
Reading package info from stdin ... done.
ghc-pkg: dependency base-2.0 doesn't exist (use --force to override)
dpkg: error while cleaning up:
 subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
 libghc6-mtl-dev_1.0.1-2_i386.deb
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] trying to install gutsy's libghc6-mtl-dev from source on feisty

2007-08-31 Thread Thomas Hartman
did you have a look at the pupeno blog link? He suggests using fakeroot 
apt-get source build. 

Not sure why the fakeroot, but perhaps it makes a difference.

thomas.




Anatoly Yakovenko [EMAIL PROTECTED] 
08/31/2007 01:56 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] trying to install gutsy's libghc6-mtl-dev from source 
on feisty






yea, i built the deb from gutsy's deb-src repository using apt-get source 
--build.  i am trying to figure out why that deb that i build doesn't work

On 8/31/07, Thomas Hartman [EMAIL PROTECTED] wrote:

you may want to generate the .deb rather than take the deb that was 
packaged for gutsy. 

http://www.haskell.org/pipermail/haskell-cafe/2007-April/024137.html 

pupeno's guide to do this: 

http://pupeno.com/2006/12/17/unstable-packages-on-ubuntu/ 




Anatoly Yakovenko [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED] 
08/31/2007 01:42 PM 


To
haskell-cafe@haskell.org 
cc

Subject
[Haskell-cafe] trying to install gutsy's libghc6-mtl-dev from source on 
feisty








i have ghc6_6.6.1-2ubuntu2_i386.deb and
ghc6-prof_6.6.1-2ubuntu2_i386.deb installed, but i cant seem to get
mtl to install, can someone tell me what this output means?   i just
switched to a debian based system from gentoo, so i dont grok dpkg
yet:

[EMAIL PROTECTED]:~$ sudo dpkg -i libghc6-mtl-dev_1.0.1-2_i386.deb
(Reading database ... 129709 files and directories currently installed.)
Preparing to replace libghc6-mtl-dev 1.0-3 (using
libghc6-mtl-dev_1.0.1-2_i386.deb) ...
ghc-pkg: cannot find package mtl-1.0
dpkg: warning - old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
ghc-pkg: cannot find package mtl-1.0
dpkg: error processing libghc6-mtl-dev_1.0.1-2_i386.deb (--install):
subprocess new pre-removal script returned error exit status 1
Reading package info from stdin ... done.
ghc-pkg: dependency base-2.0 doesn't exist (use --force to override)
dpkg: error while cleaning up:
subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
libghc6-mtl-dev_1.0.1-2_i386.deb
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


---

This e-mail may contain confidential and/or privileged information. If you 

are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] wanted: HAppS example combining state and io

2007-08-31 Thread Thomas Hartman
In the latest happs (darcs pulled, updated head is 0.9.1 iirc), I am 
experimenting with the example file in src/HAppS/Examples/HTTP1.hs.

I would like to combine state with io. Eventually io will mean stuff like 
reading from a database, but for now I'm just reading a file.

The example file HTTP1.hs has an example that demonstrates state with 
macid.

I added an example that allows you to execute arbitrary io.

I tried, but was unable to, add a handler that combines state and io. 

 ,  h [iohandler]GET $ ioReadFileHandler
 ,  h [statehandler] GET $ stateHandler
 --,  h [ioandstatehandler] GET $ ioAndStateHandler

.

-- displays contents of HAPPS.hs in current directory
ioReadFileHandler = iohandler $ readFile ./HAppS.hs 

-- displays incremented state counter
stateHandler = ok $ \() () - 
   modify (+(1::Int))  get = respond . show

-- should combine effect of iohandler with statehandler
-- specifically, should display contents of HAppS.hs, and under that an 
incremented state handler
-- is this possible
ioAndStateHandler = undefined undefined



Is mixing state and io possible with HAppS? If so, an example showing how 
to do it would be extremely helpful.

best, thomas.




---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

https1-whatsnew
Description: Binary data


HTTP1.hs
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: [Haskell] (no subject)

2007-09-05 Thread Thomas Hartman
I think you want something like this

{-# OPTIONS -fglasgow-exts #-}

f :: (Integer, Float) - Integer
f (a,b) = a * floor (10/b) 

lst :: [(Integer, Integer)]
lst = [(a ^ 2 + b ^ 2, a) | a - [1..4], b - [1..4], a^2 + b^2  20, b = 
a]

lst3 = map (f) ( map ( intTupToFloatTup  ) lst )

intTupToFloatTup :: (Integer, Integer) - (Integer, Float)
intTupToFloatTup (int1, int2) = (int1, fromInteger int2)

load the whole thing into ghci with ghci proggie.hs

when I have this type of problem, my usual approach is to put the code 
into a text file, load that in ghci, derive type sigs on the functions 
that work, and then see if I can figure out
the mismatch.

you could probably get a fast answer to this kind of question on the 
#haskell irc channel as well.

hope this helps,

thomas.




Scott Williams [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
09/05/2007 05:28 PM

To
Tomi Owens [EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
[Haskell-cafe] Re: [Haskell] (no subject)






[bcc haskell, cc haskell-cafe]

On 9/5/07, Tomi Owens [EMAIL PROTECTED] wrote:
Hi there. I'm a teacher of Maths and am working my way through the Euler 
Project problems for fun. I have mostly been using Basic, but have read up 
about Haskell and think it looks like a sensible way to solve many of the 
problems. 

OK, so I've downloaded GHCi and am trying to teach myself. 

So far I have done this: 

  ___ ___ _ 
 / _ \ /\  /\/ __(_) 
/ /_\// /_/ / /  | |  GHC Interactive, version 6.6.1, for Haskell 98. 
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/ 
\/\/ /_/\/|_|  Type :? for help. 

Loading package base ... linking ... done. 
Prelude let f (a,b) = a * floor (10/b) 
Prelude f(2,5) 
4 

Here you can find out type ghci has inferred for this function.
 :t f
f :: (RealFrac b, Integral b1) = (b1, b) - b1

 

This function works just as I want it to. 

Now I try creating a list: 

Prelude [(a2+b2,a)| a - [1..4] , b- [1..4], a2+b220, b=a] 
[(2,1),(5,2),(8,2),(10,3),(13,3),(18,3),(17,4)] 

Let's assign this to an intermediate variable so we can query it's type:

Prelude let lst = [(a ^ 2 + b ^ 2, a) | a - [1..4], b - [1..4], a^2 + 
b^2  20, b = a]
Prelude lst 
[(2,1),(5,2),(8,2),(10,3),(13,3),(18,3),(17,4)]
Prelude :t lst
lst :: [(Integer, Integer)]

aha; here's the source of the type mismatch:
Prelude :t floor
floor :: (RealFrac a, Integral b) = a - b 

Floor has to take a RealFrac. According to hoogle[1], we can use various 
floating-point approximations (Float, Double, CFloat, etc) or we can use 
the exact Rational type.
[1] http://haskell.org/hoogle/?q=RealFrac

You can get your types to match by declaring your list to be of type 
[(Rational, Rational)] either by explicitly typing one of the untyped 
variables or the entire expression: 
Prelude let lst = [(a ^ 2 + b ^ 2, a) | (a::Rational) - [1..4], b - 
[1..4], a^2 + b^2  20, b = a]
Prelude :t lst
lst :: [(Rational, Rational)]
Prelude let lst :: [(Rational, Rational)] = [(a ^ 2 + b ^ 2, a) | a - 
[1..4], b - [1..4], a^2 + b^2  20, b = a] 
Prelude :t lst
lst :: [(Rational, Rational)]


and this works 
So now I try to apply the function to the list: 

Prelude map (f) [(a2+b2,a)| a - [1..4] , b- [1..4], a2+b220, b=a] 

and I get this result: 

interactive:1:5: 
   Ambiguous type variable `t' in the constraints: 
 `Integral t' arising from use of `f' at interactive:1:5 
 `RealFrac t' arising from use of `f' at interactive:1:5 
   Probable fix: add a type signature that fixes these type variable(s) 
I'm sorry, but I don't quite get how to set the type signature and how it 
will apply to my function... 

Thanks, 

Hope this helps
 

Tomi 

 

Department for Education, Sport and Culture E Mail
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and all 
copies of it from your system, destroy any hard copies of it and notify 
the sender. You must not, directly or indirectly, use, disclose, 
distribute, print, or copy any part of this message if you are not the 
intended recipient. The Department for Education, Sport and Culture and 
any of its establishments each reserve the right to monitor all e-mail 
communications through its networks. 
Any views expressed in this message are those of the individual sender, 
except where the message states otherwise and the sender is authorised to 
state them to be the views of any such entity. 
The Department for Education, Sport and Culture shall not be liable to the 
recipient or any third party for any loss or damage, however it appears, 
from this e-mail or its content. This includes loss or damage caused by 
viruses. It is the responsibility of the recipient to ensure that the 
opening of this message and its 

Re: [Haskell-cafe] Re: [Haskell] (no subject)

2007-09-06 Thread Thomas Hartman
I think at some intermediate stage that flag helped me compile, but in the 
final version it's unnecessary.

my bad.




Thomas Hartman [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
09/05/2007 06:29 PM

To
[EMAIL PROTECTED]
cc
[EMAIL PROTECTED], haskell-cafe@haskell.org, Tomi Owens 
[EMAIL PROTECTED]
Subject
Re: [Haskell-cafe] Re: [Haskell] (no subject)







I think you want something like this 

{-# OPTIONS -fglasgow-exts #-} 

f :: (Integer, Float) - Integer 
f (a,b) = a * floor (10/b) 

lst :: [(Integer, Integer)] 
lst = [(a ^ 2 + b ^ 2, a) | a - [1..4], b - [1..4], a^2 + b^2  20, b = 
a] 

lst3 = map (f) ( map ( intTupToFloatTup  ) lst ) 

intTupToFloatTup :: (Integer, Integer) - (Integer, Float) 
intTupToFloatTup (int1, int2) = (int1, fromInteger int2) 

load the whole thing into ghci with ghci proggie.hs 

when I have this type of problem, my usual approach is to put the code 
into a text file, load that in ghci, derive type sigs on the functions 
that work, and then see if I can figure out 
the mismatch. 

you could probably get a fast answer to this kind of question on the 
#haskell irc channel as well. 

hope this helps, 

thomas. 



Scott Williams [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED] 
09/05/2007 05:28 PM 


To
Tomi Owens [EMAIL PROTECTED] 
cc
haskell-cafe@haskell.org 
Subject
[Haskell-cafe] Re: [Haskell] (no subject)








[bcc haskell, cc haskell-cafe]

On 9/5/07, Tomi Owens [EMAIL PROTECTED] wrote: 
Hi there. I'm a teacher of Maths and am working my way through the Euler 
Project problems for fun. I have mostly been using Basic, but have read up 
about Haskell and think it looks like a sensible way to solve many of the 
problems. 

OK, so I've downloaded GHCi and am trying to teach myself. 

So far I have done this: 

 ___ ___ _ 
/ _ \ /\  /\/ __(_) 
/ /_\// /_/ / /  | |  GHC Interactive, version 6.6.1, for Haskell 98. 
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/ 
\/\/ /_/\/|_|  Type :? for help. 

Loading package base ... linking ... done. 
Prelude let f (a,b) = a * floor (10/b) 
Prelude f(2,5) 
4 

Here you can find out type ghci has inferred for this function.
 :t f
f :: (RealFrac b, Integral b1) = (b1, b) - b1



This function works just as I want it to. 

Now I try creating a list: 

Prelude [(a2+b2,a)| a - [1..4] , b- [1..4], a2+b220, b=a] 
[(2,1),(5,2),(8,2),(10,3),(13,3),(18,3),(17,4)] 

Let's assign this to an intermediate variable so we can query it's type:

Prelude let lst = [(a ^ 2 + b ^ 2, a) | a - [1..4], b - [1..4], a^2 + 
b^2  20, b = a]
Prelude lst 
[(2,1),(5,2),(8,2),(10,3),(13,3),(18,3),(17,4)]
Prelude :t lst
lst :: [(Integer, Integer)]

aha; here's the source of the type mismatch:
Prelude :t floor
floor :: (RealFrac a, Integral b) = a - b 

Floor has to take a RealFrac. According to hoogle[1], we can use various 
floating-point approximations (Float, Double, CFloat, etc) or we can use 
the exact Rational type.
[1] http://haskell.org/hoogle/?q=RealFrac

You can get your types to match by declaring your list to be of type 
[(Rational, Rational)] either by explicitly typing one of the untyped 
variables or the entire expression: 
Prelude let lst = [(a ^ 2 + b ^ 2, a) | (a::Rational) - [1..4], b - 
[1..4], a^2 + b^2  20, b = a]
Prelude :t lst
lst :: [(Rational, Rational)]
Prelude let lst :: [(Rational, Rational)] = [(a ^ 2 + b ^ 2, a) | a - 
[1..4], b - [1..4], a^2 + b^2  20, b = a] 
Prelude :t lst
lst :: [(Rational, Rational)]


and this works 
So now I try to apply the function to the list: 

Prelude map (f) [(a2+b2,a)| a - [1..4] , b- [1..4], a2+b220, b=a] 

and I get this result: 

interactive:1:5: 
  Ambiguous type variable `t' in the constraints: 
`Integral t' arising from use of `f' at interactive:1:5 
`RealFrac t' arising from use of `f' at interactive:1:5 
  Probable fix: add a type signature that fixes these type variable(s) 
I'm sorry, but I don't quite get how to set the type signature and how it 
will apply to my function... 

Thanks, 

Hope this helps


Tomi 

 

Department for Education, Sport and Culture E Mail
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and all 
copies of it from your system, destroy any hard copies of it and notify 
the sender. You must not, directly or indirectly, use, disclose, 
distribute, print, or copy any part of this message if you are not the 
intended recipient. The Department for Education, Sport and Culture and 
any of its establishments each reserve the right to monitor all e-mail 
communications through its networks. 
Any views expressed in this message are those of the individual sender, 
except where the message states otherwise and the sender is authorised

Re: [Haskell-cafe] Re: wanted: HAppS example combining state and io

2007-09-06 Thread Thomas Hartman
Thanks Martin, that really helped.

After many days reading the source, I'm still trying to grok HAppS.

Meanwhile, here is a patch that adds examples to HAppS/Examples/HTTP1.hs
for combining state and io, based on your advice.

see especiallly the handler stateioH accepts an arbitrary state action,
arbitrary io action, and a function for combining the two.

Thomas.


New patches:

[add examples showing state and io
[EMAIL PROTECTED] {
hunk ./src/HAppS/Examples/HTTP1.hs 7
+import System.Directory
hunk ./src/HAppS/Examples/HTTP1.hs 68
+
+ ,h [showbashrc] GET $ ioshowH readbashrc
+ ,h [showhttp1] GET $ ioshowH readhttp1
+
+ ,h [incrementstate] GET $ stateH $ incnshow
+ ,h [decrementstate] GET $ stateH $ decnshow
+ ,h [viewstate] GET $ stateH view
+
+ ,h [showbashrc_and_inc] GET $ stateioH incnshow readbashrc
append_state
+ ,h [showbashrc_and_dec] GET $ stateioH decnshow readbashrc
append_state
+ ,h [showbashrc_and_view] GET $ stateioH decnshow
readbashrc append_state
+
hunk ./src/HAppS/Examples/HTTP1.hs 82
+append_state s io = io ++ BRState:  ++ s
+
+incnshow = modify (+1)  get =^ show
+decnshow = modify (\x - x-1)  get =^ show
+view = get =^ show
+
+
+readbashrc = do
+  home - getHomeDirectory
+  readfileSafe $ home ++ /.bashrc
+
+readhttp1 = readfileSafe ./HTTP1.hs
+
+readfileSafe file = catch
+   ( readFile file =^ format_html )
+   ( \e - return ( show e ) )
+
+stateioH stateaction ioaction combinestio = \() () - do
+   stateresult - stateaction
+   respond $ do
+  ioresult - ioaction
+  showresult (combinestio stateresult ioresult)
+
+
+stateH stateaction = ok $ \() () - stateaction = respond
+
+ioshowH :: (Monad m, Show a) = IO a - () - () - m (Either Request (IO
Result))
+ioshowH ioaction = \() () - respond $ do
+   ioresult - ioaction
+   showresult ioresult
+
+showresult showable = sresult 200 (show showable)
+
+
hunk ./src/HAppS/Examples/HTTP1.hs 151
+
+format_html xs = concat $ map newlinetobr xs
+  where  newlinetobr '\n' = br
+ newlinetobr x = [x]
+
+f =^ g = f = return . g
}








Martin Lütke [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
09/01/2007 07:04 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] Re: wanted: HAppS example combining state and io






Thomas Hartman thomas.hartman at db.com writes:



 In the latest happs (darcs pulled, updated
 head is 0.9.1 iirc), I am experimenting with the example file in
src/HAppS/Examples/HTTP1.hs.
 I would like to combine state with io.
 Eventually io will mean stuff like reading from a database, but for now
 I'm just reading a file.
 The example file HTTP1.hs has an example
 that demonstrates state with macid.
 I added an example that allows you to
 execute arbitrary io.
 I tried, but was unable to, add a handler
 that combines state and io.

,  h [iohandler]GET $ ioReadFileHandler

,  h [statehandler] GET $ stateHandler

--,  h [ioandstatehandler] GET $ ioAndStateHandler
 .
 -- displays contents of HAPPS.hs in
 current directory
 ioReadFileHandler = iohandler $ readFile
 ./HAppS.hs
 -- displays incremented state counter
 stateHandler = ok $ \() () -

  modify (+(1::Int))  get =
 respond . show
 -- should combine effect of iohandler
 with statehandler
 -- specifically, should display contents
 of HAppS.hs, and under that an incremented state handler
 -- is this possible
 ioAndStateHandler = undefined undefined
 Is mixing state and io possible with
 HAppS? If so, an example showing how to do it would be extremely
helpful.
 best, thomas.
 ---This e-mail may contain confidential and/or privileged information.
If you
are not the intended recipient (or have received this e-mail in error)
please
notify the sender immediately and destroy this e-mail. Any unauthorized
copying,
disclosure or distribution of the material in this e-mail is strictly
forbidden.

 Attachment (https1-whatsnew): application/octet-stream, 1933 bytes
 Attachment (HTTP1.hs): application/octet-stream, 4794 bytes

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



I had no trouble getting this handler to work:

h [iohandler] GET $ \() () - do
modify (+1)
x - get
respond $ do
cnts - readFile ./sometext.txt
sresult 200 (cnts ++ show x)

I believe the trick is that you cant mix io INTO the HAppS ServerPart
monad.
But from the ServerPart monad you can RETURN an io action.

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



---

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail

Re: [Haskell-cafe] Library Process (was Building production stable software in Haskell)

2007-09-18 Thread Thomas Hartman
  Instead, I think
several people should make their own personal list of libraries they
would vouch for 

Ideally along with a cabal (or otherwise) install script that would set 
everything up in one step.




Neil Mitchell [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
09/18/2007 09:02 AM

To
Ketil Malde [EMAIL PROTECTED]
cc
haskell-cafe@haskell.org, Malcolm Wallace [EMAIL PROTECTED]
Subject
Re: [Haskell-cafe] Library Process (was Building production stable 
software in Haskell)






Hi

 I think there is a niche for a subset of the hackage libraries providing
 an officially sanctioned standard library collection.  Currently,
 hackage includes, well, everything.  As such, it is a useful resource,
 but it would be useful to have a partitioning into two levels, where the
 SLC would only include libraries that meet specific criteria.  Maybe:

  - considered stable
  - is portable
  - relies only on other standard libraries
  - avoids needless duplication of functionality
  - with a responsive, named maintainer (not libraries@)
  - with acceptable documentation and unit tests
  - required by at least one separate application

I think there is a niche for this, but I don't think it should be an
officially sanctioned collection - since otherwise everyone is just
going to be debating how to add their library to this collection - and
we are going to descend into voting and politics. Instead, I think
several people should make their own personal list of libraries they
would vouch for - which meet the criteria above AND they have
personal positive experiences of.

Off the top of my head my list would include gtk2hs, and that's about it.

Thanks

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Missing Symbol (2)

2007-09-19 Thread Thomas Hartman
as provided, this won't compile because v hasn't been defined.

f [] = 0
f (x:xs) = x . f xs

compiles but gives 

f :: (Num (a - c)) = [c - c] - a - c

which seems wrong. maybe I'm not understanding what v is not supposed to 
be.

I am thinking maybe you want iterate

*Main take 5 $ iterate (+1) 0
[0,1,2,3,4]

It would be easier to understand your desired function if you would 
provide an example of desired usage.

t.




PR Stanley [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
09/19/2007 02:17 AM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] Missing Symbol (2)






Hi
Here's another one:
f [] = v
f (x:xs) = x . f xs
The . is supposed to denote a generic operator - f [] maps to some 
value v and applied to non-empty list applies head to ? operator.
Thanks, Paul

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] are some of these reverse algos better than others? is there a quick and dirty way to reveal this fact?

2007-09-22 Thread Thomas Hartman
I came up with the following functions to do reverse. The first one
is obviously bad, because of the expensive list concat. The last one,
myreverse, I think is the reference implementation you get in the
prelude. The ones between, I'm not so sure. I suspect they're naive
as the name indicates, but in practice they stop working at the same
place as myreverse, at least on hugs.

If versions naive 2-5 are indeed inferior to myreverse, is there a
quick and dirty way to reveal which ones are better via a profiling
tool, or some trick like that? Something easier than doing the
space/time complexity analysis by hand I mean?

By the way, on ghc they all work out to [1..100] and beyond.

-- fails on [1..10] on win/hugs
naivereverse [] = []
naivereverse (x:xs) = naivereverse xs  ++ [x]

-- fails on [1..100] on win/hugs
naivereverse2 [] = []
naivereverse2 (x:xs) = ( last xs ) : ( naivereverse2 ( init xs ) ++ [x] )

naivereverse3 [] = []
naivereverse3 ( x : xs ) = ( last xs ) : naivereverse3 ( init xs )

naivereverse4 xs = myreverse' [] xs
  where myreverse' reversed [] = reversed
myreverse' reversed xs = myreverse' ( (head xs) : reversed ) ( tail xs )

naivereverse5 xs = myreverse' [] xs
  where myreverse' reversed [] = reversed
myreverse' reversed (x:xs) = myreverse' ( x : reversed ) xs

-- this is the usual implementation right?
myreverse xs = foldl f [] xs
  where f accum el = el : accum

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


Re: [Haskell-cafe] more functions to evaluate

2007-10-12 Thread Thomas Hartman
how about this, for wordSize? I used quickcheck to verify that my 
wordSize2 is the same as yours.

Actually, it's not! if you allow negative integers in the list, it's not 
at any rate. (falsifiable after 50 tries)

I haven't thought through what this means... if your function isn't quite 
right, or mine, or it doesn't really matter.

Also I would be curious to see this quickchecked but not allowing negative 
integers in the list if someone can show me how to do that.

Also, I commented out intToBinWord because intToBin isn't in prelude nor 
in any library I could track down and I'm not sure what it was supposed to 
do.

thomas.

import Data.List
import Data.Maybe
import Test.QuickCheck

wordSize :: [Int] - Int
wordSize xs = head (dropWhile ((length xs)) $ iterate (*2) 8)

wordSize2 :: [Int] - Int
wordSize2 xs = fromJust $ find ((length xs)) $ iterate (*2) 8

main = quickCheck $ \xs - wordSize2 ( xs :: [Int]) == wordSize xs

{-
intToBinWord :: Int - [Int]
intToBinWord n = reverse (take elements (xs ++ repeat 0))
  where
  xs = reverse (intToBin n)
  elements = wordSize xs
-}






PR Stanley [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
10/12/2007 03:10 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] more functions to evaluate






Hi folks
Any comments and/or criticisms no matter how trivial on the following 
please:

 wordSize :: [Int] - Int
 wordSize xs = head (dropWhile ((length xs)) $ iterate 
(*2) 8)

 intToBinWord :: Int - [Int]
 intToBinWord n = reverse (take elements (xs ++ repeat 0))
   where
   xs = reverse (intToBin n)
   elements = wordSize xs

Thanks, Paul

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to thoroughly clean up Haskell stuff on linux

2007-10-12 Thread Thomas Hartman
not trying to start a flame war here, but I had pretty good success with 
apt-get and ubuntu.

however, I admit I never really got lambdabot to work.

if you install from source you can have 6.6, 6.6.1 and 6.4 all installed 
at the same time.

you just need to create simlinks for the old versions. (nothing gets 
overwritten except the symlink in /usr/bin)

are you certain haddock depends on lambdabot? that seems very strange to 
me.

t.





Lihn, Steve [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
10/12/2007 05:22 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] How to thoroughly clean up Haskell stuff on linux






Hi,
I have been hacking the Haskell installation a few days on Redhat Linux.
  GHC 6.6 - 6.6.1 - Lambdabot does not work.
  Downgrade to GHC 6.4 - Still not working, tried cabal-install to
simplify my life, but no luck.
  Then install Cabal, Haddock - Haddock cannot install bc Lambdabot is
not there. (And some dependency issues.)
  Remove .ghci, Haddock still not work.

It seems the Haskell world (outside the beautiful GHC) is in a recursive
non-functional blackhole.

Anyway, now my question is, how do I thoroughly clean up Haskell? (And
maybe try again after a few days of rest.)

My environment is Redhat Linux, install most stuff on
/home/user/product/ where product = GHC, Lambdabot, cabal,
haddock, etc. It seems there are some hidden files/dirs, .GHC, .ghci,
anything else?

Thanks,
Steve


--
Notice:  This e-mail message, together with any attachments, contains
information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp  Dohme or MSD
and in Japan, as Banyu - direct contact information for affiliates is 
available at http://www.merck.com/contact/contacts.html) that may be 
confidential, proprietary copyrighted and/or legally privileged. It is 
intended solely for the use of the individual or entity named on this 
message. If you are not the intended recipient, and have received this 
message in error, please notify us immediately by reply e-mail and then 
delete it from your system.

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] How to thoroughly clean up Haskell stuff on linux

2007-10-12 Thread Thomas Hartman
wayll... it (haddock at least) really is easy on deb/ubu with apt.

I've found a lot of stuff is harder to install on Suse back when I was 
using that, and I think Suse/Redhat suffer from the same problems.

not that the packager should matter, since it seems you're installing from 
source...

are you trying to do something like install to your home dir (non root) or 
like that?

did you look for an rpm for haddock? 

If you're committed to RH, honestly I would just take whatever comes 
nicely packaged as rpm. Life is too short (and haskell has enough other 
complications) to be installing stuff from source :)

t.




Lihn, Steve [EMAIL PROTECTED] 
10/12/2007 05:38 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe@haskell.org, [EMAIL PROTECTED]
Subject
RE: [Haskell-cafe] How to thoroughly clean up Haskell stuff on linux






 are you certain haddock depends on lambdabot? that seems very strange
to me. 

Thomas,
I also thought haddock should be an easy build, but it just won't do it.
  /home2/user/garden/haddock-0.8 runhaskell ./Setup.lhs install
  Installing: --prefix=~/cabal/lib/haddock-0.8/ghc-6.4 
--prefix=~/cabal/bin haddock-0.8...
Then it stopped and nothing got done. (I even checked rc=0 but the
lib/bin dir does not have trace of haddock!)

I don't think haddock has to depend on lamdbabot. But I saw Skipping
HaddockHoogle during the build. Isn't the Hoogle thing related to
Lambdabot? Or they are unrelated.

Again being new to the Haskell world (only a few months), I am not an
expert on what depends on what. It would be nice to have a type system
to check the dependency of the many packages. Perl CPAN does a good job
on this.

Steve


--
 
To
 haskell-cafe@haskell.org 
cc
 
Subject
 [Haskell-cafe] How to thoroughly clean up Haskell stuff 
on linux

 




Hi,
I have been hacking the Haskell installation a few days on Redhat Linux.
 GHC 6.6 - 6.6.1 - Lambdabot does not work.
 Downgrade to GHC 6.4 - Still not working, tried cabal-install to
simplify my life, but no luck.
 Then install Cabal, Haddock - Haddock cannot install bc Lambdabot is
not there. (And some dependency issues.)
 Remove .ghci, Haddock still not work.

It seems the Haskell world (outside the beautiful GHC) is in a recursive
non-functional blackhole.

Anyway, now my question is, how do I thoroughly clean up Haskell? (And
maybe try again after a few days of rest.)

My environment is Redhat Linux, install most stuff on
/home/user/product/ where product = GHC, Lambdabot, cabal,
haddock, etc. It seems there are some hidden files/dirs, .GHC, .ghci,
anything else?

Thanks,
Steve



--
Notice:  This e-mail message, together with any attachments, contains
information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp  Dohme or MSD
and in Japan, as Banyu - direct contact information for affiliates is 
available at http://www.merck.com/contact/contacts.html) that may be 
confidential, proprietary copyrighted and/or legally privileged. It is 
intended solely for the use of the individual or entity named on this 
message. If you are not the intended recipient, and have received this 
message in error, please notify us immediately by reply e-mail and then 
delete it from your system.


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


---

This e-mail may contain confidential and/or privileged information. If
you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this

e-mail is strictly forbidden.



--
Notice:  This e-mail message, together with any attachments, contains
information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp  Dohme or MSD
and in Japan, as Banyu - direct contact information for affiliates is 
available at http://www.merck.com/contact/contacts.html) that may be 
confidential, proprietary copyrighted and/or legally privileged. It is 
intended solely for the use of the individual or entity named on this 
message. If you are not the intended recipient, and have received this 
message in error, please notify us immediately by reply e-mail and then 
delete it from your system.

--



---

This e-mail may contain confidential

Re: [Haskell-cafe] Help parsing dates and times

2007-10-16 Thread Thomas Hartman
dons's blog entry on parsing dates might point somewhere useful

http://cgi.cse.unsw.edu.au/~dons/blog/2006/11/12#rpn-reloaded

t.



Don Stewart [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
10/15/2007 08:25 PM

To
Justin Bailey [EMAIL PROTECTED]
cc
Haskell-Cafe haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] Help parsing dates and times






jgbailey:
I am trying to parse various date and time formats using the 
parseTime
function found in (GHC 6.6.1) Data.Time.Format. The one that is 
giving me
trouble looks like this:
 
  2008-06-26T11:00:00.000-07:00
 
Specifically, the time zone offset isn't covered by the format 
parameters
given. I can almost parse it with this:
 
  %FT%X.000
 
But that doesn't take into account the -07:00 bit. I'm sure this 
has
been solved - can someone point me to the solution? Thanks in 
advance.

Is there anything in the parsedate library?


http://hackage.haskell.org/cgi-bin/hackage-scripts/package/parsedate-2006.11.10


http://hackage.haskell.org/packages/archive/parsedate/2006.11.10/doc/html/System-Time-Parse.html


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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Equality Question

2007-10-16 Thread Thomas Hartman
not quite the same issue, but you might be interested by 

http://people.cs.uu.nl/stefan/blog/00012.html which notes: 

Prelude let apply  = \f x - f x

Prelude let apply' = \f   - f

Prelude apply  undefined `seq` ()
()

Prelude apply' undefined `seq` ()
*** Exception: Prelude.undefined

mulling this over helped me think about functions that were similar but 
had different numbers of params. (the first only takes a function as its 
first arg, the second, which I believe is the same as id takes 
anything.)

t.





PR Stanley [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
10/15/2007 06:56 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] Equality Question






Hi
is const = id?
const 'x' 'y'
'x'
id 'x'
'x'

Cheers,
Paul

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Equality Question

2007-10-16 Thread Thomas Hartman
a good sanity check for saneness of two fxs is to quickcheck them, as I 
believe I provided an example to for a previous question of yours.

Though I think in this case that's impossible because, as someone else 
pointed out, not even the function tyes agree.

t.



PR Stanley [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
10/15/2007 06:56 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] Equality Question






Hi
is const = id?
const 'x' 'y'
'x'
id 'x'
'x'

Cheers,
Paul

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] How to thoroughly clean up Haskell stuff on linux

2007-10-16 Thread Thomas Hartman
Indeed, I don't want to waste time but have no choice (rpm needs root),

not sure if this'll help (never tried it myself) but this claims there's a 
non-root way to use rpm

http://www.techonthenet.com/linux/build_rpm.php

cheers, t.

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] using quickcheck to generate test (table) data

2007-10-16 Thread Thomas Hartman
I wanted to generate some random table data, and decided to use quickcheck 
to do this. I didn't want to be checking properties, I actually wanted to 
output the examples that quickcheck came up with using arbitrary. In this 
case, I wanted to generate lists of lists of strings.

In case this is of use to anyone else here's an example...

One thing I don't understand is the purpose of the first argument to 
generate. If it's zero it's always the same data, so I made it a larger 
number (1). Seems ok, but it would be nice to understand why. Or if 
there is a better bway to accomplish this.

t.


{-# OPTIONS -fno-monomorphism-restriction #-}
module GenTestData where

import Test.QuickCheck
import Control.Monad
import System.Random
import Test.QuickCheck

import Misc
import ArbitraryInstances

f =^ g = f = return . g
infixl 1 =^


rgenIntList = rgen (arbitrary :: Gen [Int]) :: IO [Int]
rgenInt = rgen (arbitrary :: Gen Int) :: IO Int
rgenFoo = rgen (arbitrary :: Gen Foo ) :: IO Foo
rgenFoos = rgen (arbitrary :: Gen [Foo]) :: IO [Foo]
rgenString' = rgen (arbitrary :: Gen [Char]) :: IO [Char]
rgenString len = rgenString' =^ take len 
rgenStringRow' = rgen (arbitrary :: Gen [[Char]]) :: IO [[Char]]
rgenStringRow maxlenstr maxcols  = do
  rgenStringRow'
  =^ take maxcols 
  =^ map ( take maxlenstr )
rgenStringTable' = rgen (arbitrary :: Gen [[[Char]]]) :: IO [[[Char]]]
rgenStringTable maxlenstr maxcols maxrows = do
  rgenStringTable' 
  =^ take maxrows
  =^ map ( take maxcols )
  =^ ( map . map ) (take maxlenstr)

rgen gen = do
  sg - newStdGen
  return $ generate 1 sg gen


module ArbitraryInstances where

import Test.QuickCheck
import Data.Char
import Control.Monad

instance Arbitrary Char where
arbitrary = choose ('\32', '\128')
coarbitrary c = variant (ord c `rem` 4)

-- joel reymont's example I think
data Foo
 = Foo Int
 | Bar
 | Baz
   deriving Show

instance Arbitrary Foo where
 coarbitrary = undefined
 arbitrary   = oneof [ return Bar
 , return Baz
 , liftM Foo arbitrary
 


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Suspected stupid Haskell Question

2007-10-17 Thread Thomas Hartman
Since I'm interested in the stack overflow issue, and getting acquainted 
with quickcheck, I thought I would take this opportunity to compare your 
ordTable with some code Yitzchak Gale posted earlier, against Ham's 
original problem.

As far as I can tell, they're the same. They work on lists up to 10 
element lists of strings, but on 10^6 size lists I lose patience waiting 
for them to finish. 

Is there a more scientific way of figuring out if one version is better 
than the other by using, say profiling tools?

Or by reasoning about the code?

t.



import Data.List
import qualified Data.Map as M
import Control.Arrow
import Test.QuickCheck
import Test.GenTestData
import System.Random

{-
Is there a library function to take a list of Strings and return a list of
ints showing how many times each String occurs in the list.

So for example:

[egg, egg, cheese] would return [2,1] 
-}

testYitzGale n = do
  l - rgenBndStrRow (10,10) (10^n,10^n)  -- 10 strings, strings are 
10 chars long, works. craps out on 10^6.
  m - return $ freqFold l 
  putStrLn $ map items:  ++ ( show $ M.size m )

testCScherer n = do
  l - rgenBndStrRow (10,10) (10^n,10^n)  -- same limitations as yitz gale 
code.
  m - return $ ordTable l 
  putStrLn $ items:  ++ ( show $ length m )


-- slow for big lists
--freqArr = Prelude.map ( last  length ) . group . sort

-- yitz gale code. same as chad scherer code? it's simpler to understand, 
but is it as fast?
freqFold :: [[Char]] - M.Map [Char] Int
freqFold = foldl' g M.empty
  where g accum x = M.insertWith' (+) x 1 accum
-- c scherer code. insists on ord. far as I can tell, same speed as yitz.
ordTable :: (Ord a) = [a] - [(a,Int)]
ordTable xs = M.assocs $! foldl' f M.empty xs
where f m x = let  m' = M.insertWith (+) x 1 m
   Just v = M.lookup x m'
  in v `seq` m'


l = [egg,egg,cheese]

-- other quickcheck stuff
--prop_unchanged_by_reverse = \l - ( freqArr (l :: [[Char]]) ) == ( 
freqArr $ reverse l )
--prop_freqArr_eq_freqFold = \l - ( freqArr (l :: [[Char]]) == (freqFold 
l))
--test1 = quickCheck prop_unchanged_by_reverse
--test2 = quickCheck prop_freqArr_eq_freqFold

--- generate test data: 
genBndStrRow (minCols,maxCols) (minStrLen, maxStrLen) = rgen ( genBndLoL 
(minStrLen, maxStrLen) (minCols,maxCols) )

gen gen = do
  sg - newStdGen
  return $ generate 1 sg gen

-- generator for a list with length between min and max
genBndList :: Arbitrary a = (Int, Int) - Gen [a]
genBndList (min,max) = do
  len - choose (min,max)
  vector len


-- lists of lists
--genBndLoL :: (Int, Int) - (Int, Int) - Gen [[a]]
genBndLoL (min1,max1) (min2,max2) = do
  len1 - choose (min1,max1)
  len2 - choose (min2,max2)
  vec2 len1 len2

--vec2 :: Arbitrary a = Int - Int - Gen [[a]]
vec2 n m = sequence [ vector m | i - [1..n] ]





Chad Scherrer [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
10/17/2007 01:35 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] Re: Suspected stupid Haskell Question






Big_Ham joymachine2001 at hotmail.com writes:

 
 
 Is there a library function to take a list of Strings and return a list 
of
 ints showing how many times each String occurs in the list.
 
 So for example:
 
 [egg, egg, cheese] would return [2,1]
 
 I couldn't find anything on a search, or anything in the librarys.
 
 Thanks BH.

Hi BH,

This might be overkill, but it works well for me. And it avoid stack 
overflows I
was originally getting for very large lists. Dean Herrington and I came up 
with
this:

ordTable :: (Ord a) = [a] - [(a,Int)]
ordTable xs = Map.assocs $! foldl' f Map.empty xs
where f m x = let  m' = Map.insertWith (+) x 1 m
   Just v = Map.lookup x m'
  in v `seq` m'

intTable :: [Int] - [(Int,Int)]
intTable xs = IntMap.assocs $! foldl' f IntMap.empty xs
where f m x = let  m' = IntMap.insertWith (+) x 1 m
   Just v = IntMap.lookup x m'
  in v `seq` m'

enumTable :: (Enum a) = [a] - [(a,Int)]
enumTable = map fstToEnum . intTable . map fromEnum
where fstToEnum (x,y) = (toEnum x, y)

If you like, it's easily wrapped in a Table class.

Chad




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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Suspected stupid Haskell Question

2007-10-18 Thread Thomas Hartman
  But I would expect intTable to be faster,

But if I understand correctly, intTable can only deal with integer keys, 
whereas BH's original question would have wanted string keys, and I can't 
see a way to convert string to int and back.

t.




Chad Scherrer [EMAIL PROTECTED] 
10/17/2007 11:38 PM

To
Thomas Hartman/ext/[EMAIL PROTECTED]
cc
haskell-cafe@haskell.org, [EMAIL PROTECTED]
Subject
Re: [Haskell-cafe] Re: Suspected stupid Haskell Question






Hmm, is insertWith' new? If I remember right, I think the stack overflows 
were happening because Map.insertWith isn't strict enough. Otherwise I 
think the code is the same. But I would expect intTable to be faster, 
since it uses IntMap, and there's no IntMap.insertWith' as of 6.6.1 
(though it may be easy enough to add one).

Chad

On 10/17/07, Thomas Hartman  [EMAIL PROTECTED] wrote:

Since I'm interested in the stack overflow issue, and getting acquainted 
with quickcheck, I thought I would take this opportunity to compare your 
ordTable with some code Yitzchak Gale posted earlier, against Ham's 
original problem. 

As far as I can tell, they're the same. They work on lists up to 10 
element lists of strings, but on 10^6 size lists I lose patience waiting 
for them to finish. 

Is there a more scientific way of figuring out if one version is better 
than the other by using, say profiling tools? 

Or by reasoning about the code? 

t. 

 

import Data.List 
import qualified Data.Map as M 
import Control.Arrow 
import Test.QuickCheck 
import Test.GenTestData 
import System.Random 

{- 
Is there a library function to take a list of Strings and return a list of 

ints showing how many times each String occurs in the list. 

So for example: 

[egg, egg, cheese] would return [2,1] 
-} 

testYitzGale n = do 
  l - rgenBndStrRow (10,10) (10^n,10^n)  -- 10 strings, strings are 
10 chars long, works. craps out on 10^6. 
  m - return $ freqFold l 
  putStrLn $ map items:  ++ ( show $ M.size m ) 

testCScherer n = do 
  l - rgenBndStrRow (10,10) (10^n,10^n)  -- same limitations as yitz gale 
code. 
  m - return $ ordTable l 
  putStrLn $ items:  ++ ( show $ length m ) 


-- slow for big lists 
--freqArr = Prelude.map ( last  length ) . group . sort 

-- yitz gale code. same as chad scherer code? it's simpler to understand, 
but is it as fast? 
freqFold :: [[Char]] - M.Map [Char] Int 
freqFold = foldl' g M.empty 
  where g accum x = M.insertWith' (+) x 1 accum 
-- c scherer code. insists on ord. far as I can tell, same speed as yitz. 
ordTable :: (Ord a) = [a] - [(a,Int)] 
ordTable xs = M.assocs $! foldl' f M.empty xs 
where f m x = let  m' = M.insertWith (+) x 1 m 
   Just v = M.lookup x m' 
  in v `seq` m' 


l = [egg,egg,cheese] 

-- other quickcheck stuff 
--prop_unchanged_by_reverse = \l - ( freqArr (l :: [[Char]]) ) == ( 
freqArr $ reverse l ) 
--prop_freqArr_eq_freqFold = \l - ( freqArr (l :: [[Char]]) == (freqFold 
l)) 
--test1 = quickCheck prop_unchanged_by_reverse 
--test2 = quickCheck prop_freqArr_eq_freqFold 

--- generate test data: 
genBndStrRow (minCols,maxCols) (minStrLen, maxStrLen) = rgen ( genBndLoL 
(minStrLen, maxStrLen) (minCols,maxCols) ) 

gen gen = do 
  sg - newStdGen 
  return $ generate 1 sg gen 

-- generator for a list with length between min and max 
genBndList :: Arbitrary a = (Int, Int) - Gen [a] 
genBndList (min,max) = do 
  len - choose (min,max) 
  vector len 


-- lists of lists 
--genBndLoL :: (Int, Int) - (Int, Int) - Gen [[a]] 
genBndLoL (min1,max1) (min2,max2) = do 
  len1 - choose (min1,max1) 
  len2 - choose (min2,max2) 
  vec2 len1 len2 

--vec2 :: Arbitrary a = Int - Int - Gen [[a]] 
vec2 n m = sequence [ vector m | i - [1..n] ] 





---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] will the real quicksort please stand up? (or: sorting a million element list)

2007-10-22 Thread Thomas Hartman
It has been noted in a few places that the 2 line quicksort demo in the 
Introduction section of the haskell wiki 

http://www.haskell.org/haskellwiki/Introduction

isn't a real quicksort, and wouldn't scale well with longer lists. 
Interested, and wanting to put my recently learned test data generating 
skills to the test, I put this to the test with a little suite for various 
versions of quickcheck I found lying around. 

My patience extends to 3 minutes for waiting for a result, which for my 
tests was about the amount needed for a million integer long list. This 
was definitely faster for the treesort below than the naive quicksort 
from the wiki. 

(Prelude sort, which I think is mergesort, just blew the stack.)

I wonder if there are tricks or lore that could be applied to get better 
results or insight.

t.


{-import Control.Monad (when)
import Control.Monad.ST
import Data.Array.ST
import Data.Array.IArray
import Data.Array.MArray
import System.IO.Unsafe
import Control.Monad
-}
import Test.QuickCheck hiding (test)
import System.Random
import Data.List

{-
$ time ghci -e 'test treesort 6' quicksort.hs # a real quicksort, 
according to roconnor
100

real2m18.702s
user1m3.296s
sys 0m0.453s
$ time ghci -e 'test qs1 6' quicksort.hs # naive (from the wiki intro to 
haskell, not a real quicksort
100

real4m18.174s
user1m57.615s
sys 0m0.665s
$ time ghci -e 'test sort 6' quicksort.hs # mergesort from the prelude
*** Exception: stack overflow

real0m13.634s
user0m3.805s
sys 0m0.446s
[EMAIL PROTECTED]:~/ProjectRepos/learning/quicksort
-}

-- For interactive development, I wound up working in hugs +S +I, 
-- because ghci in emacs tended to lock up 
-- hugs just segfaults, but at least the computer doesn't lock.
-- by the way, is there a way to get ghci to behave similarly to hugs? 
(restricted memory mode?)

-- t1 and t2 are about the same speed for n = 4, got bored of waiting for 
n great.
-- naive, not really quicksort according to recent reddit discussion.

test sortf n = genlist n = return . ( length . sortf ) 

-- naive
qs1 [] = []
qs1 (x:xs) = qs1 (filter ( x) xs) ++ [x] ++ qs1 (filter (= x) xs)
 

-- roconnor claims that real quicksort in haskell is really treesort.
-- from http://programming.reddit.com/info/2h0j2/comments
--I'm talking about a deforested version of tree sort. In tree sort you 
build a binary search tree by adding the head of the list to the root of 
the tree, and then building binary search trees for those items less than 
the root, and those items greater than the root.
qs2 l = treeSort l
treeSort l = foldTree (\x lft rht - lft++[x]++rht) [] (mkTree l)

-- After building the search tree, it is turned into a list by folding \x 
lft rht - lft++[x]++rht.
foldTree f g Leaf = g
foldTree f g (Node x l r) = f x (foldTree f g l) (foldTree f g r)

mkTree [] = Leaf
mkTree (x:xs) = Node x (mkTree (filter (= x) xs)) (mkTree (filter (x ) 
xs))

-- If you deforest this algorithm (removing the intermediate tree 
structure) you are left with
-- treeSort' [] = []
-- treeSort' (x:xs) = treeSort' (filter (= x) xs) ++ [x] ++ treeSort' 
(filter (x ) xs)


-- for testing
genlist n = rgen ( vector $ 10^n ) :: IO [Int]
rgenIntList = rgen (arbitrary :: Gen [Int]) :: IO [Int]
rgen gen = do sg - newStdGen
  return $ generate 1 sg gen

data Tree a = Leaf | Node a (Tree a) (Tree a)


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a million element list)

2007-10-22 Thread Thomas Hartman
another point: deforested treesort is slower.

[EMAIL PROTECTED]:~/ProjectRepos/learning/quicksorttime ghc -e test 
treeSort' 6 quicksort
100

real4m3.615s
user1m59.525s
sys 0m0.587s

The commented indicated that 

-- If you deforest this algorithm (removing the intermediate tree 
structure) you are left with
treeSort' [] = []
treeSort' (x:xs) = treeSort' (filter (= x) xs) ++ [x] ++ treeSort' 
(filter (x ) xs)

So.. my take home lesson is that deforestation isn't a performance neutral 
thing to do. Assuming the comment is correct. (I don't consider myself 
qualified  to judge.)

t.

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] List comprehension order of evaluation

2007-10-25 Thread Thomas Hartman
If I understand list comprehensions correctly, what you wrote is the same
as

do a - ab;
  b - 12;
  [a:[b]]

which is the same as

ab == \a - do b - 12; [a:[b]]

which is the same as

ab = \a - 12 = \b - [a:[b]]

which is the same as

concat $ map  (  \a - 12 = \b - [a:[b]] ) ab

 enough desugaring for now

Point is, yes it's written in stone.

List comprehensions is just syntactic sugar for monad operations.

Good exercise is to take the above expressions and add parenthesis to make
it easier to understand order of operations. (Still trips me up often
enough).

Thomas.





Maurí­cio [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
10/25/2007 05:59 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] List comprehension order of evaluation






Hi,

Today, if I write:

[a:[b] | a-ab , b-12]

I get:

[a1,a2,b1,b2]

Are there any guarantees that I'll never
get [a1,b1,a2,b2] instead, i.e.,
that the first list will always be the
last one to be fully transversed? Even
if I use a different compiler or a
future version of Haskell?

Reading how list comprehensions are
translated in the Haskell report it
seems the answer is yes. Is that
written in stone? Can compilers do
it in their own different way?

Thanks,
Maurício

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



---

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] viewing HS files in Firefox

2007-10-29 Thread Thomas Hartman
I would love an answer to this as well.



Isaac Dupree [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
10/27/2007 06:48 PM

To
Haskell-cafe haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] viewing HS files in Firefox






When I try to go to one of the Module.hs files, e.g. on 
darcs.haskell.org, it now has type HS and Firefox refuses to display it 
(and only lets me download it).  Does anyone know how to make Firefox 
treat certain file types as others (HS as plain text, in particular)? 
so that I can browse them with any convenience

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] does the order of splice definitions matter in template haskell, or is this a bug?

2007-10-31 Thread Thomas Hartman
I have a situation where

... stuff...

$(expose ['setState, 'getState]
f = SetState

compiles but

f = SetState
$(expose ['setState, 'getState]

doesn't compile, with error: Not in scope: data constructor 'SetState.

Is this a bug?

expose is defined in HAppS.State.EventTH

t,.

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] HDBC-ODBC crashes on ghc 6.8

2007-11-19 Thread Thomas Hartman
This minimal program below fails in 6.8.1, works for 6.6.1, for up to date 
HDBC-ODBC-1.1.3. (I tried installing both from package and from darcs 
head)

Installed and running from cygwin.

When I run it as runghc fail.hs I get a windows popup error ghc.exe has 
encountered a problem and needs to close, sorry for the inconvenience. 
ghci, same behavior.

When I run it as ghc -e 'main' fail.hs, I don't get a popup window, and no 
error message is output, but it fails all the same. (I know this because 
more complicated, non-minimal programs, fail.)

So this would seem to be a problem with ghc 6.8.1.

$ cat fail.hs

import Database.HDBC
import Database.HDBC.ODBC

main = connectODBC some valid connect string, works when run from 6.6.1, 
not from 6.8.1




---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] expanded standard lib

2007-11-19 Thread Thomas Hartman
Batteries included, I could take it or leave it. 

Where I think hackage could really benefit from copying perl strategy is 
automated testing of *all* packages under hackage darcs, not just blessed 
packages.

If this could be integrated into the buildbot of whatever ghc is under 
development that would be great. You would then have status reports on ghc 
itself, ghc plus extralibs (which the haskell core maintainers feel some 
degree of responsibility for), and hackage universe which the core 
people aren't responsible for, but the haskell community benefits from 
feedback. Better yet would be feedback per ghc version, and per platform 
(ubuntu, red hat, windows, on and on, whoever volunteers a test box for 
the buildbot)

For example, I just found out, it seems that HDBC-ODBC is broken on 
windows for ghc-6.8. It would be great to know this in advance before 
trying to use it. Package maintainers could get automated emails too if 
they want.

testing could be as basic as cabal install runs without errors, but could 
also include additional quickcheck tests or other types of test harness.

That would be nice for the community and the core devs, I think. 

thomas.




Justin Bailey [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
11/19/2007 02:08 PM

To
brad clawsie [EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] expanded standard lib






On Nov 19, 2007 10:25 AM, brad clawsie [EMAIL PROTECTED] wrote:
 so far the haskell community has taken the cpan route for most
 practical libs but i wonder if a batteries included approach might
 help get some key libraries to a more complete state. in particular, i
 would like to see support for basic internet protocols, database
 connectivity, and potentially xml parser support rolled into the ghc
 standard libs. there is always a strong debate on where the line is

I agree strongly. I particularly miss a standard HTTP library.

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] expanded standard lib

2007-11-19 Thread Thomas Hartman
the php documentation has user contributed notes where people can leave
sniplets of useful code as comments, eg

http://www.php.net/manual/en/introduction.php

I think this is a very nice feature.




Henning Thielemann [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
11/19/2007 05:21 PM

To
Haskell Cafe haskell-cafe@haskell.org
cc

Subject
Re: [Haskell-cafe] expanded standard lib







On Mon, 19 Nov 2007, Mads [ISO-8859-1] Lindstrøm wrote:

 It occurred to me that the voting could be implicit. That is, if 10
 libraries/programs use library X, then library X gets 10 votes. Kind of
 like Google PageRank for libraries.

It would be good if users could comment verbally. They could comment like
efficient implementation, but weakly typed interface, very general but
not very well documented. One cannot express everything with a scalar
popularity value.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Yampa Arcade: source code available?

2007-11-20 Thread Thomas Hartman
I was able to compile and play space invaders on linux. 

Hours of fun for the whole family :)

thomas.





Peter Verswyvelen [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
11/20/2007 06:46 AM
Please respond to
[EMAIL PROTECTED]


To
Don Stewart [EMAIL PROTECTED]
cc
Haskell-Cafe haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] The Yampa Arcade: source code available?






Thanks for the feedback. Unfortunatly the Space Invaders game uses HGL, 
which is not supported on Windows anymore. Is it supported on Linux?

Frag does compile and run on Windows using GHC 6.6.1, so that might be a 
better starting point.

What is the current consensus regarding (A)FRP? Is it a dead end? Are 
approaches like Modelica better suited for the job?

From the point of view of a veteran assembly/C++ game hacker like myself, 
it is funny to see that the same problems popup when doing reactive 
programming in a pure language like Haskell or an imperative language 
like C++... Recursive dependencies are problematic, be it with signals in 
FRP or with objects in C++. In videogames using an imperative language, 
this is often solved by just adding a global single frame delay between 
what is read and what is written. Ugly, but works in many cases. Or a 
third object is introduced that breaks the recursive dependency between 
the two problematic objects. If I'm correct, when switching from FRP to 
AFRP signals (type Signal a = Time - a) are no first class values 
anymore, only signal functions (type SF a b = Signal a - Signal b) are 
first class. Furthermore the handling of recursive dependencies/feedback 
is done solely in a loop arrow. 

I must say it is frustratring. I finally got to understand FRP from the 
SOE book, only to find out that it is not really the way to go ;-) Now I'm 
trying to grasp AFRP. It is incredibly interesting stuff, but for a 
not-so-abstract-thinking-average programmer like me, it is not an obvious 
task. Maybe *using* AFRP is easier than understanding the inner details...

Maybe it would be a good idea for the community if someone (maybe me, if I 
find the time ;-) to write a very very simple game using AFRP and GHC 
6.8.1? Even simpler than the Space Invaders game (which does not work 
anymore anyway), but which does show dynamic collections and switching? 
Maybe like Andrew Coppin mentioned, a very simple Tetris clone? Of course, 
this is not legal, Tetris is copyrighted, but maybe for tutorial purposes 
it can be allowed :)

Don Stewart wrote: 
sk:
 
On 19.11.2007, at 19:54, Peter Verswyvelen wrote:
 
I can find the paper, but is the source code for that Space 
Invaders alike game also available somewhere?
 
it's included here: http://haskell.org/yampa/afrp-0.4-src.tgz

btw, does anybody know what's the current state of affairs with yampa/ 
afrp? is the framework still developed further?
 

Can we get this uploaded to hackage? 

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] yhc install fails

2007-11-21 Thread Thomas Hartman
I'm having the devil of a time getting yhc to install.

http://hpaste.org/4028

or for posterity

[EMAIL PROTECTED]:~/yhc-install/yhcscons

... blah blah blah...

Compiling PreludeAux   ( src/packages/yhc-base-1.0/PreludeAux.hs )
YHC_build([src/packages/yhc-base-1.0/Foreign/Util.hbc],
[src/packages/yhc-base-1.0/Foreign/Util.hs])
inst/bin/yhc --core --cpp -c src/packages/yhc-base-1.0/Foreign/Util.hs
Compiling Foreign.Util ( src/packages/yhc-base-1.0/Foreign/Util.hs )
YHC_build([src/packages/yhc-base-1.0/Foreign/C/String.hbc],
[src/packages/yhc-base-1.0/Foreign/C/String.hs])
inst/bin/yhc --core --cpp -c src/packages/yhc-base-1.0/Foreign/C/String.hs
Error: File not found, Foreign.Storable
Reason: imported from Foreign.C.String
Looked in:
  /root/yhc-install/yhc/src/packages/yhc-base-1.0/
  /root/yhc-install/yhc/inst/lib/yhc/packages/yhc-base/1.0
scons: *** [src/packages/yhc-base-1.0/Foreign/C/String.hbc] Error 1
scons: building terminated because of errors.


[EMAIL PROTECTED]:~/yhc-install/yhcghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.1

advice?

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


Re: [Haskell-cafe] Call external program and get stdout

2007-11-24 Thread Thomas Hartman
dons did a blog post about a shell monad which I think does what you ask.

http://cgi.cse.unsw.edu.au/~dons/blog/2007/03

very nice, I use it myself.

t.

2007/11/22, Maurí­cio [EMAIL PROTECTED]:
 Hi,

 How can I call a program (like, for instance,
 'grep text *') and get the standard output?
 All actions I found (executeFile, system) do
 not give me the output of the program.

 Thanks,
 Maurício

 ___
 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] is there a more concise way to generate helper functions for a datatype built on records?

2007-11-24 Thread Thomas Hartman
I think I'm running into more or less the same issue discussed at

http://bloggablea.wordpress.com/2007/04/24/haskell-records-considered-grungy/

Just wondering if I missed anything, or if any of the ideas
considering better records setter/getters have been implemented in the
meantime.

t.


**

-- Is there any way to do the following more concisely?
-- Seems like a lot of boilerplate

data GameState = GameState { guesses :: Int, userHighScores ::
UserHighScores, answer :: Maybe Int }
  deriving Show

-- State Helpers ---
modGuesses f gSt  = _set_guesses ( (f . guesses) gSt) gSt
modUserHighScores f gSt = _set_userHighScores ( (f . userHighScores) gSt) gSt
modAnswer f gSt = _set_answer ( (f . answer) gSt) gSt

_set_guesses new gSt   = gSt {guesses=new}
_set_userHighScores new gSt = gSt { userHighScores=new }
_set_answer new gSt = gSt { answer=new }
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] An interesting monad: Prompt

2007-11-24 Thread Thomas Hartman
Looks very cool. So I tried playing with this code, unfortunately
couldn't get it to compile.

Could you double check that what you posted compiles, and if it does,
any idea what I'm doing wrong?

This is with

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

thanks, t.

Prelude :r
[1 of 1] Compiling Prompt   ( prompt.lhs, interpreted )

prompt.lhs:140:1:
Could not deduce (Monad tm)
  from the context (Monad (t m), MonadTrans t, MonadPrompt p m)
  arising from the superclasses of an instance declaration
  at prompt.lhs:140:1
Possible fix:
  add (Monad tm) to the instance declaration superclass context
In the instance declaration for `MonadPrompt p tm'

prompt.lhs:141:13:
Couldn't match expected type `tm' (a rigid variable)
   against inferred type `t1 m1'
  `tm' is bound by the instance declaration at prompt.lhs:140:1
  Expected type: p a - tm a
  Inferred type: p a - t1 m1 a
In the expression: lift . prompt
In the definition of `prompt': prompt = lift . prompt
Failed, modules loaded: none.

This is around

 -- Just for fun, make it work with StateT as well
 -- (needs -fallow-undecidable-instances)

 instance (Monad (t m), MonadTrans t, MonadPrompt p m) = MonadPrompt p (tm) 
 where
prompt = lift . prompt



2007/11/18, Ryan Ingram [EMAIL PROTECTED]:
 (This message is a literate haskell file.  Code for the Prompt monad is
 preceded by ; code for my examples is preceded by ] and isn't complete,
 but intended for illustration.)

 I've been trying to implement a few rules-driven board/card games in Haskell
 and I always run into the ugly problem of how do I get user input?

 The usual technique is to embed the game in the IO Monad:

 ] type Game = IO
 ] -- or
 ] type Game = StateT GameState IO

 The problem with this approach is that now arbitrary IO computations are
 expressible as part of a game action, which makes it much harder to
 implement
 things like replay, undo, and especially testing!

 The goal was to be able to write code like this:

 ] takeTurn :: Player - Game ()
 ] takeTurn player = do
 ] piece  - action (ChoosePiece player)
 ] attack - action (ChooseAttack player piece)
 ] bonusTurn - executeAttack piece attack
 ] when bonusTurn $ takeTurn player

 but be able to script the code for testing, allow undo, automatically
 be able to save replays, etc.

 While thinking about this problem earlier this week, I came up with the
 following solution:

  {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances
  #-}
  -- undecidable instances is only needed for the MonadTrans instance below
 
  module Prompt where
  import Control.Monad.Trans
  import Control.Monad.Identity

  class Monad m = MonadPrompt p m | m - p where
 prompt :: p a - m a

 prompt is an action that takes a prompt type and gives you a result.

 A simple example:
 ] prompt [1,3,5] :: MonadPrompt [] m = m Int

 This prompt would ask for someone to pick a value from the list and return
 it.
 This would be somewhat useful on its own; you could implement a choose
 function that picked randomly from a list of options and gave
 non-deterministic (or even exhaustive) testing, but on its own this wouldn't
 be much better than the list monad.

 What really made this click for me was that the prompt type could be built
 on a GADT:

 ] newtype GamePrompt a = GP (GameState, GameChoice a)
 ] data GameChoice a where
 ]-- pick a piece to act with
 ]ChoosePiece :: Player - GameChoice GamePiece
 ]-- pick how they should attack
 ]ChooseAttack :: Player - GamePiece - GameChoice AttackType
 ]-- etc.

 Now you can use this type information as part of a handler function:
 ] gameIO :: GamePrompt a - IO a
  ] gameIO (GP (state, ChoosePiece player)) = getPiece state player
 ] gameIO (GP (state, ChooseAttack player piece)) = attackMenu player piece
 ] -- ...

 The neat thing here is that the GADT specializes the type of IO a on the
 right hand side.  So, getPiece state player has the type IO GamePiece,
 not
 the general IO a.  So the GADT is serving as a witness of the type of
 response wanted by the game.

 Another neat things is that, you don't need to embed this in the IO monad at
 all; you could instead run a pure computation to do AI, or even use it for
 unit testing!

  -- unit testing example
  data ScriptElem p where SE :: p a - a - ScriptElem p
  type Script p = [ScriptElem p]
 
  infix 1 --
  (--) = SE


 ] gameScript :: ScriptElem GameChoice - GameChoice a - Maybe a
 ] gameScript (SE (ChoosePiece _)piece)  (ChoosePiece _)= Just piece
 ] gameScript (SE (ChooseAttack _ _) attack) (ChooseAttack _ _) = Just attack
 ] gameScript _  _
= Nothing
 ]
 ] testGame :: Script GameChoice
 ] testGame =
 ]   [ ChoosePiece  P1-- Knight
 ]   , ChooseAttack P1 Knight -- Charge
 ]   , ChoosePiece  P2-- FootSoldier
 ]   , ...
 ]   ]

 So, how to implement all of this?

  data Prompt (p 

Re: [Haskell-cafe] An interesting monad: Prompt

2007-11-24 Thread Thomas Hartman
fwiw, if I comment those two lines around 141 out, it compiles.

t.

2007/11/24, Thomas Hartman [EMAIL PROTECTED]:
 Looks very cool. So I tried playing with this code, unfortunately
 couldn't get it to compile.

 Could you double check that what you posted compiles, and if it does,
 any idea what I'm doing wrong?

 This is with

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

 thanks, t.

 Prelude :r
 [1 of 1] Compiling Prompt   ( prompt.lhs, interpreted )

 prompt.lhs:140:1:
 Could not deduce (Monad tm)
   from the context (Monad (t m), MonadTrans t, MonadPrompt p m)
   arising from the superclasses of an instance declaration
   at prompt.lhs:140:1
 Possible fix:
   add (Monad tm) to the instance declaration superclass context
 In the instance declaration for `MonadPrompt p tm'

 prompt.lhs:141:13:
 Couldn't match expected type `tm' (a rigid variable)
against inferred type `t1 m1'
   `tm' is bound by the instance declaration at prompt.lhs:140:1
   Expected type: p a - tm a
   Inferred type: p a - t1 m1 a
 In the expression: lift . prompt
 In the definition of `prompt': prompt = lift . prompt
 Failed, modules loaded: none.

 This is around

  -- Just for fun, make it work with StateT as well
  -- (needs -fallow-undecidable-instances)

  instance (Monad (t m), MonadTrans t, MonadPrompt p m) = MonadPrompt p (tm) 
  where
 prompt = lift . prompt



 2007/11/18, Ryan Ingram [EMAIL PROTECTED]:
  (This message is a literate haskell file.  Code for the Prompt monad is
  preceded by ; code for my examples is preceded by ] and isn't complete,
  but intended for illustration.)
 
  I've been trying to implement a few rules-driven board/card games in Haskell
  and I always run into the ugly problem of how do I get user input?
 
  The usual technique is to embed the game in the IO Monad:
 
  ] type Game = IO
  ] -- or
  ] type Game = StateT GameState IO
 
  The problem with this approach is that now arbitrary IO computations are
  expressible as part of a game action, which makes it much harder to
  implement
  things like replay, undo, and especially testing!
 
  The goal was to be able to write code like this:
 
  ] takeTurn :: Player - Game ()
  ] takeTurn player = do
  ] piece  - action (ChoosePiece player)
  ] attack - action (ChooseAttack player piece)
  ] bonusTurn - executeAttack piece attack
  ] when bonusTurn $ takeTurn player
 
  but be able to script the code for testing, allow undo, automatically
  be able to save replays, etc.
 
  While thinking about this problem earlier this week, I came up with the
  following solution:
 
   {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances
   #-}
   -- undecidable instances is only needed for the MonadTrans instance below
  
   module Prompt where
   import Control.Monad.Trans
   import Control.Monad.Identity
 
   class Monad m = MonadPrompt p m | m - p where
  prompt :: p a - m a
 
  prompt is an action that takes a prompt type and gives you a result.
 
  A simple example:
  ] prompt [1,3,5] :: MonadPrompt [] m = m Int
 
  This prompt would ask for someone to pick a value from the list and return
  it.
  This would be somewhat useful on its own; you could implement a choose
  function that picked randomly from a list of options and gave
  non-deterministic (or even exhaustive) testing, but on its own this wouldn't
  be much better than the list monad.
 
  What really made this click for me was that the prompt type could be built
  on a GADT:
 
  ] newtype GamePrompt a = GP (GameState, GameChoice a)
  ] data GameChoice a where
  ]-- pick a piece to act with
  ]ChoosePiece :: Player - GameChoice GamePiece
  ]-- pick how they should attack
  ]ChooseAttack :: Player - GamePiece - GameChoice AttackType
  ]-- etc.
 
  Now you can use this type information as part of a handler function:
  ] gameIO :: GamePrompt a - IO a
   ] gameIO (GP (state, ChoosePiece player)) = getPiece state player
  ] gameIO (GP (state, ChooseAttack player piece)) = attackMenu player piece
  ] -- ...
 
  The neat thing here is that the GADT specializes the type of IO a on the
  right hand side.  So, getPiece state player has the type IO GamePiece,
  not
  the general IO a.  So the GADT is serving as a witness of the type of
  response wanted by the game.
 
  Another neat things is that, you don't need to embed this in the IO monad at
  all; you could instead run a pure computation to do AI, or even use it for
  unit testing!
 
   -- unit testing example
   data ScriptElem p where SE :: p a - a - ScriptElem p
   type Script p = [ScriptElem p]
  
   infix 1 --
   (--) = SE
 
 
  ] gameScript :: ScriptElem GameChoice - GameChoice a - Maybe a
  ] gameScript (SE (ChoosePiece _)piece)  (ChoosePiece _)= Just piece
  ] gameScript (SE (ChooseAttack _ _) attack) (ChooseAttack _ _) = Just attack
  ] gameScript _  _
 = Nothing

Re: [Haskell-cafe] An interesting monad: Prompt

2007-11-24 Thread Thomas Hartman
that did it, thanks.

2007/11/24, Brent Yorgey [EMAIL PROTECTED]:


 
   -- Just for fun, make it work with StateT as well
   -- (needs -fallow-undecidable-instances)
 
   instance (Monad (t m), MonadTrans t, MonadPrompt p m) = MonadPrompt p
 (tm) where
  prompt = lift . prompt
 

 Looks like that should be MonadPrompt p (t m) rather than (tm).  Note the
 space.

 -Brent


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


Re: [Yhc] Re: [Haskell-cafe] yhc install fails

2007-11-24 Thread Thomas Hartman
Thanks, that worked.  I think there's some weird issue with the way
the build happens that requires you to do

rm -rf yhc; darccs get http://...yhc

for a truly fair build to take place. I saw something in a bug
report about how things get cached.

That means that an ok from a buildbot doesn't mean that the build is really ok.

It occurs to me that if it's possible to get the buildbot to do rm -rf
and darcs re-checkout that might be worth doing, until the issues with
stuff getting cached get resolved.

But maybe that's smiting a mosquito with a flamethrower.

thomas.

2007/11/22, Thomas Shackell [EMAIL PROTECTED]:
 Apologies, I broke this when I fixed the getArgs bug. It's actually just
 a build problem, Storable needs to be built before C/String. I didn't
 notice it because it only happens with a fresh (uncompiled) copy of yhc.
 Anyway fix pushed.


 Thanks

 Tom




 Neil Mitchell wrote:
  Yhc people:
 
  On Nov 21, 2007 8:46 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
  I'm having the devil of a time getting yhc to install.
 
  http://hpaste.org/4028
 
  or for posterity
 
  [EMAIL PROTECTED]:~/yhc-install/yhcscons
 
  ... blah blah blah...
 
  Compiling PreludeAux   ( src/packages/yhc-base-1.0/PreludeAux.hs )
  YHC_build([src/packages/yhc-base-1.0/Foreign/Util.hbc],
  [src/packages/yhc-base-1.0/Foreign/Util.hs])
  inst/bin/yhc --core --cpp -c src/packages/yhc-base-1.0/Foreign/Util.hs
  Compiling Foreign.Util ( src/packages/yhc-base-1.0/Foreign/Util.hs )
  YHC_build([src/packages/yhc-base-1.0/Foreign/C/String.hbc],
  [src/packages/yhc-base-1.0/Foreign/C/String.hs])
  inst/bin/yhc --core --cpp -c src/packages/yhc-base-1.0/Foreign/C/String.hs
  Error: File not found, Foreign.Storable
  Reason: imported from Foreign.C.String
  Looked in:
/root/yhc-install/yhc/src/packages/yhc-base-1.0/
/root/yhc-install/yhc/inst/lib/yhc/packages/yhc-base/1.0
  scons: *** [src/packages/yhc-base-1.0/Foreign/C/String.hbc] Error 1
  scons: building terminated because of errors.
 
 
  [EMAIL PROTECTED]:~/yhc-install/yhcghc --version
  The Glorious Glasgow Haskell Compilation System, version 6.8.1
 
  advice?
 
  thomas.
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
  ___
  Yhc mailing list
  [EMAIL PROTECTED]
  http://www.haskell.org/mailman/listinfo/yhc


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


[Haskell-cafe] problems building ycr2js

2007-11-24 Thread Thomas Hartman
OK, I struggled through the instructions at

http://haskell.org/haskellwiki/Yhc/Javascript/Users_guide#Downloading

and am getting tripped up at

(cd src/translator/js; make all install)

any advice?

... blah blah blah
ghc --make -i../../../depends/filepath splitter.hs -o
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/inst\
/bin/splitter
[1 of 4] Compiling System.FilePath.Version_0_11 (
../../../depends/filepath/System/FilePath/Version_0_11.hs,
../../../depend\
s/filepath/System/FilePath/Version_0_11.o )
[2 of 4] Compiling System.FilePath  (
../../../depends/filepath/System/FilePath.hs,
../../../depends/filepath/System/FilePat\
h.o )
[4 of 4] Compiling Main ( splitter.hs, splitter.o )
Linking 
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/inst/bin/splitter
...
echo  W3C/addtags.idl
for tag in SUB SUP SPAN BDO I B U S \
STRIKE BIG SMALL EM STRONG DFN CODE \
SAMP KBD VAR CITE ACRONYM ABBR \
DD DT NOFRAMES NOSCRIPT ADDRESS CENTER ; do \
ltag=`echo ${tag:1} | tr [:upper:] [:lower:]` ; \
echo   interface HTML${tag:0:1}${ltag}Element
: HTMLElement {  W3C/addtags.idl ; \
echo   };  W3C/addtags.idl ; \
echo  W3C/addtags.idl ; \
done
/bin/sh: Syntax error: Bad substitution
make: *** [W3C/addtags.idl] Error 2
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] problems building ycr2js

2007-11-25 Thread Thomas Hartman
Thanks Brandon. I'm on ubuntu feisty.

This breakage is a manifestation of

https://bugs.launchpad.net/ubuntu/+source/dash/+bug/61463

Basically, feisty switched the default shell to dash (which I'd
never heard of) from bash, because dash runs faster. But it's not 100%
compatible.

This was very controversial, but it appears that the feisty devs are
not amenable to switching /bin/sh back to bash, despite massive script
breakage, because using dash as default saves them tim. I must say, I
disagree with this move; and feel a bit let down by a distro that
overall has been very good to me.

Feisty devs suggest people fix the underlying problem, which is that
/bin/sh should not assume bash as default, but specify bash
explicitly. So I guess this is what should be done in the case of
building ycr2js; either that or make it dash compatible.

I will try to fix this myself by editing the makefile. I'll also
volunteer to the buildbot.

FWIW, this shouldn't affect ubuntu dapper (long term support) as they
still do the expected thing with sh.

thomas.

2007/11/24, Brandon S. Allbery KF8NH [EMAIL PROTECTED]:

 On Nov 24, 2007, at 17:07 , Thomas Hartman wrote:

  ltag=`echo ${tag:1} | tr [:upper:] [:lower:]
  ` ; \
  echo   interface HTML${tag:0:1}${ltag}Element
  : HTMLElement {  W3C/addtags.idl ; \
 (...)
  /bin/sh: Syntax error: Bad substitution

 Translation:  This program only works on Linux.

 That variable substitution is not supported by /bin/sh on any system
 where /bin/sh is not bash, which is to say any system that is not
 Linux.  (And possibly even not on some Linuxes; I think I've heard at
 least one distribution has tried to break the bash dependency, but
 I'm sure they'll go back soon because of all the people complaining
 about how broken it is.)

 --
 brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
 system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
 electrical and computer engineering, carnegie mellon universityKF8NH



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


Re: [Haskell-cafe] problems building ycr2js

2007-11-25 Thread Thomas Hartman
I got through this hurdle following suggestions at

https://wiki.ubuntu.com/DashAsBinSh

SHELL = /bin/bash at the top of the main makefile did not work, and I
did not bother going deeper down this route.

Rather I did sudo dpkg-reconfigure dash

and answered no when asked if sh should be dash. Thereafter, sh was bash.

Beh.

I also had to rm -rf ghc and run make again; ((cd src/translator/js;
make clean) was not sufficient. (Something wrong with clean?)

So this got me past the sh mis-aliasing issue but I'm now having
problems on the final ghc make command.

What  is System.FilePath.Version_0_09 ?

t.

[EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/jsghc
--make   -i../../compiler98 -i../../libraries/core
-i../../libraries/general -i../../../depends/filepath
-i../../../depends/play -i../../../depends/uniplate ycr2js.hs -o
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/inst/bin/ycr2js

ycr2js.hs:8:7:
Could not find module `System.FilePath.Version_0_09':
  Use -v to see a list of the files searched for.

[EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/jsghc 
--version
The Glorious Glasgow Haskell Compilation System, version 6.8.1
[EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/jsghc-pkg
list | grep -i filepath
filepath-1.1.0.0, (ghc-6.8.1), haskell-src-1.0.1.1,



2007/11/25, Brandon S. Allbery KF8NH [EMAIL PROTECTED]:

 On Nov 25, 2007, at 9:45 , Thomas Hartman wrote:

  Feisty devs suggest people fix the underlying problem, which is that
  /bin/sh should not assume bash as default, but specify bash
  explicitly. So I guess this is what should be done in the case of
  building ycr2js; either that or make it dash compatible.

 They're correct.  I now know there is no point in even thinking about
 YHC on Solaris or FreeBSD because it knows that /bin/sh is always
 bash.  But then, portability is generally not considered a useful
 feature in the Linux world

 --
 brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
 system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
 electrical and computer engineering, carnegie mellon universityKF8NH



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


Re: [Haskell-cafe] problems building ycr2js

2007-11-25 Thread Thomas Hartman
I was at least able to get things to build by doing

[EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/jsdarcs
whatsnew
{
hunk ./src/translator/js/ycr2js.hs 8
-import System.FilePath.Version_0_09
+import System.FilePath
hunk ./src/translator/js/ycr2js.hs 40
-Just x - return $ getDirectory $ getDirectory x
+Just x - return $ dropFileName x
}


2007/11/25, Thomas Hartman [EMAIL PROTECTED]:
 I got through this hurdle following suggestions at

 https://wiki.ubuntu.com/DashAsBinSh

 SHELL = /bin/bash at the top of the main makefile did not work, and I
 did not bother going deeper down this route.

 Rather I did sudo dpkg-reconfigure dash

 and answered no when asked if sh should be dash. Thereafter, sh was bash.

 Beh.

 I also had to rm -rf ghc and run make again; ((cd src/translator/js;
 make clean) was not sufficient. (Something wrong with clean?)

 So this got me past the sh mis-aliasing issue but I'm now having
 problems on the final ghc make command.

 What  is System.FilePath.Version_0_09 ?

 t.

 [EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/jsghc
 --make   -i../../compiler98 -i../../libraries/core
 -i../../libraries/general -i../../../depends/filepath
 -i../../../depends/play -i../../../depends/uniplate ycr2js.hs -o
 /home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/inst/bin/ycr2js

 ycr2js.hs:8:7:
 Could not find module `System.FilePath.Version_0_09':
   Use -v to see a list of the files searched for.

 [EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/jsghc 
 --version
 The Glorious Glasgow Haskell Compilation System, version 6.8.1
 [EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/jsghc-pkg
 list | grep -i filepath
 filepath-1.1.0.0, (ghc-6.8.1), haskell-src-1.0.1.1,



 2007/11/25, Brandon S. Allbery KF8NH [EMAIL PROTECTED]:
 
  On Nov 25, 2007, at 9:45 , Thomas Hartman wrote:
 
   Feisty devs suggest people fix the underlying problem, which is that
   /bin/sh should not assume bash as default, but specify bash
   explicitly. So I guess this is what should be done in the case of
   building ycr2js; either that or make it dash compatible.
 
  They're correct.  I now know there is no point in even thinking about
  YHC on Solaris or FreeBSD because it knows that /bin/sh is always
  bash.  But then, portability is generally not considered a useful
  feature in the Linux world
 
  --
  brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
  system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
  electrical and computer engineering, carnegie mellon universityKF8NH
 
 
 

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


Re: [Haskell-cafe] New demo/test program for Yhc Javascript backend

2007-11-26 Thread Thomas Hartman
It would be really helpful if you could include this (and other)
examples in an /examples directory under

src/translator/js

in the yhc darcs distribution, with working makefiles that validate
against the buildbot.

Something seems a bit off for me, probably forgot a tilde somewheres.

t.

2007/11/17, Dimitry Golubovsky [EMAIL PROTECTED]:
 Hi,

 For those of you who are interested in using Haskell in client-side
 web application programming:

 I have added a new demo/test program to this Wiki page (Does it leak?):

 http://haskell.org/haskellwiki/Yhc/Javascript

 This demo program shows some progress made since the first
 announcement of Yhc Javascript backend (Core to Javascript converter)
 was made about a year ago. Please test the demo for functionality and
 memory leaks in various browsers. Your feedback is appreciated.

 The demo program is self-contained (does not require any Haskell
 libraries beyond those included with Yhc). There is a darcs repo:
 http://www.golubovsky.org/repos/wsptest/ from which this demo program
 along with Makefile can be obtained if anybody wants to play with the
 code.

 Thanks.

 --
 Dimitry Golubovsky

 Anywhere on the Web
 ___
 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] getDirectoryContents still causing problems Re: problems building ycr2js (hopefully fixed)

2007-11-26 Thread Thomas Hartman
still having problems darcs pulling your updates, related to System.FilePath.

did you make clean and then make again?

I darcs pulled everything.

(cd src/translator/js; make all install)

... ...
(cd 
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskell;
\
  for f in `find . -name '*.hs' | sort` ; do make -s -f
/home/thartman/haskell-installs/yhc-install/yhc/src/translat\
or/js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)

-s flag silences, we don't want that, with verbose output again we see
that make is failing for a huge number of packages

(cd /home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/h\
askell; \
  for f in `find . -name '*.hs' | sort` ; do make -f
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/\
js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
 yhc --core --no-bytecode CDOM/Level1/DomUtils.hs
yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)

make: *** [CDOM/Level1/DomUtils.ycr] Error 1
yhc --core --no-bytecode CDOM/Level1/Events.hs
yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)

...

[EMAIL 
PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskellyhc
--core --no-bytecode CDOM/Level1/DomUtils\
.hs
yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)

Unfamiliar with yhc, I couldn't figure out where getDirectory contents
is being called from.

Grepping at the root, I guess something here is causing problems

[EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhcgrep -irl
getDirectoryContents *
Make/Useful.hs
inst/bin/yhc
src/compiler98/Package.hs
src/packages/yhc-base-1.0/System/Directory.hs
src/packages/haskell98-1.0/Directory.hs
src/tester/Main.hs
tests/conformance98/Directory/getDirContents/Main.hs

best, thomas.

2007/11/25, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 On Nov 25, 2007 5:50 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
  Thanks Dmitri, I also had to fix an issue with System.FilePath,
  there's a message about this on haskell cafe.

 In fact, takeDirectory is the right replacement for getDirectory in
 older FilePath. I have pushed this change too.

 Thanks.

 --
 Dimitry Golubovsky

 Anywhere on the Web

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


[Haskell-cafe] Re: getDirectoryContents still causing problems Re: problems building ycr2js (hopefully fixed)

2007-11-26 Thread Thomas Hartman
False alarm.

I rm -rf ed yhhc, fresh darcs got the latest yhc, reinstalled yhc, and redid

(cd src/translator/js; make all install)

and it built.


2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 It looks like this comes from Yhc, not from the Javascript backend.

 Have you done the full sequence of (starting with clean repo)?

 darcs get darcs.haskell.org/yhc
 scons core=1 build
 scons prefix=... install # whatever your stuff goes, and yhc will be
 in bin/ from that, and this bin/ should be on your path
 (cd src/translator/js; make all install)

 Please let me know where it fails.

 Thank you.

 On 11/26/07, Thomas Hartman [EMAIL PROTECTED] wrote:
  still having problems darcs pulling your updates, related to 
  System.FilePath.
 
  did you make clean and then make again?
 
  I darcs pulled everything.
 
  (cd src/translator/js; make all install)
 
  ... ...
  (cd 
  /home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskell;
  \
   for f in `find . -name '*.hs' | sort` ; do make -s -f
  /home/thartman/haskell-installs/yhc-install/yhc/src/translat\
  or/js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
  yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
  getDirectoryContents: does not exist (No such fi\
  le or directory)
 
  -s flag silences, we don't want that, with verbose output again we see
  that make is failing for a huge number of packages
 
  (cd /home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/h\
  askell; \
   for f in `find . -name '*.hs' | sort` ; do make -f
  /home/thartman/haskell-installs/yhc-install/yhc/src/translator/\
  js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
   yhc --core --no-bytecode CDOM/Level1/DomUtils.hs
  yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
  getDirectoryContents: does not exist (No such fi\
  le or directory)
 
  make: *** [CDOM/Level1/DomUtils.ycr] Error 1
  yhc --core --no-bytecode CDOM/Level1/Events.hs
  yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
  getDirectoryContents: does not exist (No such fi\
  le or directory)
 
  ...
 
  [EMAIL 
  PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskellyhc
  --core --no-bytecode CDOM/Level1/DomUtils\
  .hs
  yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
  getDirectoryContents: does not exist (No such fi\
  le or directory)
 
  Unfamiliar with yhc, I couldn't figure out where getDirectory contents
  is being called from.
 
  Grepping at the root, I guess something here is causing problems
 
  [EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhcgrep -irl
  getDirectoryContents *
  Make/Useful.hs
  inst/bin/yhc
  src/compiler98/Package.hs
  src/packages/yhc-base-1.0/System/Directory.hs
  src/packages/haskell98-1.0/Directory.hs
  src/tester/Main.hs
  tests/conformance98/Directory/getDirContents/Main.hs
 
  best, thomas.
 
  2007/11/25, Dimitry Golubovsky [EMAIL PROTECTED]:
   Thomas,
  
   On Nov 25, 2007 5:50 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
Thanks Dmitri, I also had to fix an issue with System.FilePath,
there's a message about this on haskell cafe.
  
   In fact, takeDirectory is the right replacement for getDirectory in
   older FilePath. I have pushed this change too.
  
   Thanks.
  
   --
   Dimitry Golubovsky
  
   Anywhere on the Web
  
 


 --
 Dimitry Golubovsky

 Anywhere on the Web

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


[Haskell-cafe] Re: getDirectoryContents still causing problems Re: problems building ycr2js (hopefully fixed)

2007-11-26 Thread Thomas Hartman
Based on my experience, I wouldn't recommend doing scons fullclean;
rather, I would darcs checkout and go from scratch. Annoying, but
seems to work better.

thomas.



2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 This happens sometimes as Yhc depends on many other packages not very
 well in sync (e. g. FilePath). Plus, internal dependencies are not
 always tracked very well. Or binary core format gets upgraded (that
 means, the core linker does not accept older versions of core files,
 and all of them have to be regenerated).

 You may see sometimes recommendations in the Yhc mailing list: pull
 patches, then do scons fullclean. Or re-check the whole repo out,
 which is basically the same.

 Thanks.

 On 11/26/07, Thomas Hartman [EMAIL PROTECTED] wrote:
  False alarm.
 
  I rm -rf ed yhhc, fresh darcs got the latest yhc, reinstalled yhc, and redid
 
  (cd src/translator/js; make all install)
 
  and it built.
 
  2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
   Thomas,
  
   It looks like this comes from Yhc, not from the Javascript backend.
  
   Have you done the full sequence of (starting with clean repo)?
  
   darcs get darcs.haskell.org/yhc
   scons core=1 build
   scons prefix=... install # whatever your stuff goes, and yhc will be
   in bin/ from that, and this bin/ should be on your path
   (cd src/translator/js; make all install)
  
   Please let me know where it fails.
  
   Thank you.
  
   On 11/26/07, Thomas Hartman [EMAIL PROTECTED] wrote:
still having problems darcs pulling your updates, related to 
System.FilePath.
   
did you make clean and then make again?
   
I darcs pulled everything.
   
(cd src/translator/js; make all install)
   
... ...
(cd 
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskell;
\
 for f in `find . -name '*.hs' | sort` ; do make -s -f
/home/thartman/haskell-installs/yhc-install/yhc/src/translat\
or/js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
yhc: 
/home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)
   
-s flag silences, we don't want that, with verbose output again we see
that make is failing for a huge number of packages
   
(cd 
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/h\
askell; \
 for f in `find . -name '*.hs' | sort` ; do make -f
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/\
js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
 yhc --core --no-bytecode CDOM/Level1/DomUtils.hs
yhc: 
/home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)
   
make: *** [CDOM/Level1/DomUtils.ycr] Error 1
yhc --core --no-bytecode CDOM/Level1/Events.hs
yhc: 
/home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)
   
...
   
[EMAIL 
PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskellyhc
--core --no-bytecode CDOM/Level1/DomUtils\
.hs
yhc: 
/home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)
   
Unfamiliar with yhc, I couldn't figure out where getDirectory contents
is being called from.
   
Grepping at the root, I guess something here is causing problems
   
[EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhcgrep -irl
getDirectoryContents *
Make/Useful.hs
inst/bin/yhc
src/compiler98/Package.hs
src/packages/yhc-base-1.0/System/Directory.hs
src/packages/haskell98-1.0/Directory.hs
src/tester/Main.hs
tests/conformance98/Directory/getDirContents/Main.hs
   
best, thomas.
   
2007/11/25, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 On Nov 25, 2007 5:50 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
  Thanks Dmitri, I also had to fix an issue with System.FilePath,
  there's a message about this on haskell cafe.

 In fact, takeDirectory is the right replacement for getDirectory in
 older FilePath. I have pushed this change too.

 Thanks.

 --
 Dimitry Golubovsky

 Anywhere on the Web

   
  
  
   --
   Dimitry Golubovsky
  
   Anywhere on the Web
  
 


 --
 Dimitry Golubovsky

 Anywhere on the Web

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


Re: [Haskell-cafe] New demo/test program for Yhc Javascript backend

2007-11-26 Thread Thomas Hartman
2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 All published examples (source, html) go into web/jsdemos subdirectory
 (from the root of the Yhc repo source tree).

right; it would be nice to have a makefile (or makefiles) there that
works out of the box, rather than relying on the wiki

http://haskell.org/haskellwiki/Yhc/Javascript/Users_guide#Building_and_installation_on_Unix

which, among other things, requires cleaning up tabs for the
formatting to work. Even if it can't be incorporated into the
buildbot, it would be nice to have some working make examples to
orient one's self.

Secondly, with regards to your cps changes, are you aware of *any*
demos that will compile from head?

I want to get going with this because I have a situation where ycr2js
would be really useful for an in-house project,  client side table
filtering on large tables.

Maybe I should say a bit about this as well so you can tell me if this
seems realistic, I'll write a separate email about that.

t.


 Not all of them may be compilable at the moment though (and some will
 never be compilable in the future, just kept there for historic
 reasons - that's why they are not being tested by the buildbot).

 I am currently going through transition from plain CPS to Cont monad,
 so regular monadic notation can be used instead of CPS. However I am
 experiencing memory leaks in MSIE (try the EchoM example) which I did
 not expect to happen (never had them in plain CPS). If I cannot fix
 that I'll roll back to plain CPS.

 On 11/26/07, Thomas Hartman [EMAIL PROTECTED] wrote:
  It would be really helpful if you could include this (and other)
  examples in an /examples directory under
 
  src/translator/js
 
 --
 Dimitry Golubovsky

 Anywhere on the Web

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


[Haskell-cafe] idea for ycr2js demo, actually meant for an in-house project. is this realistic?

2007-11-26 Thread Thomas Hartman
As I mentioned in a previous post, I've been spending quite some time
trying to get live with ycr2js because there's a project it would be
useful for for my day job, as well as making another nice demo to add
to the list.

Basically, I have some functionality that does client-side filtering
of large html tables. It's pretty smart -- it can filter on multiple
columns, and the filter can be any javascript expression from String
- Bool (to use haskell terminology in a javascript context). The
filter works by hiding rows that don't match the filter; it's built on
mochikit.

Unfortunately this is rather ugly from the user's perspective. You
have to type something like

x.match(my string)

into the search string or

(x  5  x  7)

where x is some variable buried in the javascript.

I would like for the user to be able to enter search criteria in a
more intuitive google style

=skittles or (=~mr. goodbar and =~15 grams)

so you need a parser that takes the search criteria and converts it
into a function from (String - Bool)

This parser is relatively easy to build in haskell; I built it. It's
surely also doable in javascript, but not as nicely, easily, and
cleanly, and being a better haskell than javascript programmer as
well, I would rather generate the javascript from haskell.

So at any rate what I have is

-- parser from String - (String - Bool) (haskell)
-- working html/javascript built on mochikit that filters a
multicolumn table with multiple filter expressions. There is a
function here that takes a string and returns a bool, but it's icky,
doesn't recognize quoted strings, doesn't recognize boolean and/or or
parentheses. I want to replace it with a function generated from
haskell that does all of these things.

What I need is to combine these two components.

I'll try and post some minimal source code for the parser and the
javascript/mochikit stuff soon, and if this problem is tractable it
can become another example for ycr2js.

A possible reason why this wouldn't work is that when you're using the
ycr2js stuff, *everything* has to be generated; it doesn't play well
plugging in an existing javascript function with a generated one. I'd
be surprised if that was the case, but since I haven't actually
successfully generated any code yet i guess anything possible. At any
rate, if this sort of thing could cause issues please someone in the
know give me fair warning.

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


Re: [Haskell-cafe] New demo/test program for Yhc Javascript backend

2007-11-26 Thread Thomas Hartman
Fair enough, I can wait for a couple of days.

You might want to fix

[EMAIL 
PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/js/testdarcs
whatsnew
{
hunk ./src/translator/js/test/Makefile 12
-   $(YHC) -includes ../lib/haskell -linkcore $
+   $(YHC) --includes ../lib/haskell --linkcore $
}

immediately though.

This is the only makefile for the javascript stuff in the repo, and it
doesn't work because of - instead of --. Given your darcs log message
that the javascript compiler would be broken I initially assumed that
was the reason and not a flags change.

More questions. So okay, it builds, I have Test1.html. It's a blank
file with a bunch of javascript. I have firebug, so I can ask execute
stuff in the javascript console. But I can't figure out what to
execute. factorial isn't there, nor sumlst... none of the interesting
looking functions? So what is this supposed to do? And can I change
the makefile so that at least it generates javascript where I can
execute the interesting functions in the firebug console?

thomas.

2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 OK, let's try to get on the same page regarding where the project is.

 The Javascript generator is maybe not optimal, but it works.

 DOM bindings are generated from W3C's IDL files, so everything DOM
 provides may be used by Haskell programs, whether in CPS notation, or
 monadic, this will become clear, which form to use, in the near
 future.

 The recent HsWTKDemo works well in major browsers (FF, MSIE, Opera)
 except for Safari, but this is probably a hard case due to the lack of
 debugging information.

 If you look at its source 
 http://darcs.haskell.org/yhc/web/jsdemos/HsWTKDemo.hs

 (no, you cannot compile it at the moment because it is plain CPS) you
 may see some stuff related to static page layout definition in
 declarative way (look for upcntW, factW, etc.) This part is almost
 finalized wrt notation. What's left undecided is whether to use plain
 CPS notation, or monadic notation for parts of the code that involve
 imperative stuff (see e. g. updateD function where node's children are
 replaced in order to update what's displayed).

 This all works perfectly in plain CPS. Understanding that nowadays
 Monads are mainstream, I am trying to adopt monadic notation based on
 the Cont monad instead of plain CPS. I ran one example (EchoM) on MSIE
 and noticed memory leaks on each user's action. However when the page
 is unloaded, MSIE shrinks in size which is a good sign. I think I know
 where the cause is, tonight I'll try to fix it. If unsuccessful, I'll
 probably unroll all monadic changes.

 Next steps are:

 1. Finalize the code notation for static layout and imperative part
 and check the base library into the Yhc repo

 2. Generate haddock documentation

 3. Write a better documentation for developers

 4. Set up a web service that would allow everybody to submit their
 Haskell source and generate HTML page with Javascript in response;
 this I think can be done based on the hpaste program (backed by
 Happs).

 Just for now, you have to wait a couple days while I am straightening
 the monadic thing out. I'd appreciate if you look at the code of
 HsWTKDemo and give me your impressions about notation, etc.

 Thank you.

 --
 Dimitry Golubovsky

 Anywhere on the Web

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


Re: [Haskell-cafe] RFI: HDBC-1.1.3 build error

2007-11-28 Thread Thomas Hartman
put 

{-# OPTIONS_GHC -fglasgow-exts #-}

at the the top of the file that complains.





Jim Stuttard [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
11/28/2007 08:06 AM
Please respond to
[EMAIL PROTECTED]


To
Haskell-Cafe@haskell.org
cc

Subject
[Haskell-cafe] RFI: HDBC-1.1.3 build error






ubuntu gutsy
ghc-6.8.1
HDBC-1.1.3$ runghc Setup.lhs build
Preprocessing library HDBC-1.1.3...
Building HDBC-1.1.3...
[3 of 6] Compiling Database.HDBC.Types ( Database/HDBC/Types.hs, 
dist/build/Database/HDBC/Types.o )

Database/HDBC/Types.hs:208:0:
Illegal polymorphic or qualified type: forall conn.
   (IConnection conn) =
   conn - b
In the type signature for `withWConn':
  withWConn :: forall b.
   ConnWrapper - (forall conn. (IConnection conn) = 
conn - b) - b

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Progress indications

2007-11-29 Thread Thomas Hartman
Obviously heaps better than what I initially proposed.

However, I would argue to go boldly with unsafePerformIO, which is the 
same thing Debug.Trace uses

http://darcs.haskell.org/ghc-6.6/packages/base/Debug/Trace.hs

since we are after debug.trace -like behavior.

In particular, you wouldn't be able to use the unsafeInterleaveIO version 
to do a progress indicator for the function I initially proposed

 t = foldr (+) 0 [1..1]

since your lift would wind up being lifted into IO. But you would be able 
to use the unsafePerformIO version, just like in what I initially proposed 
you could use trace.

t = foldr (+) 0 ( lessSafeMonitoryProgress f [1..1] )
  where f i | i mod 1000 == 0 = (putStrLn . show ) i
   | otherwise = return ()
 
Make sense?

thomas.





David Roundy [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
11/28/2007 06:16 PM

To
haskell-cafe@haskell.org
cc

Subject
Re: [Haskell-cafe] Progress indications






On Wed, Nov 28, 2007 at 05:58:07PM -0500, Thomas Hartman wrote:
 maybe Debug.Trace? like...
 
 import Debug.Trace
 
 t = foldr debugf 0 [1..1]
 
 f :: Int - Int - Int
 f = (+)
 
 -- same typesig as f
 debugf :: Int - Int - Int
 debugf x y | y `mod` 1000 == 0 = x + (trace (show y) y)
 debugf x y = x + y

Or, more flexibly:

import System.IO.Unsafe ( unsafeInterleaveIO )

monitorProgress :: (Int - IO ()) - [a] - IO [a]
monitorProgress f xs = mapM f' $ zip [0..] xs
   where f' (n,x) = unsafeInterleaveIO (f n  return x)

You could, of course, make this a function

lessSafeMonitoryProgress :: (Int - IO ()) - [a] - [a]

by using unsafePerformIO instead of unsafeInterleaveIO, but that seems
slightly scary to me.

In any case, you can stick this on whichever of the lists you want to
monitor the progress of.
-- 
David Roundy
Department of Physics
Oregon State University
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Strings and utf-8

2007-11-29 Thread Thomas Hartman
A translation of

http://www.ahinea.com/en/tech/perl-unicode-struggle.html

from perl to haskell would be a very useful piece of documentation, I
think.

That explanation really helped me get to grips with the encoding stuff, in
a perl context.

thomas.





Duncan Coutts [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
11/29/2007 07:44 AM

To
Maurí­cio [EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] Re: Strings and utf-8






On Wed, 2007-11-28 at 17:38 -0200, Maurí­cio wrote:
 (...)  When it's phrased as truncates to 8
   bits it sounds so simple, surely all we need
   to do is not truncate to 8 bits right?
  
   The problem is, what encoding should it pick?
   UTF8, 16, 32, EBDIC? (...)
  
   One sensible suggestion many people have made
   is that H98 file IO should use the locale
   encoding and do Unicode/String - locale
   conversion. (...)

 I'm really afraid of solutions where the behavior
 of your program changes with an environment
 variable that not everybody has configured
 properly, or even know to exist.

Be afraid of all your standard Unix utils in that case. They are all
locale dependent, not just for encoding but also for sorting order and
the language of messages.

Using the locale is standard Unix behaviour (and these days the locale
usually specifies UTF8 encoding). On OSX the default should be UTF8. On
Windows it's a bit less clear, supposedly text files should use UTF16
but nobody actually does that as far as I can see.

Duncan

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



---

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Progress indications

2007-11-29 Thread Thomas Hartman
However, when I actually tried this out, I couldn't get it to compile. 

So I wound up back with trace. This does compile, and I think it does 
pretty much what we want in a noninvasive way, using unsafePerformIO via 
trace.

import Debug.Trace

t = foldr (+) 0 ( monitorprogress f [1..1] ) 

monitorprogress f xs = map g $ zip [1..] xs
  where g (i,a) | f i == True = trace (show i) a
| otherwise = a 

f x | x `mod` 1000 == 0 = True
| otherwise = False




Thomas Hartman/ext/[EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
11/29/2007 10:43 AM

To
haskell-cafe@haskell.org, [EMAIL PROTECTED]
cc

Subject
Re: [Haskell-cafe] Progress indications







Obviously heaps better than what I initially proposed. 

However, I would argue to go boldly with unsafePerformIO, which is the 
same thing Debug.Trace uses 

http://darcs.haskell.org/ghc-6.6/packages/base/Debug/Trace.hs 

since we are after debug.trace -like behavior. 

In particular, you wouldn't be able to use the unsafeInterleaveIO version 
to do a progress indicator for the function I initially proposed 

 t = foldr (+) 0 [1..1] 

since your lift would wind up being lifted into IO. But you would be able 
to use the unsafePerformIO version, just like in what I initially proposed 
you could use trace. 

t = foldr (+) 0 ( lessSafeMonitoryProgress f [1..1] ) 
  where f i | i mod 1000 == 0 = (putStrLn . show ) i 
   | otherwise = return () 
 
Make sense? 

thomas. 




David Roundy [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED] 
11/28/2007 06:16 PM 


To
haskell-cafe@haskell.org 
cc

Subject
Re: [Haskell-cafe] Progress indications








On Wed, Nov 28, 2007 at 05:58:07PM -0500, Thomas Hartman wrote:
 maybe Debug.Trace? like...
 
 import Debug.Trace
 
 t = foldr debugf 0 [1..1]
 
 f :: Int - Int - Int
 f = (+)
 
 -- same typesig as f
 debugf :: Int - Int - Int
 debugf x y | y `mod` 1000 == 0 = x + (trace (show y) y)
 debugf x y = x + y

Or, more flexibly:

import System.IO.Unsafe ( unsafeInterleaveIO )

monitorProgress :: (Int - IO ()) - [a] - IO [a]
monitorProgress f xs = mapM f' $ zip [0..] xs
  where f' (n,x) = unsafeInterleaveIO (f n  return x)

You could, of course, make this a function

lessSafeMonitoryProgress :: (Int - IO ()) - [a] - [a]

by using unsafePerformIO instead of unsafeInterleaveIO, but that seems
slightly scary to me.

In any case, you can stick this on whichever of the lists you want to
monitor the progress of.
-- 
David Roundy
Department of Physics
Oregon State University
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


---

This e-mail may contain confidential and/or privileged information. If you 

are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Progress indications

2007-11-29 Thread Thomas Hartman
but there's no risk using trace is there?

t.

 The unsafe... functions are called that
for a reason, and their use should be highly discouraged,
except in cases where there is absolutely no other
reasonable way. 




Yitzchak Gale [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
11/29/2007 05:01 PM

To
Andrew Coppin [EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] Progress indications






Bit Connor wrote:
 computation is. And since it's all calls to map and filter et al., it's
 ...it's not immediately clear how to provide any feedback
 on how much longer there is to wait.

Andrew Coppin wrote:
 It seems unsafePerformIO is the way to go here.
 ...unsafeInterleaveIO

I disagree. The unsafe... functions are called that
for a reason, and their use should be highly discouraged,
except in cases where there is absolutely no other
reasonable way. I don't believe that this is one
of those cases.

A better approach is to use pure monads. Instead of

f :: ... - a

write functions whose type is something like

f :: ... - MyMonad a

where MyMonad is defined in one and only
one place in your program. Or, better yet,
polymorphic things like

f :: Monad m = ... - m a
f :: MyMonadClass m = ... - m a

Then when you later need to add something
like progress indicators, you just add that
to the capabilities of your monad, and add
some updateProgress calls to your functions.
By using do notation wisely, you can
keep your abstractions just as clear as they
were, and cleanly separated from the progress logic.

Other things you may need to add later in
real-world programs are exception handling,
logging, trace, etc. All of these are easy if you
started out in a monad.

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] An interesting monad: Prompt

2007-12-03 Thread Thomas Hartman
I've been playing with MonadPrompt for about ten days now, trying to get 
it to do something useful for me.

Specifically, I'm trying to implement guess a number since that's the 
hello world of haskell state programs, or so it seems to me. I want to 
have this with scripting / replay / undo and the other goodies claimed 
possible

http://thomashartman-learning.googlecode.com/svn/trunk/haskell/guessANumber

It's been slow going due to still getting to grips with GADTs and other 
more advanced features of the typing system.

If Ryan (or anyone) would care to share any working code for a simple game 
that uses MonadPrompt, ideally with scripting / replay / undo that would 
be extremely helpful.

Otherwise I'll be back with more specific questions about my attempts to 
use this stuff soon enough :)

(At present, that;'s just trying to get some of the more interesting code 
you posted as untested to compile.)

For what it's worth, my game currently saves high some (but not all) 
state-y information in a serialized form to track high scores. If I can 
get this working with MonadPrompt, my next quest will be to use MACID to 
do the serialization instead, and then *all* state will be saved if I 
understand correctly.

t.




Ryan Ingram [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
11/18/2007 07:22 PM

To
haskell haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] An interesting monad: Prompt






(This message is a literate haskell file.  Code for the Prompt monad is
preceded by ; code for my examples is preceded by ] and isn't 
complete, 
but intended for illustration.)

I've been trying to implement a few rules-driven board/card games in 
Haskell
and I always run into the ugly problem of how do I get user input?

The usual technique is to embed the game in the IO Monad: 

] type Game = IO
] -- or
] type Game = StateT GameState IO

The problem with this approach is that now arbitrary IO computations are
expressible as part of a game action, which makes it much harder to 
implement 
things like replay, undo, and especially testing!

The goal was to be able to write code like this:

] takeTurn :: Player - Game ()
] takeTurn player = do
] piece  - action (ChoosePiece player) 
] attack - action (ChooseAttack player piece)
] bonusTurn - executeAttack piece attack
] when bonusTurn $ takeTurn player

but be able to script the code for testing, allow undo, automatically 
be able to save replays, etc.

While thinking about this problem earlier this week, I came up with the
following solution:

 {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances  #-}
 -- undecidable instances is only needed for the MonadTrans instance 
below 

 module Prompt where
 import Control.Monad.Trans
 import Control.Monad.Identity

 class Monad m = MonadPrompt p m | m - p where
prompt :: p a - m a

prompt is an action that takes a prompt type and gives you a result. 

A simple example:
] prompt [1,3,5] :: MonadPrompt [] m = m Int

This prompt would ask for someone to pick a value from the list and return 
it.
This would be somewhat useful on its own; you could implement a choose 
function that picked randomly from a list of options and gave
non-deterministic (or even exhaustive) testing, but on its own this 
wouldn't
be much better than the list monad.

What really made this click for me was that the prompt type could be built 

on a GADT:

] newtype GamePrompt a = GP (GameState, GameChoice a)
] data GameChoice a where
]-- pick a piece to act with
]ChoosePiece :: Player - GameChoice GamePiece
]-- pick how they should attack 
]ChooseAttack :: Player - GamePiece - GameChoice AttackType
]-- etc.

Now you can use this type information as part of a handler function:
] gameIO :: GamePrompt a - IO a
] gameIO (GP (state, ChoosePiece player)) = getPiece state player
] gameIO (GP (state, ChooseAttack player piece)) = attackMenu player piece
] -- ...

The neat thing here is that the GADT specializes the type of IO a on the 

right hand side.  So, getPiece state player has the type IO GamePiece, 
not
the general IO a.  So the GADT is serving as a witness of the type of
response wanted by the game.

Another neat things is that, you don't need to embed this in the IO monad 
at
all; you could instead run a pure computation to do AI, or even use it for
unit testing!

 -- unit testing example
 data ScriptElem p where SE :: p a - a - ScriptElem p 
 type Script p = [ScriptElem p]

 infix 1 --
 (--) = SE


] gameScript :: ScriptElem GameChoice - GameChoice a - Maybe a
] gameScript (SE (ChoosePiece _)piece)  (ChoosePiece _)= Just 
piece 
] gameScript (SE (ChooseAttack _ _) attack) (ChooseAttack _ _) = Just 
attack
] gameScript _  _  = Nothing
]
] testGame :: Script GameChoice
] testGame =
]   [ ChoosePiece  P1-- Knight 
]   , ChooseAttack P1 Knight -- Charge
]   , ChoosePiece  P2-- FootSoldier
]   , ...
]   ]

So, how to implement all of this?

 

Fw: [Haskell-cafe] Re: do

2007-12-03 Thread Thomas Hartman
It took me forever to get comfortable with monads.

I think it helps if you've seen continuations, or done FP before, or a 
variety of things that build familiarity.

But probably the only thing that I think will work for the masses of 
plodders (there are always a few stars to crash the curve) is a desire to 
learn and tons of practice.

I wouldn't worry so much about the ideal way to introduce the material.

Oh, one other thing. You learn monads when you need them. You need IO 
right away... well, after you tired of playing with pure functions in the 
ghci sandbox.

my 2c.

t.






Dan Piponi [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
12/03/2007 07:19 PM

To
haskell-cafe@haskell.org
cc

Subject
Re: [Haskell-cafe] Re: do






On Dec 3, 2007 3:54 PM, Ben Franksen [EMAIL PROTECTED] wrote:

 I don't buy this. As has been noted by others before, IO is a very 
special
 case, in that it can't be defined in Haskell itself, and there is no
 evaluation function runIO :: IO a - a.

I'm not sure what a function of type m a - a has to do with the
concept of a monad. And I don't really see what the problem is with
the IO monad not being definable in (pure) Haskell. IO exposes the
same interface as every other Monad, and you need to use that
interface to get visible results. So people have to learn it whatever.
And the whole point of the Monad is that it's an interface, not a
specific implementation.

 I'd rather use a simple example like Maybe (modeling failure as an 
effect).

And I'd like to see more people getting off the ground doing
interesting stuff with Haskell before their attention spans for
pointless-seeming new stuff run out. I'm not talking about the
smartest people in computer science courses here. I'm talking about
the millions of people writing everyday Python and Ruby scripts, say,
who might benefit from a more expressive, type-safe, well-thought out,
fast and compiled language.
--
Dan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] An interesting monad: Prompt

2007-12-04 Thread Thomas Hartman
Thank you!

I really appreciate your explanation, and I hope this will enable me
to do some interesting and usefull stuff, in addition to firming up my
understanding of some of the more advanced haskell type system
features.

MACID is a sort of RDBMS replacement used as a backend by the HAppS
web framework.

To quote from http://www.haskell.org/communities/05-2007/html/report.html

Apps as Simple State Transformers

HAppS keeps your application development very simple. You represent
state with the Haskell data structure you find most natural for that
purpose. Your app then is just a set of state transformer functions
(in the MACID Monad) that take an event and state as input and that
evaluate to a new state, a response, and a (possibly null) set of
sideeffects.

It sounds great, but in practice it is not that simple to use, largely
because HAppS is in such a state of flux right now that even
installing the current codebase is pretty daunting.

However, I think a simple example of using MACID to guess a number
would be a great piece of documentation, and it might even be a step
towards using HAppS/MACID to easily do things other than serve web
apps. (HAppS is meant to be a general application serving framework,
but all the docu is oriented towards serving web pages, and even that
documentation is pretty shaky.)

What I ultimately would like to do is adapt this guess a number stuff
to HAppS/MACID so it is an example server for a multi-user console app
with this cool undo/replay/logging functionality which can then be
plugged into more sophisticated uses. Porting the console app to a web
app would be a further step. Hopefully, since all the state stuff has
been so meticulously compartmentalized it's easy and obvious how to do
this, just a matter of changing the IO to be outputting html rather
than console text. That is the HAppS tutorial I would like to see.

thomas.

2007/12/4, Ryan Ingram [EMAIL PROTECTED]:
 Ask and ye shall receive.  A simple guess-a-number game in MonadPrompt
 follows.

 But before I get to that, I have some comments:


 Serializing the state at arbitrary places is hard; the Prompt contains a
 continuation function so unless you have a way to serialize closures it
 seems like you lose.  But if you have safe points during the execution at
 which you know all relevant state is inside your game state, you can save
 there by serializing the state and providing a way to restart the
 computation at those safe points.

 I haven't looked at MACID at all; what's that?

  {-# LANGUAGE GADTs, RankNTypes #-}
  module Main where
  import Prompt
  import Control.Monad.State
  import System.Random (randomRIO)
  import System.IO
  import Control.Exception (assert)

 Minimalist functional references implementation.
 In particular, for this example, we skip the really interesting thing:
 composability.

 See http://luqui.org/blog/archives/2007/08/05/ for a real
 implementation.

  data FRef s a = FRef
{ frGet :: s - a
, frSet :: a - s - s
}

  fetch :: MonadState s m = FRef s a - m a
  fetch ref = get = return . frGet ref

  infix 1 =:
  infix 1 =:
  (=:) :: MonadState s m = FRef s a - a - m ()
  ref =: val = modify $ frSet ref val
  (=:) :: MonadState s m = FRef s a - m a - m ()
  ref =: act = act = modify . frSet ref
  update :: MonadState s m = FRef s a - (a - a) - m ()
  update ref f = fetch ref = \a - ref =: f a

 Interactions that a user can have with the game:

  data GuessP a where
 GetNumber :: GuessP Int
 Guess :: GuessP Int
 Print :: String - GuessP ()

 Game state.

 We could do this with a lot less state, but I'm trying to show what's
 possible here.  In fact, for this example it's probably easier to just
 thread the state through the program directly, but bigger games want real
 state, so I'm showing how to do that.

  data GuessS = GuessS
{ gsNumGuesses_ :: Int
, gsTargetNumber_ :: Int
}

  -- a real implementation wouldn't do it this way :)
  initialGameState :: GuessS
  initialGameState = GuessS undefined undefined

  gsNumGuesses, gsTargetNumber :: FRef GuessS Int
  gsNumGuesses   = FRef gsNumGuesses_   $ \a s - s { gsNumGuesses_   = a }
  gsTargetNumber = FRef gsTargetNumber_ $ \a s - s { gsTargetNumber_ = a }

 Game monad with some useful helper functions

  type Game = StateT GuessS (Prompt GuessP)

  gPrint :: String - Game ()
  gPrint = prompt . Print

  gPrintLn :: String - Game ()
  gPrintLn s = gPrint (s ++ \n)

 Implementation of the game:

  gameLoop :: Game Int
  gameLoop = do
 update gsNumGuesses (+1)
 guessNum - fetch gsNumGuesses
 gPrint (Guess # ++ show guessNum ++ :)
 guess - prompt Guess
 answer - fetch gsTargetNumber
 
 if guess == answer
   then do
 gPrintLn Right!
 return guessNum
   else do
 gPrintLn $ concat
 [ You guessed too 
 , if guess  answer then low else high
 , ! Try again.
 ]
 gameLoop

  game :: Game ()
  game 

Re: [Haskell-cafe] isSpace

2007-12-04 Thread Thomas Hartman
look at the examples of dropWhile usage you got from the first result
when you get when you google on dropWhile.

t.

2007/12/4, Ryan Bloor [EMAIL PROTECTED]:

 HI

  I will try and explain it better.
  I am meaning to write a function that takes a string,  apple and
 eliminates the spaces at the start ONLY. called removeSpace ::
 String - String

  I decided to use the function 'dropWhile' and another one 'isSpace' in the
 'removeSpace' function.

   removeSpace:: String - String
  removeSpace a = case dropWhile isSpace a of
   -

  I get stuck here... I am not sure how to go about this function.

  Any ideas.

  Ryan


 
 Can you guess the film? Search Charades!
 ___
 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] parser

2007-12-06 Thread Thomas Hartman
you need to write a parser.

Parser is a popular library on hackage that should do what you want. (I 
have never used it though.)

Or read

http://citeseer.ist.psu.edu/50754.html

and adopt the code from there to your purposes. 

I found this paper extremely helpful when I needed to build a parser.

t. 





Ryan Bloor [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
12/06/2007 12:06 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] parser






hi
 
Can anyone advise me on how to check whether a string contains ints, 
chars, bools, etc 
 
2345 + 6767 shoudl give IntAdd (2345) (6767)
2345 should give IntT 2345
 
Ryan

Get closer to the jungle. I'm a Celebrity Get Me Out Of Here!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] regex package for yhc?

2007-12-06 Thread Thomas Hartman
Is there some way to use any of the various regex packages on hackage via 
yhc? Has anyone installed one them successfully?

I'd like regex-tdfa, but would settle for regex-posix, or really, anything 
that brings the convenience of regex to yhc.

In general, is there a straightforward way to install extralibs type 
packages for universal import availability in yhc? 

Is there a cabal equivalent for yhc? Documentation pointer would be 
appreciated; I searched but couldn't find anything. Maybe not using the 
right keywords...

t.



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] how to compile this in yhc?

2007-12-06 Thread Thomas Hartman
Is there some way to compile the following function in yhc?

works in ghc with glasgow exts deactivated, yhc complains context for 
Prelude.read needed (in final line)


readfloat :: String - Maybe Float
readfloat x | null parse || not (null leftover) = fail $ myRead: ++x
| otherwise = return v
  where parse@((v,leftover):ps) = readsPrec 0 x

thanks!


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


role of seq, $!, and bangpatterns illuminated with lazy versus strict folds Re: [Haskell-cafe] What is the role of $!?

2007-12-10 Thread Thomas Hartman
rather than ask the role of $! I found it helpful to first grasp the role 
of seq, since $! is defined in terms of seq and seq is a primitive 
operation (no prelude definition, like with IO, it's a given).

What helped me grasp seq was its role in a strict fold.

Basically, try to sum all the numbers from 1 to a million. Prelude sum 
probably gives stack overflow (if not, up it to a billion ;) ), and so 
will a  naive fold, as is explained at

http://www.haskell.org/haskellwiki/Stack_overflow

The code below basically restates what was already on the wiki, but I 
found my definitions of foldl' (using seq, bang patterns, and $!) easier 
to understand than the definition on the wiki page, and the definition 
from Data.List. (Maybe I'll edit the wiki.)

t.

{-# LANGUAGE BangPatterns #-}

-- stack overflow
t1 = myfoldl (+) 0 [1..10^6]
-- works, as do myfoldl'' and myfoldl'''
t2 = myfoldl' (+) 0 [1..10^6] 

-- (myfoldl f q ) is a curried function that takes a list
-- If I understand currectly, in this lazy fold, this curried function 
isn't applied immediately, because 
-- by default the value of q is still a thunk
myfoldl f z [] = z
myfoldl f z (x:xs) = ( myfoldl f q  ) xs
  where q = z `f` x

-- here, because of the definition of seq, the curried function (myfoldl' 
f q) is applied immediately
-- because the value of q is known already, so (myfoldl' f q ) is WHNF
myfoldl' f z [] = z
myfoldl' f z (x:xs) = seq q ( myfoldl' f q ) xs
  where q = z `f` x

--same as myfoldl'
myfoldl'' f z [] = z
myfoldl'' f !z (x:xs) = ( myfoldl'' f q ) xs
  where q = z `f` x

myfoldl''' f z [] = z
myfoldl''' f z (x:xs) = (myfoldl''' f $! q) xs
  where q = z `f` x








PR Stanley [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
11/14/2007 06:46 PM

To
haskell-cafe@haskell.org
cc

Subject
[Haskell-cafe] What is the role of $!?






Hi
What is the role of $! ?
As far as I can gather it's something to do with strict application. 
Could someone explain what it is meant by the term strict application 
please?
Thanks,
Paul

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need help please.

2007-12-11 Thread Thomas Hartman
I second that emotion.

That is the perfect paper to read if you've never done a parser and need 
one. There is also source code corresponding to the paper if you google 
around.

t.



Paul Johnson [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
12/11/2007 03:02 AM

To
Ryan Bloor [EMAIL PROTECTED]
cc
haskell-cafe@haskell.org
Subject
Re: [Haskell-cafe] Need help please.






Ryan Bloor wrote:
 hi
 
 I am writing a basic Parser from scratch. So far I have functions;

I think you need to read http://www.cs.nott.ac.uk/~gmh/pearl.pdf

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] array documentation is missing

2007-12-14 Thread Thomas Hartman
While trying to make Regex.TDFA 0.91 install on 6.8.2 

I got 

[10 of 21] Compiling Text.Regex.TDFA.RunMutState ( 
Text/Regex/TDFA/RunMutState.\
hs, dist\build/Text/Regex/TDFA/RunMutState.o )

Text/Regex/TDFA/RunMutState.hs:601:9:
Constructor `STUArray' should have 4 arguments, but has been given 3
In the pattern: STUArray _ _ msource
In the definition of `copySTU':
copySTU (STUArray _ _ msource) (STUArray _ _ mdest)
  = ST $ \ s1# - case sizeofMutableByteArray# msource of 
n# -\
 ...
^[]0;~/hackageTarGzs/regexstuff/regex-tdfa-0.92^G
[EMAIL PROTECTED] 
^[[33m~/hackageTarGzs/regexstuff/regex-tdfa-0.92^[\
[0m

but I got stuck fixing it because the array documentation isn't there

http://www.haskell.org/ghc/docs/latest/html/libraries/haskell98/Array.html

assume I'm getting the above error because the array interface has changed

thomas.


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Fw: hdbc odbc also crashes on 6.8.2 Re: [Haskell-cafe] HDBC-ODBC crashes on ghc 6.8

2007-12-14 Thread Thomas Hartman
I just tried HDBC-ODBC on 6.8.2, but it still crashes. Works on 6.6.1. 

thomas. 




Thomas Hartman [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED] 
11/19/2007 12:05 PM 


To
haskell-cafe@haskell.org 
cc

Subject
[Haskell-cafe] HDBC-ODBC crashes on ghc 6.8









This minimal program below fails in 6.8.1, works for 6.6.1, for up to date 
HDBC-ODBC-1.1.3. (I tried installing both from package and from darcs 
head) 

Installed and running from cygwin. 

When I run it as runghc fail.hs I get a windows popup error ghc.exe has 
encountered a problem and needs to close, sorry for the inconvenience. 
ghci, same behavior. 

When I run it as ghc -e 'main' fail.hs, I don't get a popup window, and no 
error message is output, but it fails all the same. (I know this because 
more complicated, non-minimal programs, fail.) 

So this would seem to be a problem with ghc 6.8.1. 

$ cat fail.hs 

import Database.HDBC 
import Database.HDBC.ODBC 

main = connectODBC some valid connect string, works when run from 6.6.1, 
not from 6.8.1 



---

This e-mail may contain confidential and/or privileged information. If you 

are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] list utilities -- shouldn't these be in the hierarchical libs somewhere?

2007-12-17 Thread Thomas Hartman
I found

  http://haskell.cs.yale.edu/haskell-report/List.html

  had many useful one off type list functions such as subsequences and 
permutations which are nowhere to be found in hoogle, Data.List, or the 
haskell hierarchical libs

  Shouldn't these be included somewhere?

  thomas.

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] eager/strict eval katas

2007-12-21 Thread Thomas Hartman
great advice. I played with this a bit, desugared to haskell 98, and got

-- okay for 1..10^6, not ok (stack overflows) if either the fold or g
is left lazy.
-- Thanks, Dan Weston.
avg6 = uncurry (/) . foldl' g (0,0)
 where g (!sum,!count) next = ( (sum+next),(count+1))

-- same thing, in haskell98 (works without LANGUAGE BangPatterns)
-- thanks #haskell.oerjan
avg7 = uncurry (/) . foldl' g (0,0)
 where g (sum,count) next = sum `seq` count `seq` ( (sum+next),(count+1))

t = avg7 testlist
testlist = [1..10^6]



2007/12/12, Dan Weston [EMAIL PROTECTED]:
 Dan Weston wrote:
  scanl above is not strict in its second argument. The data dependencies
  cause the strictness. Cf:
 
  Prelude head ([1,3] ++ head ((scanl undefined undefined) undefined))
  1

 The first claim is of course false, nore would the example show it anyway.

 scanl is not strict in its third argument (I forgot about the initial
 value as the second argument):

 Prelude Data.List let z = [1,4,undefined,8,9] in scanl (\x y - 5) 8 z
 [8,5,5,5,5,5]

 It is the data dependence in the first argument of scanl that would make
 the above strict:

 Prelude Data.List let z = [1,4,undefined,8,9] in scanl (+) 8 z
 [8,9,13,*** Exception: Prelude.undefined


 Also note that it is better not to introduce the / operator in your
 test, as it fails with large numbers. Multiply both sides by the
 denominator before the comparison and leave everything as Num a instead
 of Floating a. You can do the division at the end.

  Thomas Hartman wrote:
 
 
   Note that 1 + ··· + n = n * (n+1) / 2, so the average of [1..n] is
  (n+1) / 2
 
  fair enough.
 
  But I believe  if I restate the problem  so that you need to find the
  average of an arbitrary list, your clever trick doesn't work and we
  need eager eval or we blow the stack.
 
  Not true:
 
  Prelude Data.List let f a = (\(a,b,c)-c) . head . dropWhile (\(s,n,_)
  - s =n*a) . scanl (\(s,n,_) x -(s+x,n+1,x)) (0,0,0) in f (10^5) [1,3..]
  21
 
 
  Also... on second thought, I actually solved a slightly different
  problem than what I originally said:  the problem of detecting when
  the moving average of an increasing list is greater than 10^6; but my
  solution doesn't give the index of the list element that bumped the
  list over the average. However I suspect my code could be tweaked to
  do that (still playing around with it):
 
  Also I actually used a strict scan not a strict fold and... ach, oh well.
 
  scanl above is not strict in its second argument. The data dependencies
  cause the strictness. Cf:
 
  Prelude head ([1,3] ++ head ((scanl undefined undefined) undefined))
  1
 
  As you see I wrote a customized version of foldl' that is strict on
  the tuple for this to work. I don't think this is necessarily faster
  than what you did  (haven't quite grokked your use of unfold), but it
  does have the nice property of doing everything in one one fold step
  (or one scan step I guess, but isn't a scan
 
  http://thomashartman-learning.googlecode.com/svn/trunk/haskell/lazy-n-strict/average.hs
 
 
  You have
 
  Prelude Control.Arrow Data.List
let avg5 = uncurry (/) . foldl' (\(s,n) x - (s + x,n + 1)) (0,0)
 in avg5 [1..1000]
  *** Exception: stack overflow
  -- This fails in 100 sec
 
  Try this. It is not foldl' that needs to be strict, but the function
  folded:
 
  Prelude Data.List let avg5 = uncurry (/) . foldl' (\(!s,!n) x - (s +
  x,n + 1)) (0,0) in avg5 [1..1000]
 
  You will need -fbang-patterns for this (there are other ways to do this
  in Haskell 98 though).
 
 
 
  t.
 
  t1 = average_greater_than (10^7) [1..]
 
  average_greater_than max xs = find (max) $ averages xs
 
  averages = map fst . myscanl' lAccumAvg (0,0)
  average = fst . myfoldl' lAccumAvg (0,0)
  lAccumAvg (!avg,!n) r = ( (avg*n/n1) + (r/n1),(n1))
   where n1 = n+1
 
  myfoldl' f (!l,!r) [] = (l,r)
  myfoldl' f (!l,!r) (x:xs) = ( myfoldl' f q xs )
   where q = (l,r) `f` x
 
  myscanl f z []  = z : []
  myscanl f z (x:xs) =  z : myscanl f (f z x) xs
 
  myscanl' f (!l,!r) []  = (l,r) : []
  myscanl' f (!l,!r) (x:xs) =  (l,r) : myscanl' f q xs
   where q = (l,r) `f` x
 
 
 
 
  *Felipe Lessa [EMAIL PROTECTED]*
 
  12/12/2007 02:24 PM
 
 
  To
  Thomas Hartman/ext/[EMAIL PROTECTED]
  cc
  haskell-cafe@haskell.org
  Subject
  Re: [Haskell-cafe] eager/strict eval katas
 
 
 
 
 
 
 
 
  On Dec 12, 2007 2:31 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
exercise 2) find the first integer such that average of [1..n] is 
  [10^6]
  (solution involves building an accum list of (average,listLength)
  tuples.
again you can't do a naive fold due to stack overflow, but in this
  case even
strict foldl' from data.list isn't strict enough, I had to define
  my own
custom fold to be strict on the tuples.)
 
  What is wrong with
 
  Prelude snd . head $ dropWhile (( 10^6) . fst) [((n+1) / 2, n) | n
  - [1..]]
  199.0
 
  Note that 1 + ··· + n = n * (n+1) / 2, so the average of [1..n] is
  (n

Re: [Haskell-cafe] Why does this blow the stack?

2007-12-26 Thread Thomas Hartman
The (extremely enlightening) discussion so far has focused on the
inconsistent (arguably buggy) behavior of [a,b..c] enumeration sugar.

I think it's worth pointing out that the code could also be made to
run by making the drop function strict. I got to thinking, in a
strictness debugging scenario like this, it seems like you can get
the behavior you want by making things strict at various levels. You
can make the inner level (enumeration sugar) stricter, or you can
leave the enumeration stuff lazy and make the drop stricter. Maybe I
didn't express that very well, so here's code:

(I would argue that this discussion could be the basis of a
strictness kata exercise, following up from a cafe post I made a
while ago.)

{-# LANGUAGE BangPatterns #-}
import Data.List
import Testing
import Test.QuickCheck
import Test.QuickCheck.Batch

tDrop = ( head . drop n ) ( edi1 1 2 )
tStrictDrop = ( head . strictDrop n ) ( edi1 1 2 )
n = 10^6

--edi: enum delta integer
-- stack overflow on 10^6 el list if use drop
-- ok with strictDrop
edi1 start next = start : edi1 next (next + delta)
  where delta = next - start

-- ok (no overflow) for drop, of course also okay for strictDrop
edi2 !start next = start : edi2 next (next + delta)
  where delta = next - start


ediWithMax start next bound = takeWhile p $ edi start next
  where p i | delta  0 = i = bound
| delta  0 = i = bound
| otherwise = i = bound
delta = next - start
edi = edi1

strictDrop _ [] = []
strictDrop n l | n = 0 = l
strictDrop n (!x:xs) | n0 = strictDrop (n-1) xs

pStrictDropSameAsDrop n xs = drop n xs == strictDrop n xs
  where types = (n::Int,xs::[Integer])


pEdi1 start next max =
abs(next-start)  0 == -- otherwise hits bottom because of eg [0,0..0]
ediWithMax start next max == [start,next..max]
  where types = (start :: Integer, next :: Integer, max :: Integer)

pEdi2 start next max = ( take 1000 $ ediWithMax start next max ) == (
take 1000 $ [start,next..max] )
  where types = (start :: Integer, next :: Integer, max :: Integer)


t2 = runTests edi testOptions
 [run pEdi1,
  run pEdi2,
  run pStrictDropSameAsDrop]
  where testOptions = TestOptions
{ no_of_tests = 100 -- number of tests to run
, length_of_tests = 1   -- 1 second max per check
   -- where a check == n tests
, debug_tests = False   -- True = debugging info
}





2007/12/21, Justin Bailey [EMAIL PROTECTED]:
 Given this function:

   dropTest n = head . drop n $ [1..]

 I get a stack overflow when n is greater than ~ 550,000 . Is that
 inevitable behavior for large n? Is there a better way to do it?

 Justin
 ___
 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] An interesting monad: Prompt

2007-12-28 Thread Thomas Hartman
Would you mind posting the code for Prompt used by

import Prompt

I tried using Prompt.lhs from your first post but it appears to be
incompatible with the guessing game program when I got tired of
reading the code and actually tried running it.

best, thomas.



2007/12/4, Ryan Ingram [EMAIL PROTECTED]:
 Ask and ye shall receive.  A simple guess-a-number game in MonadPrompt
 follows.

 But before I get to that, I have some comments:


 Serializing the state at arbitrary places is hard; the Prompt contains a
 continuation function so unless you have a way to serialize closures it
 seems like you lose.  But if you have safe points during the execution at
 which you know all relevant state is inside your game state, you can save
 there by serializing the state and providing a way to restart the
 computation at those safe points.

 I haven't looked at MACID at all; what's that?

  {-# LANGUAGE GADTs, RankNTypes #-}
  module Main where
  import Prompt
  import Control.Monad.State
  import System.Random (randomRIO)
  import System.IO
  import Control.Exception (assert)

 Minimalist functional references implementation.
 In particular, for this example, we skip the really interesting thing:
 composability.

 See http://luqui.org/blog/archives/2007/08/05/ for a real
 implementation.

  data FRef s a = FRef
{ frGet :: s - a
, frSet :: a - s - s
}

  fetch :: MonadState s m = FRef s a - m a
  fetch ref = get = return . frGet ref

  infix 1 =:
  infix 1 =:
  (=:) :: MonadState s m = FRef s a - a - m ()
  ref =: val = modify $ frSet ref val
  (=:) :: MonadState s m = FRef s a - m a - m ()
  ref =: act = act = modify . frSet ref
  update :: MonadState s m = FRef s a - (a - a) - m ()
  update ref f = fetch ref = \a - ref =: f a

 Interactions that a user can have with the game:

  data GuessP a where
 GetNumber :: GuessP Int
 Guess :: GuessP Int
 Print :: String - GuessP ()

 Game state.

 We could do this with a lot less state, but I'm trying to show what's
 possible here.  In fact, for this example it's probably easier to just
 thread the state through the program directly, but bigger games want real
 state, so I'm showing how to do that.

  data GuessS = GuessS
{ gsNumGuesses_ :: Int
, gsTargetNumber_ :: Int
}

  -- a real implementation wouldn't do it this way :)
  initialGameState :: GuessS
  initialGameState = GuessS undefined undefined

  gsNumGuesses, gsTargetNumber :: FRef GuessS Int
  gsNumGuesses   = FRef gsNumGuesses_   $ \a s - s { gsNumGuesses_   = a }
  gsTargetNumber = FRef gsTargetNumber_ $ \a s - s { gsTargetNumber_ = a }

 Game monad with some useful helper functions

  type Game = StateT GuessS (Prompt GuessP)

  gPrint :: String - Game ()
  gPrint = prompt . Print

  gPrintLn :: String - Game ()
  gPrintLn s = gPrint (s ++ \n)

 Implementation of the game:

  gameLoop :: Game Int
  gameLoop = do
 update gsNumGuesses (+1)
 guessNum - fetch gsNumGuesses
 gPrint (Guess # ++ show guessNum ++ :)
 guess - prompt Guess
 answer - fetch gsTargetNumber
 
 if guess == answer
   then do
 gPrintLn Right!
 return guessNum
   else do
 gPrintLn $ concat
 [ You guessed too 
 , if guess  answer then low else high
 , ! Try again.
 ]
 gameLoop

  game :: Game ()
  game = do
 gsNumGuesses =: 0
 gsTargetNumber =: prompt GetNumber
 gPrintLn I'm thinking of a number.  Try to guess it!
 numGuesses - gameLoop
 gPrintLn (It took you  ++ show numGuesses ++  guesses!)

 Simple unwrapper for StateT that launches the game.

  runGame :: Monad m = (forall a. GuessP a - m a) - m ()
  runGame f = runPromptM f (evalStateT game initialGameState)

 Here is the magic function for interacting with the player in IO.  Exercise
 for the reader: make this more robust.

  gameIOPrompt :: GuessP a - IO a
  gameIOPrompt GetNumber = randomRIO (1, 100)
  gameIOPrompt (Print s) = putStr s
  gameIOPrompt Guess = fmap read getLine

 If you wanted to add undo, all you have to do is save off the current Prompt
 in the middle of runPromptM; you can return to the old state at any time.

  gameIO :: IO ()
  gameIO = do
  hSetBuffering stdout NoBuffering
  runGame gameIOPrompt

 Here's a scripted version.

  type GameScript = State [Int]
 
  scriptPrompt :: Int - GuessP a - GameScript a
  scriptPrompt n GetNumber = return n
  scriptPrompt _ (Print _) = return ()
  scriptPrompt _ Guess = do
  (x:xs) - get -- fails if script runs out of answers
  put xs
  return x
 
  scriptTarget :: Int
  scriptTarget = 23
  scriptGuesses :: [Int]
  scriptGuesses = [50, 25, 12, 19, 22, 24, 23]

 gameScript is True if the game ran to completion successfully, and False or
 bottom otherwise.
 Try adding or removing numbers from scriptGuesses above and re-running the
 program.

  gameScript :: Bool
  gameScript = null $ execState (runGame (scriptPrompt scriptTarget))
 scriptGuesses


Re: [Haskell-cafe] Upgrading to Haskell Platform

2010-03-12 Thread Thomas Hartman
It should not be necessary to uninstall ghc, as hask plat and ghc are
orthogonal by design.
r
Unless there is some gotcha I am unaware of, not being a mac user.

You are aware that hask plat is beta though, right?

You might be better served simply upgrading your cabal, and waiting
for the all-in-one mac packager to be really shiny.

You can grab cabal here, and after you have unzipped it run the
bootstrap script which also downloads dependencies you might need.

cheers.

2010/3/10 David Place d...@vidplace.com:
 Hi:

 I am running GHC 6.10.4 on Mac OSX 10.6.2.   Somehow, I have a broken version 
 of Cabal (1.6.0.3) installed.  In order to fix it, I thought I should just 
 upgrade to the Haskell Platform.  Is it necessary to uninstall my current GHC 
 first?  If, so, how?

 Thanks you.

 Cheers,
 David

 ___
 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] Upgrading to Haskell Platform

2010-03-12 Thread Thomas Hartman
grab cabal here I mean:

http://hackage.haskell.org/trac/hackage/wiki/CabalInstall

2010/3/12 Thomas Hartman tphya...@gmail.com:
 It should not be necessary to uninstall ghc, as hask plat and ghc are
 orthogonal by design.
 r
 Unless there is some gotcha I am unaware of, not being a mac user.

 You are aware that hask plat is beta though, right?

 You might be better served simply upgrading your cabal, and waiting
 for the all-in-one mac packager to be really shiny.

 You can grab cabal here, and after you have unzipped it run the
 bootstrap script which also downloads dependencies you might need.

 cheers.

 2010/3/10 David Place d...@vidplace.com:
 Hi:

 I am running GHC 6.10.4 on Mac OSX 10.6.2.   Somehow, I have a broken 
 version of Cabal (1.6.0.3) installed.  In order to fix it, I thought I 
 should just upgrade to the Haskell Platform.  Is it necessary to uninstall 
 my current GHC first?  If, so, how?

 Thanks you.

 Cheers,
 David

 ___
 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] How to do the permutation and combination thing?

2010-03-12 Thread Thomas Hartman
There is also polyomino.f2s:

http://www.polyomino.f2s.com/david/haskell/combinatorics.html

Iirc correctly there is some stuff here that is not on hackage but
probably could/should be.


2010/3/12 Victor Mateus Oliveira rhapso...@gmail.com:
 Hi,

 Give a try to this library: http://hackage.haskell.org/package/permutation
 You can construct the combinations with list of indices and then apply
 it to your sets.

 []s
 Victor

 On Fri, Mar 12, 2010 at 5:16 AM, Ketil Malde ke...@malde.org wrote:
 Casey Hawthorne cas...@istar.ca writes:

  For example, I have this:
list1 = [a, b, c]
list2 = [d, e, f]
list3 = [g, h, i]

 Think in abstract terms what you want to accomplish.

 A bit more specifically, let's say the input is a list of lists, and you
 want to produce all combinations of drawing one element from each of the
 input lists¹:

  perms :: [[a]] - [[a]]

 You need to consider two cases, when the input is empty, and when the
 input contains at least one list of elements:

  perms (l:ls) = ...
  perms [] = ...

 The second case shouldn't be so hard.

 Now, if you pretend that 'perms' is already implemented, then you can
 use it to generate all permutations for the tail of the input list.  The
 first case boils down to combining the first input list with all
 permutations of the rest of the lists:

  perms (l:ls) = ... l ... perms ls

 Does this help?

 -k

 ¹ Using tuples is harder to generalize for length, but nicer typewise,
 since you'd get something like 'perms :: ([a],[b],..[x]) - [(a,b,..,x)]
 --
 If I haven't seen further, it is by standing in the footprints of giants
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




 --
 GNU/Linux user #446397 - http://counter.li.org
 ___
 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] mirroring patch tag

2010-03-12 Thread Thomas Hartman
http://blog.patch-tag.com/2010/03/13/mirroring-patch-tag/

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


Re: [Haskell-cafe] The instability of Haskell libraries

2010-04-23 Thread Thomas Hartman
1) Folks, what exactly is the situation with buildbots?
2) Easily available images for installing virtualized environments
could also ameliorate the pain, no?

wrt 1) It seems to me that in an ideal world you could have a
candidate for uploading to hackage, but before uploading you could
push a magic button and get a message within one hour stating whether
this broke any packages on hackage.

I start thinking about a (cloneable) community ec2 or slicehost server
for buildbot -- 72 bucks a month should be doable for a community in
the thousands.

Does this make sense? Is it within the realm of possibility? What
would it take to make it happen?

I made a baby step in the direction of 2) with

http://blog.patch-tag.com/2010/02/12/ec2-amis-for-gitit-happstack/

At the very least, what this means for me personally is that I (or
anybody) can spin up a working box with gitit installed on it, for
some past incarnation of gitit/happstack/haskell platform.

Now, what happens when you attempt to cabal update  cabal reinstall
gitit -- I dunno. Very possibly breakage.

But at least you get a working place to start from.

I can see how this might apply to other pain points that I have less
personal knowledge of, like glut (?)  many others.

thomas.

2010/4/23 Jason Dagit da...@codersbase.com:


 On Fri, Apr 23, 2010 at 11:34 AM, John Goerzen jgoer...@complete.org
 wrote:

 A one-character change.  Harmless?  No.  It entirely changes what the
 function does.  Virtually any existing user of that function will be
 entirely broken.  Of particular note, it caused significant breakage in the
 date/time handling functions in HDBC.

 Now, one might argue that the function was incorrectly specified to begin
 with.  But a change like this demands a new function; the original one ought
 to be commented with the situation.

 My second example was the addition of instances to time.  This broke code
 where the omitted instances were defined locally.  Worse, the version number
 was not bumped in a significant way to permit testing for the condition, and
 thus conditional compilation, via cabal.  See http://bit.ly/cBDj3Q for more
 on that one.

 This is of course in part due to a strength of cabal (remember that
 strengths and weaknesses tend to come together).  Cabal discourages testing
 libraries/apis at configure time.  The result is that version numbers need
 to encode this information.  We don't (yet), have a tool to help detect when
 a change in version number is needed or what the next version should be.  We
 leave this up to humans and it turns out, humans make mistakes :)

 Even once we have an automatic tool to enforce/check the package version
 policy, mistakes may still sneak in.  I would expect the 'T' in the time
 format to be in this same category.  More about that below.


 I don't have a magic bullet to suggest here.  But I would first say that
 this is a plea for people that commit to core libraries to please bear in
 mind the implications of what you're doing.  If you change a time format
 string, you're going to break code.  If you introduce new instances, you're
 going to break code.  These are not changes that should be made lightly, and
 if they must be made (I'd say there's a stronger case for the time instances
 than the s/ /T/ change), then the version number must be bumped
 significantly enough to be Cabal-testable.

 While I haven't participated in the library proposal process myself, I was
 under the impression that Haskell has a fairly rigorous process in place for
 modifying the core libraries.  Is the above change too small to for that
 process?  Did that process simply fail here?

 Jason

 ___
 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] Build problems (hsp, trhsx, ultimately Happstack)

2010-04-23 Thread Thomas Hartman
I've had this problem too.

I believe trhsx is installed by

http://hackage.haskell.org/package/hsx

So, you might need to
-- upgrade hsx
-- make sure that the upgraded trhsx executable is the one being
executed by cabal install hsx (maybe deleting/temporarily moving other
trhsx exes)

thomas.

2010/4/22 Alexander Solla a...@2piix.com:
 Consider the following bash session:

 [ a...@kizaru:~/ ]$ which trhsx
 /home/ajs/.cabal/bin/trhsx

 [ a...@kizaru:~/ ]$ trhsx
 Usage: trhsx infile [outfile]

 [ a...@kizaru:~/ ]$ cabal install hsp
 Resolving dependencies...
 Configuring hsp-0.4.5...
 Preprocessing library hsp-0.4.5...
 Building hsp-0.4.5...
 ghc: could not execute: trhsx
 cabal: Error: some packages failed to install:
 hsp-0.4.5 failed during the building phase. The exception was:
 ExitFailure 1

 Does anybody have any suggestions?  I'm trying to install Happstack on Arch
 Linux (GHC 6.12.1).   ~/.cabal/bin/ is in my path and trhsx runs.

 I've had this problem before, and I think I ran cabal as root for the HSP
 package.  That's not working this time.  I get the same failure.
 ___
 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] The instability of Haskell libraries

2010-04-23 Thread Thomas Hartman
So the situation is

1) The buildbot will catch dependencies with compile errors, but only
after the package has been pushed, and there is no easy way for
packagers to check that this won't happen

2) There are many important packages that will pass a compile check
but not a runtime check.

Well, 2 seems like a hard problem to solve.

But 1) could be solved by having a candidate snapshot hackage that can
be cloned at will, and buildbotted against, no?

2010/4/23 Erik de Castro Lopo mle...@mega-nerd.com:
 Thomas Hartman wrote:

 1) Folks, what exactly is the situation with buildbots?

 If I'm not mistaken, the buildbots run *after* the package has been
 pushed to hackage. Thats already too too late.

 Erik
 --
 --
 Erik de Castro Lopo
 http://www.mega-nerd.com/
 ___
 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] why does Data.Text.Lazy.IO.readFile return the internal type Data.Text.Lazy.Internal.Text, when Data.Text.IO.readFile returns plain IO Data.Text.Text?

2010-04-30 Thread Thomas Hartman
*Main :t Data.Text.IO.readFile
Data.Text.IO.readFile :: FilePath - IO T.Text

but

*Main :t Data.Text.Lazy.IO.readFile
Data.Text.Lazy.IO.readFile
  :: FilePath - IO text-0.7.1.0:Data.Text.Lazy.Internal.Text

why does the lazy version use the internal type, whereas the strict
version of Text IO just using plain Data.Text type?
and how can I get from internal type to regular type when using Data.Text?

also the internal type doesn't appear to be reflected in the haddock:
 
http://hackage.haskell.org/packages/archive/text/0.7.1.0/doc/html/Data-Text-Lazy-IO.html

ghc-pkg list | grep -i text
text-0.7.1.0

thanks for any help!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


  1   2   3   4   >