Re: [Haskell-cafe] deriving Data.HashTable - stack overflow

2013-08-09 Thread Lyle Kopnicky
Ah, thanks, folks!

I'll just implement my own hashing by generating a string and calling the
hash function on that. That's what I was doing in the old version of my
code, anyway.

It's just that in the core Data.HashTable, you had to provide a hash
function, so the point where I used the hash table was able to call a
string conversion function that was defined elsewhere.

With the hashtable package, you have to define a Hashable instance in the
same package as your datatype definition - which is not where the string
conversion is implemented. Calling the string conversion function leads to
a cyclic dependency that I wanted to avoid. So I'll have to maybe move it
to live with the datatype definition, or duplicate it, or use some other
means of hashing.

In other words, package A defines datatype A. Package B defines A -
String. Package C creates a HashTable that indexes by As, and also imports
package B, so it can build a hash function as the composition of the string
conversion and the provided string hashing.

But now I need to define the Hashable instance in A, which doesn't have
access to package B, since package B also depends on A, and I don't like
circular dependencies.

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


Re: [Haskell-cafe] deriving Data.HashTable - stack overflow

2013-08-09 Thread Lyle Kopnicky
I chose not to introduce another dependency. I just implemented the hash
function by delegating to the Show instance of the nested type:

data ValType = FloatType | IntType | StringType
deriving (Show,Eq)

data VarName = VarName ValType String
deriving (Show,Eq)

instance Hashable VarName where
hash (VarName t n) = hash (show t ++ n)

Not super-efficient, but it'll be fine. The printString function (defined
in that other package) uses a single character prefix for each ValType.

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


Re: [Haskell-cafe] deriving Data.HashTable - stack overflow

2013-08-09 Thread Lyle Kopnicky
Here's another way to do it:

data ValType = FloatType | IntType | StringType
deriving (Show,Eq)

instance Hashable ValType where
hash FloatType = 0
hash IntType = 1
hash StringType = 2

data VarName = VarName ValType String
deriving (Show,Eq)

instance Hashable VarName where
hash (VarName t n) = hash (t, n)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] deriving Data.HashTable - stack overflow

2013-08-08 Thread Lyle Kopnicky
Hi folks,

In GHC 7.6.3, the base Data.HashTable is deprecated, so I installed the
hashtables package. In order to work on your datatype, you need an instance
of Data.Hashable.Hashable.

So I went to the Data.Hashable page and looked up examples on how to derive
a Hashable instance for my datatype:
http://hackage.haskell.org/packages/archive/hashable/latest/doc/html/Data-Hashable.html

The problem occurs even when using the sample code on the page:


{-# LANGUAGE DeriveGeneric #-}

 import GHC.Generics (Generic)
 import Data.Hashable

 data Colour = Red | Green | Blue
   deriving Generic

 instance Hashable Colour

If I then type `hash Red` I get a stack overflow.

I am using the Haskell Platform, so I have hashable-1.1.2.5, but I notice
the docs are for hashable-1.2.0.10. If I install 1.2.0.10 though, other
code in my project breaks - seems like one part doesn't recognize the
instances from another part. So I'll stick with the platform version.

I am running the 32-bit Windows GHC 7.6.3. Haskell Platform 2013.2.0.0.

Any thoughts?

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


[Haskell-cafe] Unable to install Haskell Platform without readline

2009-09-11 Thread Lyle Kopnicky
Hi folks,

I just installed GHC 6.10.4 on Ubuntu 9.04 32-bit, and then tried to install
the Haskell Platform from source. It built quite a bit of stuff, with many
warnings but no errors, and then finally died with the error below.

To install editline, I need cabal, which is of course why I installed the
Platform. I read an earlier thread from May that said that editline came
with GHC 6.10.2, so the Platform didn't work with 6.10.3, but was soon to be
updated. Now the web
sitehttp://hackage.haskell.org/platform/contents.htmlfor the
Platform says it comes with 6.10.4, so I assumed it should work with
6.10.4, but apparently it still has this problem of still missing editline.

Am I doing something wrong?

checking editline/readline.h usability... no
checking editline/readline.h presence... no
checking for editline/readline.h... no
checking editline/editline.h usability... no
checking editline/editline.h presence... no
checking for editline/editline.h... no
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking for sign of read_history result on error... negative
checking for rl_completion_matches... no
checking for completion_matches... no
configure: error: editline not found, so this package cannot be built
See `config.log' for more details.

Error:
Configuring the editline-0.2.1.0 package failed
make: *** [build.stamp] Error 2

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


[Haskell-cafe] Re: Unable to install Haskell Platform without editline

2009-09-11 Thread Lyle Kopnicky
I mean editline, not readline.

On Fri, Sep 11, 2009 at 11:46 AM, Lyle Kopnicky li...@qseep.net wrote:

 Hi folks,

 I just installed GHC 6.10.4 on Ubuntu 9.04 32-bit, and then tried to
 install the Haskell Platform from source. It built quite a bit of stuff,
 with many warnings but no errors, and then finally died with the error
 below.

 To install editline, I need cabal, which is of course why I installed the
 Platform. I read an earlier thread from May that said that editline came
 with GHC 6.10.2, so the Platform didn't work with 6.10.3, but was soon to be
 updated. Now the web 
 sitehttp://hackage.haskell.org/platform/contents.htmlfor the Platform says 
 it comes with 6.10.4, so I assumed it should work with
 6.10.4, but apparently it still has this problem of still missing editline.

 Am I doing something wrong?

 checking editline/readline.h usability... no
 checking editline/readline.h presence... no
 checking for editline/readline.h... no
 checking editline/editline.h usability... no
 checking editline/editline.h presence... no
 checking for editline/editline.h... no
 checking readline/readline.h usability... yes
 checking readline/readline.h presence... yes
 checking for readline/readline.h... yes
 checking for sign of read_history result on error... negative
 checking for rl_completion_matches... no
 checking for completion_matches... no
 configure: error: editline not found, so this package cannot be built
 See `config.log' for more details.

 Error:
 Configuring the editline-0.2.1.0 package failed
 make: *** [build.stamp] Error 2

 - Lyle

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


Re: [Haskell-cafe] Unable to install Haskell Platform without editline

2009-09-11 Thread Lyle Kopnicky
On Fri, Sep 11, 2009 at 12:01 PM, Judah Jacobson
judah.jacob...@gmail.comwrote:

 The above editline requirement is for the editline C library, not the
 Haskell bindings:
 http://www.thrysoee.dk/editline

 My guess is that you need to install a recent version of the
 libedit-dev package.


After installing libedit-dev, the rest of the build worked. Thanks! Now I'm
having a new problem, that I'll post in another thread.

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


[Haskell-cafe] Haskell Platform install fails on mtl

2009-09-11 Thread Lyle Kopnicky
OK, I was able to build the Haskell Platform on Ubuntu 9.04 with GHC 6.10.4.
But when I try to install it, I get an error:

Registering haskell-platform-2009.2.0.2...
Reading package info from dist/inplace-pkg-config ... done.
Writing new package config file... done.
**
* Building each component completed successfully.
*
* Now do sudo make install
**
l...@lwk-desktop:~/downloads/haskell-platform-2009.2.0.2$ sudo make install
[sudo] password for lwk:
scripts/install.sh
Installing mtl-1.1.0.2...

Error:
The mtl-1.1.0.2/Setup script does not exist or cannot be run
make: *** [install] Error 2

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


[Haskell-cafe] Re: Haskell Platform install fails on mtl

2009-09-11 Thread Lyle Kopnicky
It's a bug in the install.sh script. Here's the fix:

36a37,42
 # Is this exact version of the package already installed?
 is_pkg_installed () {
   PKG_VER=$1
   grep  ${PKG_VER}  installed.packages  /dev/null 21
 }

40,43c46,53
   cd ${pkg} || die The directory for the component ${PKG} is missing
   echo Installing ${pkg}...
   install_pkg ${pkg}
   cd ..
---
   if is_pkg_installed ${pkg}; then
 echo Platform package ${pkg} is already installed. Skipping...
   else
   cd ${pkg} || die The directory for the component ${PKG} is
missing
   echo Installing ${pkg}...
   install_pkg ${pkg}
   cd ..
   fi

On Fri, Sep 11, 2009 at 1:04 PM, Lyle Kopnicky li...@qseep.net wrote:

 OK, I was able to build the Haskell Platform on Ubuntu 9.04 with GHC
 6.10.4. But when I try to install it, I get an error:

 Registering haskell-platform-2009.2.0.2...
 Reading package info from dist/inplace-pkg-config ... done.
 Writing new package config file... done.
 **
 * Building each component completed successfully.
 *
 * Now do sudo make install
 **
 l...@lwk-desktop:~/downloads/haskell-platform-2009.2.0.2$ sudo make install
 [sudo] password for lwk:
 scripts/install.sh
 Installing mtl-1.1.0.2...

 Error:
 The mtl-1.1.0.2/Setup script does not exist or cannot be run
 make: *** [install] Error 2

 - Lyle

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


[Haskell-cafe] Build 32-bit apps on 64-bit Windows?

2009-07-14 Thread Lyle Kopnicky
If I am running GHC on 64-bit Windows, do I have a choice of building a
32-bit or 64-bit app? On a cursory glance through the command-line options,
I didn't find anything.

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


Re: [Haskell] The speed, size and dependability of programming languages

2009-06-02 Thread Lyle Kopnicky
On Tue, Jun 2, 2009 at 1:03 PM, Paul Johnson p...@cogito.org.uk wrote:

 Lyle Kopnicky wrote:


 I think it's a combination of 1) the expressiveness measure is too
 simplistic, measuring number of lines alone, or counting comments, and 2)
 the problem set is skewed toward number-crunching, which is not (say)
 Prolog's strong suit.

 Also there is a strong tendency to optimise the code for performance rather
 than conciseness (concision?).  In the past this tended to bloat (e.g.)
 Haskell entries as simple intuitive code was replaced by arrays of unboxed
 integers and similar C-like constructs.


Well, they're supposedly measuring performance as well. If concise Haskell
is non-performant, and performant Haskell is verbose, this ought to be
reflected in the charts. But it managed to perform pretty well in both. I
don't think Haskell got short shrift in this analysis. Perhaps other
languages suffered a more written verbosely for performance problem.

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


Re: [Haskell] The speed, size and dependability of programming languages

2009-06-01 Thread Lyle Kopnicky
Thanks for the link. I find the expressiveness results odd. How can SML/NJ
be among the least expressive languages, while MLTON and OCAML are among the
most expressive? How is Smalltalk less expressive than Java? Why are Prolog
and Mercury among the least expressive?

I think it's a combination of 1) the expressiveness measure is too
simplistic, measuring number of lines alone, or counting comments, and 2)
the problem set is skewed toward number-crunching, which is not (say)
Prolog's strong suit.

On Mon, Jun 1, 2009 at 1:18 AM, Bulat Ziganshin
bulat.zigans...@gmail.comwrote:

 Hello haskell,

 Interesting blog post comparing speed and expressiveness of many
 languages:
 http://gmarceau.qc.ca/blog/2009/05/speed-size-and-dependability-of.html

 --
 Best regards,
  Bulat  mailto:bulat.zigans...@gmail.com


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


[Haskell-cafe] lift in TemplateHaskell?

2009-04-14 Thread Lyle Kopnicky
Hi folks,

I'm having trouble reading the TemplateHaskell docs and trying to do
something that seems like it should be simple. In MetaML, there is a 'lift'
function which does exactly what I want to do. Here's an example function:

let double n = [| 2 * $( litE (integerL n) ) |]

This works as intended, but instead of writing litE (integerL n) I just
want to write lift n, or something similar. I expect that would involve a
type class called something like Liftable that would lift literals using the
appropriate functions. Does this exist?

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


[Haskell-cafe] Re: lift in TemplateHaskell?

2009-04-14 Thread Lyle Kopnicky
OK, I figured it out.

The class is Language.Haskell.TH.Syntax.Lift. The function is
Language.Haskell.TH.Syntax.lift. And I can rewrite my function as:

let double n = [| 2 * n |]

I wish this were explained in the TemplateHaskell documentation.

- Lyle

On Tue, Apr 14, 2009 at 2:51 PM, Lyle Kopnicky li...@qseep.net wrote:

 Hi folks,

 I'm having trouble reading the TemplateHaskell docs and trying to do
 something that seems like it should be simple. In MetaML, there is a 'lift'
 function which does exactly what I want to do. Here's an example function:

 let double n = [| 2 * $( litE (integerL n) ) |]

 This works as intended, but instead of writing litE (integerL n) I just
 want to write lift n, or something similar. I expect that would involve a
 type class called something like Liftable that would lift literals using the
 appropriate functions. Does this exist?

 Thanks,
 Lyle

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


[Haskell-cafe] Missing dependency?

2009-04-02 Thread Lyle Kopnicky
Hi folks,

Since the time package is not included in ghc-6.10.2, I installed it via
cabal. Then I tried to configure my project, and it says that the dependency
is missing. Mysterious. Can anyone explain?

l...@lwk-desktop:~/devel/vintage-basic$ ghc-pkg list
/usr/local/lib/ghc-6.10.2/./package.conf:
Cabal-1.6.0.3, HUnit-1.2.0.3, QuickCheck-1.2.0.0, array-0.2.0.0,
base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, containers-0.2.0.1,
directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3),
(dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3),
(dph-seq-0.3), editline-0.2.1.0, filepath-1.1.0.2, (ghc-6.10.2),
ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3,
haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1,
mtl-1.1.0.2, network-2.2.1, old-locale-1.0.0.1, old-time-1.0.0.2,
packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1,
pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1,
regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3,
rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1,
unix-2.3.2.0, xhtml-3000.2.0.1
/home/lwk/.ghc/i386-linux-6.10.2/package.conf:
HTTP-4000.0.4, time-1.1.2.3, zlib-0.5.0.0
l...@lwk-desktop:~/devel/vintage-basic$ runhaskell Setup.hs configure
Configuring vintage-basic-1.0.1...
Setup.hs: At least the following dependencies are missing:
time =1.1
l...@lwk-desktop:~/devel/vintage-basic$

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


Re: [Haskell] ANNOUNCE: GHC version 6.10.2

2009-04-01 Thread Lyle Kopnicky
Great! But what happened to the time package? It was in 6.10.1. Has it been
intentionally excluded from 6.10.2?

On Wed, Apr 1, 2009 at 1:21 PM, Ian Lynagh ig...@earth.li wrote:


   ==
The (Interactive) Glasgow Haskell Compiler -- version 6.10.2
   ==

 The GHC Team is pleased to announce a new patchlevel release of GHC.
 This release contains a number of bugfixes relative to 6.10.1, including
 some performance fixes, so we recommend upgrading.

 Release notes are here:

  http://haskell.org/ghc/docs/6.10.2/html/users_guide/release-6-10-2.html

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


Re: [jhc] Re: [Haskell] ANNOUNCE: jhc 0.6.0 Haskell Compiler

2009-03-23 Thread Lyle Kopnicky
Those are impressive results. Typically on programming language benchmarks,
the speed of ghc-generated code fares well against C, sometimes
outperforming it, at best being 20x faster, at worst being 3x slower. Since
it already seems fast enough, I'm astonished that jhc could make it even
faster.

http://shootout.alioth.debian.org/u32q/benchmark.php?test=alllang=ghclang2=gccbox=1

Where ghc-generated code fares poorly against other languages is memory
usage. Has there been an effort in jhc to reduce the memory footprint of
generated code? How does it fare against ghc in this area?

Thanks,
Lyle

On Mon, Mar 23, 2009 at 1:09 AM, John Meacham j...@repetae.net wrote:

 On Mon, Mar 23, 2009 at 08:40:02AM +0100, Ketil Malde wrote:
   I had done that, actually, before even my first post, and knew that it
   changes little to the picture, at least on my system.
 
  I think Bulat was right on the money here: you're essentially testing
  the efficiency of writing integers.  Presumably, JHC is better than
  GHC at specializing/inlining this library function.

 Indeed, but isn't being better at specializing/inlining exactly what an
 optimizing compiler should do. :)

 In any case, these results are not atypical, generally, if jhc can
 compile something, it ends up being 2-3x faster than ghc. After all,
 C-comparable (or even superior) speed is the main goal of jhc
 development. And if anything, I am more convinced than when I started
 that the goal is achievable. With jhc today, C comparable performance
 from numerical code is not difficult to achieve with some attention to
 strictness annotations.

John

 --
 John Meacham - ⑆repetae.net⑆john⑈
 ___
 Haskell mailing list
 Haskell@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell

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


Re: [Haskell-cafe] ANNOUNCE: Vintage BASIC 1.0

2009-03-14 Thread Lyle Kopnicky
I've posted a new version, 1.0.1, that has a usage message if you run it
with no arguments.
There is a package for Windows now (not just a binary) as well as Linux.
Both packages include documentation and example programs.

Thanks for pointing that out!

On Fri, Mar 13, 2009 at 1:31 AM, Wolfgang Jeltsch 
jelt...@informatik.tu-cottbus.de wrote:

 When running the executable, nothing happens. The executable should show a
 usage message instead. Where are the BASIC programs? I think, you have to
 grab them from the source. They should be installed, too.

 Best wishes,
 Wolfgang

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


Re: [Haskell-cafe] ANNOUNCE: Vintage BASIC 1.0

2009-03-13 Thread Lyle Kopnicky
On Fri, Mar 13, 2009 at 1:31 AM, Wolfgang Jeltsch 
jelt...@informatik.tu-cottbus.de wrote:

 When running the executable, nothing happens. The executable should show a
 usage message instead. Where are the BASIC programs? I think, you have to
 grab them from the source. They should be installed, too.


Thanks for your feedback, and for checking out Vintage BASIC!

I will add a usage message, as you suggested. Currently the usage is only
described in the User's Guide. There are no options; you just give it the
name of one or more BASIC source files. (Naturally this extends to doing
nothing when supplied with zero source files.)

The BASIC games are at http://www.vintage-basic.net/games.html. There is a
tarball of all the games
(bcg.tar.gzhttp://www.vintage-basic.net/downloads/bcg.tar.gz)
as well. These are separated from the Vintage BASIC distribution for legal
reasons. Vintage BASIC is copyrighted by me under a BSD license. The games
were written by many authors and compiled into a book copyrighted by
Creative Computing. I have secured permission from the editor to post the
games. I do not wish to imply that they are covered by the same license as
the interpreter. If anyone has any suggestions as to how to make the process
simpler, I'd be happy to hear it.

Thanks,
Lyle

P.S. I need to get my other e-mail account subscribed to this list
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: Vintage BASIC 1.0

2009-03-12 Thread Lyle Kopnicky
I am pleased to announce the initial release of Vintage BASIC, an
interpreter for microcomputer-era BASIC. Fully unit-tested, it faithfully
implements the common elements of the language. On the web site, you can
find 102 games from the classic book BASIC Computer Games, all of which run
flawlessly. Have fun!
This is a standalone interpreter, operating on text files. Although not an
embedding, like Lennart Augustsson's clever implementation, it does use a
custom BASIC monad in order to execute the code. A unique feature of this
implementation is that control structures such as FOR are implemented using
resumable exceptions: FOR is a handler and NEXT throws an exception. A
Developer's Guide is included with the source.

This is my first public release of open source software. I have been working
on this project since 2003.

Home page: http://www.vintage-basic.net

Also available on
Hackagehttp://hackage.haskell.org/cgi-bin/hackage-scripts/package/vintage-basicand
patch-tag.com http://patch-tag.com/repo/vintage-basic/home.

Please e-mail me at l...@vintage-basic.net with any questions/comments.

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


Re: [Haskell-cafe] Distributing Linux binaries

2009-03-12 Thread Lyle Kopnicky
Thanks, folks. I have decided for now just to release a tarball with an
executable and some docs, that can be expanded where the user deems
appropriate. I'll try a static link if people are having problems with it.
- Lyle
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Distributing Linux binaries

2009-03-10 Thread Lyle Kopnicky
Thanks folks for your replies.

I did learn, from your e-mails and from the cabal documentation (example 9
on page
http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/builders.htm),
how to build a tarball with an executable and LICENSE file, via cabal copy.
It would have been nice to include the documentation (user's guide) as well,
but I don't know how to get cabal copy to put that into the bundle.

Unfortunately, I don't feel it's of great use to the end user. Now they have
a tarball with paths like /usr/local/bin/vintbas and
/usr/local/share/doc/vintage-basic-1.0/LICENSE.txt. Untarring it gives a
warning and strips the leading /, so it won't untar in root unless you CD to
root first. And of course you have to have root access to do that. If you
want to install it in your user dir, you'll have to make a substitution for
the paths.

You suggested I write my own install script. But certainly this is a common
situation, and someone has made a generic install script for this sort of
thing?

As I've said I tried to make a Debian package, folowing two different
cabal-to-debian instructions, and neither one worked.

If it is a hurdle for me, I can imagine a lot of people are getting
frustrated at trying to distribute their binaries on Linux.

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


[Haskell-cafe] Distributing Linux binaries

2009-03-09 Thread Lyle Kopnicky
Hi folks,

I've got an application to release. I'm releasing the source, but I also
wanted to release binary versions for people that don't have GHC. I
developed on Windows, so making a Windows executable was simple. I also have
access to an Ubuntu Linux box, on which I can easily build and test my app.

But, I'm a bit confused about how to release binaries for Linux. It's not so
simple as on Windows. Or, maybe it is but I don't know it. What do people
recommend as a way of distributing Linux binaries? I tried to make a Debian
package and couldn't figure it out, but maybe that's overkill. GHC itself
has some kind of tarball for the binary distributions, one for Debian and
one for Red Hat. How would I make such a package and what would go into it?
There's only one executable, so it shouldn't be too complicated.

I figure the main issue on Linux is that when you compile it, it's linked to
specific shared libraries.

Don't have a Mac myself but I'm happy to have Mac folks submit binaries.
I'll worry about that later.

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


[Haskell-cafe] Haskell Fest

2009-02-09 Thread Lyle Kopnicky
Looks like a lot of fun!

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


Re: [Haskell-cafe] GHC 6.11 missing time package?

2009-02-08 Thread Lyle Kopnicky
OK, I was able to get it to build. I just had to install MinGW and put its
bin directory in my path. Thanks for the help!
(Actually, I ended up building time-1.1.2.3 for 6.10.1.20090110.)

On Sun, Feb 1, 2009 at 2:38 AM, Krzysztof Skrzętnicki gte...@gmail.comwrote:

 It looks that you need MSYS or Cygwin to complete this build. Here you can
 find instructions regarding MSYS (and also GLUT, but you can ignore that
 part):
 http://www.haskell.org/pipermail/haskell-cafe/2007-September/031535.html

 All best

 Christopher Skrzętnicki

 2009/2/1 Lyle Kopnicky li...@qseep.net

 I tried building it from hackage. I got an error:
 Setup.hs: sh: createProcess: does not exist (No such file or
 directory)

 ...which is very similar to the error I get if I try to build it using
 6.10:

 Setup.hs: sh: runGenProcess: does not exist (No such file or
 directory)

 I don't know if there's something wrong with the package, or I don't have
 something set up right to build it on Windows.

 On Sat, Jan 31, 2009 at 10:13 PM, Antoine Latter aslat...@gmail.comwrote:

 2009/1/31 Lyle Kopnicky li...@qseep.net:
  Hi folks,
  I'm getting ready to release a piece of software. Unfortunately due to
 a bug
  in GHC 6.10 on Windows it does not handle Ctrl+C properly. Since the
 bug has
  been fixed (thank you Simon Marlow), I figured I'd download a 6.11
 build (I
  grabbed the 2009-01-29 version).
  Unfortunately, my project won't build with it because it's missing the
  time-1.1 package. This is sad because I had gone through the trouble to
  rewrite my use of oldtime to use time, thinking it was more
 future-proof. Is
  this an oversight in the nightly build, or is this package going out of
 GHC?
  Thanks,
  Lyle

 Hackage seems to have it:

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

 Does that work?

 -Antoine



 ___
 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] GHC 6.11 missing time package?

2009-02-01 Thread Lyle Kopnicky
I tried building it from hackage. I got an error:
Setup.hs: sh: createProcess: does not exist (No such file or directory)

...which is very similar to the error I get if I try to build it using 6.10:

Setup.hs: sh: runGenProcess: does not exist (No such file or directory)

I don't know if there's something wrong with the package, or I don't have
something set up right to build it on Windows.

On Sat, Jan 31, 2009 at 10:13 PM, Antoine Latter aslat...@gmail.com wrote:

 2009/1/31 Lyle Kopnicky li...@qseep.net:
  Hi folks,
  I'm getting ready to release a piece of software. Unfortunately due to a
 bug
  in GHC 6.10 on Windows it does not handle Ctrl+C properly. Since the bug
 has
  been fixed (thank you Simon Marlow), I figured I'd download a 6.11 build
 (I
  grabbed the 2009-01-29 version).
  Unfortunately, my project won't build with it because it's missing the
  time-1.1 package. This is sad because I had gone through the trouble to
  rewrite my use of oldtime to use time, thinking it was more future-proof.
 Is
  this an oversight in the nightly build, or is this package going out of
 GHC?
  Thanks,
  Lyle

 Hackage seems to have it:

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

 Does that work?

 -Antoine

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


[Haskell-cafe] GHC 6.11 missing time package?

2009-01-31 Thread Lyle Kopnicky
Hi folks,
I'm getting ready to release a piece of software. Unfortunately due to a bug
in GHC 6.10 on Windows it does not handle Ctrl+C properly. Since the bug has
been fixed (thank you Simon Marlow), I figured I'd download a 6.11 build (I
grabbed the 2009-01-29 version).

