Re: [Haskell] Random selection

2004-10-06 Thread Thomas L. Bevan
It's really irritating when people expect their homework to be done on line. It undermines the effectiveness of the mailing list by trying to take advantage of other people's good will. On Thu, 7 Oct 2004 01:18, ldou wrote: I have a string,e.g. 1245670398, now I want to select two element from

Re: [Haskell-cafe] Combination-lock problem

2004-08-09 Thread Thomas L. Bevan
Just make the function recursive. There is a simple relation between, l [a,b,c] and l [b,c] Tom On Tue, 10 Aug 2004 14:01, Florian Boehl wrote: Hi, I'ld like to generate a list (of lists) that contains all combinations of natural numbers stored in another list. It should work like a

Re: [Haskell] behavioral difference between GHC and GHCi

2004-02-08 Thread Thomas L. Bevan
You're not really doing anything wrong. You're just another victim of line buffering. Try this, import IO main = do hSetBuffering stdout LineBuffering main2 main2 = do x-hGetLine stdin putStrLn x main2 On Mon, 09 Feb 2004 11:06 am, S. Alexander Jacobson wrote: This code works echos

Re: Another fold question

2003-11-05 Thread Thomas L. Bevan
patty, what you have written is not a fold. A fold operates over a list. There is no list in your code, only some sort of tree structure. foldMusic :: (Pitch - Octave - Duration - a) - (Duration - a) - (a - a - a) - (a - a - a) - (Ratio Int - a - a) - Music

Re: haskell httpd

2003-11-04 Thread Thomas L. Bevan
If anyone ports this to work with GHC6.0 please let us know. Tom On Wed, 5 Nov 2003 09:58 am, Peter Simons wrote: S Alexander Jacobson writes: Is there a reasonably efficient Haskell httpd implementation around that uses poll/select? There is a web server written in Haskell: HWS-WP --

Re: Data types basics

2003-11-04 Thread Thomas L. Bevan
In Haskell, data types and contructors must be designated by names whose first letter is capitalised. So, data currency = ... is illegal. Instead use, data Currency = Dollar Double | Pound Double | Zloty Double | Euro Double Above are four data constructors and they can be used to contruct

Re: Database interface

2003-08-14 Thread Thomas L. Bevan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I still want to use HaskellDB (or at least the relational calculus part of it), so I was thinking of splitting it into two pieces: a library that submits SQL queries and returns the results (database interface), and a library that constructs

Re: Newbie Design Question

2003-08-04 Thread Thomas L. Bevan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I don't see that the contibutors files are fundementally different. - From what I understand, it should be possible to write a generic function, importCSV :: FilePath - IO [ (String,String) ] where the 1st value is a field name and the 2nd

Show with Strings

2003-08-03 Thread Thomas L. Bevan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Is there any reason why show :: String - String is not equivalent to 'id' ? At the moment, show one = \one\ which leads to problems because it often requires String to be treated as a special case, rather than just a member of Show. Tom

Re: Exporting GHC functions.

2003-07-31 Thread Thomas L. Bevan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sorry, I've worked it out. Didn't read the docs properly as usual. Tom On Thu, 31 Jul 2003 04:20 pm, Thomas L. Bevan wrote: Here is a copy of all the files I am using to try to export a Haskell function. This compiles but produces a executable

Linking to exported GHC functions.

2003-07-30 Thread Thomas L. Bevan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Could someone give me a command line example of how to link a C programme using functions exported via GHC FFI? I've compile C object files using an FFI function but can't for the life of me work out what arguments to pass to the compiler to make

Template Haskell - read function

2003-07-02 Thread Thomas L. Bevan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I'm struggling to write the following function in Template Haskell. I have a phantom type, data HTMLPage a = HTMLPage FilePath This type points to an HTML file, where 'a' refers to the return type of the posted form. So, mostly, I would

Re: Template Haskell - read function

2003-07-02 Thread Thomas L. Bevan
] ] vars = [ var $ show n | n - [1..i] ] So, I can now define a function f, f :: [String] - (Int, Bool) f = $(cast 2) . $(listToTuple 2) but I can still see no way to infer the size of the tuple purely from the declared type signature. Tom On Wed, 2 Jul 2003 11:56 am, Thomas L. Bevan wrote: Hi

Re: Threads

2003-06-17 Thread Thomas L. Bevan
Strange. I have used this form many times without difficulties. Perhaps, it is a platform-dependant bug. Tom On Fri, 13 Jun 2003 03:33 pm, Filip wrote: Hi, I have function f:: a - b and I need something like this: myaccept:: Socket - IO () myaccept g = do a - accept g

Networking : PortNumber

2003-06-03 Thread Thomas L. Bevan
Hi, How can I take some input and convert this into a PortID ? I don't quite understand why the constructor PortNumber doesn't have the signature PortID = PortNumber Int | ... Instead it is PortID = PortNumber PortNumber where PortNumber is not a member of the Read class. Tom

Re: Networking : PortNumber

2003-06-03 Thread Thomas L. Bevan
Sorry, I've just worked it out. PortNumber is an instance of the class Enum so we can use toEnum :: Int - a Tom On Tue, 3 Jun 2003 05:25 pm, Thomas L. Bevan wrote: Hi, How can I take some input and convert this into a PortID ? I don't quite understand why the constructor PortNumber

Re: Ambiguous defaults

2003-01-07 Thread Thomas L. Bevan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've never been very clear on this. As I understand it, Andrew's code specifies a Compound class where the type the compound determines the type (and consequently class) of the value of decompose c. In Ferenc's example, the Compound class specifies

Andy Gill's Html library

2002-06-24 Thread Thomas L. Bevan
Hi, I've been working through the source code of Andy Gill's Html library for my own edification. Andrew makes the following definitions. \begin{code} instance (Show a) = Show (BlockTable a) where showsPrec p = showsTable type TableI a = [[(a,(Int,Int))]] - [[(a,(Int,Int))]] data