Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Jeff Polakow
Hello, There is clearly a problem with the Haskell/monad tutorials out there... The tutorials seriously need to step back and start with something like, To enforce order of evaluation we evaluate closures* returning a defined type. The first closure will feed its result to the second

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Jeff Polakow
Hello, Look! You are doing it again! :) Does that paragraph even contain the word Monad? :) Sorry. Your first paragraph led me to believe you were writing about monads. I'm aware a monad is an abstraction and as such it doesn't *do* anything. My point was along the lines that you

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Jeff Polakow
Hello, On 8/14/07, Jeff Polakow [EMAIL PROTECTED] wrote: One general intuition about monads is that they represent computations rather than simple (already computed) values: x :: Int -- x is an Int x :: Monad m = m Int -- x is a computation of an Int What's

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Jeff Polakow
Hello, On 14/08/07, Jeff Polakow [EMAIL PROTECTED] wrote: Of course, the type [Int] denotes a value which is a list of Ints; additionally [Int] can be viewed as a value representing the nondeterministic computation of a single Int. Generally, the type Monad m = m Int can be viewed

Re: [Haskell-cafe] Re:Explaining monads

2007-08-15 Thread Jeff Polakow
Hello, Hence the need to perform a run operation like runIdentity, evalState or runParser (for Parsec) to get something useful to happen. Except for lists we don't seem to do this. I suppose lists are so simple that the operators :, ++ and the [] constructor do all we ever need with

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Jeff Polakow
Hello, There are 4 variants of tail: tail :: [a] - [a] -- normal tailDef :: [a] - [a] - [a] -- returns the first argument on [] tailMay :: [a] - Maybe [a] -- returns a Nothing tailNote :: String - [a] - [a] -- crashes, but with a helpful message tailSafe :: [a] - [a] -- returns [] on []

Re: [Haskell-cafe] agda v. haskell

2007-09-28 Thread Jeff Polakow
Hello, Agda is essentially an implementation of a type checker for Martin-Lof type theory (i.e. dependent types). It is designed to be used as a proof assistant. Roughly speaking propositions are represented as types and a proof of a proposition is a well-typed, total and terminating

Re: [Haskell-cafe] Strictness leak

2007-10-30 Thread Jeff Polakow
Hello, countIO :: String - String - Int - [a] - IO [a] countIO msg post step xs = sequence $ map unsafeInterleaveIO ((blank outmsg (0::Int) c):cs) where (c:cs) = ct 0 xs output = hPutStr stderr blank= output ('\r':take 70 (repeat ' ')) outmsg x

Re: [Haskell-cafe] Strictness leak

2007-10-30 Thread Jeff Polakow
I forgot to send this reponse to haskell-cafe earlier... Hello, You mean for the IO monad, right? Sorry. I meant divergence is unavoidable for any strict Monad, such as IO. However, sequence will always compute over the entire list; if the resulting computation itself is lazy then the

Re: [Haskell-cafe] Re: Semantics of uniqueness types for IO (Was: Why can't Haskell be faster?)

2007-11-02 Thread Jeff Polakow
Hello, Just a bit of minor academic nitpicking... Yeah. After all, the uniqueness constraint has a theory with an excellent pedigree (IIUC linear logic, whose proof theory Clean uses here, goes back at least to the 60s, and Wadler proposed linear types for IO before anybody had heard of

Re: [Haskell-cafe] Re: Semantics of uniqueness types for IO

2007-11-02 Thread Jeff Polakow
Hello, Just to continue the academic nitpicking.. :-) Linear logic/typing does not quite capture uniqueness types since a term with a unique type can always be copied to become non-unique, but a linear type cannot become unrestricted. Actually, that isn't quite accurate. In

Re: [Haskell-cafe] Re: Semantics of uniqueness types for IO

2007-11-02 Thread Jeff Polakow
Hello, I think you mean !U -o U is a theorem. The converse is not provable. Oops... I should read more carefully before hitting send. This is of course completely wrong. Sorry for the noise, Jeff --- This e-mail may contain confidential and/or privileged information. If you

Re: [Haskell-cafe] Re: Semantics of uniqueness types for IO

2007-11-02 Thread Jeff Polakow
Hello, I think you mean !U -o U is a theorem. The converse is not provable. Oops... I should read more carefully before hitting send. This is of course completely wrong. This is embarrassing... I was right the first time. !U -o U is a theorem in linear logic.

Re: [Haskell-cafe] type/class question: toString

2007-11-06 Thread Jeff Polakow
Hello, Have you tried using -fglasgow-exts? That should enable all ghc extensions. -Jeff [EMAIL PROTECTED] wrote on 11/06/2007 02:02:11 PM: On Nov 6, 2007 12:15 PM, David Benbennick [EMAIL PROTECTED] wrote: In ghc 6.8.1, the error messages are more helpful: foo.hs:5:0: Illegal

Re: [Haskell-cafe] fundeps and overlapping/undecidable instances

2007-12-07 Thread Jeff Polakow
Hello, You should be able to use fundeps to do exactly what you describe below. Can you make a relatively small self-contained example which exemplifies the ugliness you see? -Jeff [EMAIL PROTECTED] wrote on 12/07/2007 11:24:35 AM: I have some type-level sets using fundeps working

Re: [Haskell-cafe] fundeps and overlapping/undecidable instances

2007-12-07 Thread Jeff Polakow
Hello, Does the following code work for you? -Jeff --- {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fallow-overlapping-instances #-} data Nil = Nil data x ::: xs = x ::: xs infixr 5 ::: data HTrue = HTrue deriving Show data HFalse = HFalse deriving

Re: [Haskell-cafe] How to make Prelude.read: no parse more verbose ...

2007-12-19 Thread Jeff Polakow
Hello, You can also just use reads which returns a list of (partial) parses. -Jeff [EMAIL PROTECTED] wrote on 12/19/2007 03:17:39 PM: Hi Well, how do I compile a Haskell program in such a way, that I get a useful error message from read? I mean, like the filename/linenumber of

[Haskell-cafe] ghc-pkg on Windows XP

2006-06-21 Thread Jeff Polakow
Hello, I have installed ghc-6.4.2 on a windows XP machine. However, the machine refuses to execute ghc-pkg (thus preventing me from using Cabal) and complains that C:\ghc\ghc-6.4.2\bin\ghc-pkg.exe is not a valid Win32 application. Is there something obvious I might have overlooked while

Re: [Haskell-cafe] Haskell performance in heavy numerical computations

2006-07-07 Thread Jeff Polakow
honest, the documentation for Arrows blows my mind. I think a few examples would go a long way. John Hughes' original paper on arrows is full of examples. Additionally, Hughes wrote a tutorial on programming with arrows, for the 2004 AFP summer school in Tartu, which is very accessible. Both

[Haskell-cafe] heap issues

2006-07-27 Thread Jeff Polakow
Hello, Why would ghci run out of heap space (and crash) the second time I run a computation? More specifically, I have a ghci session which goes something like this: *Analysisrun [ ... print out of a very long list ...] *Analysisrun [ ... partial print out GHC's heap exhausted:

[Haskell-cafe] ghc profiling

2006-08-25 Thread Jeff Polakow
Hello, When I compile my program without profiling: bash-3.1$ ghc --make -auto-all -prof -O -o analysis analysis.hs Chasing modules from: analysis.hs Compiling Main ( analysis.hs, analysis.o ) Linking ... everything works fine. However when I compile with profiling:

[Haskell-cafe] hdbc linking errors

2006-10-31 Thread Jeff Polakow
Hello, When trying to compile a standalone program using hdbc in cygwin, I get many linker errors. I have no problems using my code interactively with ghci. I am using the command line: ghc --make -package HDBC -package HDBC-odbc -O -o testExecute testExecute.hs Am I missing something?

Re: [Haskell-cafe] hdbc linking errors

2006-10-31 Thread Jeff Polakow
Hello, I think my problem is a faulty ghc installation and not HDBC. sorry for the noise, Jeff [EMAIL PROTECTED] wrote on 10/31/2006 02:31:27 PM: Hello, When trying to compile a standalone program using hdbc in cygwin, I get many linker errors. I have no problems using my code

Re: [Haskell-cafe] Designing an object model in Haskell

2006-12-07 Thread Jeff Polakow
Have you looked at OOHaskell (http://homepages.cwi.nl/~ralf/OOHaskell/)? -Jeff [EMAIL PROTECTED] wrote on 12/07/2006 07:07:46 AM: Hi, I've got an object model that I have a difficult time conceptualising how it might look like in Haskell: class Element { } class Inline : Element { }

Re: [Haskell-cafe] Re: A suggestion for the next high profile Haskell project

2006-12-19 Thread Jeff Polakow
Hello, PS: Talking about smart programs: Is there a library anywhere that could be used to implement expert systems in Haskell or to evaluate Horn clauses in Prolog style? Here is one possible starting point is the backtracking monad transformer by Oleg et al:

[Haskell-cafe] hsffig build problem

2007-01-08 Thread Jeff Polakow
Hello, I am trying to install hsffig and I get the following error: bash$ make : : Linking cabal-setup.exe ... Distribution/Simple/Configure.o:fake:(.text+0x74fd): undefined reference to [EMAIL PROTECTED]' collect2: ld returned 1 exit status

Re: [Haskell-cafe] Mission: To take args from an n-tuple ... generally

2008-01-31 Thread Jeff Polakow
Hello, I wondered, why not take an n-tuple of arguments s.t. multApply' :: (a1-a2-...-an-o) - (a1,(a2,(...(an,o)...))) - o I'm not sure what you're trying to do here. Why is there an o in the argument? Also, do you really mean the number of arguments expected to match the number of

Re: [Haskell-cafe] Re: Re: Reflective capabilities of Haskell (cont'd)

2008-03-12 Thread Jeff Polakow
Hello, Thanks a lot, this helps a bit, but access to function bodies is exactly what I need. Or being more precise, I need the functionality of ghci's command ':t'. So functions that behave as follows, where everything is of course meta-represented in some way as ADT: Prelude

Re: [Haskell-cafe] Re: Re: Reflective capabilities of Haskell (cont'd)

2008-03-12 Thread Jeff Polakow
Hello, Prelude Data.Typeable typeOf (\a - (Just (a:))) (\a - (Just (a:))) :: Char - Maybe [Char] Prelude Data.Typeable getDomain $ typeOf (\a - (Just (a:))) [Char] Prelude Data.TypeablegetCodomain $ typeOf (\a - (Just (a:))) (Maybe [Char]) Data.Typeable

Re: [Haskell-cafe] List concat

2008-05-09 Thread Jeff Polakow
Hello, The function (++) :: [x] - [x] - [x] has O(n) complexity. If somebody were to invent some type that looks like [x] but actually uses some sort of tree rather than a linked list, you should be able to get O(1) concatenation. Has anybody ever implemented such a thing? You can also

[Haskell-cafe] GHC predictability

2008-05-09 Thread Jeff Polakow
Hello, One frequent criticism of Haskell (and by extension GHC) is that it has unpredictable performance and memory consumption. I personally do not find this to be the case. I suspect that most programmer confusion is rooted in shaky knowledge of lazy evaluation; and I have been able to fix,

Re: [Haskell-cafe] GHC predictability

2008-05-13 Thread Jeff Polakow
Hello, For example, the natural and naive way to write Andrew's mean function doesn't involve tuples at all: simply tail recurse with two accumulator parameters, and compute the mean at the end. GHC's strictness analyser does the right thing with this, so there's no need for seq, $!, or the

Re: [Haskell-cafe] getting output from shell commands

2008-05-15 Thread Jeff Polakow
Hello, I would like to be able to run a shell command like curl and process the output in my Haskell program, but I couldn't find anything helpful about it. Try looking in System.Process. runInteractiveProcess should work for you. -Jeff --- This e-mail may contain confidential and/or

[Haskell-cafe] Announce: Fortress talk in New York City

2008-06-13 Thread Jeff Polakow
Hello, There will be a talk on Fortress ( a new OO/Functional language from Sun) on Wednesday June 25 at 6:30pm in Manhattan. Abstract: The Java Programming Language revolutionized programming with two simple concepts: Write once run anywhere, and Garbage Collection. This led to a big

Re: [Haskell-cafe] Type level sets with GADTs, fundeps etc

2008-07-15 Thread Jeff Polakow
Hello, data LSet t where Nil :: LSet Nil --either add the new element or do nothing Ins :: (Member a t b , If b (LSet t) (LSet (a ::: t)) r) = L a - LSet t - r The constructor Ins needs to return an LSet. Maybe try replacing occurrences of r with (LSet r).

Re: [Haskell-cafe] Type level sets with GADTs, fundeps etc

2008-07-15 Thread Jeff Polakow
Hello, data LSet t where Nil :: LSet Nil --either add the new element or do nothing Ins :: (Member a t b , If b (LSet t) (LSet (a ::: t)) r) = L a - LSet t - r The constructor Ins needs to return an LSet. Maybe try replacing occurrences of

Re: [Haskell-cafe] Type level sets with GADTs, fundeps etc

2008-07-15 Thread Jeff Polakow
Hello, data LSet t where Nil :: LSet Nil Ins :: (Member a t b , If b t (a ::: t) r) = L a - LSet t - LSet r Try replacing both original occurrences of r, i.e. (untested) Ins :: (Member a t b, If b t (a ::: t) (LSet r)) = L a - LSet t - LSet r -Jeff

Re: [Haskell-cafe] Type level sets with GADTs, fundeps etc

2008-07-17 Thread Jeff Polakow
Hello, Thanks. This sort of works, but shifts the problem to another context. Now it seems that I can't hide the extra type information in the existential types, which is what I want to do. I think that you can't abstract over a type context, i.e. you can't expect type inference to

Re: [Haskell-cafe] Usage of . and $

2007-03-06 Thread Jeff Polakow
[EMAIL PROTECTED] wrote on 03/06/2007 02:43:03 PM: Usually, I can do this, but today, my brain is weak, and I'm just trying to get this piece of code out the door. My code looks like this: weight = sum (IntMap.elems (IntMap.intersectionWith (\x y - x*y) queryVector

Re: [Haskell-cafe] Usage of . and $

2007-03-06 Thread Jeff Polakow
Jefferson Heard [EMAIL PROTECTED] wrote on 03/06/2007 03:18:40 PM: Nope, I'm asking why um . IntMap.elems . IntMap.IntersectionWith (\x y - x*y) queryVector rationalProjection won't work. We have (simplifying away some typeclass details): sum . elems :: IntMap a - a and:

Re: [Haskell-cafe] Search monad

2007-03-19 Thread Jeff Polakow
Hello, You might want to look at the scrap your boilerplate papers and/or their implementation in GHC in Data.Generics. -Jeff [EMAIL PROTECTED] wrote on 03/19/2007 01:11:19 PM: Hey, I have a structure containing Xs in various places, like so data X data Structure = Structure .. [X]

[Haskell-cafe] toClockTime

2007-03-20 Thread Jeff Polakow
Hello, On my system, GHC 6.6 running on windows xp, System.Time.toClockTime fails on calendar times later than (by days, I didn't check hours, minutes, etc.) January 18, 2038. Is this a bug? thanks, Jeff --- This e-mail may contain confidential and/or privileged information. If you

Re: [Haskell-cafe] Partial Evaluation

2007-03-21 Thread Jeff Polakow
Hello, Partial evaluation in this context (programming languages research) usually refers to compile time optimization techniques such as statically evaluating as much of a function as possible (e.g. going into the function body and evaluating as much as possible that doesn't depend on the

Re: [Haskell-cafe] Is ([] - []) an arrow?

2007-03-21 Thread Jeff Polakow
Hello, In John Hughes's Programming With Arrows (http://www.cs.chalmers.se/~rjmh/afp-arrows.pdf), he discusses a stream function type newtype SF a b = SF {runSF :: [a] - [b]} and gives instance Arrow SF where He gives some examples using this, and everything seems to go just fine. I

Re: [Haskell-cafe] [IO Int] - IO [Int]

2007-05-04 Thread Jeff Polakow
Hello, I'm trying to learn haskell, so here's is my first newbie question. I hope this list is appropriate for such help requests. Yes. I'm trying to write a function with the signature [IO Int] - IO [Int] As other people have mentioned, the library function sequence has this type

Re: [Haskell-cafe] Question about HList possibilities

2007-06-25 Thread Jeff Polakow
Hello, Hello all, Given an HList (http://homepages.cwi.nl/~ralf/HList/) would it be possible to do the following: Create a class/function/magicks that would essentially do what hOccursMany does, except it would not return a list of elements, but a new HList. For example, would this

Re: [Haskell-cafe] Propositional logic question

2007-06-25 Thread Jeff Polakow
Hello, But here I am only entitled to discharge (A /\ B) in the preceding proof and not A and B on their own. What proof which would allow me to discharge my assumptions A and B? I can see in my head how it makes perfect sense, but can't jiggle a way to do it using only the given

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Jeff Polakow
Hello, On 8/1/07, Andrew Wagner [EMAIL PROTECTED] wrote: For me, I think the key to monads is to really understand 2 things about them: ... 2.) Monads are about sequencing Now I disagree on 2. Monads are no more about sequencing than binary operators are about sequencing. Sure, if

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Jeff Polakow
Hello, 'Monad' is a type class. So what's 'IO'? Is the correct terminology 'instance' as in 'IO is an instance of Monad'. I consider 'IO' to be 'a monad' as that fits with mathematical terminology. I agree with this. But what about an actual object of type 'IO Int', say? I usually

Re: [Haskell-cafe] Re: Using haskell with emacs

2007-08-08 Thread Jeff Polakow
Hello, :r is also *much* faster in general; :l reloads all modules from scratch, while :r only reloads the modules that have changed. :r also doesn't seem check the import declarations for changes. For example, if I add a new import statement to my file, without adding code which uses the