Unfortunately, my project won't build with it because it's missing the
time-1.1 package. This is sad because I had gone through the trouble to
rewrite my use of oldtime to use time, thinking it was more future-proof. Is
this an oversight in the nightly build, or is this package going out of GHC?

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


[Haskell-cafe] How does one use Text.Regex.Base.RegexLike?

2008-12-23 Thread Lyle Kopnicky
I'm trying to migrate code from using the old Text.Regex to the new
Text.Regex.Base. But, I'm getting type errors. I can't even create a regex.
Looking at the docs, it seems like this should print bcd:

import Data.Array
import Text.Regex.Base
import Text.Regex.Posix

rx = makeRegex a(.*)A

Just (_, mt, _) = matchOnceText rx abcdA

main = putStrLn (fst (mt ! 0))


But I get an error:

src\regex.hs:5:5:
No instance for (RegexMaker regex compOpt execOpt [Char])
  arising from a use of `makeRegex' at src\regex.hs:5:5-22
Possible fix:
  add an instance declaration for
  (RegexMaker regex compOpt execOpt [Char])
In the expression: makeRegex a(.*)A
In the definition of `rx': rx = makeRegex a(.*)A

src\regex.hs:7:18:
No instance for (RegexLike regex [Char])
  arising from a use of `matchOnceText' at src\regex.hs:7:18-41
Possible fix:
  add an instance declaration for (RegexLike regex [Char])
In the expression: matchOnceText rx abcdA
In a pattern binding: Just (_, mt, _) = matchOnceText rx abcdA

Why does it say there is no instance? Isn't the instance imported by
Text.Regex.Posix?

Why in the world is it so complicated just to get a matched substring out of
the text? Is there an easier way?

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


Re: [Haskell-cafe] How does one use Text.Regex.Base.RegexLike?

2008-12-23 Thread Lyle Kopnicky
Yes, sort of. It enables me to get some simple examples working with (=~).
But I still don't know how to get makeRegex to work. You need it to specify
options like case insensitivity, or to use functions like matchAllText.

On Tue, Dec 23, 2008 at 11:29 AM, Jeremy Shaw jer...@n-heptane.com wrote:

 Hello,

 Does this help?


 http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/

 j.

 At Tue, 23 Dec 2008 11:21:41 -0800,
 Lyle Kopnicky wrote:
 
  [1  multipart/alternative (7bit)]
  [1.1  text/plain; ISO-8859-1 (7bit)]
  I'm trying to migrate code from using the old Text.Regex to the new
  Text.Regex.Base. But, I'm getting type errors. I can't even create a
 regex.
  Looking at the docs, it seems like this should print bcd:
 
  import Data.Array
  import Text.Regex.Base
  import Text.Regex.Posix
 
  rx = makeRegex a(.*)A
 
  Just (_, mt, _) = matchOnceText rx abcdA
 
  main = putStrLn (fst (mt ! 0))
 
 
  But I get an error:
 
  src\regex.hs:5:5:
  No instance for (RegexMaker regex compOpt execOpt [Char])
arising from a use of `makeRegex' at src\regex.hs:5:5-22
  Possible fix:
add an instance declaration for
(RegexMaker regex compOpt execOpt [Char])
  In the expression: makeRegex a(.*)A
  In the definition of `rx': rx = makeRegex a(.*)A
 
  src\regex.hs:7:18:
  No instance for (RegexLike regex [Char])
arising from a use of `matchOnceText' at src\regex.hs:7:18-41
  Possible fix:
add an instance declaration for (RegexLike regex [Char])
  In the expression: matchOnceText rx abcdA
  In a pattern binding: Just (_, mt, _) = matchOnceText rx abcdA
 
  Why does it say there is no instance? Isn't the instance imported by
  Text.Regex.Posix?
 
  Why in the world is it so complicated just to get a matched substring out
 of
  the text? Is there an easier way?
 
  Thanks,
  Lyle
  [1.2  text/html; ISO-8859-1 (7bit)]
 
  [2  text/plain; us-ascii (7bit)]
  ___
  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 does one use Text.Regex.Base.RegexLike?

2008-12-23 Thread Lyle Kopnicky
Yes, that worked, thanks. I just figured that out too. Here's a whole
working program:

import Text.Regex.Base
import Text.Regex.Posix

rx :: Regex
rx = makeRegex a(.*)A

mr = match rx abcdA

text = head $ mrSubList mr

main = putStrLn text


On Tue, Dec 23, 2008 at 12:30 PM, Daniel Fischer
daniel.is.fisc...@web.dewrote:

 Am Dienstag, 23. Dezember 2008 21:09 schrieb Lyle Kopnicky:
  Yes, sort of. It enables me to get some simple examples working with
 (=~).
  But I still don't know how to get makeRegex to work. You need it to
 specify
  options like case insensitivity, or to use functions like matchAllText.
 

 Your problem is that GHC can't know which instance to choose. You can help
 it
 by giving a type signature, e.g.

 rx :: Regex
 rx = makeRegex a(.*)A

 HTH,
 Daniel


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


Re: [Haskell-cafe] Re: TimeDiff to Int?

2008-11-13 Thread Lyle Kopnicky
Thanks, but that doesn't seem to work. I got an answer of -3. I tried it
again a minute later and it was still -3. I tried again a minute later and
it was -1. It's just after 9am here, so I have no idea what to make of those
numbers.

I have settled on this code:

secondsSinceMidnight :: IO Int
secondsSinceMidnight = do
  zonedTime - getZonedTime
  return $ floor $ toRational $ timeOfDayToTime $ localTimeOfDay $
zonedTimeToLocalTime zonedTime

On Thu, Nov 13, 2008 at 2:29 AM, Jon Fairbairn
[EMAIL PROTECTED]wrote:

 Lyle Kopnicky [EMAIL PROTECTED] writes:

  I had some code using the oldtime package, and want to convert it to use
  the time package.
  One of the things I need to do is calculate the number of seconds since
  midnight. The easy part is getting a TimeDiff result:

 You mean DiffTime?

  utc - getCurrentTime
  tz - getCurrentTimeZone
  let td = timeOfDayToTime $ localTimeOfDay $ utcToLocalTime tz utc
  Now td is a TimeDiff representation of the number of seconds since
  midnight. It prints nicely, but I'm having a heck of a time figuring out
  how to truncate it to an Int.

 You could do something like
 fromEnum td `div` fromEnum (secondsToDiffTime 1)
 which says that you are computing a whole number of seconds.

 --
 Jón Fairbairn [EMAIL PROTECTED]
 http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2008-04-26)

 ___
 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] TimeDiff to Int?

2008-11-12 Thread Lyle Kopnicky
Hi folks,

I had some code using the oldtime package, and want to convert it to use the
time package.

One of the things I need to do is calculate the number of seconds since
midnight. The easy part is getting a TimeDiff result:

utc - getCurrentTime
tz - getCurrentTimeZone
let td = timeOfDayToTime $ localTimeOfDay $ utcToLocalTime tz utc

Now td is a TimeDiff representation of the number of seconds since midnight.
It prints nicely, but I'm having a heck of a time figuring out how to
truncate it to an Int.

The floor function is only supported by the RealFrac class. Although
TimeDiff has an instance of RealFrac and Fractional, it doesn't have an
instance of RealFrac. I looked up the various to* and from* functions and
have come up short. fromEnum yields an Int but it's the wrong value. I know
I could use show and then use readS to get an Integer, or use formatTime
(and reparse that), but that's a hack.

I can convert it to a TimeOfDay which gives me hours, minutes, and seconds,
but then I have to do arithmetic on it, and the seconds are of type Pico,
which I can't call floor on either. I can convert it to a Rational via
timeOfDayToDayFraction, but a TimeDiff is already a Rational those don't
have floor.

What am I missing? There has got to be an easy way to count seconds!

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


Re: [Haskell-cafe] TimeDiff to Int?

2008-11-12 Thread Lyle Kopnicky
Thanks Philip and Roger,

I think I'll use...

  floor $ toRational td

...although I could have sworn that didn't work last night. I don't see that
TimeDiff has an instance of RealFrac, where floor is defined, though it does
have a instances of Real and Fractional.

Yes, the numeric classes are a bit hard to follow. Especially confusing is
the conversions. I'm thinking of making a multiparameter Coercible class,
with a coerce function, to help address that.

- Lyle

On Wed, Nov 12, 2008 at 9:43 AM, Philip Weaver [EMAIL PROTECTED]wrote:



 2008/11/12 Lyle Kopnicky [EMAIL PROTECTED]

 Hi folks,

 I had some code using the oldtime package, and want to convert it to use
 the time package.

 One of the things I need to do is calculate the number of seconds since
 midnight. The easy part is getting a TimeDiff result:

 utc - getCurrentTime
 tz - getCurrentTimeZone
 let td = timeOfDayToTime $ localTimeOfDay $ utcToLocalTime tz utc

 Now td is a TimeDiff representation of the number of seconds since
 midnight. It prints nicely, but I'm having a heck of a time figuring out how
 to truncate it to an Int.

 The floor function is only supported by the RealFrac class. Although
 TimeDiff has an instance of RealFrac and Fractional, it doesn't have an
 instance of RealFrac. I looked up the various to* and from* functions and
 have come up short. fromEnum yields an Int but it's the wrong value. I know
 I could use show and then use readS to get an Integer, or use formatTime
 (and reparse that), but that's a hack.

 I can convert it to a TimeOfDay which gives me hours, minutes, and
 seconds, but then I have to do arithmetic on it, and the seconds are of type
 Pico, which I can't call floor on either. I can convert it to a Rational via
 timeOfDayToDayFraction, but a TimeDiff is already a Rational those don't
 have floor.

 What am I missing? There has got to be an easy way to count seconds!


 Well, you could always (read . takeWhile (not . (=='.')) . show), but
 here's a better way:

let x = toRational td
in numerator x `div` denominator x

 This was just the first thing I could come up with.  I bet there's a nicer
 way.

 - Phil


 Thanks,
 Lyle


 ___
 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] getLine and ^C on Windows

2008-11-12 Thread Lyle Kopnicky
Hi folks,
I'm using System.IO.getLine to read input in my program. I've compiled it on
Windows Vista with ghc-6.10.1. I've noticed that if I press Ctrl+C while the
program is waiting for input, it will get stuck. No keypresses can get me
out of the program - I have to kill the shell. I've tried cmd.exe,
Powershell and cygwin - same behavior.

I'm sure editline would work better, but it's overkill. I just want to read
lines of text and don't need fancy edit behavior. And I think editline
complicates the build process. I also want my program to work right in
non-interactive mode, reading redirected input.

Am I missing something?

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


Re: [Haskell-cafe] vector vs uvector

2008-07-14 Thread Lyle Kopnicky

stefan kersten wrote:

hi,

what's the difference between the vector [1] and uvector [2] packages? 
should one of those preferred over the other?


thanks,
sk

[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vector-0.1
[2] 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uvector-0.1.0.1 

You should use the most mature and stable package, which is of course, 
uvector, being a whole 0.0.0.1 versions past vector.


;)

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


Re: [Haskell-cafe] uvector and the stream interface

2008-07-14 Thread Lyle Kopnicky

Don Stewart wrote:


Yes, we have long been discussing a generic Stream library to which
the various sequence structures can be translated to and from. Already
it is useful to say, stream bytestrings into uvectors and out to lists.
  

Isn't there already such a thing?

   http://www.haskell.org/haskellwiki/Library/Streams

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


[Haskell-cafe] Poor Parsec error message

2008-07-10 Thread Lyle Kopnicky

Hi folks,

I'm using Parsec to parse a stream of tokens. The token primitive takes, 
among other arguments, a function to print tokens. However, this 
function is not always applied. Try the code below:


-
import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Pos(newPos)

mytoken :: (Eq t, Show t) = t - GenParser (SourcePos,t) () t
mytoken x = token showTok posFromTok testTok where
  showTok (pos,t) =  ++ show t ++ 
  posFromTok (pos,t) = pos
  testTok (pos,t) = if (x == t) then Just t else Nothing

main = do
  putStrLn 
  case parse the123Parser  [(newPos  1 n, n) | n - [1,2,3,4]] of
  (Left err) - putStrLn (show err)
  (Right _) - putStrLn parsed correctly
  putStrLn 
  case parse the123Parser  [(newPos  1 n, n) | n - [1,3,4]] of
  (Left err) - putStrLn (show err)
  (Right _) - putStrLn parsed correctly

the123Parser = do
  mytoken 1
  mytoken 2
  mytoken 3
  eof
  return 123
---

The output I get looks like this:

(line 1, column 4):
unexpected [((line 1, column 4),4)]
expecting end of input

(line 1, column 3):
unexpected 3

In the second parse case, it correctly uses my showTok function to show 
the token. But in the first case, it just uses the regular show method. 
I guess that's because the eof parser doesn't know anything about how to 
show the token it sees. Any ideas on how I can get the error message in 
the first case to look more like the second case?


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


Re: [Haskell-cafe] Poor Parsec error message

2008-07-10 Thread Lyle Kopnicky
I figured it out, but it's not pretty. The problem is that the eof 
parser had no awareness of the showTok function. To fix the problem, I 
had to replace eof with its definition in terms of notFollowedBy, then 
replace notFollowedBy with its definition in terms of try and 
unexpected. Then, I changed the show [c] into showToken c.


Passing a token shower to the token function isn't a very robust way of 
guaranteeing your tokens display properly in error messages, because the 
other combinators don't take the same option. Of course, you can 
implement a Show instance for your tokens as you like. But, if you make 
the Show instance show the pretty version for the user, you lose the 
ability to see the real structure you get from a derived Show instance. 
In my real code, I want debugging to show tokens using a derived Show 
instance, so I can see all the structure. But when I show them to the 
user, I don't want them to see the embedded SourcePos, or the 
constructor names - I just want them to see a representation of what was 
lexed in order to produce that token.


I think there should be a class called Token, with a method called 
showToken, or unlex, or display, or displayInError, something like that. 
This class should be a precondition of all the GenParser combinators. It 
should use the provided method to show the token in error messages.


Here's the working version:

import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Pos(newPos)

showToken (pos,t) =  ++ show t ++ 

myToken :: (Eq t, Show t) = (t - Bool) - GenParser (SourcePos,t) () 
(SourcePos,t)

myToken q = token showToken posFromTok testTok where
   posFromTok (pos,t) = pos
   testTok (pos,t) = if (q t) then Just (pos,t) else Nothing

main = do
   putStrLn 
   case parse the123Parser  [(newPos  1 n, n) | n - [1,2,3,4]] of
   (Left err) - putStrLn (show err)
   (Right _) - putStrLn parsed correctly
   putStrLn 
   case parse the123Parser  [(newPos  1 n, n) | n - [1,3,4]] of
   (Left err) - putStrLn (show err)
   (Right _) - putStrLn parsed correctly

the123Parser = do
   myToken (==1)
   myToken (==2)
   myToken (==3)
   try (do{ c - myToken (const True); unexpected (showToken c) } | 
return ())

   notFollowedBy (myToken (==4))
   return 123

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


Re: [Haskell-cafe] Aim Of Haskell

2006-12-11 Thread Lyle Kopnicky

Taral wrote:

On 12/11/06, Nia Rium [EMAIL PROTECTED] wrote:

In my humble opinion, in this context, GUI doesn't mean a library to
implement a GUI application. It rather means an interpreter/compiler 
that

provides graphical interface.


Windows users can use Visual Haskell...


It's still in an early development phase.

- Lyle

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


[Haskell-cafe] Why so slow?

2006-12-10 Thread Lyle Kopnicky
The code below is using way more RAM than it should. It seems to only 
take so long when I build the 'programs' list - the actual 
reading/parsing is fast. For a 5MB input file, it's using 50MB of RAM! 
Any idea how to combat this?


Thanks,
Lyle

