Re: [Haskell-cafe] A very edgy language

2007-07-07 Thread Albert Y. C. Lai
Donald Bruce Stewart wrote: trebla: I don't know. #math is larger than #accounting. Is it because math is more mainstream than accounting? I bet it is because math is more math is more *interesting* than accounting? :-) With all due respect to accounting, which is a fine profession and a

Re: [Haskell-cafe] A very edgy language

2007-07-07 Thread Albert Y. C. Lai
Thomas Conway wrote: [great comments on non-strict, static typing, purely functional] Don't worry, I was just writing a sarcasm to an apparent attitude of X is rare edge iff I can't figure out X. I have always been believing in all the points you make.

[Haskell-cafe] A very edgy language (was: A very nontrivial parser)

2007-07-06 Thread Albert Y. C. Lai
Andrew Coppin wrote: Personally, I just try to avoid *all* language extensions - mainly because most of them are utterly incomprehensible. (But then, perhaps that's just because they all cover extremely rare edge cases?) Haskell is an extremely rare edge case to begin with. Non-strict (most

Re: [Haskell-cafe] A very edgy language

2007-07-06 Thread Albert Y. C. Lai
Donald Bruce Stewart wrote: Give #haskell is a far larger community than: #lisp #erlang #scheme #ocaml As well as #java #javascript #ruby #lua #d #perl6 Maybe we need to reconsider where the (FP) mainstream is now? :-) I don't know. #math is larger

Re: [Haskell-cafe] Profiling and Threading: never the twain shall meet

2007-07-05 Thread Albert Y. C. Lai
Dougal Stanton wrote: do (hin, hout, herr, ph) - runInteractiveProcess cmd args Nothing Nothing forkIO $ hPutStr hin content hClose hin out - hGetContents hout return (ph, out) which seems to require threading. If I compile without, it will hang indefinitely, I presume deadlocked. Is

Re: [Haskell-cafe] Callback functions?

2007-07-02 Thread Albert Y. C. Lai
Hugh Perkins wrote: What makes a callback different from any other kind of function? Well... what about inside monads? Does this break purity??? Does this require adding IO to the monad if the callback function does IO? As I'm writing this I kindof have this sense inside me that this is

Re: [Haskell-cafe] Collections

2007-06-20 Thread Albert Y. C. Lai
Andrew Coppin wrote: But what kind of thing would you use a general graph for? (Rather than some more specific custom data type.) Representing networks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Collections

2007-06-19 Thread Albert Y. C. Lai
Take a look at http://www.haskell.org/ghc/docs/latest/html/libraries/index.html There are more elsewhere. I am actually amazed that we have a comprehensive, widely-distributed package for graphs and graph algorithms. I can't say the same about other programming communities (they tend to

Re: [Haskell-cafe] found monad in a comic

2007-06-14 Thread Albert Y. C. Lai
Andrew Coppin wrote: ...is everybody else looking at a different web page to me? *blinks* Everybody is interpreting it differently. (As usual.) I see an unsafePerformIO. :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: Keys and Maps [Was: Re: I just don't get it (data structures and OO)]

2007-06-07 Thread Albert Y. C. Lai
Justin Bailey wrote: On 6/7/07, Grzegorz [EMAIL PROTECTED] wrote: All this hard work for something that in a lesser language would be the unimpressive: universe[Milky Way][Sun] ;-P Well, if you want to get picky there is the '!' operator defined in Data.Map: universe ! Milky Way ! Sun I

Re: [Haskell-cafe] FP v. OOP

2007-06-06 Thread Albert Y. C. Lai
Michael T. Richter wrote: I'm tempted to quote something about history, learning and repetition now, but won't bother because I suspect most of the people in this mailing list know the quote and have learned from history. Those who have learned from history are bound to helplessly watch it

Re: [Haskell-cafe] What puts False before True?

2007-06-05 Thread Albert Y. C. Lai
PR Stanley wrote: What do the ≤ symbols represent? I see you are still stuck in ISO-8859-1 and deprived of international characters and symbols. (And this reply in ISO-8859-1 too accordingly; normally I use UTF-8.) Unicode and UTF-8 FTW! :) ___

Re: [Haskell-cafe] newbie question on Parsers from Programming In Haskell

2007-06-04 Thread Albert Y. C. Lai
Dan Weston wrote: Is this true? I thought do (like all sugar) was desugared before semantic analysis. So long as you have the right =, return, and fail in scope, I would have thought the desugaring is oblivious to their definition (and particularly ignorant of instancing of the Monad

Re: [Haskell-cafe] What puts False before True?

2007-06-04 Thread Albert Y. C. Lai
Scott Brickner wrote: It's actually not arbitrary. [...] A ≤ B iff A ⊆ B A ⊆ B iff (x ∊ A) ⇒ (x ∊ B) Alternatively and dually but equally naturally, A ≥ B iff A ⊆ B iff (x ∊ A) ⇒ (x ∊ B) and then we would have False True. Many of you are platonists rather than formalists; you have a

Re: [Haskell-cafe] What puts False before True?

2007-06-01 Thread Albert Y. C. Lai
PR Stanley wrote: The question, however, still remains: why False = 0 and True 1? I appreciate that it's so in boolean algebra but why? Why not True = 0 and False = 1? A Boolean value denotees veracity whereas an ordered value concerns magnitude (priority), indeed, order!! Other members have

Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-30 Thread Albert Y. C. Lai
Roberto Zunino wrote: I actually misread the first one as Control.Monad.Fix.fix ((1:) . tail . scanl (+) 1) which is quite nice too, although map (2^) [0..] would be much simpler! ;-) We apply a lesson learned from my last derivation. The lesson was to look at s!!(n+1). s = 1 : tail

Re: [Haskell-cafe] Cute code [was: The C Equiv of != in Haskell miscommunication thread]

2007-05-29 Thread Albert Y. C. Lai
Vincent Kraeutler wrote: Donald Bruce Stewart wrote: P.S. Have some cute code: Control.Monad.Fix.fix ((1:) . scanl (+) 1) either way, if one of the Masters Of The Shadow Y Style on this list feels like throwing in another koan or two, you'll have at least one thankful audience member

Re: [Haskell-cafe] Control.Monad.State.Strict, mdo and let

2007-05-29 Thread Albert Y. C. Lai
Gracjan Polak wrote: Hi, I stumbled at some interaction of Control.Monad.State.Strict, mdo and let I do not understand. The following program: {-# OPTIONS_GHC -fglasgow-exts #-} module Main where import Control.Monad.State.Strict thenumber :: Float thenumber = flip execState 1.3 $ mdo c

Re: [Haskell-cafe] Why this exception occurs ?

2007-05-25 Thread Albert Y. C. Lai
Donald Bruce Stewart wrote: instance Num String anyone? Mwhaha addString xs ys = add 0 xs ys where m = fromEnum (maxBound :: Char) + 1 alu c x y = let s = c + fromEnum x + fromEnum y in if s = m then (1, s-m) else (0, s) add c (x:xs) (y:ys) = case alu c x

Re: [Haskell-cafe] Stack overflow

2007-05-24 Thread Albert Y. C. Lai
Grzegorz wrote: hammingDistance [] _ = 0 hammingDistance _ [] = 0 hammingDistance (x:xs) (y:ys) | x==y = hammingDistance xs ys | otherwise = 1 + hammingDistance xs ys hammingDistance xs ys = h xs ys 0 where h [] _ n = n h _ [] n = n h

Re: [Haskell-cafe] Currying: The Rationale

2007-05-23 Thread Albert Y. C. Lai
PR Stanley wrote: What is the rationale behind currying? Given map :: (a-b) - [a]-[b] take :: Int - [a] - [a] I can write map f . take 10 or take 10 map f. Given tmap :: (a-b, [a]) - [b] ttake :: (Int, [a]) - [a] I have to write \x - tmap(f, ttake(10, x)). It is not just

Re: [Haskell-cafe] Re: Editor

2007-05-22 Thread Albert Y. C. Lai
This recent development of the thread leads me to these conclusions and conjectures. * If you want to demonstrate the mouse to be faster than the keyboard, you can contrive an experiment to do so. Example: Randomize occurences of X's in a text, ask to replace them by Y's, but make sure there

Re: [Haskell-cafe] Editor

2007-05-21 Thread Albert Y. C. Lai
Michael T. Richter wrote: 1. A real GUI environment that takes into account some of the HID advances made in the past 30 years. (Emacs and Vim don't count, in other words.) I for my life think HID refers to human input devices: keyboard, mouse, joystick, gamepad, pedal,

Re: [Haskell-cafe] global variables

2007-05-20 Thread Albert Y. C. Lai
Adrian Hey wrote: Also, I don't know if the OP was a noob, but telling people (especially noobs) that if they can't figure out how to solve a problem without using a global variable then that must be down to inexperience and general cluelessness on their part just seems wrong to me. It simply

Re: [Haskell-cafe] quiry

2007-05-16 Thread Albert Y. C. Lai
Pixel wrote: from http://pleac.sourceforge.net/pleac_haskell/numbers.html#AEN118 : -- read handles both octal and hexadecimal when prefixed with 0x or 0o -- here are versions adding the prefix and calling read hex s = read (0x ++ s) :: Integer oct s = read (0o ++ s) :: Integer -- hex 45 == 69

[Haskell-cafe] Imagining a G-machine

2007-05-16 Thread Albert Y. C. Lai
A native G-machine --- physical, or chemical, or biological, but not a repressed simulation over the imperative cpu-memory architecture --- is the dream of every lazy-functional programmer of great devotion. If only it became the dominant computing architecture! People would say, Haskell is

Re: [Haskell-cafe] Is Excel a FP language?

2007-04-24 Thread Albert Y. C. Lai
Tony Morris wrote: My opposition proposed (after some weeding out) that there is a distinction between Excel, the application, the GUI and Excel, the language (which we eventually agreed (I think) manifested itself as a .xls file). I say Excel is a functional language. If there needs to be the

Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-23 Thread Albert Y. C. Lai
Albert Y. C. Lai wrote: I try using WordSet = [String] (plus corresponding change in code) and get great speedup, actually way more than 3x. There was also a memory growth phenomenon using Set String, and replacement by [String] stops that too, now it's constant space (constant = 20M

Re: [Haskell-cafe] newbie question on ordering

2007-04-22 Thread Albert Y. C. Lai
Nikolay Metchev wrote: data Face = Ace | Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King deriving (Enum, Show, Eq) listComparator :: (Eq a) = [a] - a - a - Ordering listComparator xs a b = compare x y where x =

Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-21 Thread Albert Y. C. Lai
I try using WordSet = [String] (plus corresponding change in code) and get great speedup, actually way more than 3x. There was also a memory growth phenomenon using Set String, and replacement by [String] stops that too, now it's constant space (constant = 20M). It is possible to attribute

Re: [Haskell-cafe] Tutorial on Haskell

2007-04-16 Thread Albert Y. C. Lai
Neil Mitchell wrote: Things like laziness are cool, but are harder to convince a strict programmer that they are useful. Strict programmers like the yield command too. The same behaviour can be obtained by laziness, with easier reasoning. That said, strict programmers may or may not like

Re: [Haskell-cafe] Parsec: buildExpressionParser of a different type than parsed term

2007-04-09 Thread Albert Y. C. Lai
Joel Reymont wrote: I'm trying to parse NumExpr NumExpr (example) which should return a logical expression while parsing numeric terms. I can't figure out how to make buildExpressionParser do this for me since it takes the type of the term parser given to it. If I supply a parser for numeric

Re: [Haskell-cafe] Parsec: buildExpressionParser of a different type than parsed term

2007-04-09 Thread Albert Y. C. Lai
Albert Y. C. Lai wrote: However, you can make two uses of buildExpressionParser, one for numeric expressions and the other for logical expressions. Mutual reference is no problem since, OK, I now see this is easier said than done in most common applications

Re: [Haskell-cafe] Parsec: Help needed with simple parser

2007-04-09 Thread Albert Y. C. Lai
Joel Reymont wrote: My expression is x + 1 where x can be either Close, or Close[N] or Close[N] of DataM where N and M are positive integers. What happens in my case is that 1 + x parses fine but x + 1 doesn't. In fact, I would be fine with parsing Close + such that it ignores the plus and

Re: [Haskell-cafe] Keeping a symbol table with Parsec

2007-04-02 Thread Albert Y. C. Lai
Joel Reymont wrote: Meaning that if a keyword Output is followed by : and an identifier and then (NumericSimple) then add identifier to the symbol table as a Number and box it in a constructor. Then in my lexer I do a lookup to check if I have seen this identifier and if I have seen one of

Re: [Haskell-cafe] infinite lists

2007-03-27 Thread Albert Y. C. Lai
Matthias Fischmann wrote: here is the bug, narrowed to four lines. a function that only sometimes terminates. f = do n - randomRIO (0,5) let l = replicate n '*' i = join $ repeat l -- infinite extension print (take 12 i) In this paragraph I speak about just this program,

Re: [Haskell-cafe] Algorithms

2007-03-19 Thread Albert Y. C. Lai
P. R. Stanley wrote: yes, this is good. So, let's start with A. How would you sope the problem? What's your algorithm for identifying problems? What is understanding? Discuss... To relate a problem to known problems, I think I use a heuristic search that may bite the bullet and do a

Re: [Haskell-cafe] There can be only one fix? Pondering Bekic's lemma

2007-03-19 Thread Albert Y. C. Lai
Nicolas Frisby wrote: My question is: Given products and a fixed point combinator, can any pure expression be transformed into a corresponding expression that has just a single use of fix? If yes, has there been any usage of such a transformation, or is it just crazy? Yes. One use is

Re: [Haskell-cafe] Algorithms

2007-03-17 Thread Albert Y. C. Lai
P. R. Stanley wrote: When you write a general solution for a class of problems, as opposed to a specific solution to a single problem, you have written an algorithm. Discuss! Follow this algorithm of three easy steps to solve any problem: A. understand the problem B. decompose or reduce it

Re: [Haskell-cafe] Haskell beginner

2007-03-15 Thread Albert Y. C. Lai
Sebastian Sylvan wrote: So here's the strategy: 1. Read tutorials 2. When you get stuck, ask on #haskell 3. Goto 1 (yes I deliberately wrote an imperative algorithm using gotos to describe how to learn Haskell, and I found it amusing) It is just a standard transformation away from a

Re: [Haskell-cafe] How to convert Num a = a to Int

2007-03-14 Thread Albert Y. C. Lai
Moreover: from RealFrac to Int (or Integral): truncate, round, ceiling, or floor, depending on how you want to lose information. from Num to Int: there is none with such generality, since there are too many conceivable variations. ___

Re: [Haskell-cafe] Mixed-type arithmetic, or type coercion

2007-03-13 Thread Albert Y. C. Lai
Dave Hinton wrote: Arithmetic operators in haskell appear to require their operands to have the same type. How can I do arithmetic between operands of different types? Alternatively, how do I coerce a value from being an Int to being a Double? fromIntegral can do this coercion. It is more

Re: [Haskell-cafe] Type and State Confusion

2007-03-12 Thread Albert Y. C. Lai
Hans van Thiel wrote: sequence :: Monad m = [m a] - m [a] You write: The = used by sequence is the same = in the MyState monad, since you instantiate m to MyState String. Therefore, sequence performs all the state transformations correctly, since = is correct. So the m becomes MyState String,

Re: [Haskell-cafe] Maybe and partial functions

2007-03-12 Thread Albert Y. C. Lai
Dougal Stanton wrote: The Maybe construction is very useful for explicitly handling circumstances where the function cannot produce a sensible answer. But how far should this notion be taken? When you're writing a function which you realise may not produce what you want, in what circumstances

Re: [Haskell-cafe] State of Ignorance

2007-03-11 Thread Albert Y. C. Lai
Hans van Thiel wrote: toMyState :: String - MyState String Int toMyState x = MyStateC (repl1 x) where the monad is defined as: data MyState a b = MyStateC ([a] - ([a], b)) instance Monad (MyState a) where return x = MyStateC (\tb - (tb, x)) (MyStateC st) = f = MyStateC (\tb

Re: [Haskell-cafe] Re: Trouble with record syntax and classes

2007-02-27 Thread Albert Y. C. Lai
Thomas Nelson wrote: data ISine = Sine Integer Integer Integer String | MetaSine Integer Integer Integer [ISine] Having advised you to use different field names for different record types last time, I now confuse you by saying you can share field names in the different cases

Re: [Haskell-cafe] Trouble with record syntax and classes

2007-02-26 Thread Albert Y. C. Lai
All record fields are in the same namespace, and furthermore this is also the same namespace of functions and class methods. In other words you cannot have two record types containing the same field name, and you cannot have a record field and a function using the same name, and you cannot

Re: [Haskell-cafe] process

2007-02-22 Thread Albert Y. C. Lai
h. wrote: But it does not work as I expected. As long as there is no need to put some input after having received some output it is no problem, but real interaction seems not possible. Right, this particular program works just for a particular interaction. What real interaction do you have

Re: [Haskell-cafe] A real Haskell Cookbook

2007-02-22 Thread Albert Y. C. Lai
Call me a technophile, but it saddens me that ASCII has already held us back for too many decades, and looks like it will still hold us back for another. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] functional database queries

2007-02-21 Thread Albert Y. C. Lai
Henning Thielemann wrote: At http://www.haskell.org/hawiki/HaskellDbTutorial it is described, how database queries can be modelled with a monad. However, I wonder if this is also possible without monads. Say, writing DB.map col1 $ DB.filter (\row - col2 row == 10+2) myTable for SELECT col1

Re: [Haskell-cafe] Re: functional database queries

2007-02-21 Thread Albert Y. C. Lai
[EMAIL PROTECTED] wrote: Albert Y. C. Lai wrote: If and only if the database is a purely functional immutable data structure, this can be done. [...] Many interesting databases are not purely functional immutable; most reside in the external world and can spontaneously change behind your

Re: [Haskell-cafe] Network.CGI.Compat.pwrapper

2007-02-12 Thread Albert Y. C. Lai
Bjorn Bringert wrote: pwrapper is not an HTTP server, though the Haddock comment can make you think so. pwrapper allows you to talk *CGI* over a TCP port, but I have no idea why anyone would like to do that. Here is a scenerio. I want a basic web application: someone makes a request, and my

<    1   2   3   4