[Haskell-cafe] Re: Control.Exceptions and MonadIO

2006-04-23 Thread Robert Dockins
On Sunday 23 April 2006 02:19 pm, you wrote: [snip some discussion] > Perhaps something like: > > class MonadIO m => MonadIOE m where > catch :: m a-> (Exception -> m a) -> m a > throw > catchDyn > throwDyn > -- etc > > instance MonadIOE m => StateT s m where ... > instan

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Robert Dockins
On Apr 21, 2006, at 1:27 PM, Brian Hulley wrote: Robert Dockins wrote: On Apr 21, 2006, at 10:34 AM, Brian Hulley wrote: Robert Dockins wrote: On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: Hi - I've run into the global mutable state problem described in http:// [snip] There is

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Robert Dockins
On Apr 21, 2006, at 10:34 AM, Brian Hulley wrote: Robert Dockins wrote: On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: Hi - I've run into the global mutable state problem described in http:// www.haskell.org/hawiki/GlobalMutableState Since the page was last edited in March last year

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Robert Dockins
On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: Hi - I've run into the global mutable state problem described in http:// www.haskell.org/hawiki/GlobalMutableState Since the page was last edited in March last year, I'm wondering if there have been any developments or further thoughts on how

Re: [Haskell-cafe] Advice needed on best way to simulate an STL vector

2006-04-19 Thread Robert Dockins
On Apr 19, 2006, at 3:06 PM, Brian Hulley wrote: Thanks. I might try this if I don't have any luck with finger trees (from Udo's post), or if they seem too heavy for the simple thing I'm planning to use them for (implementing the text buffer for an edit control which needs a mutable array

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Robert Dockins
On Apr 12, 2006, at 4:09 PM, Scott Weeks wrote: Or carry an instance in along with a type parameter, using existentials or GADT. Brandon Moore Do you know of an example that would apply to my situation? I think I neglected to state part of my problem. I am storing the root nodes of bt

Re: [Haskell-cafe] Ambiguous types for collection keys

2006-04-12 Thread Robert Dockins
On Apr 12, 2006, at 3:18 PM, Scott Weeks wrote: Well, if you get an "ambiguous type variable" error, you probably (I think) need to add some type annotations. For example: class Foo a where foo :: a bar :: a -> String Evaluating bar foo will result in an error, but bar (foo :: Integer

Re: [Haskell-cafe] Counting bits: Sanity Check

2006-04-12 Thread Robert Dockins
On Apr 11, 2006, at 10:09 AM, David F. Place wrote: Hi All, Since it seems that real applications need more than just union, intersection, difference and complement to be fast to make EnumSet useful, I've been looking into the less naive approaches to the other things. In particular,

Re: [Haskell-cafe] Understanding allocation behavior

2006-04-10 Thread Robert Dockins
ng that those lovely, inscrutable algorithms don't help, though ;-) Rob Dockins Cheers, Daniel Am Sonntag, 9. April 2006 00:54 schrieb Robert Dockins: On Apr 8, 2006, at 1:58 PM, David F. Place wrote: Thanks Bulat and Robert. I implemented Bulat's idea as the following. It test

Re: Re[2]: [Haskell-cafe] Understanding allocation behavior

2006-04-08 Thread Robert Dockins
On Apr 8, 2006, at 1:58 PM, David F. Place wrote: Thanks Bulat and Robert. I implemented Bulat's idea as the following. It tests faster than Roberts. I use Robert's to compute the table. The performance seems satisfactory now. size :: Set a -> Int size (Set w) = countBits w where

Re: Re[2]: [Haskell-cafe] Understanding allocation behavior

2006-04-08 Thread Robert Dockins
On Apr 8, 2006, at 4:24 AM, Bulat Ziganshin wrote: Hello Daniel, Saturday, April 8, 2006, 4:21:14 AM, you wrote: Unless I overlooked something, I use foldBits only via size (though that's used a lot). size of set? there is much faster method - use a table [0..255] -> number of bits in t

Re: [Haskell-cafe] Justification for Ord inheriting from Eq?

2006-04-07 Thread Robert Dockins
On Apr 7, 2006, at 9:43 AM, Jacques Carette wrote: Robert Dockins wrote: The behaviour of NaN actually makes perfect sense when you realise that it is Not a Number. Things that are not numbers are incomparable with things that are. Yes, NaN can be of type Float. But it's not a

Re: [Haskell-cafe] Justification for Ord inheriting from Eq?

2006-04-07 Thread Robert Dockins
On Apr 7, 2006, at 1:36 AM, [EMAIL PROTECTED] wrote: G'day all. Quoting Robert Dockins <[EMAIL PROTECTED]>: Eww! Be careful how far you depend on properties of typeclasses, and make sure you document it when you do. The behaviour of NaN actually makes perfect sense when

Re: [Haskell-cafe] Justification for Ord inheriting from Eq?

2006-04-06 Thread Robert Dockins
On Thursday 06 April 2006 06:44 pm, John Meacham wrote: > On Thu, Apr 06, 2006 at 10:52:52PM +0100, Brian Hulley wrote: [snip a question about Eq and Ord classes] > well, there are a few reasons you would want to use inheritance in > haskell, some good, some bad. > > 1. one really does logically

Re: [Haskell-cafe] Re: [Haskell] What's up with this Haskell runtime error message:

2006-04-06 Thread Robert Dockins
On Apr 6, 2006, at 11:25 AM, Michael Goodrich wrote: Thanks so much for your help. I should have made clear that I was aware that the definitions were mutually dependent. What I was hoping was that Haskell could solve this for me without my having to resort to effectively finessing any se

Re: [Haskell-cafe] What's up with this Haskell runtime error message:

2006-04-05 Thread Robert Dockins
On Wednesday 05 April 2006 04:51 pm, Michael Goodrich wrote: > Oops, I just realized that you gave me the answer, namely that it won't > find fixed points of numeric sets of equations. > > Pity, that would really have made Haskell useful for this kind of > scientific computing. See section 4 of:

Re: [Haskell-cafe] "show" for functional types

2006-04-05 Thread Robert Dockins
On Apr 5, 2006, at 12:42 PM, Josef Svenningsson wrote: Sorry to barge in in the middle of your discussion here.. Hey, if we wanted a private conversation, we'd take it off-list. :-) On 4/5/06, Robert Dockins <[EMAIL PROTECTED]> wrote: There is a fair bit of disagreement

Re: [Haskell-cafe] "show" for functional types

2006-04-05 Thread Robert Dockins
On Apr 5, 2006, at 10:49 AM, Brian Hulley wrote: Robert Dockins wrote: On Apr 1, 2006, at 3:23 PM, Brian Hulley wrote: [snip] " For particular types T1 and T2, if (f (x::T1))::T2 === g x for all x in T1 then f :: T1->T2 and g ::T1->T2 can be freely substituted since the context T1

Re: [Haskell-cafe] "show" for functional types

2006-04-04 Thread Robert Dockins
On Apr 1, 2006, at 3:23 PM, Brian Hulley wrote: Robert Dockins wrote: [snip] From an earlier post: Now since f and g compute the same results for the same inputs, anywhere in a program that you can use f you could just replace f by g and the observable behaviour of the program would be

Re: [Haskell-cafe] "show" for functional types

2006-04-01 Thread Robert Dockins
[snip] > No, it doesn't, because that wasn't my argument. Consider: > > f :: C a => a->a > g :: C a => a->a > > Now if we can define just one instance of C, eg T1 where f (x::T1) \= g > (x::T1), then we can tell f and g apart for all instances of C, even when > there is another instance of C, eg T

Re: [Haskell-cafe] "show" for functional types

2006-04-01 Thread Robert Dockins
On Saturday 01 April 2006 11:53 am, Brian Hulley wrote: > Claus Reinke wrote: > > the usual way to achieve this uses the overloading of Nums in Haskell: > > when you write '1' or '1+2', the meaning of those expressions depends > > on their types. in particular, the example above uses 'T Double', no

Re: [Haskell-cafe] "show" for functional types

2006-04-01 Thread Robert Dockins
On Saturday 01 April 2006 07:50 am, Brian Hulley wrote: > Greg Buchholz wrote: > >Hmm. It must be a little more complicated than that, right? Since > > after all you can print out *some* functions. That's what section 5 > > of _Fun with Phantom Types_ is about. Here's a slightly different >

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-03-22 Thread Robert Dockins
On Mar 22, 2006, at 2:16 PM, David F. Place wrote: Hi All, I really appreciate all the help I received when I asked you to critique my PrefixMap module a few weeks ago. I think I am making good progress in correcting the "lisp" in my Haskell programming. I'll be very grateful to anyone

Re: [Haskell-cafe] Returning a list element?

2006-03-20 Thread Robert Dockins
On Mar 20, 2006, at 5:15 PM, Neil Rutland wrote: Hi there, thank you all for your help with regards to the integer addition question that i asked yesterday it was very good in clarifying my ideas. However i would now like to ask for your expert help once again. Basically i have a list o

Re: [Haskell-cafe] Lists of Lists

2006-03-08 Thread Robert Dockins
On Mar 8, 2006, at 2:27 PM, zell_ffhut wrote: Could you explain what the function does.. I can't seem to peice it together. It takes three things 1) a function 2) an index and 3) a list. It finds the nth element of the list, applies the function to it and then returns a new list containi

Re: [Haskell-cafe] Lists of Lists

2006-03-08 Thread Robert Dockins
On Mar 8, 2006, at 1:29 PM, zell_ffhut wrote: Im afraid im baffled again! Im now trying to add a char to a string of strings (eg - ["434233434" "444929192" "909313434"] Im sure i can use my previous function to help me achive this, but i can't seem to get it workinging charToGrid :: Char

Re: [Haskell-cafe] Dropping trailing nulls from a list of list

2006-03-08 Thread Robert Dockins
On Mar 8, 2006, at 12:08 PM, [EMAIL PROTECTED] wrote:Today, I reviewed a function I wrote a few months ago.  The function, dropTrailNulls, takes a list of lists and drops trailing null lists.  For instance: *Main> dropTrailNulls [[1],[2,3],[],[]] [[1],[2,3]] My original implementation was terribl

Re: [Haskell-cafe] Comparing programs

2006-03-06 Thread Robert Dockins
On Mar 6, 2006, at 1:05 PM, Harry Chesley wrote: This is more of an algorithm question than a language question, but any insights would be much appreciated. The problem is to input a series of programs and find previous occurrences of the same algorithm. The programs consist of a set of

Re: [Haskell-cafe] PrefixMap: code review request

2006-02-27 Thread Robert Dockins
On Feb 27, 2006, at 2:30 PM, David F.Place wrote: Hi, I'm a newish Haskell hacker with way too much experience hacking Lisp.At first, I found my Haskell code looking very lisp-y. I think my code is becoming more idiomatic haskell. I would be very grateful to anyone who would take

Re: [Haskell-cafe] haskell programming guidelines

2006-02-20 Thread Robert Dockins
On Feb 20, 2006, at 2:26 PM, Henning Thielemann wrote: On Mon, 20 Feb 2006, Robert Dockins wrote: I personally disagree with your preference for custom datatypes with a value representing failure to lifting types with Maybe. I understood that part of the guidelines as a pleading for Maybe

Re: [Haskell-cafe] haskell programming guidelines

2006-02-20 Thread Robert Dockins
On Feb 20, 2006, at 12:48 PM, Christian Maeder wrote: Hi, haskell admits many programming styles and I find it important that several developers of a prject agree on a certain style to ease code review. I've set up guidelines (still as plain text) for our (hets) project in http://www.inf

Re: [Haskell-cafe] Overlapping instance problem

2006-02-13 Thread Robert Dockins
On Feb 13, 2006, at 2:26 PM, [EMAIL PROTECTED] wrote:Hi, I've posted a couple messages to the Haskell Cafe in the last few months.  I'm new to Haskell.  But, I've set out to implement my own vectors, matrices, complex numbers, etc. One goal I have, is to overload operators to work with my new typ

Re: [Haskell-cafe] question about type lambda and decidability of typechecking

2006-02-10 Thread Robert Dockins
For the record, a little more digging turned up this http://portal.acm.org/citation.cfm?id=583852.581496 which answers most of my questions. On Feb 10, 2006, at 2:02 PM, Robert Dockins wrote: OK. I've been doing a little thinking about type lambda in Haskell. Now, I understan

[Haskell-cafe] question about type lambda and decidability of typechecking

2006-02-10 Thread Robert Dockins
OK. I've been doing a little thinking about type lambda in Haskell. Now, I understand the prevailing wisdom is that adding type lambda and/or partially applied type synonyms to the haskell type system would make type checking/inference undecidable. The reason given is that higher-order un

Re: [Haskell-cafe] Combinatory logic interpreter?

2006-02-10 Thread Robert Dockins
On Feb 10, 2006, at 11:09 AM, Colin Paul Adams wrote: Is there any Haskell code around that can interpret combinatory logic expressions? Humm. That's kind of a broad question. I've written a shell for interpreting the pure untyped lambda calculus which has definitions for Turner's Combin

[Haskell-cafe] Re: Re[2]: Tuple-like constructors

2006-02-08 Thread Robert Dockins
[Moved to cafe; time to stop bothering the Haskell' committee...] On Feb 8, 2006, at 1:19 PM, Malcolm Wallace wrote: Robert Dockins <[EMAIL PROTECTED]> writes: instance (Bin a,Bin b,Bin c,Bin d) => Bin (a,b,c,d) See the problem? Sooner or later (probably sooner) I'll

Re: [Haskell-cafe] extending bang proposal Re: strict Haskell dialect

2006-02-06 Thread Robert Dockins
ems pretty ugly, and I think they'd be pretty hard to bolt onto an HM base. Robert Dockins Speak softly and drive a Sherman tank. Laugh hard; it's a long way to the bank. -- TMBG ___ Haskell-Cafe mailing list Haskell-Cafe@ha

Re: [Haskell-cafe] Re: Haskell code for this example of flow control

2006-02-03 Thread Robert Dockins
On Feb 3, 2006, at 11:28 AM, Maurício wrote: Kurt Hutchinson wrote: On 2/2/06, Maurício <[EMAIL PROTECTED]> wrote: I understand those examples, but I really would like to know how to do that with monads. I would like to ask the same question, but now with this code: double a = 1000; dou

Re: [Haskell-cafe] Re: Haskell code for this example of flow control

2006-02-02 Thread Robert Dockins
I think you're looking for IORef http://www.haskell.org/ghc/docs/ latest/html/libraries/base/Data-IORef.html Something like this (untested) should do what you want: example :: IO () example = do { ref <- newIORef 1000; loop ref } where loop ref = do x <- readIORef ref print x

[Haskell-cafe] library(s) for numeric constant folding?

2006-01-29 Thread Robert Dockins
Does anyone know of a good library or libraries which will allow me to perform arithmetic operations on 1) binary integers (signed and unsigned) of various fixed sizes? 2) IEEE 754 floating point numbers (single and double precision). Pure Haskell is preferable, but I'll make do with C bin

Re: [Haskell-cafe] How to redirect a handle within a thread (GHC 6.4.1 runtime)?

2006-01-18 Thread Robert Dockins
perfectly matching Robert Dockins' 'threadlocal' proposal? Yes, actually. This is precisely the use case that got me thinking about threadlocal storage in the first place. I'm working on Shellac (http://www.mail-archive.com/haskell@haskell.org/msg17871.html) and it

Re: [Haskell-cafe] Yet another top-level IO proposal

2006-01-17 Thread Robert Dockins
"unique" state for each OS separate. > Maybe you should put all this > on the wiki page. I'd like to see how/if you could implement > the hypothetical device driver API I put there, or even just > use the "oneShot" function or similar at the top level.

[Haskell-cafe] Yet another top-level IO proposal

2006-01-16 Thread Robert Dockins
Fellow haskellers, I have a proposal I would like to enter into the eternal top-level IO debate. The proposal involves a minor language extension and some runtime support for thread local reference cells. I believe it has the potential to meet many of the needs of those requesting top leve

Re: [Haskell-cafe] Splitting a string into chunks

2006-01-13 Thread Robert Dockins
On Jan 13, 2006, at 4:35 PM, Jon Fairbairn wrote: On 2006-01-13 at 13:32PST Jared Updike wrote: That works except it loses single newline characters. let s = "1234\n5678\n\nabcdefghijklmnopq\n\n,,.,.,." Prelude> blocks s ["12345678","abcdefghijklmnopq",",,.,.,."] Also the argument to groupB

Re: [Haskell-cafe] Is there a notion for identity?

2006-01-09 Thread Robert Dockins
On Monday 09 January 2006 04:09 am, Tim Walkenhorst wrote: > Thanks for all infos. > > I'll apply that Ref-datatype from the "observable sharing" paper > to my problem and see where this brings me. I'm also looking > into the solution Paul Hudak presented in the > "Detecting Cycles in Datastructure

Re: [Haskell-cafe] Is there a notion for identity?

2006-01-08 Thread Robert Dockins
On Sunday 08 January 2006 06:43 am, Tim Walkenhorst wrote: > {- Disclaimer: I'm rather new to Haskell and completely new to this board. > I may not use the correct terminology in all cases, but I hope my > intention becomes clear when you have a look at the code-snippets. -} > > Hey ho, >

Re: [Haskell-cafe] How to read this syntax?

2005-12-29 Thread Robert Dockins
On Dec 29, 2005, at 11:26 AM, David F. Place wrote: Hi, I am trying to read _Arrows, Robots, and Functional Reactive Programming_ by Hudak, et al. http://www.haskell.org/yampa/AFPLectureNotes.pdf In section 2.1 there are a number of equations of the form: g’ :: SF A C g’ = arr g = ar

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Robert Dockins
On Dec 28, 2005, at 1:38 PM, Tomasz Zielonka wrote: On Wed, Dec 28, 2005 at 05:28:28PM +, Chris Kuklewicz wrote: But STM, wrapped in small pieces, makes for interesting IO commands (untested): waitForZero :: (Num a, Ord a) => (TVar a) -> IO () waitForZero tv = atomically $ do v <- rea

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Robert Dockins
On Dec 28, 2005, at 11:14 AM, Chris Kuklewicz wrote: John Goerzen wrote: Hello, I have the need for a locking object that can provide shared and exclusive locks in much the same manner as the POSIX flock() function. A thread that acquires an exclusive lock has a guarantee that no other

Re: [Haskell-cafe] Prime numbers

2005-12-20 Thread Robert Dockins
-divides a b = (mod a b == 0) +divides a b = (mod b a == 0) On Dec 20, 2005, at 11:09 AM, Daniel Carrera wrote: John Peterson wrote: Add a type signature: prime :: Integer -> Bool It's defaulting to Int and you're getting overflows Thanks. Hmm... it's still not working. Btw, I mis-reporte

Re: [Haskell-cafe] Re: Bringing Erlang to Haskell

2005-12-13 Thread Robert Dockins
BTW, there has already been some work in this area. http://www-i2.informatik.rwth-aachen.de/~stolz/dhs/ http://www.informatik.uni-kiel.de/~fhu/PUBLICATIONS/1999/ifl.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mai

Re: [Haskell-cafe] Tail-call optimization

2005-12-11 Thread Robert Dockins
On Sunday 11 December 2005 06:54 pm, Joel Reymont wrote: > Thank you Andrew! Does it have any effect on performance? Is there a > speed up of any sort from not passing parameters? Shooting from the hip here, but I doubt it -- AFAIK it all gets lambda-lifted in the compiler anyway. > On Dec 11, 2

Re: [Haskell-cafe] Can't Haskell catch upwith Clean's uniqueness typing?

2005-12-06 Thread Robert Dockins
On Tuesday 06 December 2005 04:00 pm, [EMAIL PROTECTED] wrote: > From: "Shae Matijs Erisson - [EMAIL PROTECTED]" > Sent: Tuesday, December 06, 2005 6:16 PM > > > [EMAIL PROTECTED] writes: > > > being occupied with learning both languages, I'm getting curious if > > > Haskell couldn't achieve most o

Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread Robert Dockins
On Oct 27, 2005, at 11:54 AM, Creighton Hogg wrote: Hi, so I'm a newbie getting used to Haskell. I'm writing some simple things like genetic algorithms in it for practice, and I keep coming across something that really bugs me: are there any standard libraries that allow you to do imperative s

Re: [Haskell-cafe] Haskell scripting system (please help me simplify the design)

2005-10-27 Thread Robert Dockins
On Oct 27, 2005, at 11:01 AM, Joel Reymont wrote:Folks,With lots of help from #haskell and haskell-cafe I came up with the following setup. It's working fine but requires quite a bit of boilerplate code. Could you please help me simplify it?I apologize for the very long message and will describe an

Re: [Haskell-cafe] Parsec, state and/of my cluelessness

2005-10-17 Thread robert dockins
[snip] Now comes the tricky part for me. Since the control can have three different types of children I use a helper that parses the body of the control using other parsers, collecting their results in three lists: ctrlBodyParser :: CharParser ([Value], [Property], [Control])

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread robert dockins
use Data.Typeable ? Thank you very much. On 10/13/05, *robert dockins* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: In GHC you can do this: > import Data.Typeable > isString :: (Typeable a) => a -> Bool > isString x = typeOf x == typeOf (un

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-13 Thread robert dockins
In GHC you can do this: > import Data.Typeable > isString :: (Typeable a) => a -> Bool > isString x = typeOf x == typeOf (undefined::String) Why do you want this? It's not the kind of operation one does very often in Haskell. Huong Nguyen wrote: Hi all, I want to write a small function

Re: [Haskell-cafe] Typing problems with basic arithmetic - help!

2005-09-23 Thread robert dockins
For the version with type signatures, you are trying to divide integers using the (/) function. This function expects values in the class Fractional, and Integer isn't a member. Replace with div, which does integer division. pnorep days n = (numeratorex days n) `div` (denominatorex days n)

Re: [Haskell-cafe] Growing Trees

2005-09-22 Thread robert dockins
It sounds like you are porting an algorithm which does destructive updates on this tree. If so, you can use the ST (or IO) monad and use STRef (IORef). data Tree a = TreeRoot { stuff:: STRef a , children :: STRef [Tree] } . you would get at the data li

Re: [Haskell-cafe] Trapped by the Monads

2005-09-20 Thread robert dockins
Mark Carter wrote: I'm puzzling out how to get a Bool from am IO Bool. I know I'm not supposed to, but I don't see any way around my predicament. The basic setup is: I have an edit box, and a panel. If you click the LMB on the panel when the edit box is checked, this means you want to move a

Re: [Haskell-cafe] Eq Type Class: Overloading (==)

2005-09-18 Thread Robert Dockins
On Sunday 18 September 2005 07:59 am, Tom Hawkins wrote: > Aaron Denney wrote: > > On 2005-09-17, Jason Dagit <[EMAIL PROTECTED]> wrote: > >>A link to supertyping can be found here: > >>http://repetae.net/john/recent/out/supertyping.html > >> > >>After reading that, I wonder why it's not implemente

Re: [Haskell-cafe] Updating the Haskell Standard

2005-07-25 Thread robert dockins
ckends (optimization, code gen, linking) which interface via something that looks a lot like external core, as well as making Haskell more amenable to formal verification. Robert Dockins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www

Re: [Haskell-cafe] How to variables

2005-07-19 Thread robert dockins
Some people may suggest that you to create top-level IORefs using unsafePerformIO, but I don't recommend that for this situation. Well I can't imagine which particular people you have in mind :-) But, as a vocal advocate of sound support for top level mutable state, I would just like to go on

Re: [Haskell-cafe] How to variables

2005-07-18 Thread robert dockins
I'm doing a 3D simulation. Now I need something like variables in imperative languages. My mainLoop check for new events and renders scene. Then you want IORef. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.IORef.html Consider, however, that this kind of construct can be do

Re: [Haskell-cafe] How to variables

2005-07-18 Thread robert dockins
yin wrote: Hello all! I'm doing a 3D simulation. Now I need something like variables in imperative languages. My mainLoop check for new events and renders scene. To use input for controling camera position I need variables. An equivalent code in C: void main_loop() { int loop_num = 0;

Re: [Haskell-cafe] How to variables

2005-07-18 Thread robert dockins
I'm doing a 3D simulation. Now I need something like variables in imperative languages. My mainLoop check for new events and renders scene. Then you want IORef. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.IORef.html I saw it. The problem is, I need an amount of 100*X of mu

Re: [Haskell-cafe] How to variables

2005-07-18 Thread robert dockins
Uhm... and what if I write some runtines in plain C, then bind them to Haskell and and use then as in OOP: [snip] Is this apoarch safe enougth, what do you think? If you do it carefully. But why? It sounds like you are planning to write a transliteration of the code you would write in

Re: [Haskell-cafe] Can't explain this error

2005-07-11 Thread robert dockins
Thanks for your reply, i just simply removed the first line and it works, but i dont understand why 1/x is not Float. It depends on the type of 'x'. If 'x' is a Float, (1/x) will be a Float. If 'x' is a Double, (1/x) will be a Double. If 'x' is an Integer (1/x) will not typecheck becaus

Re: [Haskell-cafe] Can't explain this error

2005-07-11 Thread robert dockins
You are trying to divide by an Integer and get a Float. Haskell doesn't do automatic numeric conversion, so you have to do the casts manually. Prelude> let sumHam n = sum [ 1 / (fromIntegral x) | x <- [1..n] ] Prelude> sumHam 5 2.283 Dinh Tien Tuan Anh wrote: could anyone tell

Re: [Haskell-cafe] Re: ANNOUNCE: GHC survey results

2005-06-28 Thread robert dockins
you are completely skipped the point that these is just for C++ programmers wanting to program in Haskell and aimed to give them faster learning path and easy to use instruments Not to forget to make learning easier for programmers of Perl, Ruby, Python, Rexx, Tcl, APL, C#, Java, Bash, Fortran,

Re: [Haskell-cafe] Compiling an extremely large Haskell file (in GHC)

2005-06-27 Thread robert dockins
Arjun Guha wrote: I have an extremely large source file of about 11 MB. It's the all-pairs shortest paths data for a map of the Hyde Park area of Chicago (no real reason, really). I generated information in Scheme and printed the result to a Haskell source file as a list. I then edited the

Re: [Haskell-cafe] Why distinct tyvars in instance declarations?

2005-06-27 Thread robert dockins
but GHC complains: Illegal instance declaration for `Foo (Either b b)' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Foo (Either b b)' unless I'm totally mistaken, your proble

Re: [Haskell-cafe] Annotating calculations

2005-06-15 Thread robert dockins
Here is an idea I slammed out. Maybe it will help you. The basic idea is to create two types -- one which supports annotations and one which ignores them. Only write your calculations once, with annotations. Uses typeclasses to ignore the annotations when you don't want them. Rene de Viss

Re: [Haskell-cafe] Trivial question... solve_qe

2005-06-15 Thread robert dockins
> So, in a word: I need a tutorial for dummies I don't know of any tutorials like you have described. Perhaps someone else does? Now, my current problem is: my program for solving quadratic equation won't compile... You left out some 'Just' constructors. import System solve_qe :: May

Re: [Haskell-cafe] Generic types

2005-06-13 Thread robert dockins
I'm writing a small unit library to excercise my barely existing Haskell skills. However I can't figure out how to make Haskell accept any type of a specific class. [snip] What you want is a technique called "existential types". The wiki page is here: http://haskell.org/hawiki/ExistentialT

Re: [Haskell-cafe] A reference manual for the Haskell monad > functions

2005-06-09 Thread robert dockins
Frank-Andre Riess wrote: >>L.S., >> >>I have written a reference manual for the most common Haskell monad >>functions, in the >>style of "A Tour of the Haskell Prelude". It can be found at: >>http://members.chello.nl/hjgtuyl/tourdemonad.html >> >> >>Known bug: >>Not all keywords in the "See a

Re: [Haskell-cafe] About ($)

2005-06-02 Thread robert dockins
there are other more esoteric things, but this is about as complex as I try to go to avoid severe headaches :) Robert Dockins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Question about classes from a Haskell newbie.

2005-05-24 Thread robert dockins
oComplex' is a class which relates two types 'a' and 'b' AND the type 'a' uniquely determines the type 'b'. Hope that helps, Robert Dockins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] APIs

2005-05-24 Thread robert dockins
> One of the best bad example is the use of boolean as arguments. Oh, yes. That's a pet peeve of mine. About 99% of boolean arguments should be meaningful two-valued enumerated types. It's literally a one-liner to create such an enumerated type, so there's no excuse. The documentation eff

Re: [Haskell-cafe] Bit fiddling

2005-05-17 Thread robert dockins
If you want C compatibility, you need http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.Array.Storable.html which is similar. You then use the "withStorableArray" to call out to your C functions. Florian Weimer wrote: * robert dockins: Probably you have seen this alre

Re: [Haskell-cafe] Bit fiddling

2005-05-17 Thread robert dockins
Probably you have seen this already, but I thought I'd mention it on the off-chance you missed it: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.Bits.html http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.Word.html Probably you'll want to think about an IOUArray of

Re: [Haskell-cafe] supplying some of the arguments to a function

2005-05-06 Thread robert dockins
'a' 0 :: Bool -> () Mostly, one should just try to write functions so that they take their parameters in the most convenient order for partial application. Robert Dockins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Haskell vs OCaml

2005-05-04 Thread robert dockins
That leaves one aspect of Haskell vs Ocaml I don't yet understand. What are the advantages of lazy evaluation? I'd recommend this paper (once again): http://www.md.chalmers.se/~rjmh/Papers/whyfp.html One of the main points of the paper is that lazy evaluation enables a new way of modularizing cod

Re: [Haskell-cafe] How to join two lists of lists?

2005-05-03 Thread robert dockins
> Hi all! > I'm trying to join to lists of lists. The problem is, i would like to > get a new list of lists of tuples and not list of tuples of lists (that > what zip makes). > > list1 = [[1,2],[3,4],[5,6]] > list2 = [[a,b],[c,d],[e,f]] > > desiredlist = [[(1,a),(2,b)],[(3,c),(4,d)],[(5,e),(6,f)]]

Re: [Haskell-cafe] Where do you use Haskell?

2005-05-03 Thread robert dockins
Hi all, Again, I'm the new guy slowly learning this "fuctional programming" thing. :-) [snip] So, I'm tempted to conclude that FP is only applicable to situations where user interaction is a small part of the program. For example, for simulations. Now, I'm sure I'm not the first person to have

Re: [Haskell-cafe] Clarification on proof section of HS: The Craft of FP

2005-05-02 Thread robert dockins
Well, yes, but I'd argue that ordinary (transfinite) mathematical induction will work just fine here. It's just that the set we're doing mathematical induction over is one larger (in the ordinal sense) than usual. Let S = N union {w}, where N is the usual set of naturals and w is an additional new

Re: [Haskell-cafe] Clarification on proof section of HS: The Craft of FP

2005-05-02 Thread robert dockins
Well, I also omited the word "countable". I figure it's understood since computers only deal with finite data. And given an infinite list, any finite "head" of it would meet the criteria, so the distinction is moot. Unless Haskell has some neat property I am not aware of :-) Due to lazyness, we can

Re: [Haskell-cafe] Ambiguous type signature in class declaration

2005-04-27 Thread robert dockins
See: http://haskell.org/hawiki/FunDeps > class CRank a b where > rank :: a -> b -> Maybe Integer -- Nothing means b is out of range or badly constructed > unrank :: a -> Integer -> Maybe b -- Nothing means rank is out of range > count :: a -> Maybe Integer -- Nothing means infinity [sn

Re: [Haskell-cafe] Using catch and errors

2005-04-22 Thread robert dockins
Now I have one problem (Well 2 really but the second one is just me not having programmed in haskell for so long that I forgot). getLine is used for the sole purpous of stopping the program and allowing the user to read the error message before the window closes but error does not allow me to do t

Re: [Haskell-cafe] Using catch and errors

2005-04-22 Thread robert dockins
No, that should work. Haskell equality is not at all like Java equality. In java, '=' basicaly means pointer equality. I am not aware of a way to even make that comparison in Haskell (in general). Haskell '=' behaves a lot more like equals() in Java. Of course, you mean Haskell '==', as Haskel

Re: [Haskell-cafe] a newbie's question

2005-04-21 Thread robert dockins
Hi, I'm beginning to study Haskell, For the following a = [1,2,3] b = "there" do x <- a y <- b return (x , y) Winhugs cannot run it. Gives Syntax error in input (unexpected backslash ( lambda)) Your problem is that you're using monads to grab the contents of a and b, while a and b are

Re: [Haskell-cafe] interesting IO oriented code

2005-03-17 Thread robert dockins
2) It is performant (mostly). At least it outperforms other Haskell IO methods I have tried. My 'wc' is about twice as fast as the current shootout version in informal tests (the shootout code is included in the repo). My md5 can sum somewhere between 2-4Mb/Sec on my hardware. You know that

[Haskell-cafe] interesting IO oriented code

2005-03-17 Thread robert dockins
tations (the original purpose after all) and see how that goes. I'd also like to try gzip and gunzip transformer layers. Any ideas for improvements (including patches!) are welcome. Robert Dockins PS the code currently includes a number of vestigial remnants of false starts, and is gen

Re: [Haskell-cafe] Parser problem continued

2005-03-15 Thread robert dockins
expr :: Parser Int expr = do t <- term do symbol "+" e <- expr return e return (t + e) +++ return t<- 't' is not in scope at the arrow. t only exists inside the do block, and your code parses like this ( do t <- return (t+e) )

Re: [Haskell-cafe] Re: File path programme

2005-01-31 Thread robert dockins
Well, there is a sort-of canonic version for every path; on most Unix systems the function realpath(3) will find it. Here is the BUGS listing from 'man realpath' on my system: Never use this function. It is broken by design since it is impossible to determine a suitable size for the output buffe

Re: [Haskell-cafe] Re: File path programme

2005-01-31 Thread robert dockins
I have been ruminating on the various responses my attempted file path implementation has generated. I have a design beginning to form in the back of my head which attempts to address the file path problem as I lay out below. Before I develop it any further, are there any important considerati

Re: [Haskell-cafe] File path programme

2005-01-28 Thread robert dockins
I don't pretend to fully understand various unicode standard but it seems to me that these problems are deeper than file path library. The equation (decode . encode) /= id seems confusing for me. Can you give me an example when this happen? I am pretty sure that ISO 2022 encoded strings can have m

Re: [Haskell-cafe] File path programme

2005-01-27 Thread robert dockins
Even simple manipulations break in the presence of encoding issues, or even just of unusual paths. What is the extension of "\\.\TAPE0" ? Its not "\TAPE0". BTW this is a valid path on Windows 2000 upwards. If you don't care about corner cases, then you have no worries. It would be nice to

Re: [Haskell-cafe] File path programme

2005-01-27 Thread robert dockins
- Keep the existing System.IO API the same. openFile, createDirectory ... will take the file path as string. The problem is that "string" means different things in haskell and in C. A C "string" is really just a contiguous sequence of octets in memory. A haskell string has a particular interpreta

<    1   2   3   >