{-# OPTIONS_GHC -fglasgow-exts #-}

-- linear_importer.hs

import Control.Monad (unless)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BS
import Text.Regex as RE
import Data.Time.Calendar
import Data.Time.LocalTime
import System.Environment

-- Consider adding strictness as necessary for performance.

-- STB time  channel
data ChannelChange = ChannelChange Int LocalTime Int
   deriving Show

-- channel program_no start 
end   network_no
data ScheduleProgram = ScheduleProgram Int IntLocalTime 
LocalTime (Maybe Int)

   deriving Show

main = do
   fileNames - getArgs
   ensure (length fileNames == 2) usageMessage
   let [eventFileName,programFileName] = fileNames
   putStrLn (Reading program schedule file from ' ++ programFileName 
++ '...)

   text - BS.readFile programFileName
   programs - sequence $ map parseScheduleProgram (BS.lines text)
   print (take 20 programs)
   return ()

usageMessage = Usage: linear_importer channel change file schedule 
file


parseScheduleProgram :: ByteString - IO ScheduleProgram
parseScheduleProgram s = do
   let fields = BS.split '|' s
   ensure (length fields == 7) (Wrong number of fields in schedule 
program:  ++ BS.unpack s)
   let 
[_,channelNoText,programNoText,_,startTimeText,endTimeText,networkNoText] 
= fields

   let channelNo = read $ BS.unpack channelNoText
   programNo = read $ BS.unpack programNoText
   startTime - parseProgramTime startTimeText
   endTime - parseProgramTime endTimeText
   let networkNo = if BS.null networkNoText then Nothing else Just 
(read (BS.unpack networkNoText))

   return $ ScheduleProgram channelNo programNo startTime endTime networkNo

parseProgramTime :: ByteString - IO LocalTime
parseProgramTime s = do
   let parts = BS.split 'T' s
   ensure (length parts == 2)
   (Expected exactly one T in eventChannelChange time:  ++ 
BS.unpack s)

   let [datePart,timePart] = parts
   ensure (BS.length datePart == 8)
   (Expected 8 digits in date part of eventChannelChange time:  
++ BS.unpack s)

   let (yearPart, monthDayPart) = BS.splitAt 4 datePart
   (monthPart, dayPart) = BS.splitAt 2 monthDayPart
   year = read $ BS.unpack yearPart
   month = read $ BS.unpack monthPart
   day = read $ BS.unpack dayPart
   let date = fromGregorian year month day
   ensure (BS.length timePart == 6)
   (Expected 6 digits in time part of eventChannelChange time:  
++ BS.unpack s)

   let (hoursPart,minutesSecondsPart) = BS.splitAt 2 timePart
   (minutesPart,secondsPart) = BS.splitAt 2 minutesSecondsPart
   hours = read $ BS.unpack hoursPart
   minutes = read $ BS.unpack minutesPart
   seconds = read $ BS.unpack secondsPart
   let time = TimeOfDay hours minutes (fromInteger seconds)
   return (LocalTime date time)

ensure :: Bool - String - IO ()
ensure x s = unless x $ ioError (userError s)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell] Re: Streams 0.1 ported to GHC 6.6

2006-10-17 Thread Lyle Kopnicky

Bulat Ziganshin wrote:

Hello Lyle and all,

i'm glad to inform you that Stream 0.1 library is now compatible
with just released GHC 6.6. please download new version as
http://www.haskell.org/library/Streams.tar.gz

this archive contains file Streams.cabal.6.6 that is cabal file
developed specially for new GHC. if you use ghc 6.6, just rename it to
Streams.cabal and then build library as usual
Following the instructions above, I'm still getting the following error 
when building Streams:
[16 of 21] Compiling Data.AltBinary.Class ( Data/AltBinary/Class.hs, 
dist/build/Data/AltBinary/Class.o )


Data/AltBinary/Class.hs:526:0: Parse error in pattern
make: *** [build] Error 1
l

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


[Haskell-cafe] Multiple stages in Template Haskell

2006-10-10 Thread Lyle Kopnicky

Hi folks,

I noticed that in Template Haskell, you can only have one level of 
splicing or quasi-quoting. E.g., you can't write:


   $(zipN ($(sel 2 3) (zip level,3,( ['a'..'Z'] [1..] (words now 
is the time)


Because you can't have a splice inside a splice. But wouldn't it be 
handy to use all these macros when defining other macros?


This would be like stages in MetaML, which have no such limitation. But 
all the stages but the last one would be evaluated at compile time. The 
compiler would look for the deepest level of nested splices and evaluate 
it first.


On the other hand, I can understand why you wouldn't include splices and 
quasi-quotes in the Language.Haskell.TH.Syntax - programmers could write 
functions that dynamically created arbitrarily (even infinitely) nested 
splices - so it would be undecidable where to start.


I'm wondering if there's some reason this restriction is imposed. Is it 
particularly difficult to implement, or are there more theoretical 
problems? Does that mean I'm volunteering? ;)


- Lyle

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


Re: [Haskell-cafe] Error building Edison 1.2.0.1

2006-10-06 Thread Lyle Kopnicky




Robert Dockins wrote:

  On Thursday 05 October 2006 16:51, Lyle Kopnicky wrote:
  
  
Robert Dockins wrote:

  
  
mtl is the Monad Transformer Library.  It's a part of the standard libraries 
in 6.4.x.  There's been a good deal of chatter recently about reducing the 
set of libraries the GHC ships with; it may be that mtl is on that list.  I 
haven't really been following, so I'm not sure.

  
  
Maybe there's something broken in this GHC 
snapshot. I've already noticed Template Haskell seems to be broken in it.

  
  
Possible.  I also notice that QuickCheck isn't in your list of installed 
packages.  You'll need that to compile edison-core.

  

OK, now I've uninstalled GHC 6.5.x, and installed 6.4.2, and now I can
compile Edison without any problem. I think that 6.5.x snapshot was
missing some libraries. Three cheers for stable releases.

- Lyle


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


Re: [Haskell-cafe] Error building Edison 1.2.0.1

2006-10-05 Thread Lyle Kopnicky




Robert Dockins wrote:

  On Wednesday 04 October 2006 16:16, Lyle Kopnicky wrote:
  
  
Robert Dockins wrote:


  Whats the output of

ghc-pkg -l

?
  

[EMAIL PROTECTED]:~$ ghc-pkg -l
/usr/local/lib/ghc-6.5.20060924/package.conf:
Cabal-1.1.4, base-2.0, (ghc-6.5.20060924), haskell98-1.0,
parsec-2.0, readline-1.0, regex-base-0.71, regex-compat-0.71,
regex-posix-0.71, rts-1.0, stm-2.0, template-haskell-2.0, unix-1.0
l

  
  
Hummm.  Well, I confess that I'm confused.  Cabal 1.1.4 should work, because 
that's what I have on my machines; I've just tested it here.  The only thing 
I can think of is that the 'runhaskell' command is still bound to your old 
GHC, or to something else (Hugs maybe?).  If that's the case, you can edit 
the makefile and set the 'RUNHS' variable in the first line to the full path 
to your 6.5 runghc.  Or you can edit the .cabal files as suggested above.


  

I don't have hugs installed, and I've uninstalled ghc 6.4.1, so it can
only be running 6.5.

I've pasted the error in again here for reference:
[EMAIL PROTECTED]:~/devel/edison-1.2.0.1-source$
sudo make system
Password:
cd edison-api  \
  runhaskell Setup.hs configure  \
  runhaskell Setup.hs build  \
  runhaskell Setup.hs install
Configuring EdisonAPI-1.2...
configure: Dependency base=1.0: using base-2.0
configure: Dependency haskell98=1.0: using haskell98-1.0
Setup.hs: cannot satisfy dependency mtl=1.0
make: *** [api-system] Error 1
[EMAIL PROTECTED]:~/devel/edison-1.2.0.1-source$

Do you know what mtl is? Maybe there's something broken in this GHC
snapshot. I've already noticed Template Haskell seems to be broken in
it.

- Lyle



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


Re: [Haskell-cafe] Error building Edison 1.2.0.1

2006-10-04 Thread Lyle Kopnicky




Robert Dockins wrote:

  On Tuesday 03 October 2006 22:58, Lyle Kopnicky wrote:
  
  
Robert Dockins wrote:


  On Tuesday 03 October 2006 22:00, Lyle Kopnicky wrote:
  
  
Hi folks,

I tried to build edison-1.2.0.1-sources with the command 'make system'
but got:

*** Exception: Line 10: Unknown field 'hs-source-dirs'

I am using GHC 6.4.1. Any idea how to fix this?

  
  You are probably using an older version of Cabal.  You can either upgrade
Cabal or, from the Edison README*:


This version of edison builds correctly with Cabal version 1.1.4,
which is shipped with GHC 6.4.2.  To build on earlier versions,
it should suffice to:

s/UndecidableInstances/AllowUndecidableInstances/
s/Hs-Source-Dirs:/Hs-Source-Dir:/

in the .cabal files.



The 'hs-source-dir' cabal directive was depreciated in 1.1.4, but perhaps
I should have waited a bit longer to change it.  OTOH, there isn't any
good way to deal with the change in the undecidable instances flag, since
it was outright changed.  G. *grumble* incompatible changes in
minor releases *grumble*.


(*) Further, g... in the above, I've fixed several embarrasing typos
in the text of the README.
  

Oh, OK, thanks! Well, now I'm running GHC 6.5.20060924, and getting the
error mentioned in my previous message.

  
  
Whats the output of

ghc-pkg -l

?

  

[EMAIL PROTECTED]:~$ ghc-pkg -l
/usr/local/lib/ghc-6.5.20060924/package.conf:
    Cabal-1.1.4, base-2.0, (ghc-6.5.20060924), haskell98-1.0,
    parsec-2.0, readline-1.0, regex-base-0.71, regex-compat-0.71,
    regex-posix-0.71, rts-1.0, stm-2.0, template-haskell-2.0, unix-1.0
l


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


[Haskell-cafe] Error building Edison 1.2.0.1

2006-10-03 Thread Lyle Kopnicky

Hi folks,

I tried to build edison-1.2.0.1-sources with the command 'make system' 
but got:


*** Exception: Line 10: Unknown field 'hs-source-dirs'

I am using GHC 6.4.1. Any idea how to fix this?

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


Re: [Haskell-cafe] Error building Edison 1.2.0.1

2006-10-03 Thread Lyle Kopnicky




Robert Dockins wrote:

  On Tuesday 03 October 2006 22:00, Lyle Kopnicky wrote:
  
  
Hi folks,

I tried to build edison-1.2.0.1-sources with the command 'make system'
but got:

*** Exception: Line 10: Unknown field 'hs-source-dirs'

I am using GHC 6.4.1. Any idea how to fix this?

  
  
You are probably using an older version of Cabal.  You can either upgrade 
Cabal or, from the Edison README*:


This version of edison builds correctly with Cabal version 1.1.4,
which is shipped with GHC 6.4.2.  To build on earlier versions,
it should suffice to:

s/UndecidableInstances/AllowUndecidableInstances/
s/Hs-Source-Dirs:/Hs-Source-Dir:/

in the .cabal files.



The 'hs-source-dir' cabal directive was depreciated in 1.1.4, but perhaps I 
should have waited a bit longer to change it.  OTOH, there isn't any good way 
to deal with the change in the undecidable instances flag, since it was 
outright changed.  G. *grumble* incompatible changes in minor 
releases *grumble*.


(*) Further, g... in the above, I've fixed several embarrasing typos in 
the text of the README.
  

Oh, OK, thanks! Well, now I'm running GHC 6.5.20060924, and getting the
error mentioned in my previous message.

- Lyle




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


Re: [Haskell-cafe] Optimizing a title matcher

2006-09-27 Thread Lyle Kopnicky

Ketil Malde wrote:

Do you really need that to search for movie titles?  At any rate, an
exact-match finite-map implementation is a good start - to get good
performance, you probably will need to use some kind of index to
reduce the amount of data to search exhaustively (all-against-all).

For text searching I think it is effective to use an index that
maps from words (so that looking up a word gives you all the movies
with that word in the title). 
  
Gotcha. That's exactly the approach I've switched to. It is possible to 
miss titles, if words are misspelled, but it's unlikely that all words 
in the title will be misspelled, so you can at least narrow your search 
to titles that have at least one matching (non-trivial) word.


- Lyle

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


Re: [Haskell-cafe] Re: Getting the latest

2006-09-27 Thread Lyle Kopnicky

Max Vasin wrote:

Lyle I have no idea how it decides where to go. Right now ghc
Lyle 6.4.1 is in /usr/local/bin/ghc. After I 'make install', will it
Lyle be ghc 6.5? I don't want to screw up the installed package so it
Lyle can't be updated later.
It should be :-)
  

It should be screwed up? Or it should be updated later?

Ideally I'd like to keep the Ubuntu package where it is. I'd like to 
install the experimental GHC in a different place. Then I want to change 
my path to point to the experimental one for building.

PS: It is better to build a custom package (dh_make will help you).
  
I don't have a command called dh_make. I do have some other dh_* 
commands. What do I need to run dh_make? Where can I find documentation?


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


Re: [Haskell-cafe] Unable to profile program using Data.ByteString.Lazy

2006-09-26 Thread Lyle Kopnicky




Donald Bruce Stewart wrote:

  
You're cabal version is too old then. Try updating either Cabal or GHC.

-- Don
  


It's the latest version (6.4.1) packaged for Ubuntu. I'll have to
download and install a newer version manually. Unfortunately, the
download site seems to be down again :(

- Lyle



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


[Haskell-cafe] Optimizing a title matcher

2006-09-26 Thread Lyle Kopnicky

Hi folks,

I'm competing in a contest at work, and we're allowed to use whatever 
language we want. I decided this was my chance to prove to people that 
Haskell was up to the challenge. Unfortunately, I ran into performance 
problems. Since the contest ends this Friday, I've decided to switch to 
C++ (gasp!). But if any of you have advice on how to speed up this code, 
it could help me advocate Haskell in the future.


It's supposed to match movie titles from an imported database to a 
reference database. The version I've sent doesn't do anything very smart 
- it's just doing literal title matches. The first argument to the 
program is the filename of the table to be imported, and the second is 
the filename of the reference table. The first line of each table is a 
pipe-separated list of field names; the rest of the lines are records, 
each a pipe-separated list of values.


The import files each have 3,000 records, and the reference table has 
137,986 records.


Building the hash tables out of the files is quick - it just takes a few 
seconds. But doing the matching of title_id in one table to title_id in 
the other, in a nested loop between both tables, takes way too long. 
It's matching two import titles (against each of the reference titles) 
per second. It needs to do at least 20 per second to qualify for the 
contest, and it's not doing anything fancy yet.


I tried various improvements to speed it up. One was to specifically 
use ByteString, eliminating the AbsString class. Didn't make a 
difference. Another was to use arrays instead of lists to store each 
record, and precompute the indices of each of the fields within those 
records. I also iterated over a list of keys instead of the list of 
Maps, and only converted each record to a Map one at a time, hoping they 
would be disposed of sooner. Instead of speeding up the program, this 
slowed it down by a factor of 20!


I've profiled it, and I can't make much out of that. It seemed to be 
spending 25% of its time doing scoring, and I though the problem must be 
due to laziness, but I'm not sure.


So if anyone has any ideas how to speed this up by a factor of at least 
10 times, it would be really appreciated! Even the Ruby solutions are 
doing that, which is embarrassing.


Thanks,
Lyle
{-# OPTIONS_GHC -fglasgow-exts #-}

-- AbsString.hs
-- An abstract string class, which makes it easier to switch string representations.

module AbsString where

import Prelude as P
import Data.ByteString.Base (c2w, w2c)
import Data.ByteString.Char8 as BSC
import Data.ByteString.Lazy.Char8 as BSLC
import Text.Regex as RE
import Test.HUnit

class (Eq s, Ord s) = AbsString s where
s :: String - s
toString :: s - String
sLength :: s - Int
sAppend :: s - s - s
sConcat :: [s] - s
putStr :: s - IO ()
putStrLn :: s - IO ()
readFile :: String - IO s
lines :: s - [s]
split :: Char - s - [s]

(+++) :: AbsString s = s - s - s
(+++) = sAppend

instance AbsString String where
s = id
toString = id
sLength = P.length
sAppend = (++)
sConcat = P.concat
putStr = P.putStr
putStrLn = P.putStrLn
readFile fn = P.readFile fn
lines = P.lines
split c = RE.splitRegex (mkRegex (escapeRegexChar c))

regexMetaChars = \\|()[]^.*+?{}

escapeRegexChar :: Char - String
escapeRegexChar c = if c `P.elem` regexMetaChars then \\++[c] else [c]

instance AbsString BSC.ByteString where
s = BSC.pack
toString = BSC.unpack
sLength = fromIntegral . BSC.length
sAppend = BSC.append
sConcat = BSC.concat
putStr = BSC.putStr
putStrLn = BSC.putStrLn
readFile = BSC.readFile
lines = BSC.lines
split = BSC.split

instance AbsString BSLC.ByteString where
s = BSLC.pack
toString = BSLC.unpack
sLength = fromIntegral . BSLC.length
sAppend = BSLC.append
sConcat = BSLC.concat
putStr = BSLC.putStr
putStrLn = BSLC.putStrLn
readFile = BSLC.readFile
lines = BSLC.lines
split c s = BSLC.split c s

test_showString = TestCase $ do
  let aStr = s Hello there :: String
  assertEqual  Hello there (toString aStr)

test_showByteString = TestCase $ do
  let aStr = s Hello there :: BSC.ByteString
  assertEqual  Hello there (toString aStr)

test_showByteStringLazy = TestCase $ do
  let aStr = s Hello there :: BSLC.ByteString
  assertEqual  Hello there (toString aStr)

runTests = runTestTT $
   TestList [TestLabel test_showString test_showString,
 TestLabel test_showByteString test_showByteString,
 TestLabel test_showByteStringLazy test_showByteStringLazy]
{-# OPTIONS_GHC -fglasgow-exts #-}

-- TextTable.hs
-- Defines a TextTable type, which defines a map of strings to a record
-- of text fields.

module TextTable(TextTable(..),TextRecord,makeTable,lookupRecord,listKeys,listRecords) where

import Prelude hiding (putStr,putStrLn,readFile,lines)
import qualified Data.ByteString.Lazy as BSL (ByteString)
import Data.Array.Unboxed
import 

[Haskell-cafe] Getting the latest

2006-09-26 Thread Lyle Kopnicky

Hi folks,

I am running GHC 6.4.1 on my Linux box at work, which is the latest 
packaged version for Ubuntu Dapper Drake. (They have a 6.4.2 package for 
Edgy, but I don't know how to install that. The Synaptic Package Manager 
seems to only want to install packages specifically labeled for Dapper 
Drake.)


I tried downloading the latest binary snapshot. But when I try to unpack 
the archive, bzip2 tells me it's a bad archive. So, I downloaded the 
latest source version. That unpacked just fine, and I'm currently 
building it.


My question is, when I do 'make install', will it just overwrite the 
version (6.4.1) I already have? Or will they go in separate places? I 
have no idea how it decides where to go. Right now ghc 6.4.1 is in 
/usr/local/bin/ghc. After I 'make install', will it be ghc 6.5? I don't 
want to screw up the installed package so it can't be updated later.


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


Re: [Haskell-cafe] Optimizing a title matcher

2006-09-26 Thread Lyle Kopnicky

Lemmih wrote:


Do you have some test input online?
I've attached some (very short) input files. Sorry I can't provide more 
- they're proprietary databases. I know that means you can't actually 
test the performance, but can only give me advice. At least you can run 
the program on them, and there is one match.


- Lyle

title_id|ref_title_id|importance|title|studio|run_time|rating|theatrical_release|home_video_release|box_office_gross|synopsis|actors|director
26246|157067|2|Sniper|TRI||R|29-JAN-93|04-AUG-93|18994653|A rebel leader and a 
wealthy drug lord are pursued in Panama by a marine sergeant and Oympic 
marksman.|Dale Dye;Aden Young;Tom Berenger;J.T. Walsh;Richard Lineback;Billy 
Zane|Luis Llosa
68308|174883|2|Northern Passage||97|||27-FEB-96|0|In the wilds of North America 
in the 1800s, Paul a young zoologist has pledged to keep as eye on his longtime 
friend's beautiful daughter, Nepeese.  Nepeese and Paul fall in love, but their 
relationship is interrupted when an abusive fur trader kidnaps Nepeese.  
Starring Jeff Fahey.|Jeff Fahey;Neve Campbell|
68591|196655|2|Old Man And The Sea (1990)||97|||01-JUL-96||An old man heads out 
to sea, hooks a large fish, and battles a shark who has taken his 
catch.|Anthony Quinn;Alexis Cruz|
51506|190181|2|Shoot Out||95|||27-APR-99|||Gregory Peck;Robert F. Lyons|
title_id|importance|title|studio|runtime|rating|theatrical_release|home_video_release|theatrical_box_office_gross|actors|director
214063|2|Elvis: His Best Friend Remembers|UNI||NR||30-JUL-02||Elvis Presley|
133868|2|Mighty Hercules, The - Speed Racer - V. 5||30|NR|
174883|2|Northern Passage|VMM|97|PG-13||18-JAN-00||Jeff Fahey;Neve 
Campbell;Jacques Weber;Lorne Brass;Genevieve Rochette|Arnaud Selignac
121430|2|Appointment With Death|WAR|||15-APR-88||960040|Peter Ustinov;Lauren 
Bacall;Carrie Fisher;Piper Laurie;John Gielgud;Hayley Mills;Jenny 
Seagrove;David Soul|Michael Winner
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Optimizing a title matcher

2006-09-26 Thread Lyle Kopnicky

Robert Dockins wrote:

Humm... well, double nested loops seems like the wrong approach.

It may be. I had hoped it would be fast enough that way.
  Also, if you 
are using GHC, it's hashtable implementation has farily well-known 
performance problems. If all you care about is exact matching, then the 
operation is essentially a finite map intersection (if I've understood what 
you are trying to do).
  
No, I don't just care about exact matching. I care about very fuzzy 
matching. It's just that the code I've implemented so far only does 
exact matching on the title strings. It's a first step.
This is just a guess, but I suspect you will probably get much better 
performance (and better-looking code!) by just using Data.Map.intersection
 
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Map.html#v%3Aintersection
  

Thanks, but that won't help with the fuzzy matching.
Alternately, there is the ternary trie implementation from Edison 
(http://www.eecs.tufts.edu/~rdocki01) that may also work for you.
  

That may be useful.
If you need to do prefix matching, then a trie is the way to go.  You can 
probably code up a nice prefix-intersection operation using tries that should 
go pretty fast.


If you have some other metric other than prefix in mind for partial matches, 
then things probably get a lot more complicated.  You're probably looking at 
calculating minimum distances in some feature-space, which calls for pretty 
sophisticated algorithms if you need good performance.
  
Yes, that's the kind of thing I'm looking at doing. Looking at edit 
distance.


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


Re: [Haskell-cafe] Optimizing a title matcher

2006-09-26 Thread Lyle Kopnicky




Bertram Felgenhauer wrote:

  Lyle Kopnicky wrote:
  
  [snip]
  
  
listRecords :: AbsString s = TextTable s - IO [TextRecord s]
listRecords (TextTable fields _ records) = do
  keyRecs - HT.toList records
  return $ map (fromList . zip fields . elems . snd) keyRecs

  
  
Doing fromList again and again can't be good. Why don't you make
tableFields a map that maps names to array indices? Then you can just
pass the bare arrays along, and the later lookups will be cheaper, too.
  

That might make a difference. It does spoil the interface a bit, since
now the caller has to look up a field name to get an index, then use
that to look up a value, instead of just using the field name to get
the value.

  Now due to lazyness this will probably be evaluated in matchscore,
because before that the resulting Map isn't used. Which is exactly where
you said a lot (most?) of the time is spent.
  

Yes, likely. I had to run on a small pair of files in order to get the
profiling to work. So, probably more time was spent in matchScore than
it admitted. (The overhead of the initial read would decrease as the
table size increases.)

  Another thing is that you should compile your code with -O, but I guess
you are already doing that.

  

Yep. Thanks.

- Lyle


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


Re: [Haskell-cafe] Optimizing a title matcher

2006-09-26 Thread Lyle Kopnicky

Hi folks,

It turns out Haskell is vindicated. It's my algorithm that was slow. As 
Robert Dockins pointed out, the double nested loop is just going to take 
a long time.


As evidence, it turns out my C++ version is just as slow as the Haskell 
version.


So, I'm going to go back to Haskell, but be more selective about which 
titles from the reference table I choose to match against, for any given 
import title.


Thanks,
Lyle

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


Re: [Haskell-cafe] Unable to profile program using Data.ByteString.Lazy

2006-09-24 Thread Lyle Kopnicky

Donald Bruce Stewart wrote:

Probably you didn't build fps with profiling as well? You can rebuild
fps with:
runhaskell Setup.hs configure -p 
as the first step.


-- Don
  


Thanks, I'll try it. Does that mean when I want to optimize my program, 
I'll need to rebuild fps without profiling?


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


[Haskell-cafe] Unable to profile program using Data.ByteString.Lazy

2006-09-23 Thread Lyle Kopnicky

Hi folks,

I wrote a program that uses some of the Data.ByteString libraries. I'm 
using GHC 6.4.1 and FPS 0.7.


The program compiles and works just fine. But when I try to profile it, 
by compiling with -prof, I get:


   Failed to load interface for `Data.ByteString.Lazy':
   Could not find module `Data.ByteString.Lazy':
 locations searched:
   Data/ByteString/Lazy.hi
   Data/ByteString/Lazy.hi-boot
   /f/g/lib/fps-0.7/Data/ByteString/Lazy.p_hi

Why can it find the module when it's compiling without -prof, but not 
when it's compiling with it? I would really like to get profiling to work.


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


[Haskell-cafe] System threads?

2006-09-19 Thread Lyle Kopnicky

Hi folks,

I'm working on a project for which the solution is highly 
parallelizable. I've been writing it so far for GHC as a single-threaded 
app. I'd like to be able to split the job into multiple pieces, and 
spawn different system threads for each piece, so they will run on 
separate CPUs. Either each thread needs to write to the same IO handle, 
or else the results need to be collected when the threads are merged, so 
the results can all be printed.


I'm working on Linux. What's the easiest way to accomplish this? Glasgow 
Parallel Haskell? Is there a Posix.Threads library? I understand that 
Haskell threads (Control.Concurrent) all run in one system thread, so 
would not take advantage of SMP.


I suppose in the worst case I can write a shell program that divides up 
the problem, runs several worker processes to output intermediate 
results to files, then combines the results to the desired filehandle.


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


[Haskell-cafe] SMTP, HTTP, Telnet

2006-06-16 Thread Lyle Kopnicky




Hi all,

Anybody know of some good Haskell libraries providing:

  an SMTP client,
  an HTTP client,
  or a Telnet client?

There's a significant amount to these protocols, over and above the
socket layer.

Thanks,
Lyle Kopnicky



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


[Haskell-cafe] Bug in WinHugs?

2006-06-13 Thread Lyle Kopnicky

Hi folks,

I just installed the May 2006 release of Hugs. When I use the 
command-line version, the '$$' symbol to reference the last expression 
works fine. It does not work in WinHugs, but yields 'ERROR - Syntax 
error in expression (unexpected symbol $$)'. I typed ':set' to verify 
the '-r$$' option was set properly.


Is this a known bug, or am I doing something wrong?

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


Re: [Haskell] Mixing monadic and non-monadic functions

2005-09-15 Thread Lyle Kopnicky

Bulat Ziganshin wrote:


Hello Ben,

Wednesday, September 14, 2005, 6:32:27 PM, you wrote:

BRG  do { ... ; ... borrow E ... ; ... }

BRG is transformed into

BRG  do { ... ; x - E ; ... x ... ; ... }

i strongly support this suggestion. actually, i suggest the same for
dealing with references (IORef/MVar/...), for example:

do x - newIORef 0
  y - newIORef 0
  z - newIORef 0
  z := *x + *y   -- translated to { x' - readIORef x; y' - readIORef y; 
writeIORef z (x'+y') }

 

Right, I realize my suggestion is the same as Ben's.  I just prefer a 
more succinct notation, like special brackets instead of a keyword.  I 
like your idea about IORefs.  I think it should work as well for 
STRefs... perhaps it needs to belong to a type class, in a way?


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


[Haskell] Re: Mixing monadic and non-monadic functions

2005-09-14 Thread Lyle Kopnicky

It appears to me that:

* Many people don't like having to extract values from a monad on a 
separate line, but would like to be able to mix monadic return values 
into pure expressions, on the way to calculating a monadic result.


* Some people want to fix this by doing an implicit lifting operation on 
functions, when their parameters are monadic


* It is not really clear what values are monadic and which aren't, so 
the implicit lifting is a guessing game, and likely to produce 
confounding errors.


* If you aren't going to be precise about what's in the monad and what's 
not, you might as well use ML.


I propose instead an explicit, lightweight notation, with a simple 
rewrite rule.  Instead of:


do
   putStr What is your name? 
   s - getLine
   putStrLn (Hello  ++ s)

I would like to write something like:

do
   putStr What is your name? 
   putStrLn (Hello  ++ {* getLine *})

In other words, we use some kind of special brackets (I don't care what) 
to indicate that this value needs to be extracted from the monad on a 
previous line, and inserted back here as a pure value.  If these occur 
multiply nested, they can be flattened out according to a dependency 
rule.  E.g.,


do
   m1 {* m2 {* m3 *} v4 *} {* m5 *}

...would be rewritten as...

do
   v3 - m3
   v2 - m2 v3 v4
   v5 - m5
   m1 v2 v5

...and...

do
   m1 {* {* m2 *} *}

...would become...

do
   m2a - m2
   v2 - m2a
   m1 v2

I'm sure this has been suggested before... but what do folks think?

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


[Haskell-cafe] Re: [Haskell] Haskell recruitment?

2004-09-06 Thread Lyle Kopnicky
I think there are so few such opportunities that it would not overwhelm 
the list.  I should also point out that you can post such openings at 
http://www.haskell.org/jobs.html by sending an e-mail to 
[EMAIL PROTECTED] and [EMAIL PROTECTED]

Regards,
Lyle
Jochen L. Leidner wrote:
Finally, would it be considered spam to post Haskell-realted job postings 
in this group? Thanks in advance.

Regards,
Jochen
 

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


Re: [Haskell-cafe] Partially-applied type synonyms?

2004-09-02 Thread Lyle Kopnicky
Chung-chieh,
Well, I tried what you suggested, and it seems to work.  Unfortunately, 
it's not very useful.  The point of creating MonadPCont, was, like 
MonadCont or MonadState, to automatically provide features to a monad 
built from a transformer, without having to redefine them.  Since ContT 
is the monad transformer, I want any monad created from it to 
automatically support the MonadPCont operations.  But they can't, 
because I can't make ContT an instance of MonadPCont.

I can make FlipContT an instance of MonadPCont, but I can't make 
FlipContT a monad transformer.  So what you have to do is create your 
layered monadwith ContT on top, and then apply the FlipCont constructor 
to get a monad with the methods of MonadPCont.  Now since FlipContT 
isn't a monad transformer, you can't lift things into it.  You can lift 
them into ContT and then write a wrapper around that.

My point is that, unfortunately,  I don't think it's very practical to 
create this type class.  I think the problem is that, although MonadCont 
attempts to describe a monad as having certain operations, MonadPCont 
attempts to describe a group of related monads as having certain 
operations.  They are related by being formed from the same type 
constructor.

Here's the modified code:
module MonadPCont where
import Control.Monad
import Control.Monad.Cont
import Control.Monad.Trans
import Control.Monad.Reader
import Control.Monad.Writer
import Control.Monad.State
import Control.Monad.RWS 

class (Monad (mc a), Monad (mc r)) = MonadPCont mc a r where
   shift :: ((forall b. Monad (mc b) = a - mc b r) - mc r r) - mc r a
   reset :: mc a a - mc r a
instance MonadPCont Cont a r where
   shift f = Cont (\c - runCont (f (\x - Cont (\c' - c' (c x id)
   reset m = Cont (\c - c (runCont m id))
data FlipContT m r a = FlipContT { unFlipContT :: (ContT r m a)}
instance Monad m = Monad (FlipContT m r) where
   return x = FlipContT $ return x
   (FlipContT m') = f = FlipContT $ m' = (unFlipContT . f)
runFlipContT :: FlipContT m r a - (a - m r) - m r
runFlipContT (FlipContT m) = runContT m
 
instance Monad m = MonadPCont (FlipContT m) a r where
   shift f = FlipContT $ ContT $ \c -
   runFlipContT (f (\x - FlipContT $ ContT $ \c' - c x 
= c'))
return
   reset m = FlipContT $ ContT $ \c - runFlipContT m return = c

- Lyle
Chung-chieh Shan wrote:
On 2004-08-31T09:55:10-0700, Lyle Kopnicky wrote:
 

Sorry, I don't think I made myself clear.  I'm not defining PI, it's the 
standard type binding operator, like lambda is the variable binding 
operator.  Maybe I could write it as 'II' so it looks more like a 
capital pi.  It's not a feature of Haskell, but part of type theory 
(dependent types).  I was mixing and matching and making it look like 
Haskell.  So instead of 'PI r - ContT r m', I could write 'flip ContT', 
except that 'flip' needs to work on a type level instead of a value 
level.  Or I could write '(`ContT` m)', or 'ContT _ m', where the '_' is 
a hole.  Does this make sense now?
   

Yes, it makes sense now.  You need to define
   newtype FlipContT m r a = FlipContT (ContT r m a)
or more generally,
   newtype Flip c (m :: * - *) r a = Flip (c r m a)
The rationale for disallowing matching partially-applied type synonyms
is that higher-order unification is undecidable.
See also:
Neubauer, Matthias, and Peter Thiemann. 2002.  Type classes with
more higher-order polymorphism.  In ICFP '02: Proceedings of the ACM
international conference on functional programming. New York: ACM Press.
http://www.informatik.uni-freiburg.de/~neubauer/papers/icfp02.pdf
http://www.informatik.uni-freiburg.de/~neubauer/papers/icfp02.ps.gz
 

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


[Haskell-cafe] Partially-applied type synonyms?

2004-08-30 Thread Lyle Kopnicky
Hi all,
I'm trying to write a monad transformer class called MonadPCont, for 
partial continuations, which fits in with the Control.Monad libraries.  
I'm having a typing problem.  What I have so far looks like this:


module MonadPCont where
import Control.Monad
import Control.Monad.Cont
import Control.Monad.Trans
import Control.Monad.Reader
import Control.Monad.Writer
import Control.Monad.State
import Control.Monad.RWS
class (Monad (mc a), Monad (mc r)) = MonadPCont mc a r where
   shift :: ((forall b. Monad (mc b) = a - mc b r) - mc r r) - mc r a
   reset :: mc a a - mc r a
instance MonadPCont Cont a r where
   shift f = Cont (\c - runCont (f (\x - Cont (\c' - c' (c x id)
   reset m = Cont (\c - c (runCont m id))
type ContT' m r a = ContT r m a
instance Monad m = MonadPCont (ContT' m) a r where
   shift f = ContT (\c -
runContT (f (\x - ContT (\c' - c x = c'))) return)
   reset m = ContT (\c - runContT m return = c)

The error I get is:
MonadPCont.hs:21:
   Type synonym `ContT'' should have 3 arguments, but has been given 1
   In the instance declaration for `MonadPCont (ContT' m) i o'
Failed, modules loaded: none.
I guess it's not possible to partially apply a synonym for a type 
constructor.  Essentially, I'm trying to do a 'flip', but at the type level.

The underlying problem is that ContT is written to take the final result 
type (call it 'r') as the first parameter, and the underlying monad 
(call it 'm') as the second parameter, e.g. 'ContT r m a'.  This is done 
so that 'ContT r' can be made an instance of the MonadTrans class.

Unfortunately, I need 'PI r - ContT r m', along with a and r, to be a 
member of the MonadPCont class (PI is the type binding operator).  So I 
thought I'd define ContT' to take the arguments the other way around.  
Unfortunately, it can't be partially applied.

Any ideas, or is it just not feasible to work this class into the library?
Thanks,
Lyle Kopnicky
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hiding functions

2004-08-13 Thread Lyle Kopnicky
Simon,
That makes good sense, as it's hard to read code that contains standard 
terms used in a nonstandard way.  I was just concerned that the function 
name I wanted to use was already in the Prelude!  Perhaps the Prelude 
'catch', I reasoned, could be called 'catchIO', since it is specific to 
the IO monad, allowing people to write their own 'catch'.  Or 'catch' 
could be a member of a type class, which could be overloaded for any new 
monad.

But then I realized this argument could be made for practically every 
function in the Prelude.  To dilute it with such abstraction would be a 
waste of resources.  And there are loads of synonyms... I could use 
'fling' and 'nab', 'punt' and 'snare', 'toss' and 'capture'

Thanks for the point.
- Lyle
Simon Peyton-Jones wrote:
It's an explicit Haskell 98 design choice
http://haskell.org/onlinereport/modules.html
5.6.2  Shadowing Prelude Names
The rules about the Prelude have been cast so that it is possible to use
Prelude names for nonstandard purposes; however, every module that does
so must have an import declaration that makes this nonstandard usage
explicit.
It's a decision one could debate, but it was an explicit choice.
Simon

| -Original Message-
| From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lyle
| Kopnicky
| Sent: 12 August 2004 20:23
| To: Haskell Cafe
| Subject: [Haskell-cafe] Hiding functions
| 
| Hi all,
| 
| I'm working on a program that uses my own brand of exceptions, and I
| created two functions called 'throw' and 'catch'.  In order for this
to
| work, I hide the Prelude 'catch' in my module, called 'Cont.hs'.
Thus:
| 
| module Cont where
| import Prelude hiding (catch)
| ...
| throw = ...
| catch = ...
| 
| This works hunky-dory until I create another file that imports Cont.
I
| get a conflict when I use 'catch', so I have to  hide the Prelude one
again:
| 
| import Prelude hiding (catch)
| import Cont
| ...
| ... throw ...
| ... catch ...
| 
| So I'm a bit annoyed by this 'propagation' of hiding clauses.  Then I
| created a new file,  that redefined throw:
| 
| module ResumableExceptions where
| import Cont hiding (throw)
| import qualified Cont (throw)
| ...
| throw = ... Cont.throw ...
| 
| Finally, I created a file using ResumableExceptions:
| 
| import Cont hiding (throw)
| import ResumableExceptions
| ...
| ... throw ...
| 
| If I wanted to also use 'catch' I'd have to hide that from the Prelude
| as well.
| 
| I can't use type classes to solve this problem, because the types of
the
| two 'throw' functions are different.
| 
| Perhaps I should just make up new names for these things, eh?  But
there
| might be code that uses 'throw' and doesn't really care which one is
| used, and it would be nice to just modify the import line and be done
| with it.
| 
| Any opinions?
| 
| Thanks,
| Lyle
| ___
| Haskell-Cafe mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/haskell-cafe
 

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


Re: [Haskell-cafe] Hiding functions

2004-08-13 Thread Lyle Kopnicky
Alistair,
I'm throwing my own exceptions in my own monad, not the IO one.  But 
thanks for pointing me to the stuff about dynamic types.  I'm going to 
be creative and pick some new names.

- Lyle
Bayley, Alistair wrote:
What is wrong with creating your own catch and throw with different names?
e.g.
 data MyException = MyException ...
   deriving (Typeable, Show)
 catchMyEx :: IO a - (MyException - IO a) - IO a
 catchMyEx = catchDyn
 throwMyEx :: MyException - a
 throwMyEx = throwDyn
 

But there might be code that uses 'throw' and doesn't really 
care which one is used, and it would be nice to just modify 
the import line and be done with it.
   

Can you expand on this? (more example code?) If you want to throw your own
exceptions, then you must use throwDyn/catchDyn, so you have to use
something other than catch/throw anyway.
Alistair.
 

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


Re: [Haskell-cafe] Combination-lock problem

2004-08-12 Thread Lyle Kopnicky
Even shorter:
c=mapM(\k-[0..k])
- Lyle
Fritz Ruehr wrote:
Well, as far as that goes, we can shave off a little bit (around 7%) 
this way:

  combs = mapM (\k-[0..k])
(As a bonus, it's even a bit more cryptic/symbolic, in the fine 
tradition of APL one-liner character-shavings.)

But who's counting? :) :) :)
  --  Fritz Ruehr
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Closed Classes

2004-08-12 Thread Lyle Kopnicky
Notwithstanding module Y, I don't think you should infer in module X 
that g::Int (or, rather, Int-Int).  Since f is defined in a type class, 
it should be polymorphic, and so should g.  When you apply g to a type, 
it will check to see what instances are available, and match only if Int 
is the type of the variable.  But there's no reason to restrict the type 
of g itself.

- Lyle
[EMAIL PROTECTED] wrote:
Informally, what I see as the defining rule for closed world is: an
expression is typed according to the set of definitions that are
visible in the context in which it is used. Other possibilities
exist, but the nice thing about this is that it is an extension of
what happens without overloading.
With this definition, given
  _____
 | module X (f,g) where  |   | module Y where |
 |   |   ||
 | class A a where   |   | import X   |
 |   f :: a - a |   ||
 | instance A Int where  |   | instance A Float where |
 |   f = id  |   |   f x = x + 1.0|
 |   |   ||
 | g x = f x |   | h x = g x  |
 -   --
we would infer: g::Int (since the context in g's definition has only
f:Int) and thus h::Int in Y (since the context in h's definition has
only one g::Int). If h was defined as h x = f x in Y, *then* it
would have a polymorphic type (because there are two instances of f
in Y).
Carlos
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
 

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


Re: [Haskell-cafe] Combination-lock problem

2004-08-11 Thread Lyle Kopnicky
Henning Thielemann wrote:
On Wed, 11 Aug 2004, Lyle Kopnicky wrote:
 

Here's my version:
combs [] = []
combs [n] = [[i] | i - [0..n]]
combs (n:r) = let combsr = combs r in [i:cr | i - [0..n], cr - combsr]
   

Since there is one zero combination, it should be
 

combs [] = [[]]
   

Ah, yes.  I knew I must be missing something.  That would be a lock 
which has no numbers on it, but can be opened at any time.

Then you can also remove the definition of combs [n] .
What is the advantage of introducing 'combsr' instead of using 'combs r'
immediately? 
 

I initially did that to save recalculation, but later shifted things 
around, and now I see there is no need for it.  Thanks.  Here is the 
improved version:

combs [] = [[]]
combs (n:r) = [i:cr | i - [0..n], cr - combs r]
- Lyle
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Library sizes (was: Toy application advice wanted)

2004-05-06 Thread Lyle Kopnicky




I don't want to pick on any particular library, as this issue can pop
up with any library in any language. I feel it's an issue which has
been addressed before, but the solutions are largely ignored. This is
most likely because 1) people assume we have plenty of space or 2) the
library isn't yet complete, and it's easier to statically link a big
library for now, and worry about alternatives later. If I were writing
a library, I probably wouldn't be too concerned with the issue myself.

It seems there are two ways to address this problem:

1) Shared libraries. Why not link the library dynamically instead of
statically? Is this possible with GHC? Then multiple applications
using the library wouldn't balloon the memory use, but share a copy of
the same library. For simple development and testing, it's easier to
statically link, since we only have to worry about one file. But if we
expect people to run many programs using this library, we ought to be
more careful about space usage. Dynamic linking ought to be an option.

2) Linking in only what's used. If a simple 'Hello, World!' program
only needs a window and some buttons, why link in all the code for
other widgets? Is there a library format which allows pulling out only
those operations which are needed? An alternative is to recompile the
library code with the program each time, throwing away dead code - that
is, the library code which is never called. Recompiling the library
code with the application takes longer, but need only be done once the
program is ready for distribution.

If anyone knows of existing solutions in either of these areas, please
inform us.

- Lyle Kopnicky

Duncan Coutts wrote:

  On Wed, 2004-05-05 at 16:24, Andrei de A. Formiga wrote:
  
  
   I'm finding wxHaskell very nice, and a wxWidgets
binding is something many other "advanced" languages
don't have (even OCaml). The only downside is having a
'Hello World' GUI application with 7 Mb... but it runs
quite well and smooth once it's loaded.

  
  
We have the same problem with gtk2hs. A stripped simple(ish) prog weighs
in at about 2.5Mb.

I'm not quite sure what's in there that makes it so big.

Duncan

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



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


Re: [Haskell-cafe] Toy application advice wanted

2004-05-05 Thread Lyle Kopnicky
David Roundy wrote:
I think that sounds like a good idea (not doing a GUI just yet) but would
recommend that perhaps you could do something pretty impure in terms of
file or directory browsing.  That wouldn't involve going beyond the
standard libraries, but might give you some idea of the expressive power of
the languages in terms of IO actions.  I'm thinking something like a
recursive grep, or wc -l... except preferably a bit more tailored to the
sort of IO you'll have to do in your actual application.  I guess the trick
would be in finding something tough enough, since wc -l would be something
like a two-liner...
A one-liner:
main = interact (show . length . lines)
- Lyle Kopnicky
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: How do I sleep in Ghc?

2003-12-08 Thread Lyle Kopnicky





  
  
  Here's a POSIX implementation of a sleep function in C, as found
in the book "Advanced Programming in the UNIX Environment":

 http://www.yendor.com/programming/unix/apue/lib.svr4/sleep.c

AFAIK, all the GHC platforms, including Windows, are POSIX compliant.
You could compile this code separately and call it via the FFI. If it
doesn't work on Windows, you could instead call:
  


  Win32::Sleep(TIME)
  
[CORE] Pauses for TIME milliseconds. The
timeslices are made available
to other processes and threads.

  
  Hope that helps,
Lyle Kopnicky

BTW, you have a very interesting disclaimer in your message. I hope I
will not go to jail for reading it.
  



[EMAIL PROTECTED] wrote:

  Hi there,

In Ghc, how do I sleep for say, 1 minute? I'm trying to write a simple file
arrival listener and could not find the sleep api. Can haskell do it at
all?

Thanks.

Ben.


This message is intended only for the addressee and may contain information
that is confidential or privileged. Unauthorized use is strictly prohibited
and may be unlawful. If you are not the intended recipient, or the person
responsible for delivering to the intended recipient, you should not read,
copy, disclose or otherwise use this message, except for the purpose of
delivery to the addressee. If you have received this email in error, please
delete and advise us immediately.


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
  



___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell