Re: [Haskell-cafe] Typing efficient folds

2009-04-27 Thread Matthew Brecknell
Keith Battocchi wrote:
 data Nest a = Nil | Cons(a, (Nest (Pair a)))
 type Pair a = (a,a)
 
 pair f (a,b) = (f a, f b)
 
 efold :: forall n m b. 
   (forall a. n a) 
   - (forall a . (m a, n (Pair a)) - n a)
   - (forall a. Pair (m a) - m (Pair a))
   - (forall l z. (l b - m (z b)) - Nest (l b) - n (z b))
 efold e f g h Nil = e
 efold e f g h (Cons(x, xs)) = f(h x, efold e f g (g . pair h) xs)

If the problem is just understanding the type error, it may help to
manually check the types. You only need to look at the second branch of
the function definition, since this is the case that generates the
error.

From the pattern-match, you get the type of xs:

xs :: Nest (Pair (l b))  -- (1)

Combining the type of f with the result type of the efold definition,
you get the type of the result of the recursive call:

efold e f g (g . pair h) xs :: n (Pair (z b))  -- (2)

This function makes use of polymorphic recursion. To analyse the type of
the recursive call, you need a fresh batch of type variables, so you can
distinguish the types of the arguments to the recursive call from the
types of the formal parameters of the function definition. Since the
first three arguments to the recursive call are unchanged, you only need
fresh variables for b, l and z. I'll use primed versions of these
variables:

efold e f g :: (l' b' - m (z' b')) - Nest (l' b') - n (z' b')  -- (3)

From (3), you get an alternative view of the type of xs:

xs :: Nest (l' b')  -- (4)

You can now perform unification on these results. You need to be careful
unifying with Pair types, since (Pair a) is really ((,) a a).

Unifying (1) and (4), you get:

Nest ((,) (l b) (l b)) ~ Nest (l' b')
l' ~ (,) (l b)
b' ~ (l b) -- (5)

Unifying (2) and the result type from (3):

n ((,) (z b) (z b)) ~ n (z' b')
z' ~ (,) (z b)
b' ~ (z b) -- (6)

From (5) and (6), you require: l b ~ z b, and therefore l ~ z, but the
forall l z in the type signature requires l and z to be independent.

I'm no expert in nested data types, but I doubt there is any additional
generality to be had from trying to distinguish l and z. In that case,
you can write both l b and z b as a. You can also remove a
superfluous tuple from the type definition:

data Nest a = Nil | Cons a (Nest (Pair a))
type Pair a = (a,a)

efold :: (forall a. n a)
  - (forall a. m a - n (Pair a) - n a)
  - (forall a. Pair (m a) - m (Pair a))
  - (a - m a)
  - (Nest a - n a)
efold e f g h Nil = e
efold e f g h (Cons x xs) = f (h x) (efold e f g (g . pair h) xs)

For example, to flatten a Nest to a simple list, you can take m to be Id
and n to be [], something like this:

nest = Cons 0 (Cons (1,2) (Cons ((3,4),(5,6)) Nil))

newtype Id a = Id a

-- [0,1,2,3,4,5,6]
flat_nest = efold []
  (\(Id xs) ys - xs : concatMap (\(p,q) - [p,q]) ys)
  (\(Id x, Id y) - Id (x,y))
  Id nest

It's a little unpleasant having to use the Id type like this, but I
can't see a way around it. I'd be interested to see an example with a
non-trivial m.

Regards,
Matthew


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


[Haskell-cafe] Re: old-time conflict when installing phooey

2009-04-27 Thread Andy Stewart
Hi,

Daryoush Mehrtash dmehrt...@gmail.com writes:

 When I try to install phooey I get conflict with old-time that I am not sure 
 how to resolve.  Any
 ideas?

 cabal install phooey
 Resolving dependencies...
 cabal: dependencies conflict: ghc-6.10.1 requires old-time ==1.0.0.2 however
 old-time-1.0.0.2 was excluded because ghc-6.10.1 requires old-time ==1.0.0.1
1. Use command ghc-pkg list list package-list, then you will get
two package-list, remove same package that exist *two* package-list.

(Use command ghc-pkg unregister PackageName -force remove pacakge).

2. And then remove pacakge old-time-1.0.0.2, use command ghc-pkg
unregister old-time-1.0.0.2 --force.

Then everything is okay.

  -- Andy


 Thanks

 Daryoush

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

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


[Haskell-cafe] RE: [Haskell] ANN control-monad-exception-0.1: Explicitly typed exceptions

2009-04-27 Thread Simon Peyton-Jones
Is there a Haskell Wiki page on extensible exceptions?  The paper is a fine 
reference, it'd be cool to have a wiki page giving programmer-oriented 
guidance, saying
what comes with GHC
what other packages are available

and some simple examples of how to use them.

Simon

| -Original Message-
| From: haskell-boun...@haskell.org [mailto:haskell-boun...@haskell.org] On 
Behalf Of
| Pepe Iborra
| Sent: 25 April 2009 19:52
| To: hask...@haskell.org
| Subject: [Haskell] ANN control-monad-exception-0.1: Explicitly typed 
exceptions
|
| The control-monad-exception package [1] provides explicitly typed
| exceptions for Haskell.
| In other words, this is a perfect example of bundling in a Haskell
| library what for other
| programming languages is a native feature.
|
| The type of a computation in the EM monad carries a list of the exceptions 
that
| the computation may throw. A exception is raised with 'throw', which
| in addition adds it
| to the type, and captured with 'catch', which correspondingly removes
| it from the type.
| Only safe computations (all exceptions handled) can escape from the monad.
|
| The encoding used for the exception list is based on a phantom type
| variable carrying a
| @Throws@ constraint for every exception type. Catching an exception
| @e@ satifies the constraint
| @Throws e@ thus removing it from the type. It is possible to teach
| Throws about exception subtyping
| by manually inserting new instances declaring the subtyping relations
| between exceptions. I don't
| believe there is a better way to handle this, as the existential
| wrapper encoding used
| for Control.Exception.SomeException does not reveal the subtyping
| relations, but ideas are
| welcome.
|
| Example
| 
| GHCi infers the following types
|
|  eval :: (Throws DivideByZero l, Throws SumOverflow l) = Expr - EM l Double
|  eval `catch` \ (e::DivideByZero) - return (-1)  :: Throws
| SumOverflow l = Expr - EM l Double
|  runEM (eval `catch` \ (e::SomeException) - return (-1))  :: Expr - Double
|
| for the code below.
|
|
|  import Control.Monad.Exception
|  import Data.Typeable
|
|  data Expr = Add Expr Expr | Div Expr Expr | Val Double
|  eval (Val x) = return x
|  eval (Add a1 a2) = do
| v1 - eval a1
| v2 - eval a2
| let sum = v1 + v2
| if sum  v1 || sum  v2 then throw SumOverflow else return sum
|  eval (Div a1 a2) = do
| v1 - eval a1
| v2 - eval a2
| if v2 == 0 then throw DivideByZero else return (v1 / v2)
|
|  data DivideByZero = DivideByZero deriving (Show, Typeable)
|  data SumOverflow  = SumOverflow  deriving (Show, Typeable)
|
|  instance Exception DivideByZero
|  instance Exception SumOverflow
|
|
| Comments and patches are welcome.
| Cheers,
| Pepe Iborra
|
| [1] - 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/control-monad-
| exception
| ___
| Haskell mailing list
| hask...@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell

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


[Haskell-cafe] Memory usage of cabal install

2009-04-27 Thread Krzysztof Kościuszkiewicz
Hello Haskell-Café,

I have a problem with high memory usage of cabal-install.  Whenever I
try to install or upgrade a package, cabal manages to consume 1,3G of
memory before I killed it (on a 32-bit machine with 1 GB of memory).

Increasing verbosity does not help, memory consumption goes up after the
message Resolving dependencies... shows up.

I use ghc 6.8.2 and cabal-install version 0.5.1 using version 1.4.0.1 of
the Cabal library.

Is there a workaround? I would like to avoid fetching  building packages
manually.
-- 
Krzysztof Kościuszkiewicz
Simplicity is the ultimate sophistication -- Leonardo da Vinci
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Memory usage of cabal install

2009-04-27 Thread Krzysztof Skrzętnicki
Jakiej platformy dokładnie dotyczy Twój problem?
Proponuję upgrade do najnowszej wersji - można ją ściągnąć ze strony GHC.

Pozdrawiam

Krzysztof Skrzętnicki

2009/4/27 Krzysztof Kościuszkiewicz k.kosciuszkiew...@gmail.com:
 Hello Haskell-Café,

 I have a problem with high memory usage of cabal-install.  Whenever I
 try to install or upgrade a package, cabal manages to consume 1,3G of
 memory before I killed it (on a 32-bit machine with 1 GB of memory).

 Increasing verbosity does not help, memory consumption goes up after the
 message Resolving dependencies... shows up.

 I use ghc 6.8.2 and cabal-install version 0.5.1 using version 1.4.0.1 of
 the Cabal library.

 Is there a workaround? I would like to avoid fetching  building packages
 manually.
 --
 Krzysztof Kościuszkiewicz
 Simplicity is the ultimate sophistication -- Leonardo da Vinci
 ___
 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] Memory usage of cabal install

2009-04-27 Thread Duncan Coutts
On Mon, 2009-04-27 at 12:56 +0200, Krzysztof Kościuszkiewicz wrote:
 Hello Haskell-Café,
 
 I have a problem with high memory usage of cabal-install.  Whenever I
 try to install or upgrade a package, cabal manages to consume 1,3G of
 memory before I killed it (on a 32-bit machine with 1 GB of memory).
 
 Increasing verbosity does not help, memory consumption goes up after the
 message Resolving dependencies... shows up.
 
 I use ghc 6.8.2 and cabal-install version 0.5.1 using version 1.4.0.1 of
 the Cabal library.

The only instance of this behaviour that I know of involves using that
version of cabal-install with ghc-6.10.1.

http://haskell.org/cabal/FAQ.html#cabal-goes-into-an-infinite-loop--runs-out-of-memory

The older version of cabal-install goes into an infinite loop when using
ghc-6.10, when it is presented with two installed versions of the base
package (and one depends on the other). In version 0.6.x cabal-install
was updated to understand this situation.

Are you absolutely sure you are using ghc 6.8 and not 6.10?

 Is there a workaround? I would like to avoid fetching  building packages
 manually.

If you're using ghc 6.10 then the solution is to update to cabal-install
0.6.x. If you're quite sure you are using 6.8 then the bug is unknown.
It may still be worth trying upgrading to cabal-install 0.6.x.

Duncan

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


Re: [Haskell-cafe] old-time conflict when installing phooey

2009-04-27 Thread Duncan Coutts
On Sun, 2009-04-26 at 21:49 -0700, Daryoush Mehrtash wrote:
 
 When  I try to install phooey I get conflict with old-time that I am
 not sure how to resolve.  Any ideas?
 
 
  cabal install phooey
 Resolving dependencies...
 cabal: dependencies conflict: ghc-6.10.1 requires old-time ==1.0.0.2
 however
 old-time-1.0.0.2 was excluded because ghc-6.10.1 requires old-time
 ==1.0.0.1

This looks very similar to:

http://haskell.org/cabal/FAQ.html#dependencies-conflict

but with a different core package.


Duncan

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


[Haskell-cafe] Re: Is 78 characters still a good option? Was: breaking too long lines

2009-04-27 Thread Christian Maeder
Richard O'Keefe wrote:
 
 On 25 Apr 2009, at 8:59 pm, Miguel Mitrofanov wrote:
 
 Something like

 newtype MyCoolMonad = MyCoolMonad (FirstTransformer (SecondTransformer
 (ThirdTransformer Whatever))) deriving (Functor, Monad, FirstClass,
 SecondClass, ThirdClass, SomeOtherClass)
[...]
 For what it's worth, my personal Haskell style lines up
 
 data T
= C1 ...
| ...
| Cn ...
deriving (...)

This has the clear advantage that indentation does not depend on the
length of the type name as in the quite typical layout of Xiao-Yong Jin:
http://www.haskell.org/pipermail/haskell-cafe/2009-April/060541.html

 so I'd have this as
 
 newtype MyCoolMonad
   = MyCoolMonad (FirstTransformer (SecondTransformer
 (ThirdTransformer Whatever)))
   deriving (Functor, Monad, FirstClass, SecondClass, ThirdClass,
 SomeOtherClass)
 
 where the longest line is 86 columns.

(which is still too long as my reply-wrap proofs.)
[...]

However, indenting by 3 or 6 characters depending on data or newtype
 is also a bit arbitrary. Consider:

newtype MyCoolMonad =
MyCoolMonad
  (FirstTransformer
(SecondTransformer (ThirdTransformer Whatever)))
  deriving
  ( Functor, Monad, FirstClass, SecondClass, ThirdClass
  , SomeOtherClass)

Either all alternatives fit on one line or they go on separate lines
each. The  same should apply to all components of one alternative.
Additionally, as above, a long type-application may need to be broken
over several lines. (Breaking before = and having = above | looks
also nice.)

Pretty-printing a comma-separated list (following deriving) is an extra
subject with a couple of variations:

Putting commas in the front, better indicates the continuation, but the
extra space following the open bracket ( looks a bit odd. (Surely one
could also leave a space before the closing bracket, although I wouldn't
like spaces around all brackets.)

The alternative:
   (Functor, Monad, FirstClass, SecondClass, ThirdClass,
SomeOtherClass)

has the disadvantage, that the second line is only indented by one
character (relative to the previous one), but intending further (+1 or
+3 or even one less) is an alternative.

(I'm no friend of putting the closing bracket on a separate line in the
same column as the opening one. Too easily such indentations are messed
up.)

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


Re: [Haskell-cafe] Memory usage of cabal install

2009-04-27 Thread Krzysztof Kościuszkiewicz
On Mon, Apr 27, 2009 at 02:10:28PM +0100, Duncan Coutts wrote:

  [...]
  Increasing verbosity does not help, memory consumption goes up after the
  message Resolving dependencies... shows up.
  
  I use ghc 6.8.2 and cabal-install version 0.5.1 using version 1.4.0.1 of
  the Cabal library.
 
 The only instance of this behaviour that I know of involves using that
 version of cabal-install with ghc-6.10.1.
 
 http://haskell.org/cabal/FAQ.html#cabal-goes-into-an-infinite-loop--runs-out-of-memory

 [...]

 Are you absolutely sure you are using ghc 6.8 and not 6.10?

Yes:

 k...@copper:~$ ghc -V ; cabal -V
 The Glorious Glasgow Haskell Compilation System, version 6.8.2
 cabal-install version 0.5.1
 using version 1.4.0.1 of the Cabal library 

  Is there a workaround? I would like to avoid fetching  building packages
  manually.
 
 If you're using ghc 6.10 then the solution is to update to cabal-install
 0.6.x. If you're quite sure you are using 6.8 then the bug is unknown.
 It may still be worth trying upgrading to cabal-install 0.6.x.

I'll try that and report success/failure.

Thanks,
-- 
Krzysztof Kościuszkiewicz
Simplicity is the ultimate sophistication -- Leonardo da Vinci
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] subscribing to the comments, online Real World Haskell

2009-04-27 Thread John Goerzen
Michael P Mossey wrote:
 Michael P Mossey wrote:
 However, I would like some ability to subscribe to specific comments. I 
 want to see if people have replied to me or what the latest discussion is.
 
 Okay, to follow up my own post, I discovered the subscription 
 button for each chapter. That's good. However, using Live 
 Bookmarks in Firefox, I have a problem... the links that should 
 bring me to the book itself (with the comment in context) are 
 broken. Maybe this is the fault of Live Bookmarks. Anyone 
 recommend another program for subscribing to comments?

I recommend bloglines.com -- pretty nice interface and works well.

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


[Haskell-cafe] how can one load Prelude into ghci?

2009-04-27 Thread Thomas Hartman
One reason it would be nice to be able to do this, is you could then
get lambdabot :src style listings of prelude function definitions by
using the ghci debugger and :list for prelude functions.

is this possible? so far I have tried

thart...@ubuntu:~/haskellInstalls/ghcInstalls/source/ghc-6.10.1/libraries/basehead
Prelude.hs
{-# OPTIONS_GHC -XNoImplicitPrelude #-}
-

thart...@ubuntu:~/haskellInstalls/ghcInstalls/source/ghc-6.10.1/libraries/baseghci
-i. Prelude.hs
GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
command line: module `Prelude' is not loaded

thart...@ubuntu:~/haskellInstalls/ghcInstalls/source/ghc-6.10.1/libraries/baseghci
Prelude.hs
GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
command line: module `Prelude' is not loaded
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: atom-0.0.2

2009-04-27 Thread Don Stewart
tomahawkins:
 Atom is a DSL in Haskell for designed hard realtime embedded programs.
  At Eaton, we are using it to control hydraulic hybrid refuse trucks
 and shuttle buses.  After my talk at CUFP
 (http://cufp.galois.com/2008/schedule.html), a few people inquired
 about atom -- I finally had a chance to upload it to Hackage.
 
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/atom-0.0.2
 
 Some new enhancements:
 - A simple rule scheduler for load balancing.
 - Signal probing for debug and data logging.
 - Functional coverage to monitor which rules have executed.
 - Started integration with the Yices SMT solver for bounded model checking.
 
 Experiences with our Eaton project:
 - 5K lines of Haskell/atom replaced 120K lines of matlab, simulink,
 and visual basic.
 - 2 months to port simulink design to atom.
 - 3K lines of atom generates 22K lines of embedded C.
 - Design composed of 450 atomic state transition rules.
 - Rules with execution periods from 1ms to 10s all scheduled at
 compile time to a 1 ms main loop.
 - 3 minute compilation time from atom source to ECU.
 - Atom design clears electronic/sw testing on first pass.
 - Currently in vehicle testing with no major issues.


Congratulations on the release! 

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


Re: [Haskell-cafe] Memory usage of cabal install

2009-04-27 Thread Krzysztof Kościuszkiewicz
On Mon, Apr 27, 2009 at 02:10:28PM +0100, Duncan Coutts wrote:

 If you're using ghc 6.10 then the solution is to update to cabal-install
 0.6.x. If you're quite sure you are using 6.8 then the bug is unknown.
 It may still be worth trying upgrading to cabal-install 0.6.x.

I've upgraded to cabal-install 0.6.2 and the problem went away.

Thanks for help!
-- 
Krzysztof Kościuszkiewicz
Simplicity is the ultimate sophistication -- Leonardo da Vinci
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to install HOpenGL to Windows?

2009-04-27 Thread Sven Panne
Am Montag, 27. April 2009 00:11:20 schrieb Duncan Coutts:
 On Sun, 2009-04-26 at 19:03 +0200, Sven Panne wrote:
 [...]
 * How to link programs using OpenGL

 This is because the GL libs are called different names on different
 platforms right? But they're consistent within each platform, it's just
 Windows vs everyone else isn't it?

 How about:

 if os(windows)
   extra-libraries: gl32
 else
   extra-libraries: GL

As usual, things are always a bit trickier than they appear initially: On non-
Windows systems it is not always sufficient to link against libGL alone, 
sometimes you'll have to link against several X11 libs, too. I am not sure if 
this is still a widespread problem, but in the past it was. Hopefully most 
*nices get their dynamic library dependencies right nowadays... :-P Windows 
is, as always, a special beast, especially when you take Cygwin into account: 
On Cygwin you can either build against the native OpenGL or against Cygwin's 
X11 OpenGL. This can be configure via --without-x. How can we do this in 
.cabal files? And MacOS had some peculiarities which I can't fully remember 
anymore, too.

 * The Haskell types corresponding to the OpenGL types

 Does hsc2hs #type not help us with this? [...]

I am not sure, because I haven't had a look at hsc2hs for a long time, and at 
the beginning of the OpenGL binding there were no such tools, not even the FFI 
in its current form. Perhaps I'll have a look at this, but to make this work, 
I am sure that we'll have to solve the next item:


 * To do the former: How to find the OpenGL C headers

 What's needed here? Are they not in standard locations? Cabal has
 support for users to specify non-standard locations.

What is a standard location for headers on Windows? There is no such 
concept. On *nices you look into /usr/include and /usr/local/include, and 
that's it, unless the user tells you something different. And Apple is always 
a very creative company, so they decided to put *their* OpenGL headers in a 
completely different path where no -I flag can help...

Having access to the OpenGL headers is crucial for finding out which C types 
are behind OpenGL types like GLint, GLenum, ... The OpenGL spec only specifies 
minimum requirements for these types and *not* their C mapping.

 * The library calling convention

 This is stdcall on Windows and ccall everywhere else right?

 How about:

 if os(windows)
   cpp-options: -DCALLCONV=stdcall
 else
   cpp-options: -DCALLCONV=ccall

This should be fine, at least when we solve the Cygwin problem discussed 
above: The X11 OpenGL libraries on Windows do *not* use stdcall, only the 
native OpenGL libraries. (The whole calling convention story on Windows 
really, really sucks, IMHO...) Using CPP for this simple task doesn't look 
right, but with the current FFI I don't see a way around this, which is a 
shame. Any ideas/proposals for a FFI change?

 * How to load OpenGL extensions

 I don't know enough of the details here to comment.

You'll have to know if wglGetProcAddress, NSAddressOfSymbol (+ a bit more 
code) or some variant of glXGetProcAddress has to be used, plus their 
necessary headers. This is probably doable via some platform switches in 
Cabal, too.

A few general remarks:

 * Ignoring the (usual) Windows trouble, I like autoconf's approach of testing 
features instead of relying on extremely fragile platform conditionals. The 
latter are a constant source of troubles and from a SW engineering point of 
view, they are a clear step backwards. The I know my platform approach which 
you basically propose reminds me of the xmkmf hell from the last millennium: 
If X11 didn't know your platform, you had a *lot* of fun getting the platform 
description right.

 * We can go this autoconf-free route, but this is a part of my bindings which 
I definitely won't maintain in full time. I'll be happy to review and accept 
patches, but making things work on Windows, Cygwin, Linux, *BSD, MacOS X, ... 
is a lot of work, which is a fact I have painfully learned in the past few 
years. The autoconf code may be ugly, but the tons of platform differences are 
ugly, to. I want to work on the binding itself mainly, not on the build 
system, which currently works. To repeat myself: Patches are happily accepted, 
but I propose incremental changes and heavy testing on various platforms.

 * Most of the tasks my autoconf scripts perform are not specific to OpenGL at 
all. I guess that most bindings for non-trivial C libraries face the same 
challenges (Where are my libs? Where are my headers? What are my types?) 
Having good Cabal support for these would be very nice.

Cheers,
   S.

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


Re: [Haskell-cafe] Thread priority?

2009-04-27 Thread Don Stewart

lane:

 Is there any interest or movement in developing thread priority or any  
 other realtime support in Haskell?

I think thread priorities would be really cool :)

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


Re: [Haskell-cafe] Thread priority?

2009-04-27 Thread Don Stewart
semanticphilosopher:
 Count me in too

 I've got a library that endeavours to deliver 'rate-equivalence' - i.e  
 there may be some jitter in when the events should have occurred but  
 their long term rate of progress is stable.

 Testing has shown that I can get events to occur at the right time  
 within 1ms (99%+ of the time, with 50%+ of the events  0.5ms) - choose 
 your O/S carefully though. And this is without resorting to marking the 
 threads as real time with the kernel. If it matters you can tune the 
 scheduling to further reduce the timer scheduling latency (at the cost of 
 more CPU) and increase the fidelity of event timing another order of 
 magnitude or more.

 As for 'garbage collection ruins my real time properties' argument -  
 I've been pragmatic about this, you can configure the scheduler to go  
 and perform a GC if it knows that it is going to sleep for a while (yes, 
 this doesn't resolve the issues of external events arriving in that time 
 but read on) but not perform that too often. Turning off GHCs timers (to 
 stop it garbage collecting after it has actually been idle for a while) 
 and having code that doesn't create vast amounts of garbage means that a 
 GC takes 0.1ms.

 Now if I could see within Haskell the amount of heap that has been  
 recently mutated and some other GC statistics when it was running I  
 could even decide to schedule that more effectively.

You could actually do this by importing symbols from Stats.c in the
runtime (the same variables used for +RTS -sstderr output). I'm not sure
anyone's  ctually tried this yet though, but the effect would be a
program that can monitor its own heap health.

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


Re: [Haskell-cafe] Thread priority?

2009-04-27 Thread Don Stewart
semanticphilosopher:
 Count me in too

 I've got a library that endeavours to deliver 'rate-equivalence' - i.e  
 there may be some jitter in when the events should have occurred but  
 their long term rate of progress is stable.

 Testing has shown that I can get events to occur at the right time  
 within 1ms (99%+ of the time, with 50%+ of the events  0.5ms) - choose 
 your O/S carefully though. And this is without resorting to marking the 
 threads as real time with the kernel. If it matters you can tune the 
 scheduling to further reduce the timer scheduling latency (at the cost of 
 more CPU) and increase the fidelity of event timing another order of 
 magnitude or more.

 As for 'garbage collection ruins my real time properties' argument -  
 I've been pragmatic about this, you can configure the scheduler to go  
 and perform a GC if it knows that it is going to sleep for a while (yes, 
 this doesn't resolve the issues of external events arriving in that time 
 but read on) but not perform that too often. Turning off GHCs timers (to 
 stop it garbage collecting after it has actually been idle for a while) 
 and having code that doesn't create vast amounts of garbage means that a 
 GC takes 0.1ms.

 Now if I could see within Haskell the amount of heap that has been  
 recently mutated and some other GC statistics when it was running I  
 could even decide to schedule that more effectively.

 We use this to create synthetic network traffic sources and other  
 timing/performance related activities in the wide area context - it  
 serves our needs.


This is very interesting. Do you have any further documentation / notes
on controlling jitteriness?

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


[Haskell-cafe] Re: Typing efficient folds

2009-04-27 Thread Keith Battocchi
Matthew Brecknell haskell at brecknell.org writes:
 [...]
 Nest ((,) (l b) (l b)) ~ Nest (l' b')
 l' ~ (,) (l b)
 b' ~ (l b) -- (5)
 
 Unifying (2) and the result type from (3):
 
 n ((,) (z b) (z b)) ~ n (z' b')
 z' ~ (,) (z b)
 b' ~ (z b) -- (6)
 
 From (5) and (6), you require: l b ~ z b, and therefore l ~ z, but the
 forall l z in the type signature requires l and z to be independent.
 

Thanks for explicitly writing out the unification steps; this makes it 
perfectly clear where things are going wrong.  I was hoping to be able to have 
b' ~ b, l' b' ~ (l b, l b), and z' b' ~ (z b, z b).  I guess it makes sense 
that these types can't be inferred - is there any way to explicitly add 
signatures somewhere so that these alternate interpretations will be used 
instead?  This would allow l and z to remain independent.

 [...]
 efold :: (forall a. n a)
   - (forall a. m a - n (Pair a) - n a)
   - (forall a. Pair (m a) - m (Pair a))
   - (a - m a)
   - (Nest a - n a)
 efold e f g h Nil = e
 efold e f g h (Cons x xs) = f (h x) (efold e f g (g . pair h) xs)
 
 For example, to flatten a Nest to a simple list, you can take m to be Id 
 and n to be [], something like this:
 
 nest = Cons 0 (Cons (1,2) (Cons ((3,4),(5,6)) Nil))
 
 newtype Id a = Id a
 
 -- [0,1,2,3,4,5,6]
 flat_nest = efold []
   (\(Id xs) ys - xs : concatMap (\(p,q) - [p,q]) ys)
   (\(Id x, Id y) - Id (x,y))
   Id nest
 
 It's a little unpleasant having to use the Id type like this, but I
 can't see a way around it. I'd be interested to see an example with a
 non-trivial m.

It may depend on your notion of trivial, but if you've got a Nest [a] and want 
to get the sum of the lengths of the lists, you'd want m a to be something 
like K Int a where

K t a = K t

Thanks again for your help.

Regards,
Keith

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


Re: [Haskell-cafe] Re: Converting IO [XmlTree] to [XmlTree]

2009-04-27 Thread Tillmann Rendel

Achim Schneider wrote:

In other words:

1) Explain Pointed
2) Explain Functor
3) Explain Applicative
4) Explain Monad


Why Pointed first? Functor seems more useful and more basic.

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


Re: [Haskell-cafe] Re: Converting IO [XmlTree] to [XmlTree]

2009-04-27 Thread Martijn van Steenbergen

Tillmann Rendel wrote:

Achim Schneider wrote:

In other words:

1) Explain Pointed
2) Explain Functor
3) Explain Applicative
4) Explain Monad


Why Pointed first? Functor seems more useful and more basic.


They are in order of power: every monad is an applicative; every 
applicative is a functor; every functor is pointed.


Though I can't think of any non-functor pointiness at the moment.

Martijn.

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


Re: [Haskell-cafe] ghci debugger problem with :continue. is it broken, or is it me?

2009-04-27 Thread Thomas Hartman
Most enlightening, thanks.

The same effect can be seen with Debug.Trace.trace around the two versions of f.

I suppose this means that the points-free/pattern binding-style
version is a bit less work for ghc to execute (fewer reductions),
whereas the version with lambda bound variables is easier to debug.

On balance, I think I'll frequently write my functions with lambda
bound variables then.

Getting better use out of the ghc debugger seems worth the few extra cycles.

2009/4/26 Bernie Pope florbit...@gmail.com:
 2009/4/25 Thomas Hartman tphya...@gmail.com

 In the program below, can someone explain the following debugger output to
 me?

  After :continue, shouldn't I hit the f  breakpoint two more times?
  Why do I only hit the f breakpoint once?
  Is this a problem in the debugger?

 thart...@ubuntu:~/haskell-learning/debuggercat debugger.hs

 -- try this:
 -- ghci debugger.hs
 --  :break f
 --  :trace t
 --  :history -- should show you that f was called from h
 t = h . g . f $ hey!
 t2 = h . g . f $ heh!
 t3 = h . g . f $ wey!

 f = (f --  ++)
 g = (g --  ++)
 h = (h --  ++)

 ts = do
  putStrLn $ t
  putStrLn $ t2
  putStrLn $ t3

 What you are observing is really an artifact of the way breakpoints are
 attached to definitions in the debugger, and the way that GHCi evaluates
 code.
 f is clearly a function, but its definition style is a so-called pattern
 binding. The body contains no free (lambda bound) variables, so it is also
 a constant. GHCi arranges for f to be evaluated at most once. The breakpoint
 associated with the definition of f is fired if and when that evaluation
 takes place. Thus, in your case it fires exactly once.
 You can re-write f to use a so-called function binding instead, by
 eta-expansion (introduce a new fresh variable, and apply the function to it
 on both sides):
    f x = (f --  ++) x
 This denotes the same function, but the breakpoint on f works differently.
 In this case, a breakpoint attached to f will fire whenever an application
 of f is reduced. If you write it this way you will see that the program
 stops three times instead of one.
 You might ask: if both definitions denote the same function, why does the
 debugger behave differently? The short answer is that the debugger in GHCi
 is an operational debugger, so it exposes some of the operational details
 which may be invisible in a denotational semantics. In this case it revels
 that GHCi treats the two definitions of f differently.
 Cheers,
 Bernie.

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


Re: [Haskell-cafe] how can one load Prelude into ghci?

2009-04-27 Thread Brandon S. Allbery KF8NH

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Apr 27, 2009, at 12:25 , Thomas Hartman wrote:

One reason it would be nice to be able to do this, is you could then
get lambdabot :src style listings of prelude function definitions by
using the ghci debugger and :list for prelude functions.


I think up-to-date binary versions are preferred over source versions  
(thus the debugger is limited in what it can do with the Prelude).   
You would have to copy all the Prelude sources and modify them to make  
them look newer.  You don't need other hackery beyond that, but that's  
plenty enough; GHC's Prelude isn't a single file or even a small  
collection of files.


(It might be possible to borrow the Online Report's Prelude... won't  
be optimum but if you're going to interpret it won't be anyway)


- --
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH


-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (Darwin)

iEYEARECAAYFAkn2GccACgkQIn7hlCsL25UOhQCgtaAgs5/bLmIJ0hM+Her7HmN3
aakAnRXKJpelTrPMfuGLf2Ro8obZET+K
=UB0V
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread siki

I'm not sure if this is possible at all. I'd like to do something like this:

class A a where
foo :: a - Double

foo a = 5.0


class (A a) = B a where
foo a = 7.0

data Blah = Blah
data Bar = Bar

instance A Blah
instance B Bar 

let blah = Blah
bar = Bar

foo blah -- should print out 5
foo bar  -- should print out 7

Basically, I have a bunch of instances that have a common functionality but
I'd like to be able to group those instances and give each group a different
default implementation of that functionality. It's so easy to do this in
Java, for example, but I have no idea how to do it in Haskell. The above
example will not compile, btw.

Thanks a lot
-- 
View this message in context: 
http://www.nabble.com/Can-subclass-override-its-super-class%27-default-implementation-of-a-function--tp23264975p23264975.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree]

2009-04-27 Thread Jason Dusek
2009/04/21 Manlio Perillo manlio_peri...@libero.it:
 Luke Palmer ha scritto:
 And many other permutations, with differing degrees of
 laziness and parametericity.

 As long as you stricly read a string from the socket, this is
 ok. But you can not read a string lazily.

  Why not? It changes the way in which the program fails (if it
  does) but it does not change the result.

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


Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread Martijn van Steenbergen

siki wrote:

I'm not sure if this is possible at all. I'd like to do something like this:

class A a where
foo :: a - Double

foo a = 5.0



class (A a) = B a where
foo a = 7.0


This is currently not possible in Haskell. It's been proposed, though:

http://haskell.org/haskellwiki/Class_system_extension_proposal

If you have an actual example we might be able to come up with a 
different way of modelling it so that it does what you want, though.


Martijn.

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


Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread Ryan Ingram
No, but functionality similar to this has been proposed several times,
under the name Class Aliases [1].

The big problem is in the definition of B:
   class (A a) = B a where ...

In this case, you must make something an instance of A before it can
be an instance of B, and, in order to make something an instance of A,
you must provide an implementation of foo.  Not providing an
implementation is the same as providing the default.

With the class alias proposal you would write

 class B a = A a where
foo a = 7.0

In this case, (B a) and (A a) are the same class, but provide
different default implementations for the methods.  So you *cannot*
declare something an instance of both B and A.  But if you declare
something an instance of B without providing an implementation of
foo, it would use B's default, whereas instances of A would use A's
default.

Unfortunately, I don't believe anyone is working on implementing this
proposal.  It's high on my list of desired features, but I think
that not all the details have been figured out with how it interacts
with other features of the language.

  -- ryan

[1] http://repetae.net/recent/out/classalias.html,
http://haskell.org/haskellwiki/Class_alias

On Mon, Apr 27, 2009 at 2:00 PM, siki ga...@karamaan.com wrote:

 I'm not sure if this is possible at all. I'd like to do something like this:

 class A a where
    foo :: a - Double

    foo a = 5.0


 class (A a) = B a where
    foo a = 7.0

 data Blah = Blah
 data Bar = Bar

 instance A Blah
 instance B Bar

 let blah = Blah
    bar = Bar

 foo blah -- should print out 5
 foo bar  -- should print out 7

 Basically, I have a bunch of instances that have a common functionality but
 I'd like to be able to group those instances and give each group a different
 default implementation of that functionality. It's so easy to do this in
 Java, for example, but I have no idea how to do it in Haskell. The above
 example will not compile, btw.

 Thanks a lot
 --
 View this message in context: 
 http://www.nabble.com/Can-subclass-override-its-super-class%27-default-implementation-of-a-function--tp23264975p23264975.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.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


Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread siki

The actual problem is quite similar to the one that I provided or to the one
in the description of the proposed extension that you linked. 

Someone on another forum suggested record functions but I'm not sure I
understood correctly how that would work around this problem. Any suggestion
is greatly appreciated!

Thanks,

-Gabor



Martijn van Steenbergen-2 wrote:
 
 siki wrote:
 I'm not sure if this is possible at all. I'd like to do something like
 this:
 
 class A a where
 foo :: a - Double
 
 foo a = 5.0
 
 
 class (A a) = B a where
 foo a = 7.0
 
 This is currently not possible in Haskell. It's been proposed, though:
 
 http://haskell.org/haskellwiki/Class_system_extension_proposal
 
 If you have an actual example we might be able to come up with a 
 different way of modelling it so that it does what you want, though.
 
 Martijn.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://www.nabble.com/Can-subclass-override-its-super-class%27-default-implementation-of-a-function--tp23264975p23265759.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


[Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-27 Thread Bas van Gijzel
Hello everyone,

I'm doing a bachelor project focused on comparing parsers. One of the parser
libraries I'm using is Parsec (2) and I'm going to implement a very small
subset of haskell with it, with as most important feature the off-side rule
(indentation based parsing) used in function definitions and possibly in
where clauses.

But I'm still a bit stuck on how to implement this cleanly. I tried to
search for some examples on blogs but I haven't found anything yet. As far
as I can see the way to go would be using getState and updateState methods
defined in Parsec.Prim and to use the methods in Parsec.Pos to compare the
difference in indendation for tokens.

But I haven't completely wrapped my head around any state monad yet and I
don't understand Parsec enough yet to see how to use the methods Parsec.Pos
and state easily. Some examples or pointers to something to read would
really be helpful.

Thanks in advance,

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


Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-27 Thread Jason Dagit
On Mon, Apr 27, 2009 at 2:41 PM, Bas van Gijzel neneko...@gmail.com wrote:
 Hello everyone,

 I'm doing a bachelor project focused on comparing parsers. One of the parser
 libraries I'm using is Parsec (2) and I'm going to implement a very small
 subset of haskell with it, with as most important feature the off-side rule
 (indentation based parsing) used in function definitions and possibly in
 where clauses.

 But I'm still a bit stuck on how to implement this cleanly. I tried to
 search for some examples on blogs but I haven't found anything yet. As far
 as I can see the way to go would be using getState and updateState methods
 defined in Parsec.Prim and to use the methods in Parsec.Pos to compare the
 difference in indendation for tokens.

I've never tried to implement a whitespace sensitive parser like you'd
need for Haskell or Python, but my thought was that maybe you use a
stack and you push/pop from it when the indentation level changes.
That way, I think you could isolate the part of the parser that
handles changes in indentation from the rest.  Maybe I haven't thought
about this enough yet because I'm not sure what I would store on the
stack.  In some sense, you want the indentation level change to
determine which production(s) of the grammar you are looking for.  You
might also use it to track scope so that you know the scope of the
names in the program source.

 But I haven't completely wrapped my head around any state monad yet and I
 don't understand Parsec enough yet to see how to use the methods Parsec.Pos
 and state easily. Some examples or pointers to something to read would
 really be helpful.

I'd start by playing with some toy examples in the State monad, then
try implementing a State monad.  Only look at the real implementation
when you get stuck.  Once you get State, then go back to Parsec which
is more complex.  This way you'll be in over your head less.

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


[Haskell-cafe] LAST CALL: Haskell Communities and Activities Report

2009-04-27 Thread voigt
Dear Haskellers,

It is not yet too late to contribute to the May 2009 edition of the
Haskell Communities and Activities Report.

If you haven't already, please write an entry for your new project, or
update your old entry.

Please mail your entries to h...@haskell.org in LaTeX format. More
information can be found in the original Call for Contributions at

  http://www.haskell.org/pipermail/haskell/2009-April/021180.html

I look forward to receiving your contributions.

Thanks a lot,

Janis.

-- 
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:vo...@tcs.inf.tu-dresden.de


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


Re: [Haskell-cafe] Can subclass override its super-class' defaultimplementation of a function?

2009-04-27 Thread Claus Reinke

Basically, I have a bunch of instances that have a common functionality but
I'd like to be able to group those instances and give each group a different
default implementation of that functionality. It's so easy to do this in
Java, for example, but I have no idea how to do it in Haskell. The above
example will not compile, btw.


Before going into language extensions, is there anything wrong with:

class C a where foo :: a - Double

fooA a = 5.0 --default A
fooB a = 7.0 -- default B

data Blah = Blah
data Bar = Bar

instance C Blah where foo = fooA
instance C Bar  where foo = fooB

blah = Blah
bar = Bar

main = do
 print $ foo blah -- should print out 5
 print $ foo bar  -- should print out 7

It seems to match your spec.

Claus


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


[Haskell-cafe] Announce: GraphViz: Change of Maintainer

2009-04-27 Thread Matthew Sackman
I no longer have the time to continue development of the (apparently,
judging from the number of emails I'm getting, rather popular) graphviz
package. Fortunately, Ivan Lazar Miljenovic who has extended it himself
and sent me patches (some of which I did get round to folding in) has
agreed to take on the package. Please direct all further queries to him!

Many thanks Ivan!

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


[Haskell-cafe] createProcess problem

2009-04-27 Thread Vasili I. Galchin
Hello,


I am trying to use createProcess. Following is a small fragment. I am trying
to run a program called blastall (a bio-informatics program). It is kind of
like mv/cp/ln on Unix platforms (where the executable examines the program,
i.e. arg[0], and then provides appropriate behavior/semantics). In the case
of blastall, it alters its behavior based on the -p(program) CLI
argument.WSo in the following it should provide nucleotide behavior ... that
is what the 'n' on the end of blastn means.

import System.Process


main = do
 handle - runProcess
   blastall -- executable
   [-p blastn]  -- CLI args
   Nothing-- optional cwd
   Nothing-- optional env
   Nothing-- optional stdin
   Nothing-- optional stdout
   Nothing-- optional stderr
 return ()


When I run this program with ghci, blastall is not a happy camper. It is
complaining about -p blastn:
[NULL_Caption] ERROR: Program name undefined:  blastn  the space
between the double quote and 'b' is really there!!!
[NULL_Caption] ERROR: Program name undefined:  blastn

Yet if I run 'blastall -p blastn' from the DOS prompt no errors(I will try
tonight on my Linux machine).

If I try 'blastall -p bozo from the DOS prompt I get the same two errors as
when I run my test program using ghci.

I feel that it has something to do with double quotes in Haskell ...
probably something obviously silly that I am doing.

Any ideas?

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


Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread Donn Cave
Quoth siki ga...@karamaan.com,

 The actual problem is quite similar to the one that I provided or to the one
 in the description of the proposed extension that you linked. 

 Someone on another forum suggested record functions but I'm not sure I
 understood correctly how that would work around this problem. Any suggestion
 is greatly appreciated!

Maybe it was function records.  That's kind of the poor man's OOP in
Haskell - no typeclasses needed.

data FileRec = FileRec {
  fileRecRead :: Int - IO String
, fileRecWrite :: String - IO ()
}
socketFileRec socket = {
  fileRecWrite = \ s - send socket s 0
, fileRecRead = \ i - recv socket i 0
}
pipeFileRec p0 p1 = {
  fileRecWrite = writeFd p1
, fileRecRead = readFd p0
}
echoBlock file count = (fileRecRead file) count = fileRecWrite file

Maybe you could use that, maybe you couldn't.  That's why Martin suggested
that you reveal the actual problem.  Not the solution you had in mind,
but the thing you're trying to solve.

Donn

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


[Haskell-cafe] createProcess problem

2009-04-27 Thread Vasili I. Galchin
Hello,


I am trying to use createProcess. Following is a small fragment. I am trying
to run a program called blastall (a bio-informatics program). It is kind of
like mv/cp/ln on Unix platforms (where the executable examines the program,
i.e. arg[0], and then provides appropriate behavior/semantics). In the case
of blastall, it alters its behavior based on the -p(program) CLI
argument.WSo in the following it should provide nucleotide behavior ... that
is what the 'n' on the end of blastn means.

import System.Process


main = do
 handle - runProcess
   blastall -- executable
   [-p blastn]  -- CLI args
   Nothing-- optional cwd
   Nothing-- optional env
   Nothing-- optional stdin
   Nothing-- optional stdout
   Nothing-- optional stderr
 return ()


When I run this program with ghci, blastall is not a happy camper. It is
complaining about -p blastn:
[NULL_Caption] ERROR: Program name undefined:  blastn  the space
between the double quote and 'b' is really there!!!
[NULL_Caption] ERROR: Program name undefined:  blastn

Yet if I run 'blastall -p blastn' from the DOS prompt no errors(I will try
tonight on my Linux machine).

If I try 'blastall -p bozo from the DOS prompt I get the same two errors as
when I run my test program using ghci.

I feel that it has something to do with double quotes in Haskell ...
probably something obviously silly that I am doing.

Any ideas?

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


Re: [Haskell-cafe] createProcess problem

2009-04-27 Thread Claude Heiland-Allen

Hi Vasili,

Vasili I. Galchin wrote:
 [snip]


import System.Process


main = do
 handle - runProcess
   blastall -- executable
   [-p blastn]  -- CLI args


Try:

[-p, blastn]

This passes multiple command line arguments instead of just one that 
contains a space.  Most shells use spaces to separate arguments.


 [snip]

Hope this helps,


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


Re: [Haskell-cafe] createProcess problem

2009-04-27 Thread Felipe Lessa
On Mon, Apr 27, 2009 at 06:00:52PM -0500, Vasili I. Galchin wrote:
 I feel that it has something to do with double quotes in Haskell ...
 probably something obviously silly that I am doing.

The problem is that [-p blastn] means that there's only one
argument, while [-p, blastn] means what you want.  In a Unix
shell, what you're doing is the same as 'blastn -p blastn',
which is clearly wrong.

Why are things like this?  Well, imagine that you wanted to pass
a file as argument, and that file had a space in its name.
Having a list of arguments leaves you unconcerned about these
subtleties.

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


Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-27 Thread Ryan Ingram
I don't have experience solving this problem, but I've read a few
horror stories from people who had state affect the results of parsing
in Parsec.

Haskell's layout rules replace indentation levels with braces and
semicolons; you could run an initial tokenizing parser that builds
tokens including the indentation level of each line, then convert
those tokens into the appropriate braces and semicolons (via a pure
function) before feeding the results into the real Haskell parser.

  -- ryan

On Mon, Apr 27, 2009 at 2:41 PM, Bas van Gijzel neneko...@gmail.com wrote:
 Hello everyone,

 I'm doing a bachelor project focused on comparing parsers. One of the parser
 libraries I'm using is Parsec (2) and I'm going to implement a very small
 subset of haskell with it, with as most important feature the off-side rule
 (indentation based parsing) used in function definitions and possibly in
 where clauses.

 But I'm still a bit stuck on how to implement this cleanly. I tried to
 search for some examples on blogs but I haven't found anything yet. As far
 as I can see the way to go would be using getState and updateState methods
 defined in Parsec.Prim and to use the methods in Parsec.Pos to compare the
 difference in indendation for tokens.

 But I haven't completely wrapped my head around any state monad yet and I
 don't understand Parsec enough yet to see how to use the methods Parsec.Pos
 and state easily. Some examples or pointers to something to read would
 really be helpful.

 Thanks in advance,

 Bas van Gijzel

 ___
 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] createProcess problem

2009-04-27 Thread Brandon S. Allbery KF8NH

On Apr 27, 2009, at 18:55 , Vasili I. Galchin wrote:

   [-p blastn]  -- CLI args


createProcess expects a list of individual argument strings.  You're  
sending it a single argument [-p blastn]; you want to send it two  
arguments [-p, blastn] (or [-pblastn] without the space; like  
most commands you can combine the parameter with the option or pass it  
as the next argument).


The command line equivalent of what you're doing would be:  blastall '- 
p blastn'


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problem with installing phooey

2009-04-27 Thread Daryoush Mehrtash
When I try to install Phooey I get the following error:

cabal  install --constraint=Stream == 0.3 phooey
Resolving dependencies...
[1 of 1] Compiling Main (
/tmp/phooey-2.016943/phooey-2.0/Setup.lhs,
/tmp/phooey-2.016943/phooey-2.0/dist/setup/Main.o )
Linking /tmp/phooey-2.016943/phooey-2.0/dist/setup/setup ...
Configuring phooey-2.0...
Warning: No 'build-type' specified. If you do not need a custom Setup.hs or
./configure script then use 'build-type: Simple'.
Preprocessing library phooey-2.0...
Building phooey-2.0...

src/Graphics/UI/Phooey/WinEvents.hs:66:7:
Could not find module `Data.Reactive':
  Use -v to see a list of the files searched for.

It seems that the current version of reactive (0.10.5) no longer has
Data.Reactive module (it seem to have been removed since 0.5 version of the
reactive).

Does Phooey really need 0.5 version of the reactive or is there a problem in
my installation?

Thanks

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


[Haskell-cafe] LondonHUG talk: Engineering Large Projects in Haskell

2009-04-27 Thread Don Stewart
Slides from last week's London HUG http://www.londonhug.net/ talk are
now online. The talk attempts to document some of the tips and tricks
Galois has accumulated using Haskell commercially for the past 10 years.

You can now read the slides of the talk here:


http://www.galois.com/blog/2009/04/27/engineering-large-projects-in-haskell-a-decade-of-fp-at-galois/

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