Re: [Haskell-cafe] Endian conversion

2005-10-03 Thread Mark Carroll
On Mon, 3 Oct 2005, Joel Reymont wrote: On Oct 3, 2005, at 6:51 AM, Marc Ziegert wrote: data (Integral a) = BigEndian a = BigEndian a deriving (Eq,Ord,Enum,...) be = $( (1::CChar)/=(unsafePerformIO $ with (1::CInt) $ peekByteOff `flip` 0) ) :: Bool Will this always correctly

[Haskell-cafe] Re: [Haskell] pros and cons of static typing and side effects ?

2005-08-11 Thread Mark Carroll
The previous comments make sense to me. The lots-of-unit-tests aspect of static typing I find really useful, far exceeding any BDSM cost. If I'm engaging in exploratory programming, the type inference combined with the ability to write 'error armadillo' in stubs for values I can't be bothered to

Re: [Haskell-cafe] Word32 to Int converions

2005-07-20 Thread Mark Carroll
On Wed, 20 Jul 2005, yin wrote: Bernard Pope wrote: On Wed, 2005-07-20 at 11:43 +0200, yin wrote: how do I convert an Word32 (or WordXYZ) to Int, or Integer, or Float, ...? The Int conversion is the priority. fromIntegral to convert to an instance of Integral, such as Int, Integer

Re: [Haskell-cafe] Coin changing algorithm

2005-07-13 Thread Mark Carroll
On Wed, 13 Jul 2005, Dinh Tien Tuan Anh wrote: (snip) eg: m = 75, k = 5 = [50, 20, 5] [50, 20, 1,2,2] (snip) Is this problem suitable for functional programming language ? Oh, what fun. I like this sort of thing. My quick attempt is: module Coins where import Data.Maybe

Re: [Haskell-cafe] About ($)

2005-06-02 Thread Mark Carroll
On Thu, 2 Jun 2005, Frank-Andre Riess wrote: name's Frank-Andre Riess. Nice to meet you m(_ _)m Hello! So, well, my first question on this list is admittedly somewhat simple, but I managed to delay it long enough and now I think I should ask about it: Does ($) have any relevance at all

Re: [Haskell-cafe] List containing different types but all implementing the same class

2005-04-08 Thread Mark Carroll
On Fri, 8 Apr 2005, Bo Herlin wrote: (snip) Is it possible to make this work? This is an extension beyond the 1998 standard, but http://haskell.org/hawiki/ExistentialTypes may be interesting to you. -- Mark ___ Haskell-Cafe mailing list

[Haskell-cafe] Linux device drivers

2005-03-20 Thread Mark Carroll
I was wondering about the possibility of using Haskell for developing device drivers that would be kernel modules for Linux. If nothing else, it would be quite an educational experience for me, as I've not yet experimented with either the Linux kernel or Haskell FFI, nor have I had to learn how to

Re: [Haskell-cafe] invalid character encoding

2005-03-19 Thread Mark Carroll
On Sat, 19 Mar 2005, David Roundy wrote: That's not true, there could be many filesystems, each of which uses a different encoding for the filenames. In the case of removable media, this scenario isn't even unlikely. The nearest desktop machine to me right now has in its directory structure

Re: [Haskell-cafe] Typeclasses and instances

2005-03-17 Thread Mark Carroll
newtype Floating a = Vector a = Vector [a] Okay, I now know a little more about this, with help from friends. The obvious Functor instance seems not to work with GHC 6.2.2 but does work with GHC 6.4. With 6.2.2 I can still use GHC's newtype-deriving extension to derive an instance for

Re: [Haskell-cafe] Typeclasses and instances

2005-03-17 Thread Mark Carroll
Another note, with more help from friends: It turns out that GHC 6.4 will let me do, newtype Floating a = Test a = Test [a] deriving Show x = Test [False, True] but, if I change newtype to data, it then says, No instance for (Floating Bool) I'm not sure I quite

[Haskell-cafe] Typeclasses and instances

2005-03-16 Thread Mark Carroll
If I have, newtype Floating a = Vector a = Vector [a] if I want to make it an instance of Functor (with the obvious meaning), how do I write that? Thanks, Mark -- Haskell vacancies in Columbus, Ohio, USA: see http://www.aetion.com/jobs.html

Re: [Haskell-cafe] Parser question

2005-03-15 Thread Mark Carroll
On Tue, 15 Mar 2005, Nicola Whitehead wrote: (snip) term :: Parser Int term = do f - factor do symbol * e - expr return (f * t) +++ return f (snip) symbol and natural are defined elsewhere and work fine, but when I compile it I get

Re: [Haskell-cafe] Solution to Thompson's Exercise 4.4

2005-03-12 Thread Mark Carroll
I had a go with things along this theme and came up with a couple of options, with different type signatures. I use some functions from the Data.List library. If we know that, as with Ints, we are dealing with list members that are instances of Ord, we can do: howManyEqual :: (Eq a, Ord a) = [a]

[Haskell-cafe] Card trick

2005-03-10 Thread Mark Carroll
Having heard about an interesting card trick, I thought I'd try implementing it in Haskell. With luck, I didn't make any mistakes. I thought it was cool enough to be worth sharing with you guys. -- Mark module CardTrick where import Data.List import Data.Maybe This code is by Mark Carroll

Re: [Haskell-cafe] State Monad

2005-03-04 Thread Mark Carroll
On Fri, 4 Mar 2005, Mark Carroll wrote: (snip) Enclosed is a programme that asks for two ints from standard input, adds (snip) Let me try again. (-: -- Markmodule StackMTest where import StackM import Control.Monad import Control.Monad.Trans import System.IO import System.Random add :: Num

Re: [Haskell-cafe] State Monad

2005-03-02 Thread Mark Carroll
On Thu, 3 Mar 2005, Sam G. wrote: I need a Monad to represent an internal stack. I mean I've got a lot of functions which operates on lists and I would not like to pass the list as an argument everytime. Could you help me writing this monad? To start, I just need a + function which will

Re: [Haskell-cafe] Literate Haskell

2005-02-18 Thread Mark Carroll
On Fri, 18 Feb 2005, Dmitri Pissarenko wrote: I'm curious what experienced Haskellers think about using literate Haskell in daily work. It seems to me like a good idea, since during coding it often helps to write down one's thoughts (often, I find a solution to a complicated problem in this

Re: [Haskell-cafe] Haskell programs in C

2005-01-25 Thread Mark Carroll
On Tue, 25 Jan 2005, Dmitri Pissarenko wrote: Is it possible (at least theoretically) to write a program in Haskell, then convert it into C and then compile the C program into an executable, which is optimized for the microcontroller? I would guess so. Wasn't there someone mentioning here a

Re: [Haskell-cafe] Parsing a string

2005-01-25 Thread Mark Carroll
On Tue, 25 Jan 2005, Dmitri Pissarenko wrote: (snip) I need to read the height and width, then cut them from the string, create an array (or finite map) of Int's (for this I need to know the height and width), and then recursively process the pixel values (i. e. put them into the array). The

Re: [Haskell-cafe] File path programme

2005-01-25 Thread Mark Carroll
On Tue, 25 Jan 2005, Marcin 'Qrczak' Kowalczyk wrote: (snip) If problems are in the implementation but the interface is right, then the module should be provided. It can be fixed later. (snip) A lot of the Haskell libraries are sufficiently poorly documented that I work out what they do by

Re: [Haskell-cafe] wxFruit examples

2005-01-25 Thread Mark Carroll
On Tue, 25 Jan 2005, John Peterson wrote: The wxFruit effort was a senior project that focused pretty much exclusively on the paddleball game. It didn't really create any software that we intend to maintain and distribute. Still, is wxFruit the best shot we have at being The Way Forward for

[Haskell-cafe] File path programme

2005-01-20 Thread Mark Carroll
I tried writing a little command-line utility to find the relative path of one thing from another thing (with Unix-like systems in mind). For example, $ ./pathfromof /etc/init.d/ /etc/X11/XF86Config-4 ../X11/XF86Config-4 $ ./pathfromof /tmp/baz/ /tmp/foo/ . $ ls -l /tmp/baz lrwxr-xr-x 1 markc

Re: [Haskell-cafe] Using Haskell as a database

2005-01-10 Thread Mark Carroll
On Mon, 10 Jan 2005, Dmitri Pissarenko wrote: (snip) At the moment, I think that it makes more sense to store the data in form of facts (not tables as in relational database). (snip) A Haskell binding for something some of the stuff at http://www.ai.sri.com/~gfp/ might be useful? I'd often

Re: [Haskell-cafe] Re: Utility functions

2004-12-29 Thread Mark Carroll
On Wed, 29 Dec 2004, John Goerzen wrote: (snip) I accept patches for things like this for MissingH. You can send me code or diffs as you prefer. I've been accepting code licensed under GPL, LGPL, or BSD, and will need a statement such as: (snip) Can you mix in BSD code with GPL, though,

[Haskell-cafe] Utility functions

2004-12-28 Thread Mark Carroll
I find myself writing things like, splitListOn :: Eq a = a - [a] - [[a]] splitListOn delimiter = unfoldr splitter . (delimiter :) where splitter [] = Nothing splitter xs = Just (span (/= delimiter) (tail xs)) This is a sort of intersperse-opposite, in that... myId delimiter =

Re: [Haskell-cafe] Haskell IO and exceptions

2004-12-10 Thread Mark Carroll
On Sun, 5 Dec 2004, Scott Turner wrote: (snip) Yes. Although Control.Monad.Error forces your error type to be in the Error class, that puts no constraints on what you save in the errors. If you thread your errors with the IO Monad then you would be using the monad: ErrorT YourErrorType IO

RE: [Haskell-cafe] Non-technical Haskell question

2004-12-06 Thread Mark Carroll
On Mon, 6 Dec 2004 [EMAIL PROTECTED] wrote: (snip) someone else wrote: gcc of course leaves .o files lying around, so this is no different than C. (snip) When I use javac every file that is created is necessary for the application to run. This can't be said of the ghc compiler. Having an

[Haskell-cafe] Haskell IO and exceptions

2004-12-04 Thread Mark Carroll
All this talk of IO and exceptions reminds me of a small issue I've been having. I like Control.Monad.Error but often my stuff is threaded through the IO monad so, AFAICT from the functional dependency stuff, that means my errors have to be IOErrors. Is that right? And, then, I want control over

[Haskell-cafe] Propagating Parsec errors

2004-12-04 Thread Mark Carroll
Is there a way in Parsec to, within a parser, throw an error generated by another parser? For instance, something of type ParseError - GenParser tok st a or whatever. -- Mark ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

[Haskell-cafe] Job

2004-09-23 Thread Mark Carroll
The company I'm involved with - Aetion, a tiny defense contractor in Columbus, Ohio - is now looking for an affordable Haskell programmer to hire. So, on the offchance that any of you guys are interested, or know of someone who might be, feel free to e-mail me for more information or to supply

[Haskell-cafe] Functional Reactive Programming

2004-09-09 Thread Mark Carroll
I was wondering, how much active development is done on FRP frameworks these days. What direction is it going in, and who are the users? I haven't seen much new on Yampa lately so I wondered how that was doing, or if it was thought largely finished and maybe something else was going on. For

Re: [Haskell-cafe] newbie problems

2004-07-05 Thread Mark Carroll
On Sat, 3 Jul 2004, paolo veronelli wrote: I'd like to have a simple definition of the meanings of 'type' and 'data' and maybe a clarifing example on their use. (snip) The way I see it, you use type for genuine synonyms where you don't care about the distinction, newtype where you want to make

[Haskell-cafe] Surprising bugs

2004-05-12 Thread Mark Carroll
I clearly don't understand Haskell very deeply yet because I dealt with a couple of interesting types of bug this week. One sort was where, if I have, f :: SomeType - Stuff ... f = whatever g :: Stuff ... g = f someValue ...then I can get an error that suggests that maybe I'm violating the

[Haskell-cafe] Data constructors

2004-04-25 Thread Mark Carroll
I keep running into annoyance in having to name data constructors differently if they're for different types if they're in the same module or something. I wish that something like some Type.Constructor syntax worked in order to disambiguate. Or, better still, I have that problem with function

Re: [Haskell-cafe] Data constructors

2004-04-25 Thread Mark Carroll
On Sun, 25 Apr 2004, Scott Turner wrote: (snip) Must function concepts such as 'union' can be made into type classes, to the extent that the concept can be described in the type system. (snip) Unfortunately, you still need the different names when you make the instances, and you can't do things

Re: [Haskell-cafe] Perl-ish =~ operator

2004-02-23 Thread Mark Carroll
On Tue, 24 Feb 2004 [EMAIL PROTECTED] wrote: In my effort to turn Haskell into a language more like Perl (muahaha)[1], I got a bit fed up and implemented something like Perl 5's =~ binding operator (a.k.a. regex operator); I thought maybe (snip) This reminds me that one thing I do miss from

Re: [Haskell-cafe] Perl-ish =~ operator

2004-02-23 Thread Mark Carroll
On Mon, 23 Feb 2004, John Meacham wrote: (snip) a standard pcre (pcre.org) binding would also be a cool thing to work on. (snip) Heh - maybe a Cambridge computer science student could do it, having both PCRE's author and Haskell experts handy locally. (-: -- Mark

[Haskell-cafe] Haskell overview

2004-02-04 Thread Mark Carroll
A colleague with a mathematics and Lisp background is wanting to learn more about Haskell. The books he's looked at concentrate more on building up from the basics and getting the syntax right, etc., whereas really he's looking more of a top-down view that makes Haskell's features and behavior

Re: [Haskell-cafe] Simple Maybe question

2004-01-27 Thread Mark Carroll
On Tue, 27 Jan 2004, Jim Lewis wrote: I'm new to Haskell and can't find an example to solve a trivial problem. I have code like this: findBlank :: [] - Int findBlank str = findIndex (==' ') str But interpreter complains elsewhere of mismatch of Int with Maybe Int. I want to handle the

Re: Combining distinct-thread state monads?

2004-01-09 Thread Mark Carroll
Another bit of code that seems to work is: convertState :: (s1 - s2) - (s2 - s1) - State s2 a - State s1 a convertState fromState toState computation = do oldState - get let (result, newState) = runState computation (fromState

Re: JVM bridge

2004-01-06 Thread Mark Carroll
I should add that I see things like -Wl -rpath /usr/lib/jvm-bridge/lib/ in the verbose output which maybe should be -Wl,-rpath,/usr/lib/jvm-bridge/lib/ instead. -- Mark ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Re: Parsec question

2004-01-01 Thread Mark Carroll
Thanks to Tom for his interesting points. I am still developing an inuition for how the error reporting goes. (-: On Thu, 1 Jan 2004, Derek Elkins wrote: (snip) testOr3 = do{ try (string (a); char ')'; return (a) } (snip) example both issues come up. If we successfully parse the (a then

Monads

2003-12-31 Thread Mark Carroll
Omitting the typeclass bit, I'm trying to write something like (s1 - s2) - StateT s1 m () - StateT s2 m a - StateT s1 m a That is, it sequences two StateT computations, providing a way to translate from the first's state to the second to keep the chain going. I can easily write something for

Parsec question

2003-12-31 Thread Mark Carroll
I tried posting this before but, from my point of view, it vanished. My apologies if it's a duplicate. In http://www.cs.uu.nl/~daan/download/parsec/parsec.html we read, testOr2 = try (string (a)) | string (b) or an even better version: testOr3 = do{ try (string (a); char ')';

Re: Monads

2003-12-31 Thread Mark Carroll
On Wed, 31 Dec 2003, Ken Shan wrote: Don't you need a (s2 - s1) function as well, to translate the final state back into StateT s1? Yes, you're right: the thing actually running the stateful computation presumably expects to start it with a state of type s1 and to be able to extract from it a

Re: Why are strings linked lists?

2003-11-28 Thread Mark Carroll
(shifting to Haskell-Cafe) On Fri, 28 Nov 2003, Donald Bruce Stewart wrote: ajb: (snip) As a matter of pure speculation, how big an impact would it have if, in the next version of Haskell, Strings were represented as opaque types with appropriate functions to convert to and from [Char]?

Data representation, maybe reflection, laziness

2003-10-31 Thread Mark Carroll
People have been talking about transmitting Haskell values on the GHC users' list, and I wanted to ask some more general stuff, partly out of mild ignorance. Ralf Hinze and Simon Peyton-Jones wrote an interesting paper on generic programming and derivable type classes. It looked like maybe

Re: Type design question

2003-07-28 Thread Mark Carroll
On Mon, 28 Jul 2003, Konrad Hinsen wrote: What is the general attitude in the Haskell community towards compiler-specific extensions? My past experience with Fortran and C/C++ tells me to stay away from them. Portability is an important criterion for me. It depends which ones. Some are

Simple monads

2003-06-26 Thread Mark Carroll
Not really seeing why Unique is in the IO monad, not deeply understanding the use of Haskell extensions in the State source, and wanting to try to learn a bit more about monads, I thought I'd try to write my own monad for the first time: something for producing a series of unique labels. This is

Assembling lists start-to-end

2003-06-21 Thread Mark Carroll
I am assembling a list from start to end. I can add elements to the end with previous ++ [current] or I can add them with current : previous and reverse it when I'm done. Or, maybe I should use some other data structure. (I don't know the length in advance.) Any thoughts? -- Mark

Re: African money

2003-03-25 Thread Mark Carroll
On Tue, 25 Mar 2003, Jerzy Karczmarczuk wrote: (snip) Anyway, I am willing to spend a part of this money on your behalf. If somebody has any idea how to empoison, strangle, shoot, electrocute or burn alive this annoying bastard who proposes regularly to everybody on Internet all that financial

Re: Parsing date and time specifications

2002-12-20 Thread Mark Carroll
On 20 Dec 2002, Ketil Z. Malde wrote: (snip) Since it's almost Christmas, I'd also like a way to specify things like first Tuesday of every month, or the day before (last Thursday of every month). And a GHC target for my Palm Pilot :-) We could build a really cool Cron replacement, and

Re: Parsing date and time specifications

2002-12-19 Thread Mark Carroll
On 19 Dec 2002, Peter Simons wrote: (snip) datatype. It appears that in order to construct one of those, I need _all_ the information it contains, including the weekday (Day) and the number of the day in the year. The problem now is that I do not have this information! Of course I could

Re: Random

2002-12-17 Thread Mark Carroll
On Tue, 17 Dec 2002, Filipe Santos wrote: I need some help to do a function so that I cant get 4 numbers between 1 and 6, i tried to use random but i can't make it work well. This might be useful, import Random dice :: (RandomGen g) = g - Int - (g, [Int]) dice rng

Re: Random

2002-12-17 Thread Mark Carroll
On 17 Dec 2002, Ketil Z. Malde wrote: (snip) dice :: Integer - StdGen - [Integer] dice n g = take n $ randomRs (1,6) g Can we still do this concisely and get the new state of the rng back out the other end after the die has been thrown a few times? Or are things like newStdGen

Re: Random

2002-12-17 Thread Mark Carroll
On 17 Dec 2002, Ketil Z. Malde wrote: Mark Carroll [EMAIL PROTECTED] writes: (snip) Can we still do this concisely and get the new state of the rng back out the other end after the die has been thrown a few times? Oops; I missed that part! No problem - it wasn't exactly clearly part

Re: Error Handling

2002-12-13 Thread Mark Carroll
On Fri, 13 Dec 2002, Fergus Henderson wrote: (snip) and [slightly] reduced need to use Monads would be outweighed by the drawbacks mentioned above, i.e. code bloat and compiler complexity.) Ah - that's the impression I got from your earlier reply, too. (snip) time-outs or user interrupts.

Re: Error Handling

2002-12-10 Thread Mark Carroll
On 10 Dec 2002, Alastair Reid wrote: (snip) To do this, we have to actually build the set of all exceptions that an expression could raise. This could take quite a while to build Why? I can see that, to do the ordering, you may want to know all the exceptions that can arise somewhere in the

RE: AW: slide: useful function?

2002-12-02 Thread Mark Carroll
On Mon, 2 Dec 2002, David Bergman wrote: (snip) Till then, we Haskellers will probably continue expressing our patterns either directly in Haskell or using highly formal language, with terms such as catamorphisms. The virtue, and weakness, of traditional design patterns is their vagueness

Re: deriving (was Re: storing to a file)

2002-11-15 Thread Mark Carroll
On Thu, 14 Nov 2002, matt hellige wrote: (snip) well, here's one way it might work: http://research.microsoft.com/~simonpj/Papers/derive.htm I'll take a look at that - thanks - it might answer a few of my generic programming questions. although i'm not exactly sure what you mean by 'add your

Re: storing to a file

2002-11-14 Thread Mark Carroll
On 14 Nov 2002, Johan Steunenberg wrote: thanks for your advice, I guess it sweetens the situation, though I really would like to know how to store in a binary format. http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne/haskell_libs/Binary.html might be interesting for you. Actually,

Re: Question about use of | in a class declaration

2002-08-21 Thread Mark Carroll
On Wed, 21 Aug 2002, Christian Sievers wrote: (snip) It might not have become clear from the previous answers: this construction is not Haskell 98, but an extension. That's why it's not in the report. (snip) One issue we have here is that any Haskell we write is stuff we'll probably want to

Re: Writing a counter function

2002-06-30 Thread Mark Carroll
On Sun, 30 Jun 2002, Jon Fairbairn wrote: (snip) But there's the rub. It's not beautiful and it doesn't make much sense. I really wish we could get away from the How do I convert this imperative code snippet into Haskell questions into How do I solve this abstract problem? The question as

Re: Writing a counter function

2002-06-29 Thread Mark Carroll
On Sat, 29 Jun 2002, Samuel E. Moelius III wrote: (snip) Here's another not-exactly-what-you-wanted solution. :) (snip) Do any of the experimental extensions to Haskell allow a what-he-wanted solution? I couldn't arrange one in H98 without something having an infinitely-recursive type

Re: Constructing Cases

2002-05-24 Thread Mark Carroll
If you can live with f's domain being ordered, I'd probably use something like f = lookupWithDefaultFM (listToFM list) (-1) importing FiniteMap from ghc's libraries. HTH. -- Mark ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Re: finding ....

2002-03-20 Thread Mark Carroll
On Wed, 20 Mar 2002, Lennart Augustsson wrote: (snip) examples you gave are broken. Sometimes it doesn't matter much, but I'd hate to see that code like that, e.g., in the control software for an airplane. (Or in the kernel for that matter.) ...or, indeed, in any software that might be

Hiring and porting

2002-03-12 Thread Mark Carroll
Thanks, everyone, for your responses! It's all been very helpful. Some things I should mention, then: We're based in central Ohio, but are not currently hiring FPers. Whether we will be in the future depends somewhat on this porting issue. However, if we do decide to hire any Haskell

Hiring Haskell programmers

2002-03-11 Thread Mark Carroll
How easy is it to hire reasonable Haskell programmers? Of course, this may mean, hiring people with the aptitude and interest to quickly learn Haskell. Has anyone any experience of this that they can share? -- Mark ___ Haskell-Cafe mailing list [EMAIL

RE: Hiring Haskell programmers

2002-03-11 Thread Mark Carroll
On Mon, 11 Mar 2002, Konst Sushenko wrote: I have always been wondering what exactly does quickly learn Haskell mean? Quickly learn Haskell syntax? Can one learn how to paint quickly? Be able to modify or add to the code base within a few weeks, in such a way that somebody doesn't have to

Re: Help

2002-02-27 Thread Mark Carroll
On Wed, 27 Feb 2002, Juan M. Duran wrote: I got a function with type :: IO [[Double]], and what I want is write this output in a file, how can I do it... I mean, I cannot doit by just using writeFile (snip) Does something like this help at all? myfn :: IO [[Double]] myfn = return

Re: add something to a list

2002-02-17 Thread Mark Carroll
On Sun, 17 Feb 2002, Jay Cox wrote: (snip) PS: Anybody got any other suggestions for IO monad entry-level docs? (snip) Simon's Tackling the Awkward Squad paper was a revelation for me. -- Mark ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Re: oops (was: Re: if-then-else inside a do)

2002-01-30 Thread Mark Carroll
On Wed, 30 Jan 2002, Kevin Glynn wrote: I think the Haskell Wiki was going to be the place to collect interesting code fragments. However, I must add that these functions are already part of the Haskell 98 standard. See the Monad module in the Library Report. Ah, cool, both points sound

Re: oops (was: Re: if-then-else inside a do)

2002-01-29 Thread Mark Carroll
On Wed, 30 Jan 2002, Bernard James POPE wrote: (snip) when :: (Monad m) = Bool - m () - m () when p s = if p then s else return () unless :: (Monad m) = Bool - m () - m () unless p s= when (not p) s (snip) That's cute. People post all sorts of handy

Re: Integer to String Conversion?

2001-12-03 Thread Mark Carroll
On Tue, 4 Dec 2001, Chris wrote: is there a function that converts Integers to Strings and vice versa? Prelude (reads 123 abc) :: [(Integer, String)] [(123, abc)] Prelude show 123 123 HTH. (-: -- Mark ___ Haskell-Cafe mailing list [EMAIL

Re: help for exercise 4.10

2001-10-11 Thread Mark Carroll
On Fri, 12 Oct 2001, rock dwan wrote: Iam having some difficulties doing exercise 4.10 from craft of functional programming book second edition ..is their a possible solution for this ? How far have you got with it so far? I'm sure we'd prefer to help you along instead of just giving a

= vs -

2001-10-09 Thread Mark Carroll
What is the rationale for when Haskell demands a = and when it demands a -? Ideas that occur to me are: (a) The distinction helps the parser a lot (b) There's a semantic difference that the language's grammar is trying to express that isn't obvious to me -- Mark

newtype | data

2001-10-05 Thread Mark Carroll
Why does newtype exist, instead of letting people always use data and still get maximum efficiency? After all, surely the implementation is an implementation detail - a compiler could see the use of data with a unary constructor and implement it as it does newtype, instead of making the

Re: newtype | data

2001-10-05 Thread Mark Carroll
On 5 Oct 2001, Marcin 'Qrczak' Kowalczyk wrote: (snip) It could indeed be represented in the same way, but they behave differently in pattern matching: case undefined of T _ - () is () in the case of newtype and undefined in the case of strict data. Ah. I don't really use error or anything in

let/where

2001-09-19 Thread Mark Carroll
There seem to be a few situations where it's not clear to me when to use let and when where. For instance, in this little example I was playing with to work out what syntax works, main = putStr (show (if maybe_index == Nothing then DP_Unknown else DP_Number index) ++ \n) where

Re: let/where

2001-09-19 Thread Mark Carroll
Thanks very much everyone, especially for the notes about the differences between let and where, and the uses of case and maybe! Someday it would be interesting to try a programming assignment and comparing my coding style with the useful idioms that everyone else uses to see how much I still

Re: Application letters at the Haskell workshop: suggestion

2001-09-15 Thread Mark Carroll
On Sat, 15 Sep 2001, Ashley Yakeley wrote: At 2001-09-15 08:31, Mark Carroll wrote: AFAICS a simple way to get out of this is to only have one exception type that carries no information instead of different ones so we can't distinguish one exception from another, but that's obviously

Re: Another query (-:

2001-08-01 Thread Mark Carroll
On Wed, 1 Aug 2001, Yao Guo wrote: (snip) What add list does is adding a True to the end of the list, however, grow list will ignore the first element of the result, change it to False (snip) That makes a lot of sense. Thank you very much! I think I understand it now. (-: -- Mark

Simple compiler question

2001-07-25 Thread Mark Carroll
Do any of the decent Haskell compilers allow you to just type function definitions at an interpreter prompt and use them in subsequent interactions, as you'd expect from a Lisp environment? I'm fed up of editing a tiny file separately and typing :reload each time, etc. Surely I'm missing

Multithreaded stateful software

2001-05-28 Thread Mark Carroll
Often I've found that quite how wonderful a programming language is isn't clear until you've used it for a non-trivial project. So, I'm still battling on with Haskell. One of the projects I have coming up is a multi-threaded server that manages many clients in performing a distributed

Novice question

2001-04-22 Thread Mark Carroll
Is this a good place for novice questions? I have just started to try to learn Haskell, and am using Hugs to start with. When I write the not-very-useful function, greaterthan 0 _ _ = False greaterthan _ (x:xs) (y:ys) = x y and test it, Main greaterthan 2 [3] [4] False Main greaterthan 3 [4]