Re[2]: [Haskell-cafe] Inheritance without OOHaskell
Hello Cale, Saturday, January 14, 2006, 12:22:08 AM, you wrote: CG On 13/01/06, John Goerzen [EMAIL PROTECTED] wrote: i want to answer, but Gale covered all that i have to say :) the only additions is that i use more old-fashioned Hugs-compatible declarations instead of GADT-style CG data Connection where CG Conn :: (IsConnection c) = c - Connection data Connection = forall c . (IsConnection c) = Conn c and that i use the delegation pattern: class (Show h) = Stream h where vClose :: h - IO () .. vSetEncoding :: h - Encoding - IO () vGetEncoding :: h - IO Encoding data WithEncoding h = WithEncoding h (IORef Encoding) openWithEncoding encoding h = do e - newIORef encoding return (WithEncoding h e) instance (Stream h) = Stream (WithEncoding h) where vClose(WithEncoding h _) = vClose h vIsEOF(WithEncoding h _) = vIsEOF h vMkIOError(WithEncoding h _) = vMkIOError h vReady(WithEncoding h _) = vReady h .. vSetEncoding (WithEncoding h e) = writeIORef e vGetEncoding (WithEncoding h e) = readIORef e you can see WithEncoding type as a one adding server-specific features to general driver implementation. of course, this idea of stream transformers is more general that you really requested, but the delegation pattern will remain the same -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] formal methods functional programming
Hi, I have been searching papers about tha raltionship between formal methods in software engineering and functinal programmming, but i haven't found enough information. can u hel me?. Thanks Abigail. __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.espanol.yahoo.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Formated output with ghci
A 'stupid' question (sort of an embarassing one): I want to do formated output by converting data types to strings and the bring them in a formated way together. I use ghci 6.4 and when I want to see this text then it is shown as a string (i.e. with ... added around) and the formating characters in the text (e.g. \n) are quoted and not executed. (if I apply show to the text string, then the above is done twice!) This does occur if I use a defined function (something like 'toString' or 'text') and does not occur if I use show (but I have other reasons not to use show). Is there a cure to have output formated with ghci without using show to individually convert data types into strings? Here an example output: text s2 last id used #2\n\n(#2,EntType {unEntType = \Point\})\n(#1,EntType {unEntType = \Point \})\n\n\n deleted\nRelX empty\n\nHCons (Region2start \start of region\,RelX empty\n) ( HCons (Region2end \end of region\,RelX empty\n) (HCons (Point2coord \Coordinates of Poi nt\,\n(#2,\n[NV 0.0 100.0])\n(#1,\n[NV 0.0 0.0])\n\n) HNil)) Wrapping the text string into a data type and then apply show to this data type gives also the desired result. Is there an easier way? Help is highly appreciated module OutputTest where data X = X Int Int Floatderiving (Show) x1 = X 3 4 4.5 text :: X - String text (X a b c) = show a ++ show b ++ \n ++ show c -- example output -- text x1 --34 \n4.5 data T a = T a instance Show a = Show (T a) where show (T a) = Tx ++ show a tx1 = T x1 instance Show (T X) where show (T a) = text a works: -- tx1 --34 --4.5 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Formated output with ghci
On 14/01/06, Frank [EMAIL PROTECTED] wrote: A 'stupid' question (sort of an embarassing one): I want to do formated output by converting data types to strings and the bring them in a formated way together. I use ghci 6.4 and when I want to see this text then it is shown as a string (i.e. with ... added around) and the formating characters in the text (e.g. \n) are quoted and not executed. (if I apply show to the text string, then the above is done twice!) This does occur if I use a defined function (something like 'toString' or 'text') and does not occur if I use show (but I have other reasons not to use show). Is there a cure to have output formated with ghci without using show to individually convert data types into strings? Here an example output: text s2 last id used #2\n\n(#2,EntType {unEntType = \Point\})\n(#1,EntType {unEntType = \Point \})\n\n\n deleted\nRelX empty\n\nHCons (Region2start \start of region\,RelX empty\n) ( HCons (Region2end \end of region\,RelX empty\n) (HCons (Point2coord \Coordinates of Poi nt\,\n(#2,\n[NV 0.0 100.0])\n(#1,\n[NV 0.0 0.0])\n\n) HNil)) Wrapping the text string into a data type and then apply show to this data type gives also the desired result. Is there an easier way? Help is highly appreciated module OutputTest where data X = X Int Int Floatderiving (Show) x1 = X 3 4 4.5 text :: X - String text (X a b c) = show a ++ show b ++ \n ++ show c -- example output -- text x1 --34 \n4.5 data T a = T a instance Show a = Show (T a) where show (T a) = Tx ++ show a tx1 = T x1 instance Show (T X) where show (T a) = text a works: -- tx1 --34 --4.5 Basically, GHCi and Hugs follow the rule that if the expression you type is an IO action, then that action gets run, and otherwise, the function 'print' is applied to it automatically, to print the value. The print function is the composition of putStrLn with show, and the show instance for Strings quotes them. The solution is to explicitly apply putStrLn to your String value rather than letting it be quoted. putStrLn $ text x1 34 4.5 - Cale ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] powerful type checking false expectations that a program is correct
Programmers who use languages without static type checking sometimes claim that static type checking gives folk the false impression that once the program passes type checking the program is correct. That always seemed silly to me, but I'm starting to wonder ;-) Of course, the shootout programs are a silly entertainment; but after taking the time to optimise and write the programs, I'm a little surprised that there have been Haskell contributions which just don't give 'the correct answer' in a way that visual inspection with the expected answer would detect. For example ackermann Haskell GHC program regex-dna (new) Haskell GHC #2 program Oh well, they are just easy to fix formating bugs :-) __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Inheritance without OOHaskell
Hi, I would like to add some minor improvement on usability of the existential type Connection proposed by Bulat. data Connection = forall c . (IsConnection c) = Conn c The thing is that you usually have functions like send :: (isConnection c) = c - String - IO() or whatever. In order to be able to feed a variable of type Connection into functions like send it is handy to define instance IsConnection Connection where foo (Conn c) = foo c setFoo bar (Conn c) = Conn $ setFoo bar c ... which delegates functions into the item inside the exitential wrapper. Cheers, Georg -- Georg Martius, Tel: (+49 34297) 89434 --- http://www.flexman.homeip.net - pgptjsuHVMKMf.pgp Description: PGP signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] formal methods functional programming
I can't think of any Haskell papers about ``formal methods'' in software engineering, but many papers and books talk about proving program correctness, which is difficult in traditional, imperative languages (which is why it is probably not stressed as much as //testing// is in formal software methods). Paul Hudak, in the textbook, The Haskell School of Expression (http://www.amazon.com/gp/product/0521644089/104-7074974-5852762?v=glancen=283155) writes a lot about proving program correctness (especially induction on recursive algorithms) for Haskell and purely functional programs, reasoning mathematically. If you want to do strenuous testing, you can use QuickCheck: Automatic Specification-Based Testing: http://www.cs.chalmers.se/~rjmh/QuickCheck/ A professor I had at Caltech researches formal methods in constructing reliable software systems, specifically using robust programming language and compiler technology (in this case OCaml). http://mojave.caltech.edu/ Jared. On 1/14/06, Abigail [EMAIL PROTECTED] wrote: Hi, I have been searching papers about tha raltionship between formal methods in software engineering and functinal programmming, but i haven't found enough information. can u hel me?. Thanks Abigail. __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.espanol.yahoo.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- [EMAIL PROTECTED] http://www.updike.org/~jared/ reverse )-: ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] using cabal? add your package to the list!
I started a list of packages using cabal (including those uplaoded to Hackage). Please either upload your packages to hackage, or add it here. I want this list so that I can try to figure out things like how much a given modification to Cabal will break stuff: http://hackage.haskell.org/trac/hackage/wiki/CabalPackages To add your package to the list, hit Edit Page at the bottom of the page. Feel free to make the page into a table, add links for the packages already there, reorganize, etc. peace, isaac ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Shootout rankings
:D Haskell now ranked 2nd overall, only a point or so behind C: http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=all And still a bit more we can squeeze out... -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] formal methods functional programming
Abigail [EMAIL PROTECTED] writes: Hi, I have been searching papers about tha raltionship between formal methods in software engineering and functinal programmming, but i haven't found enough information. I don't think there are any papers, but Galois Connections employs Haskell and formal methods such as proof checkers in our work. You might email for more information: http://www.galois.com/ peace, isaac ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Shootout rankings
On Sun, 2006-01-15 at 14:01 +1100, Donald Bruce Stewart wrote: :D Haskell now ranked 2nd overall, only a point or so behind C: http://shootout.alioth.debian.org/gp4/benchmark.php?test=all〈=all And still a bit more we can squeeze out... I saw it a day or two ago, but thought it mut be some error :-) Huh, now I have to go doing some Haskell advo *cough* some mailing. Sincerely, Gour signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe