Re: [Haskell-cafe] adjunction of product and exponentiation
Thanks! -- _jsn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Last Call for the Italian Haskellers Summer Meeting
On Thursday 07 August 2008 19:35:17 Dan Weston wrote: Shouldn't that be posta elettronica (or posteletta along the lines of the Frence courriel)? Somehow I doubt that Dante would have approved of the word email. Actually I don't think that he would have disapproved. Dante wrote the Divina Commedia in the Florentine dialect, a 'vulgar' language that was far from codified and quite open to external influences. Mussolini, on the contrary, with his nationalistic/racist mindset would have been mightly pissed off by my usage of 'email' and would have certainly insisted for 'posta elettronica' (a perfect valid term by the way, just a bit longer than necessary). But then who cares if Mussolini spins in his grave? Best, titto Titto Assini wrote: As usual we will now switch to Dante's bella lingua. Ottimissimi, mancano pochi giorni al primo incontro estivo/balneare degli haskeller italiani. Per informazioni e registrarsi date uno sguardo a: http://www.haskell.org/haskellwiki/ItaloHaskell/Summer_2008 Oppure contattate il sottoscritto via email o per telefono al 0584 791669. A presto ragazzi, titto -- Pasqualino Titto Assini PhD 25 Heath Road - Wivenhoe CO79PT - Colchester - U.K. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building fastcgi from hackage on windows.
have you installed this? http://www.softpedia.com/progDownload/Microsoft-FastCGI-Extension-for- IIS-Download-84830.html I use Asp.Net when I'm on Windows, so I don't know the answers to your questions but you might find more info on running it here http://forums.iis.net/1103.aspx Iain On 8 Aug 2008, at 2:10 am, Edward Ing wrote: Oh yes. I should mention that I am building this on Windows XP. I build Network.FastCGI on Ubuntu and it worked because I was able to install the libfcgi-dev (which had the libraries and the headers.) My guess is that WIndows XP is the problem, and that the task of building on XP is quite different. Where are include headers and libraries found in Windows XP system? What fastcgi implementation would you need for a Windows XP? These are the probably the important questions. Edward Ing On Thu, Aug 7, 2008 at 7:54 PM, Iain Barnett [EMAIL PROTECTED] wrote: On 7 Aug 2008, at 8:58 pm, Edward Ing wrote: I am using the cabal system to build the hackage version of fastcgi. I get the below messages with the runghc Setup.lhs build command. Network\FastCGI.hsc:59:21: fcgiapp.h: No such file or directory Network\FastCGI.hsc: In function `main': Network\FastCGI.hsc:200:0: error: `FCGX_Request' undeclared (first use in this function) It looks like I need the fastcgi sources. Where does this source come from? I didn't get any dependency messages when I did the setup config. Edward Ing I had a similar problem about a month ago, but I can't remember *exactly* what I did to fix it. I think I made sure the following were installed (I'm pretty sure I ran cabal installs for all of them regardless of what ghc-pkg told me, and it worked) network-2.0 alex-2.2 HTTP-3001.0.4 cgi-3001.1.6.0 From my cabal build-log: ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: interval and polynomial enclosure arithmetics
Hello, I have recently released the following two Haskell packages, which model and reasonably efficiently implement exact real arithmetic: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/AERN-Real implements arbitrary-precision interval arithmetic for approximating real numbers http://hackage.haskell.org/cgi-bin/hackage-scripts/package/AERN-RnToRm implements arbitrary-precision arithmetic of bounded-degree piecewise-polynomial enclosures for approximating functions of type R^n - R^m The libraries are fairly stable and complete (AERN-Real more so than AERN-RnToRm) and members of the KEG research group at Aston University have used it for reliably solving differential equations and numerical constraint satisfaction problems. Also, the libraries are designed in multiple levels of abstraction that are clearly separated by type classes. Thanks to this it is very easy to switch between different implementations of the lower-levels, eg using a different floating point type or different representation of polynomials. There are many similarities between AERN-Real and Augustsson's numbers package. The main difference is in how the bit-size of arbitrary precision floating point numbers is determined. In numbers, the bit size is determined statically via types using a type-level encoding of natural numbers. In AERN-Real, the bit-size is part of the floating-point number, which slows the arithmetic down a bit but one can change precision dynamically. Best regards, Michal -- |-| Dr. Michal Konecny, Computer Science, Aston University |-| Room MB212D | Tel +44 121 204 3462 | Fax +44 121 204 3681 |-| http://www.aston.ac.uk/~konecnym |-| OpenPGP key http://www.aston.ac.uk/~konecnym/ki.aston 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
[Haskell-cafe] Re: USB and serial port
Interesting! The new version of the library really deserves a wrapper. Thanks, Maurício I'm currently using partial wrapper around libusb[1] in my work. It doesn't provide full interface to the library itself, so I didn't have to translate C structures. Perhaps someone can make a regular wrapper - the libusb API is pretty small and concise. Regards, Christopher Skrzętnicki [1] http://libusb.wiki.sourceforge.net/ On Wed, Aug 6, 2008 at 23:11, Maurício [EMAIL PROTECTED] wrote: Hi, What are the alternatives to read a USB port(...) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building fastcgi from hackage on windows.
I have this installed. The problem is that I have no binary version of the Network.FastCGI. So to install it I am going through the cabal process and on the build it seems to need the Fastcgi.h to build the foreign interfaces (and probably the static libraries to link ?). Unfortunately the Microsoft download pack doesn't have that - just the .dll (or perhaps cabal can't find where the fastcgi.h are). Edward Ing On Fri, Aug 8, 2008 at 6:08 AM, Iain Barnett [EMAIL PROTECTED] wrote: have you installed this? http://www.softpedia.com/progDownload/Microsoft-FastCGI-Extension-for-IIS-Download-84830.html I use Asp.Net when I'm on Windows, so I don't know the answers to your questions but you might find more info on running it here http://forums.iis.net/1103.aspx Iain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: USB and serial port
Which version do you consider new: the current 0.1.12 or the future 1.0 version? Regards, Christopher Skrzętnicki On Fri, Aug 8, 2008 at 14:54, Maurício [EMAIL PROTECTED] wrote: Interesting! The new version of the library really deserves a wrapper. Thanks, Maurício I'm currently using partial wrapper around libusb[1] in my work. It doesn't provide full interface to the library itself, so I didn't have to translate C structures. Perhaps someone can make a regular wrapper - the libusb API is pretty small and concise. Regards, Christopher Skrzętnicki [1] http://libusb.wiki.sourceforge.net/ On Wed, Aug 6, 2008 at 23:11, Maurício [EMAIL PROTECTED] wrote: Hi, What are the alternatives to read a USB port(...) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Show me
Jonathan Cast wrote: instance Show x = Show (Foo x) where showsPrec n foo = (list_foo ++) . shows (foo_list foo) You use the n parameter if you've got an infix operator in your syntax and you want to put parentheses around an instance of it if n has the wrong value (either too high or too low, I can never remember). OK. So... should the call to shows actually be showsPrec? Or does it not matter in this case? Actually, now that I think of it, my *next* problem is going to be writing a matching Read instance... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Phantoms
I just (re)discovered that I can do things like data Foo x = Foo Int Int Now Foo Int and Foo Double are, as far as the type checker cares, two completely different types, even though in fact they are the same. This is actually Quite Useful, in the particular case I'm working on. Here's the thing though... How do I get it so that Foo Int and Foo Double produce slightly different strings when printed? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: USB and serial port
1.0. By the time one finishes a Haskell wrapper, 1.0 will be probably available, so I think it's better to start with that. Which version do you consider new: the current 0.1.12 or the future 1.0 version? Regards, Christopher Skrzętnicki On Fri, Aug 8, 2008 at 14:54, Maurício [EMAIL PROTECTED] wrote: Interesting! The new version of the library really deserves a wrapper. Thanks, Maurício I'm currently using partial wrapper around libusb[1] (...) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Phantoms
Hello Andrew, Wednesday, August 6, 2008, 10:09:43 PM, you wrote: Here's the thing though... How do I get it so that Foo Int and Foo Double produce slightly different strings when printed? instnace Show (Foo Int) ... instnace Show (Foo Double) ... -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Show me
On Wed, 2008-08-06 at 19:06 +0100, Andrew Coppin wrote: Jonathan Cast wrote: instance Show x = Show (Foo x) where showsPrec n foo = (list_foo ++) . shows (foo_list foo) You use the n parameter if you've got an infix operator in your syntax and you want to put parentheses around an instance of it if n has the wrong value (either too high or too low, I can never remember). OK. So... should the call to shows actually be showsPrec? Or does it not matter in this case? According to http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/GHC-Show.html#shows, shows = showsPrec 0 (which is a global function like show, not a class method). In this case, showsPrec will then further dispatch to your showList method, which has the default implementation, which will ignore the precedence parameter. So it doesn't matter in this case. Actually, now that I think of it, my *next* problem is going to be writing a matching Read instance... Are you familiar with Text.ParserCombinators.ReadP? http://www.haskell.org/ghc/docs/latest/html/libraries/base/Text-ParserCombinators-ReadP.html? It's an explicit monad, so it's rather easier to use that ReadS. jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Phantoms
Hi Andrew, Here's an example that might help: import Data.Typeable data Test a = Test Int instance Typeable a = Show (Test a) where show t@(Test i) = Test ++ show (typeOf (ty t)) ++ ++ show i where ty :: Test a - a, ty = undefined and its use: *Main show (Test 10 :: Test Int) Test Int 10 *Main show (Test 10 :: Test String) Test [Char] 10 --trevor On Wed, 2008-08-06 at 19:09 +0100, Andrew Coppin wrote: I just (re)discovered that I can do things like data Foo x = Foo Int Int Now Foo Int and Foo Double are, as far as the type checker cares, two completely different types, even though in fact they are the same. This is actually Quite Useful, in the particular case I'm working on. Here's the thing though... How do I get it so that Foo Int and Foo Double produce slightly different strings when printed? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe 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
[Haskell-cafe] please help me to find errors from my first app
Hi. I want to write a reverse proxy like perlbal to practive haskell. Now I just write a very simple script to forward any request to www.google.com. but it dosn't work. I run command ' runhaskell Proxy.hs' and 'wget http://localhost:8080/'. but wget just wait forever and runhaskkell can get request. when I break wget, the 'runhaskell' can print response returned from www.google.com. why? module Main where import System.Posix.Process import Network import Prelude hiding (putStr) import System.IO hiding (hGetContents, putStr) import Control.Concurrent import System.Posix.Signals import Data.ByteString.Lazy.Char8 (hGetContents, hPut, putStr,hGet,cons) listenPort = PortNumber 8080 connectToHost = 208.67.219.230 connectToPort = PortNumber 80 main :: IO () main = do hSetBuffering stdout NoBuffering socket - listenOn listenPort let doLoop = do (hdl, _, _) - accept socket forkIO $ processRequest hdl doLoop doLoop processRequest :: Handle - IO () processRequest hRequest = do installHandler sigPIPE Ignore Nothing; hSetBuffering hRequest NoBuffering hSetBuffering stdout NoBuffering request - hGetContents hRequest putStr $ '' `cons` (' ' `cons` request) hResponse - connectTo connectToHost connectToPort hSetBuffering hResponse NoBuffering hPut hResponse request response - hGetContents hResponse putStr $ '' `cons` (' ' `cons` response) hPut hRequest response hClose hRequest hClose hResponse -- Thanks Regards Changying Li ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Phantoms
On Wed, 6 Aug 2008, Andrew Coppin wrote: I just (re)discovered that I can do things like data Foo x = Foo Int Int Now Foo Int and Foo Double are, as far as the type checker cares, two completely different types, even though in fact they are the same. This is actually Quite Useful, in the particular case I'm working on. Here's the thing though... How do I get it so that Foo Int and Foo Double produce slightly different strings when printed? The non-hacky Haskell 98 solution is: class ShowPhantom a where showPhantom :: Foo a - String You can call this from the 'show' implemention for 'Foo a'. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building fastcgi from hackage on windows.
Hi Edward, I have never compiled the fastcgi package on Windows myself, but my best tip would be to try to install the FastCGI development kit (= C headers and libraries), see http://www.fastcgi.com/#TheDevKit /Bjorn On Fri, Aug 8, 2008 at 4:53 PM, Edward Ing [EMAIL PROTECTED] wrote: I have this installed. The problem is that I have no binary version of the Network.FastCGI. So to install it I am going through the cabal process and on the build it seems to need the Fastcgi.h to build the foreign interfaces (and probably the static libraries to link ?). Unfortunately the Microsoft download pack doesn't have that - just the .dll (or perhaps cabal can't find where the fastcgi.h are). Edward Ing On Fri, Aug 8, 2008 at 6:08 AM, Iain Barnett [EMAIL PROTECTED] wrote: have you installed this? http://www.softpedia.com/progDownload/Microsoft-FastCGI-Extension-for-IIS-Download-84830.html I use Asp.Net when I'm on Windows, so I don't know the answers to your questions but you might find more info on running it here http://forums.iis.net/1103.aspx Iain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Currying function using values from array
2008/8/7 Sukit Tretriluxana [EMAIL PROTECTED]: How in Haskell that I can create a function that curries any other function, which receives multiple parameters, by using a the input from a list (same data type) or a tuple (mixed data type) such that it either returns another closure (if not all parameters are curried) or the final value of the computation (when all parameters are known)? Here's a solution that uses tuples only (no lists, they are somewhat more difficult to typecheck correctly), along with several tests. The payoff is functions with signatures like this: -- tncurry :: (a - b - c - r) - (a,b,c) - r -- trcurry :: ((a,b,c) - r) - a - b - c - r -- ncurry :: (a - b - c - r) - (a, (b, (c, ( - r -- rcurry :: ((a, (b, (c, ( - r) - a - b - c - r but that work on any number of arguments. (disclaimer: I've only implemented tncurry trcurry up to 4-tuples; additional tuple sizes require 3 lines of boilerplate code each). -- ryan {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fno-monomorphism-restriction #-} module Curry where -- no-monomorphism-restriction is just so we don't -- have to put dummy arguments on the tests. class IsFunction f a r | f - a r, a r - f where apply :: f - a - r instance IsFunction (a - b) a b where apply = ($) class NCurry f a r | f a - r where ncurry :: f - a - r instance NCurry r () r where ncurry x _ = x instance (IsFunction f' b f, NCurry f a r) = NCurry f' (b,a) r where ncurry f (b,a) = ncurry (apply f b) a class RCurry t x r | t x - r where rcurry :: (t - x) - r instance RCurry () r r where rcurry f = f () instance RCurry t x r = RCurry (a,t) x (a - r) where rcurry f x = rcurry (\t - f (x,t)) -- some tests test1 = ncurry (+) (5, (10, ())) -- test1 :: Num f = f -- test1 = 15 plus :: Num a = (a, (a, ())) - a plus = ncurry (+) test2 = rcurry plus -- test2 :: Num a = a - a - a test_broken = rcurry (ncurry (+)) -- test_broken :: (Num a, NCurry (a - a - a) t r, RCurry t r r1) = r1 {- test_broken 5 10 = No instances for (NCurry (a - a - a) t r, RCurry t r (t1 - t2 - t3)) This is an instance of the read.show problem; ncurry (+) has many types: ncurry (+) :: Num a = () - a - a - a ncurry (+) :: Num a = (a,()) - a - a ncurry (+) :: Num a = (a,(a,())) - a Even though rcurry would work on any of these, it's ambiguous which one to choose, so the type inferencer gives up. -} test3 = test2 5 10 -- test3 :: Num t = t -- test3 = 15 -- stupid constant function dumb a b c d = c test4 = ncurry dumb (wrong, (5, (correct, ([1..50], () -- test4 :: [Char] -- test4 = correct dumb2 (a, (b, (c, (d, () = c test5 = rcurry dumb2 -- test5 :: t - t1 - r - t2 - r test6 = rcurry dumb2 wrong 5 correct [1..50] -- test6 :: [Char] -- test6 = correct -- We can also use real tuples instead of tuple-lists, with -- some boilerplate... class TupleChange n t | n - t, t - n where toTuple :: n - t fromTuple :: t - n -- Haskell doesn't have a 1-tuple, so make it ourselves data Tuple1 x = Tuple1 x deriving (Eq, Show, Ord) instance TupleChange () () where toTuple = id fromTuple = id instance TupleChange (a, ()) (Tuple1 a) where toTuple (a, ()) = Tuple1 a fromTuple (Tuple1 a) = (a, ()) instance TupleChange (a, (b, ())) (a, b) where toTuple (a, (b, ())) = (a,b) fromTuple (a,b) = (a, (b, ())) instance TupleChange (a, (b, (c, ( (a,b,c) where toTuple (a, (b, (c, ( = (a,b,c) fromTuple (a,b,c) = (a, (b, (c, ( instance TupleChange (a, (b, (c, (d, () (a,b,c,d) where toTuple (a, (b, (c, (d, () = (a,b,c,d) fromTuple (a,b,c,d) = (a, (b, (c, (d, () tncurry f = ncurry f . fromTuple trcurry f = rcurry (f . toTuple) -- Tests of tncurry/trcurry show closures test7 = tncurry (+) (Tuple1 5) -- test7 :: Num a = a - a -- test7 10 = 15 dumb3 (a,b,c,d) = c test8 = trcurry dumb3 -- test8 :: t - t1 - r - t2 - r -- test9 creates a closure waiting for more -- arguments... test9 = tncurry dumb (foo, bar, hat) -- test9 :: t - [Char] -- test9 baz = hat -- although you do have to use tncurry again -- with each call if you want to keep applying -- it with tuples test10 = tncurry (tncurry dumb (foo, bar, hat)) (Tuple1 baz) -- test10 :: [Char] -- test10 = hat ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Currying function using values from array
Sukit Tretriluxana schrieb: Thanks Tom and Henning for your response. Let me put the question in another way by generalizing and tweaking it a little bit. How in Haskell that I can create a function that curries *any *other function, which receives multiple parameters, by using a the input from a list (same data type) or a tuple (mixed data type) such that it either returns another closure (if not all parameters are curried) or the final value of the computation (when all parameters are known)? Is this a theoretical question or do you actually need this? If yes, I wonder what application it may be. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Currying function using values from array
Thanks so much for the response so far. To Lemming's question, this is just a theoretical question. I try comparing what I can do in Groovy with Haskell. So far I could come up with solutions but not this one. I'm not an expert on this but I'm not sure if template haskell or type class would come to rescue this situation. And if so, I wonder how it looks like. Ed On Fri, Aug 8, 2008 at 2:39 PM, Lemming [EMAIL PROTECTED]wrote: Sukit Tretriluxana schrieb: Thanks Tom and Henning for your response. Let me put the question in another way by generalizing and tweaking it a little bit. How in Haskell that I can create a function that curries *any *other function, which receives multiple parameters, by using a the input from a list (same data type) or a tuple (mixed data type) such that it either returns another closure (if not all parameters are curried) or the final value of the computation (when all parameters are known)? Is this a theoretical question or do you actually need this? If yes, I wonder what application it may be. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe