Re: [Haskell-cafe] Working with the code For Typing Haskell In Haskell

2011-10-25 Thread Tom Pledger
Patrick LeBoutillier patrick.leboutillier at gmail.com writes: [...] exprt = Ap (Const mapt) (Const idt) test = runTI $ tiExpr initialEnv [] exprt When I execute the test function above in ghci I get: ([],TVar (Tyvar v3 Star)). I was expecting someting like below for the type

[Haskell-cafe] Re: Problems with threading?

2010-06-08 Thread Tom Pledger
Louis Wasserman wasserman.louis at gmail.com writes: While working on the Shootout, I noticed the following benchmarks: http://shootout.alioth.debian.org/u64/program.php?test=chameneosreduxlang=ghcid=3 http://shootout.alioth.debian.org/u64q/program.php?test=chameneosreduxlang=ghcid=3 [...]

[Haskell-cafe] Re: Need some help with an infinite list

2009-06-18 Thread Tom Pledger
Daniel Peebles pumpkingod at gmail.com writes: My solution attempted to exploit this using Numeric.showIntAtBase but failed because of the lack of 0 prefixes in the numbers. If you can find a simple way to fix it without duplicating the showIntAtBase code, I'd be interested! Another

[Haskell-cafe] Re: Need some help with an infinite list

2009-06-16 Thread Tom Pledger
GüŸnther Schmidt gue.schmidt at web.de writes: Hi guys, I'd like to generate an infinite list, like [a, b, c .. z, aa, ab, ac .. az, ba, bb, bc .. bz, ca ...] If you're happy to have a before the a, you can do this as a fairly cute one-liner in a similar style to this list of

[Haskell-cafe] Re: Typeclass question

2008-12-27 Thread Tom Pledger
Andrew Wagner wagner.andrew at gmail.com writes: I'm sure there's a way to do this, but it's escaping me at present. I want to do something like this: data Foo = Bar a = Foo a Bool ... That is, I want to create a new type, Foo, whose constructor takes both a Boolean and a value of

[Haskell] simple function: stack overflow in hugs vs none in ghc

2007-09-23 Thread Tom Pledger
John Lask wrote: : | The following code causes a C stack overflow in hugs (version 20051031) | but not in ghc (version 6.6) | The point of the exercise is to process a very large file lazily, | returning the consumed and unconsumed parts (i.e. basic parser combinators). : | sqnc p

[Haskell] question about a failure to generalize

2007-09-16 Thread Tom Pledger
Norman Ramsey wrote: : | This code fails to compile because the compiler is willing to | use 'fold' at only one type (CmmExpr as it happens) : When it failed to compile, was fold = foldRegsUsed a top-level declaration in the module, rather than local to foldRegsUsed? If so, try

Re: [Haskell] question about a failure to generalize

2007-09-16 Thread Tom Pledger
Quoting Stefan O'Rear [EMAIL PROTECTED]: On Mon, Sep 17, 2007 at 04:15:10PM +1200, Tom Pledger wrote: Norman Ramsey wrote: : | This code fails to compile because the compiler is willing to | use 'fold' at only one type (CmmExpr as it happens) : When it failed to compile, was fold

[Haskell-cafe] expension of fractions

2007-07-25 Thread Tom Pledger
Arie Groeneveld wrote: : | Looking at the result of my rewriting gives me the idea it isn't | Haskelly enough. | | Anyways, here's my interpretation: | | -- period m/n base = (period length, preperiod digits, period digits) | period :: Integer - Integer - Integer - (Int, ([Integer],

[Haskell-cafe] xkcd #287 NP-Complete

2007-07-15 Thread Tom Pledger
We've seen some nice concise solutions that can deal with the original problem: solve 1505 [215, 275, 335, 355, 420, 580] I'll be a nuisance and bring up this case: solve 150005 [2, 4, 150001] A more scalable solution is to use an explicit heap that brings together all the ways to

[Haskell-cafe] Construct all possible trees

2007-06-13 Thread Tom Pledger
*Andrew Coppin wrote: * | I'm trying to construct a function | | all_trees :: [Int] - [Tree] | | such that all_trees [1,2,3] will yield : If you write a helper function that takes an N element list, and returns all 2^N ways of dividing those elements into 2 lists, e.g. splits ab --

[Haskell-cafe] Switch optimization

2007-06-10 Thread Tom Pledger
Stefan O'Rear wrote: | On Mon, Jun 11, 2007 at 09:43:17AM +1000, Thomas Conway wrote: : | codeLen 127 = 0 | codeLen 128 = 1 | ... | codeLen 255 = 8 | | Now, compiling with ghc 6.6.1 and -O3, I see that it generates a long | chain of conditional branches. : That's deeply tied in

Re: [Haskell-cafe] The difference between ($) and application

2004-12-14 Thread Tom Pledger
[EMAIL PROTECTED] wrote: [...] However, if we try t2' = W $ id we get an error: /tmp/t1.hs:13: Inferred type is less polymorphic than expected Quantified type variable `a' escapes Expected type: (a - a) - b Inferred type: (forall a1. a1 - a1) - W In the first argument

Re: [Haskell-cafe] Is this a useful higher-order function, or should I RTFM?

2004-12-08 Thread Tom Pledger
Steven Huwig wrote: On Dec 6, 2004, at 11:05 PM, Tom Pledger wrote: import Data.Char(isSpace) import Data.List(groupBy) (op `on` f) x y = f x `op` f y wordsAndSpaces = groupBy ((==) `on` isSpace) `on` is a handy little function in this instance. Does it have a technical name

Re: [Haskell-cafe] ghc has problems with 'zipWith' ?

2004-12-08 Thread Tom Pledger
Daniel Fischer wrote: Hi, I have recently come across the curious phenomenon that ghci is sometimes much slower than hugs. [...] ms as = zipWith (+) (zipWith (*) as (1:ms as)) (0:1:ms as) Hugs has(**) a specific optimisation for the case where the left hand side of the declaration occurs as a

Re: [Haskell-cafe] Is this a useful higher-order function, or should I RTFM?

2004-12-06 Thread Tom Pledger
Steven Huwig wrote: [...] 1) Did I miss something in the Prelude or standard library that gives me this functionality, or something close to it? [...] 3) The 3-tuple output of unravel looks ugly to me, but I can't think of an alternative. For the case where there is an equal number of

Re: [Haskell-cafe] Set of reals...?

2004-10-29 Thread Tom Pledger
Keith Wansbrough wrote: [...] Your data structure should be something like: data Interval = Interval { left :: Double, leftopen :: Bool, right :: Double, rightopen :: Bool } data Set = Set [Interval] If you want more efficiency, you probably want a bintree

Language extension idea (was Re: [Haskell-cafe] Re: OCaml list sees...)

2004-10-09 Thread Tom Pledger
MR K P SCHUPKE wrote: [...] I dont see why you cannot change the implementation of lists without changing the interface... Good old lists will behave like good old lists - just the implementation would try and take advantage of blocking of the data wherever possible. Perhaps a pragma to change the

Re: Language extension idea (was Re: [Haskell-cafe] Re: OCaml list sees...)

2004-10-09 Thread Tom Pledger
[EMAIL PROTECTED] wrote: [...] Actually we merely need to add a deconstructor. Also, we can leave the type of elements fully polymorphic. Something like this: class List l where nil :: l a cons :: a - l a - l a decon :: l a - w -- on empty - (a - l a - w)

Re: [Haskell-cafe] Haskell extension/improvement

2004-08-17 Thread Tom Pledger
Ron de Bruijn wrote: --- Martin_Sjögren [EMAIL PROTECTED] wrote: [...] mapM_ quickCheck [Test prop_revrev, Test prop_trivial, Test prop_something] Regards, Martin I didn't expect these replies (including one mentioning the HList idea(the enforced ordening is nice, though)), while I tried to be

Re: [Haskell] newbie question: variable not in scope: isSpace

2004-08-14 Thread Tom Pledger
A.J. Bonnema wrote: If I use isSpace from the hugs interpretor, it works. If I use isSpace from a test.hs file I get the error message: Undefined variable isSpace From ghc I get the error message: Variable not in scope: isSpace What is wrong? Hugs automatically imports a few extra things as well

Re: [Haskell-cafe] Control.Monad.Error with a custom error type

2004-08-14 Thread Tom Pledger
Brian Smith wrote: [...] instance MonadError (Either ReferenceError) Kind error: `Either ReferenceError' is not applied to enough type arguments When checking kinds in `MonadError (Either ReferenceError)' In the instance declaration for `MonadError (Either ReferenceError)' MonadError takes

Re: [Haskell-cafe] Question on Exercise from SOE

2004-07-03 Thread Tom Pledger
Nathan Weston wrote: I am learning haskell (and functional programming), from the School of Expression book. There's an exercise to rewrite the following function (for computing the area of a polygon) using map, fold, etc: data Shape = Polygon [Vertex] area (Polygon (v1:vs)) = polyArea vs

Re: [Haskell] State Transformers and Control.Monad.ST.Lazy

2004-06-22 Thread Tom Pledger
Vivian McPhail wrote: Hi, From the very helpful posts of John Hughes and others concerning Monadic Loops, I've been advised to re-implement my neural net simulator using lazy state threads to avoid crashes to which recursive (and tail-recursive) monads lead. I had been using monad

Re: [Haskell] Annoying naming clashes

2004-06-16 Thread Tom Pledger
[EMAIL PROTECTED] wrote: Tom, Then what will you do when naming operations in a class? Is it right that care has to be taken in order not to conflict with other classes? Say, I have a Person class where I want to define an operation getName. Is it wise to name it getPersonName instead? Class

Re: [Haskell] Annoying naming clashes

2004-06-16 Thread Tom Pledger
John Meacham wrote: [...] I find trying to draw analogies between haskell classes and constructs in other languages to be problematic as people then try to apply knowledge from other fields incorrectly to haskell unless you give a full explanation of haskell classes anyway.. but YMMV. John

Re: [Haskell] Annoying naming clashes

2004-06-11 Thread Tom Pledger
[EMAIL PROTECTED] wrote: Hi, when writing haskell code. It is so annoying that name clashes keep happening. I have to be careful about the data constructor names, about the class names, about the class member names. [...] As a novice haskell programmer, I might be missing something here though. If

[Haskell-cafe] Modelling Java Interfaces with Existential data types

2004-06-08 Thread Tom Pledger
Hi. Another way is to take advantage of Haskell's laziness: class Foo a where foo :: a - Int data Oof1 = Oof1 Int instance Foo Oof1 where foo (Oof1 i) = i data Oof2 = Oof2 Int instance Foo Oof2 where foo (Oof2 i) = i list1 = [foo (Oof1 10), foo (Oof2 20)] That's all it takes. The applications

Re: [Haskell] a newbie question

2004-04-26 Thread Tom Pledger
[EMAIL PROTECTED] wrote: Hi there. I got this question while I'm messing around with my toy monad. I was thinking about creating a generic monad that can persist state change even when fail is called. The StateT monad will discard the state change so it makes it hard to add tracing to the

Re: [Haskell-cafe] operating on nested monads

2004-03-27 Thread Tom Pledger
Marco Righele wrote: Hello everyone, I have some operations that have to be done in sequence, with each one having the result of the previous as input. They can fail, so they have signature a - Maybe b Checking for error can be quite tedious so I use monadic operations: f :: a - Maybe b do

Re: [Haskell-cafe] Where's the error in this snippet of code?

2004-03-24 Thread Tom Pledger
Stefan Holdermans wrote: Alex, AG Ignore the layout AG I can't find the error, running it gives parse error during AG compile on pStack, it is not very descriptive and I don't AG what is wrong. Well, ignoring the layout is not a good thing here, since that's the one of the causes for your

Re: [Haskell] Per-type function namespaces (was: Data.Set whishes)

2004-03-05 Thread Tom Pledger
) which was quite similar to Cayenne's open ... use ... in ... feature. Regards, Tom Pledger ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell

Re: [Haskell-cafe] State Monad

2004-03-03 Thread Tom Pledger
Georg Martius wrote: [...] I could write: modifyT :: ((a, String) - (a, String)) - a - State String a modifyT trans a = do str - get let (a', str') = trans (a, str) put str' return a' f :: State String () f = do put hallo modify strTrans i -

Re: [Haskell-cafe] a rant from a stoned suicidal person

2004-03-03 Thread Tom Pledger
There are a lot of hoaxes on the internet, but just in case you're for real, here's an idea... Step 1: Take 20 minutes to get some fresh air. Step 2: When you get back to your computer, take 5 minutes to read Desiderata (http://shell.world-net.co.nz/~unikorn/desiderata.htm), especially the

Re: [Haskell] updating graphs non-destructively

2004-02-16 Thread Tom Pledger
S. Alexander Jacobson wrote: In imperative languages, updating an object in a graph is an O(1) operation. However, non-destructive update appears to be O(n) with the size of the graph. For example, suppose we were to implement an auction system like eBay: [snip] One alternative is to store

constrained datatype

2004-01-14 Thread Tom Pledger
Wang Meng writes: : | class Foo n | data Erk n = Foo n = Erk | | test.hs:53: | All of the type variables in the constraint `Foo n' are already in | scope | (at least one must be universally quantified here) : | Is there any reason for this error? I think it implies that

Mismatched contexts

2003-12-03 Thread Tom Pledger
Armin Größlinger writes: : | GHC says | | Mismatched contexts | When matching the contexts of the signatures for | functions :: Functions | f2a :: forall a. (Integral a) = a - a | The signature contexts in a mutually recursive group | should all be identical

List - Mutable List

2003-11-21 Thread Tom Pledger
Rafael Martinez Torres writes: | Hi: | | Given the classes IArray,Marray | | instance IArray Array.Array | instance Marray IOArray e IO | | I'm searching for some think like | | MLists ( Stands for Mutable-Lists ) | | Is there some thing so ? | | | I need it to implement a

Re: Partially ordered collections (revisited)

2003-11-20 Thread Tom Pledger
Graham Klyne writes: : | Ah, yes. I've grown a little wary of foldl, but I see it's | appropriate in this case. As it's part of the standard prelude, I | personally have no qualms about depending upon it ... or should I? (Hope you don't mind my returning this to haskell-cafe.) Most of

Subsumption in partially ordered sets

2003-11-17 Thread Tom Pledger
Graham Klyne writes: : | Below is some code I have written, which works, but I'm not sure | that it's especially efficient or elegant. Are there any published | Haskell libraries that contain something like this? Hi. Partially ordered sets are in cahoots with lattices, so you may be

set representation question

2003-11-11 Thread Tom Pledger
Hal Daume III writes: : | *all* i care about is being able to quickly calculate the size of | the intersection of two sets. these sets are, in general, very | sparse, which means that the intersections tend to be small. | | for example, i might have two sets reprsented by the arrays: |

RE: Expiring cached data?

2003-11-04 Thread Tom Pledger
[EMAIL PROTECTED] writes: | G'day all. | | Tom Pledger wrote: | | How about adapting splay trees so that their pointers become weak | after a certain depth? The advantage for caching is that the more | frequently used elements move closer to the root, so you wouldn't have | to add

RE: Expiring cached data?

2003-11-03 Thread Tom Pledger
Conal Elliott writes: | Hi Andrew. This situation is what weak pointers [1] are for. You keep | weak rather than regular pointers to your cache data. The garbage | collector clears out the weak pointers and reclaims cache data when | necessary. However, I don't think there is any policy to

Using field selectors in a type constructor

2003-10-14 Thread Tom Pledger
Graham Klyne writes: : | What I'd really like to do is assign it to field vbMap, and reference that | from the definition of vbEnum, but I can't figure out if there's a way | to do so. Writing this: | [[ | joinVarBindings vb1 vb2 | | vbNull vb1 = vb2 | | vbNull vb2 = vb1 |

Database interface - would like advice on oracle library binding

2003-09-23 Thread Tom Pledger
Bayley, Alistair writes: : | Still making slow progress on an Oracle database binding... now I'm trying | to fit the API I have into some sort of abstract interface (like the one(s) | discussed previously: | http://haskell.org/pipermail/haskell-cafe/2003-August/004957.html ). | | | 1.

Re: The Future of Haskell discussion at the Haskell Workshop

2003-09-09 Thread Tom Pledger
Hi. Here's another opinion for the Records! Records! chorus: - The record and module system is one of the two big things I'd like to see changed in Haskell. (OT: the other is subtyping.) - It shouldn't happen before Haskell 2, because of backward compatability. (The dot operator

Poll result: How to respond to homework questions

2003-09-02 Thread Tom Pledger
Hi. The stream of votes has dried up, and the ICFP people and monthly digest people have had an opportunity, so here's the collated result. 22 people voted. (A) Give a perfect answer. (B) Give a subtly flawed answer. (C) Give an obfuscated answer. (D) Give a critique of what the questioner has

Poll: How to respond to homework questions

2003-08-27 Thread Tom Pledger
Hi. I'm curious about what the people on this list consider appropriate, as responses to homework questions. Even if there isn't a consensus, it may be interesting to see how opinion is divided. Please consider the following. (A) Give a perfect answer. (B) Give a subtly flawed answer. (C) Give

Re: overlapping instances and functional dependencies

2003-08-21 Thread Tom Pledger
C T McBride writes: : | but I'm not allowed | | class Bad x y z | x y - z | | instance Functor f = Bad (f x) (f y) Bool | | instance Functor f = Bad x (f y) Int | | I don't quite see why. Naively, I imagine that if the OK instances are | effectively prioritized, then Bad's

Re: No safety in numbers

2003-08-21 Thread Tom Pledger
Konrad Hinsen writes: | On Thursday 21 August 2003 23:23, Jon Cast wrote: | I can make such a declaration, but it still gets converted to Double. | | How are you doing this? I'm not seeing the behavior you describe. | | module Foo where | x = 0.5 :: Fractional a = a Try x ::

RE: Database interface

2003-08-21 Thread Tom Pledger
Tim Docker writes: : | Is it normal or common to support multiple simultaneous queries on | a single DB connection? In transaction processing, yes. There's an idiom where you use one query to select all the (financial) transactions in a batch, but there's so much variation in how you need to

RE: Database interface

2003-08-20 Thread Tom Pledger
Tim Docker writes: : | The list being folded over | is implied by the DB query, is accessible through the IO monad. | Hence a parameter is not required. It would really be: | | doquery :: Process - String - b - (b - IO (b,Bool)) - IO b : | One thing that I am unsure about is whether the

RE: Database interface

2003-08-14 Thread Tom Pledger
Tim Docker writes: | Tom Pledger writes: | | This is a pretty good way to stop those nasty vague SQL row types at | the Haskell border and turn them into something respectable. Perhaps | it would even be worth constraining the extracted type to be in | DeepSeq | | doquery

Database interface

2003-08-14 Thread Tom Pledger
Thomas L. Bevan writes: | Does anyone know if there is work being done on a standard Haskell | database interface. I suspect that there isn't. The pattern seems to be that someone gets an interface working well enough for some purposes, and perhaps shares it, but is too modest and/or busy to

Text.PrettyPrint.HughesPJ bug (return of the dead?)

2003-07-20 Thread Tom Pledger
Johannes Waldmann writes: : | spaces 0 = | spaces n = ' ' : spaces (n - 1) | | this should be replicate n ' ' or something | that behaves nicely for negative arguments. Like an n+k pattern? ;-) ___ Glasgow-haskell-users mailing list

Re: Function composition and currying

2003-07-17 Thread Tom Pledger
K. Fritz Ruehr writes: : | But Jerzy Karczmarczuk enlightened me as to the full generality possible | along these lines (revealing the whole truth under the influence of at | least one beer, as I recall). Namely, one can define a sequence of | functions (let's use a better notation now, with

callbacks in Haskell

2003-06-25 Thread Tom Pledger
Robert Vollmert writes: | Hello, | | I've been having a little trouble writing a module that waits for and | handles IO events, e.g. by reading from a pipe. It seemed natural to | use some form of callbacks here, though that may very well be the | wrong approach. I'd be happy to hear of

Arbitrary precision reals?

2003-03-24 Thread Tom Pledger
Niall Dalton writes: | Hi, | | Its been a while since I've been using Haskell seriously, so I might simply | have overlooked the answer.. | | Is there an arbitrary precision real number library available for Haskell? | IIRC, atleast GHC uses the GMP library, but only for integers? Hi.

Question about scope of 'let' and 'where'

2003-03-17 Thread Tom Pledger
Graham Klyne writes: | In the function body (rhs): | | let | { a = (e1) } | in | (e2) | where | { b = f a } : | comment : | I now see that use of 'where' is restricted to specific contexts. I wonder | if such restriction is needed?

Re: How to search for a string sequence in a file a rewrite it???

2003-03-13 Thread Tom Pledger
I've replied to this in haskell-cafe. Alexandre Weffort Thenorio writes: : | But I get this error saying: | | Expected Type: [String] | Inferred Type: String : ___ Haskell mailing list [EMAIL PROTECTED]

Re: How to search for a string sequence in a file a rewrite it???

2003-03-13 Thread Tom Pledger
(moving to haskell-cafe) Alexandre Weffort Thenorio writes: | Ooops a small error before but here is the right one. | | Great. I got almost everything. My problem now is: | | I got a function called findstr where | | findstr z [,xxxxxx] = | [z,xxxzxxx]

polymorphic type in state of state monad

2003-03-10 Thread Tom Pledger
Wang Meng writes: | Hi All, | | Any one of your have the experience of defining a state of a state monad | as a polymorphic type? | I want to have: | | type State = Term a = [a] | data M a = M (State - IO(State,a)) | | GHC yields a error message Illegal polymorphic type. | How to

Re: data vs. newtype, abstractly

2003-03-09 Thread Tom Pledger
Dean Herington writes: : | My question came up in the context of describing such an abstract type for | users of the type. Like many others, I like to include actual Haskell | code where appropriate in the documentation. It didn't seem right to | commit there to either `data` or `newtype`.

Re: Evaluation Question

2003-01-12 Thread Tom Pledger
Hal Daume III writes: : | So, you're probably better off with: | | nco wn = nco' | where wn' = cis wn |nco' = 1 : map (wn'*) nco' | | In which case it will only be evaluated once. The following version also evaluates 'cis wn' only once. nco wn = iterate (cis wn *) 1 I've

Re: Field labels must be globally unique?

2003-01-07 Thread Tom Pledger
A third way is to put each datatype declaration in a separate module and use qualified imports. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell

Re: How to force recursion

2002-12-09 Thread Tom Pledger
Cai john writes: : | what I want to do is eliminate b,c d into a | recursive function: | | insertList tree [] = Empty | insertList tree (x:xs) = insertList(insert tree x) | | but hugs is complaining about a top-level overloading | error.Any idea how to fix it, thanks. I don't see

Re: AW: slide: useful function?

2002-12-02 Thread Tom Pledger
Nick Name writes: : | Ok I can't resist longer. It's ages I have been wondering what's a | catamorphism, and an anamorphism, and what the hell does it mean | data is expressed by destructors and not by constructors, but I | have had no time till now. Please some of you all catamorphism |

Re: Time library underspecified

2002-11-14 Thread Tom Pledger
John Meacham writes: : | another useful thing would be | endOfTime and beginningOfTime constants, representing the minimum and | maximum values representable by ClockTime. : | ___ | Haskell mailing list | [EMAIL PROTECTED] |

Odd Performance

2002-10-22 Thread Tom Pledger
Tim Otten writes: : | Can anyone suggest why the tighter algorithm exhibits significantly | worse performance? Is takeWhile significicantly more expensive than | take? No. | Is the \z lambda expression expensive? No. | The intsqrt isn't recalculated each time takeWhile evalutes a |

Odd Performance

2002-10-22 Thread Tom Pledger
Tom Pledger writes: | Tim Otten writes: | : | | Can anyone suggest why the tighter algorithm exhibits significantly | | worse performance? Is takeWhile significicantly more expensive than | | take? | | No. Correction (before anyone else pounces on it): Only if the predicate function

Re: mutable records

2002-09-05 Thread Tom Pledger
Scott J. writes: : | Sill I want to make objects packed with their objects and | functions. Doesn't mean that I have to use existential data types? Sometimes you can avoid using existentials by making all your object-updating functions return the post-update object explicitly. For example:

Modification of State Transformer

2002-08-08 Thread Tom Pledger
Shawn P. Garbett writes: : | What I want is something like this, so that the state transformer has a | generic state type: | | newtype St a s = MkSt (s - (a, s)) | | apply :: St a s - s - (a, s) | apply (MkSt f) s = f s | | instance Monad St where | return x = MkSt

idiom for different implementations of same idea

2002-08-01 Thread Tom Pledger
Hal Daume III writes: | Hi all, | | I'm looking for some advice on what's the cleanest way to implement | something. : | where the main driver does something like: | | prepareData | initialize | iterate until converged | doThingOne | doThingTwo | getResults | |

encapsulation

2002-07-07 Thread Tom Pledger
Mark Fielder writes: | How does Haskell provide encapsulation? What mechanisms does it | use? The ways that spring to mind are modules and nested declarations: http://haskell.cs.yale.edu/onlinereport/modules.html http://haskell.cs.yale.edu/onlinereport/decls.html#sect4.4 | What are

typeclass versioning

2002-06-12 Thread Tom Pledger
From: Cagdas Ozgenc [EMAIL PROTECTED] | Greetings. | | What happens if a type is made an instance of a typeclass in two | different modules with different implementations? That's OK, provided that the two instance declarations are never in scope together, i.e. neither of the modules imports

functional programming contest

2002-04-04 Thread Tom Pledger
Andre W B Furtado writes: | I was visiting http://www.ai.mit.edu/extra/icfp-contest/ and noticed that | there was a functional programming contest in ICFP 98. I'd like to know if | there are any periodic functional progamming contests around the world, such | as the ACM contest for the C

Is there a name for this structure?

2002-03-26 Thread Tom Pledger
Joe English writes: : | Suppose you have two morphisms f : A - B and g : B - A | such that neither (f . g) nor (g . f) is the identity, | but satisfying (f . g . f) = f. Is there a conventional name | for this? Is it equivalent to saying that (f . g) is the identity on the range of f?

typeclasses

2002-03-24 Thread Tom Pledger
Cagdas Ozgenc writes: | Greetings. | | How can I make all types that belong to class A and instance of | class B, if the implementations of functions in class B can be | realized by only using the functions in class A? | | Thanks for taking time. Something like this, you mean?

Question about something in Hudak's book

2002-03-12 Thread Tom Pledger
Ludovic Kuty writes: : | Is it an idiom or some sort of optimization ? It's more to do with the particular algorithm for finding the area of a convex polygon. Try working through the calculation of the area of this kite. Polygon [(0, 0), (1, 0), (2, 2), (0, 1)] I think the two versions

pattern-matching with labelled types

2002-03-07 Thread Tom Pledger
Andre W B Furtado writes: : | Of course, it is possible to do something like | | update :: MyType - Int - MyType | update mt newValue = MT {x = newValue, y = oldValue} | where oldValue = y mt | | but this really annoys me when MyType has too many fields. Suggestions? update mt

Lazy Evaluation

2002-03-03 Thread Tom Pledger
Nguyen Phan Dung writes: : | mylist :: [Integer] | mylist = [1..10] | | In Hugs, I type mylist to print out all the elements inside. However, | after printing about 22000 elements, the system crashs outputs: | Garbage collection fails to reclaim sufficient memory The declaration

Lazy Evaluation

2002-03-03 Thread Tom Pledger
Nguyen Phan Dung writes: : | mylist :: [Integer] | mylist = [1..10] | | In Hugs, I type mylist to print out all the elements inside. However, | after printing about 22000 elements, the system crashs outputs: | Garbage collection fails to reclaim sufficient memory The declaration

Behavior of fromInteger on out-of-range arguments

2002-02-26 Thread Tom Pledger
David Feuer writes: : | Question: Is there any standard way in Haskell of determining the | maximal and minimal Int values? Yes, instance Bounded Int, which means you can use maxBound :: Int and minBound :: Int ___ Haskell mailing list

higher-kind deriving ... or not

2002-02-26 Thread Tom Pledger
C T McBride writes: : | A little more tinkering, and it looks like it might be | | show :: Show (f (Wonky f)) = Wonky f - String | | Is this really the type of show? That looks correct to me. | If so, no wonder there's a problem. Yes, there's a vicious circle in context reduction,

higher-kind deriving ... or not

2002-02-26 Thread Tom Pledger
Tom Pledger writes: | C T McBride writes: | : | | A little more tinkering, and it looks like it might be | | | | show :: Show (f (Wonky f)) = Wonky f - String | | | | Is this really the type of show? | | That looks correct to me. Well, after the first context reduction

Haskell problem

2002-02-20 Thread Tom Pledger
Mark Wotton writes: | Hi, | | I'm trying out some combinatorial parsers, and I ran into a slightly | inelegant construction. To parse a sequence of things, we have a function | like | | pThen3 :: (a-b-c-d) - Parser a - Parser b - Parser c - Parser d | pThen3 combine p1 p2 p3 toks = |

Composition Monad

2002-02-17 Thread Tom Pledger
Andre W B Furtado writes: | Roughly speaking, I'm in need of a monad (say MyIO) that interprets the | following code | | f :: MyIO () | f = do | action1 | action2 | action3 | ... | return () | | | as applying action1 to g, then action2 to

question about kinds

2002-01-20 Thread Tom Pledger
Hal Daume III writes: | Now, I want to say that if some data type 'd' is Traversable and | another data type 'e' is Traversable, then the combined data type | is Traversable. That is, for example, I want to say that a Tree of | Lists is traversable, or that a List of Trees, or a List of

RE: First class modules (was Existential Typing)

2001-11-01 Thread Tom Pledger
Simon Peyton-Jones writes: : | A key design choice in our system is to use *nominal* not *structural* | typing. The structural choice makes perfect sense, but it leads to | complications we don't have (as well as benefits). So we don't have | structural subtyping, and it would not be easy

Re: Enum class

2001-10-23 Thread Tom Pledger
Jan-Willem Maessen writes: | * Split the Enum class into two. Possibly correspondence with Int | belongs in Bounded---but it depends what you think Bounded | means. FWIW I sometimes use a data type for the very purpose of adding bounds to an open-ended type. data Close a =

Constructor class

2001-10-18 Thread Tom Pledger
Raul Sierra writes: | Hi all, | | What is the difference between regular classes and constructor classes | and how do you specify that a class is a constructor class? | | Thanks in advance, | Raul The term `constructor class' is meant to include classes like Functor and Monad, whose

Working character by character in Haskell

2001-10-18 Thread Tom Pledger
Andre W B Furtado writes: : | copyFile :: String - String - IO String | copyFile [] s = return (reverse s) | copyFile (a:as) s = copyFile as ( (doSomeStuffWith a):s) : | For example, suppose function doSomeStuffWith returns its own | parameter. Using a 1.5MB file in this case, the Haskell

Re: Extensible downcasts impossible in Haskell?

2001-10-09 Thread Tom Pledger
Thanks for the further explanation, Marcin. If I understand correctly, you're talking about explicitly named algebraic types, not just unions where the type is an anonymous reflection of the structure as in: Var (foo :: Int, bar :: Char) -- in the style of A Polymorphic Type System for

Extensible downcasts impossible in Haskell? (was Re: Monomorphism, monomorphism...)

2001-10-08 Thread Tom Pledger
Marcin 'Qrczak' Kowalczyk writes: : | Since OO languages often use subtypes to emulate constructors of | algebraic types, they need downcasts. In Haskell it's perhaps less | needed but it's a pity that it's impossible to translate an OO | scheme which makes use of downcasts into Haskell in

0-based versus 1-based

2001-09-27 Thread Tom Pledger
Just as a matter of idle curiosity, is there a particular reason for tuples starting at element 1 (fst) whereas lists start at element 0? fst ('x', 'y') -- 'x' xy !! 1 -- 'y' ___ Haskell mailing list [EMAIL PROTECTED]

Re: 0-based versus 1-based

2001-09-27 Thread Tom Pledger
Thanks for the replies. I keep forgetting to read (!!1) as the element at 1 and not as the 1st element. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell

type classes and generality

2001-07-09 Thread Tom Pledger
Norman Ramsey writes: : | how can I show that if a type has class Real, it also has class | Random.Random? Is there a way to accomplish this goal other than | by changing the library? How about the default-implementations-as-external-functions approach Marcin suggested, adapted for Real

Re: Haskell 98 Report

2001-05-30 Thread Tom Pledger
Zhanyong Wan writes: : | I can't help wondering why it isn't | | deleteBy' :: (a - Bool) - [a] - [a] | deleteBy' f [] = [] | deleteBy' f (y:ys) = if f y then ys else | y : deleteBy' f ys deleteBy'' f = filter (not . f) Malcolm Wallace

Re: Haskell 98 Report

2001-05-30 Thread Tom Pledger
Zhanyong Wan writes: | Tom Pledger wrote: : | deleteBy'' f = filter (not . f) | | No. deleteBy' f only deletes the *first* element that satisfies the | predicate f, while filter (not . f) deletes *all* such elements. Oops. Sorry. I ought to become less SQL-oriented

Why is there a space leak here?

2001-05-28 Thread Tom Pledger
David Bakin writes: : | I have been puzzling over this for nearly a full day (getting this | reduced version from my own code which wasn't working). In | general, how can I either a) analyze code looking for a space leak | or b) experiment (e.g., using Hugs) to find a space leak? Thanks!

  1   2   >