Re: [Haskell-cafe] [reactive] A pong and integrate

2010-05-19 Thread Patai Gergely
 I that the saw sleep time at each loop is fixed (0.02). So game speed
 will
 depend on processor speed, since with a more powerful CPU frames will be
 computed quicklier?
Yes, that's how it works.

 So we don't have (with the Simple branch) some way to say I want my
 sprite
 to move 100 pixels *per second* on the left, except if we provide
 ourselves a time signal?
That's exactly the case, although I'd probably provide a delta time
signal. The Simple version is a discrete stream library, and it doesn't
pretend to have continuous-time abstractions.

Gergely

-- 
http://www.fastmail.fm - Access your email from home and the web

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-install

2010-05-19 Thread Serguey Zefirov
2010/5/19 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com:
 Serguey Zefirov sergu...@gmail.com writes:
 Why there is no switch to turn off any use of proxy in cabal-install?
 Or to supply username/password pair in command line.
 I have a strange situation: wget works like charm ignoring proxy (I
 downloaded Cabal and cabal-install to investigate the problem using
 wget), Firefox works like charm igoring proxy, and only cabal cannot
 access anything, because it follows proper proxy protocol and our
 proxy requires username and password.
 Ignoring proxy?

Yes, they go right to internet. Firefox set to No proxy connection type.

 And I don't know of proper way to supply them through http_proxy
 environment variable.
 export http_proxy=http://${username}:${passwo...@${proxy_url};

I tried it and it didn't work. I don't know reason, though, maybe it
was because my current password not entirely alphanumeric.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Ralph Hodgson
Hello Neil ,

 

I was using TagSoup 0.8 with great success. On upgrading to 0.9 I have this
error:

 

TQ\TagSoup\TagSoupExtensions.lhs:29:17:

`Tag' is not applied to enough type arguments

Expected kind `*', but `Tag' has kind `* - *'

In the type synonym declaration for `Bundle'

Failed, modules loaded: TQ.Common.TextAndListHandling.

 

where line 29 is the type declaration for 'bundle' in the following code:

 

 module TQ.TagSoup.TagSoupExtensions where 

 

 import TQ.Common.TextAndListHandling

 import Text.HTML.TagSoup

 import Text.HTML.Download

 import Control.Monad

 import Data.List

 import Data.Char

 

 type Bundle = [Tag]

 

[snip]

 

 tagsOnPage :: String - IO(String)

 tagsOnPage url = do

  tags - liftM parseTags $ openURL url

  let results = unlines $ map(show) $ tags

  return (results)

 

 extractTags :: Tag - Tag - [Tag] - [Tag]

 extractTags fromTag toTag tags = takeWhile (~/= toTag ) $ dropWhile (~/=
fromTag ) tags 

 

 extractTagsBetween ::  Tag - [Tag] - [Tag]

 extractTagsBetween _ [] = []

 extractTagsBetween markerTag tags = if startTags == []

  then []

  else [head startTags] ++ (takeWhile (~/= markerTag ) $ tail
startTags) 

  where

startTags = dropWhile (~/= markerTag ) tags

 

I need to repair this code quickly. I am hoping you can quickly help me
resolve this. Thanks.

 

Ralph Hodgson, 

@ralphtq http://twitter.com/ralphtq 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: What do _you_ want to see in FGL?

2010-05-19 Thread Heinrich Apfelmus
Ivan Lazar Miljenovic wrote:
 Heinrich Apfelmus writes:
 Yes; what I mean is that you can retrofit a custom vertex type to any
 graph implementation that uses a fixed vertex type. So, let's say that

data Gr a b = .. -- graph with vertex type  Vertex Gr = Int

 then

type Gr' node a b = CustomVertex node Gr a b

data CustomVertex node gr a b = CV (gr a b) (Map node (Vertex gr))

 is a graph with custom vertex type  node .
 
 Sounds like it's more complicated than it's worth tbh ;-)

Yup. ;)


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-install

2010-05-19 Thread Ivan Lazar Miljenovic
Serguey Zefirov sergu...@gmail.com writes:
 export http_proxy=http://${username}:${passwo...@${proxy_url};

 I tried it and it didn't work. I don't know reason, though, maybe it
 was because my current password not entirely alphanumeric.

Shouldn't matter as long as you put it within quotes.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Malcolm Wallace
Neil says that the API of TagSoup changed in 0.9.
All usages of the type Tag should now take a type argument, e.g. Tag String.


Regards,
Malcolm

 
On Wednesday, May 19, 2010, at 08:05AM, Ralph Hodgson 
rhodg...@topquadrant.com wrote:
___
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


[Haskell-cafe] Bug with [Double]

2010-05-19 Thread Dmitry Olshansky
Hello all,

It seems that I saw something like this in Cafe recevtly. But I am not sure...
In GHC 6.12.1 (Platform 2010 on Windows Vista) I have

Prelude [1,1+2/3..10]
[1.0,1.6665,2.333,2.9996,3.666,4.332,4.998,5.664,6.33,6.9964,7.6625,8.329,8.995,9.66,10.327]

-- It is a bug!

Prelude [1,5/3..10]
[1.0,1.6667,2.3335,3.0,3.6665,4.333,5.0,5.667,6.334,7.001,7.668,8.336,9.004,9.671]

-- correct, but...

Prelude [1,5/3..4]
[1.0,1.6667,2.3335,3.0,3.6665,4.333]

-- ... wrong again

Prelude [1,1+2/3..10] :: [Float]
[1.0,1.667,2.335,3.002,3.67,4.34,5.01,5.68,6.35,7.02,7.69,8.36,9.03,9.7]

-- correct

Prelude [1,1+2/3..10] :: [Double]
[1.0,1.6665,2.333,2.9996,3.666,4.332,4.998,5.664,6.33,6.9964,7.6625,8.329,8.995,9.66,10.327]

-- wrong

Any comments?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Erik de Castro Lopo
Dmitry Olshansky wrote:

 It seems that I saw something like this in Cafe recevtly. But I am not sure...
 In GHC 6.12.1 (Platform 2010 on Windows Vista) I have

snip


 Any comments?

The problem you point out is not a problem with Haskell, but a problem
with the whole concept of floating point arithmetic as implemented on
all modern CPUs. See:

http://docs.sun.com/source/806-3568/ncg_goldberg.html

You would have got similar problems with just about any language running
on the same hardware.

Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Ivan Lazar Miljenovic
Dmitry Olshansky olshansk...@gmail.com writes:

 Hello all,

 It seems that I saw something like this in Cafe recevtly. But I am not sure...
 In GHC 6.12.1 (Platform 2010 on Windows Vista) I have

 Prelude [1,1+2/3..10]
 [1.0,1.6665,2.333,2.9996,3.666,4.332,4.998,5.664,6.33,6.9964,7.6625,8.329,8.995,9.66,10.327]

 -- It is a bug!

No it isn't, because of the dodgy Ord instance for Float and Double values.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Serguey Zefirov
2010/5/19 Erik de Castro Lopo mle...@mega-nerd.com:
 Dmitry Olshansky wrote:

 It seems that I saw something like this in Cafe recevtly. But I am not 
 sure...
 In GHC 6.12.1 (Platform 2010 on Windows Vista) I have

 snip


 Any comments?

 The problem you point out is not a problem with Haskell, but a problem
 with the whole concept of floating point arithmetic as implemented on
 all modern CPUs. See:

    http://docs.sun.com/source/806-3568/ncg_goldberg.html

 You would have got similar problems with just about any language running
 on the same hardware.

This is what used for Double list generation (Haskell Platform 2010):
--
numericEnumFromThenTo   :: (Ord a, Fractional a) = a - a - a - [a]
numericEnumFromThenTo e1 e2 e3
= takeWhile predicate (numericEnumFromThen e1 e2)
where
 mid = (e2 - e1) / 2
 predicate | e2 = e1  = (= e3 + mid)
   | otherwise = (= e3 + mid)
--
So normal C loop like for {double i = 1; i = 10; i += 1+2/3) {
insert_list(i); } won't generate the same list, as Haskell does in
[1,1+2/3..10].

PS
Rationals:
Prelude [1,1+2/3..10] :: [Rational]
[1 % 1,5 % 3,7 % 3,3 % 1,11 % 3,13 % 3,5 % 1,17 % 3,19 % 3,7 % 1,23 %
3,25 % 3,9 % 1,29 % 3,31 % 3]

Same result.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Ivan Lazar Miljenovic
Ivan Lazar Miljenovic ivan.miljeno...@gmail.com writes:

 Dmitry Olshansky olshansk...@gmail.com writes:

 Hello all,

 It seems that I saw something like this in Cafe recevtly. But I am not 
 sure...
 In GHC 6.12.1 (Platform 2010 on Windows Vista) I have

 Prelude [1,1+2/3..10]
 [1.0,1.6665,2.333,2.9996,3.666,4.332,4.998,5.664,6.33,6.9964,7.6625,8.329,8.995,9.66,10.327]

 -- It is a bug!

 No it isn't, because of the dodgy Ord instance for Float and Double
 values.


And by Ord, I of course mean Enum...

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Type famillies Lifting IO

2010-05-19 Thread Maciej Piechotka
I started playing with type families. I wanted to achieve, for the
beginning, something like:

 import qualified Control.Monad.IO.Class as IOC
 import Control.Monad.Trans.Class
 import Control.Monad.Trans.Cont
 import Data.Functor.Identity

 class (Monad m, Monad (IO' m)) = MonadIO m where
 type IO' m :: * - *
 liftIO :: IO a - IO' m a
 liftM :: m a - IO' m a

It allows to add IO to computation even if computation originally was
'pure'.

First step was easy:

 instance MonadIO Identity where
 type IO' Identity = IO
 liftIO = id
 liftM = return . runIdentity
 
 instance MonadIO IO where
 type IO' IO = IO
 liftIO = id
 liftM = id
 
 instance MonadIO (ST r) where
 type IO' (ST r) = IO
 liftIO = id
 liftM = unsafeSTToIO
 
 --instance IOC.MonadIO m = MonadIO m where
 --type IO' m = m
 --liftIO = IOC.liftIO
 --liftM = id

However I run into problems - this code doesn't want to compile:

 instance MonadIO m = MonadIO (ContT r m) where
 type IO' (ContT r m) = ContT r (IO' m)
 liftIO f = ContT $ \cont - liftIO f = cont
 liftM f = ContT $ \cont - liftM f = cont

Or this:

 instance MonadIO m = MonadIO (ContT r m) where
 type IO' (ContT r m) = ContT r (IO' m)
 liftIO f = lift . liftIO
 liftM f = lift . liftIO

In fact there is strange interfering types of ghci:

ghci :t lift . liftIO
lift . liftIO
  :: (m ~ IO' m1, MonadTrans t, Monad m, MonadIO m1) = IO a - t m a
ghci :t lift . liftIO :: (m ~ IO' m1, MonadTrans t, Monad m, MonadIO
m1) = IO a - t m a

interactive:1:7:
Couldn't match expected type `IO' m' against inferred type `m1'
  `m1' is a rigid type variable bound by
   an expression type signature at interactive:1:18
  NB: `IO'' is a type function, and may not be injective
In the second argument of `(.)', namely `liftIO'
In the expression:
lift . liftIO ::
(m ~ (IO' m1), MonadTrans t, Monad m, MonadIO m1) = IO a -
t m a

What's the problem? I guess I don't understand something basic about
type famillies.

Regards


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


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Dmitry Olshansky
But

Prelude Data.List [1,1+2/3..4] :: [Double]
[1.0,1.6665,2.333,2.9996,3.666,4.332]

Prelude Data.List unfoldr (\n - let n'=n+2/3 in if n' = 4 then Just
(n',n') else Nothing) 1 :: [Double]
[1.6665,2.333,2.9996,3.666]

Prelude Data.List takeWhile (=4) $ iterate (+2/3) 1 :: [Double]
[1.0,1.6665,2.333,2.9996,3.666]

How 'dodgy' it should be to produce different result?
How [a,b..c] works in this case?



 2010/5/19 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com:
 Dmitry Olshansky olshansk...@gmail.com writes:

 Hello all,

 It seems that I saw something like this in Cafe recevtly. But I am not 
 sure...
 In GHC 6.12.1 (Platform 2010 on Windows Vista) I have

 Prelude [1,1+2/3..10]
 [1.0,1.6665,2.333,2.9996,3.666,4.332,4.998,5.664,6.33,6.9964,7.6625,8.329,8.995,9.66,10.327]

 -- It is a bug!

 No it isn't, because of the dodgy Ord instance for Float and Double values.

 --
 Ivan Lazar Miljenovic
 ivan.miljeno...@gmail.com
 IvanMiljenovic.wordpress.com


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Dmitry Olshansky
Thanks, it's clear now.

2010/5/19 Serguey Zefirov sergu...@gmail.com:
 2010/5/19 Erik de Castro Lopo mle...@mega-nerd.com:
 Dmitry Olshansky wrote:

 It seems that I saw something like this in Cafe recevtly. But I am not 
 sure...
 In GHC 6.12.1 (Platform 2010 on Windows Vista) I have

 snip


 Any comments?

 The problem you point out is not a problem with Haskell, but a problem
 with the whole concept of floating point arithmetic as implemented on
 all modern CPUs. See:

    http://docs.sun.com/source/806-3568/ncg_goldberg.html

 You would have got similar problems with just about any language running
 on the same hardware.

 This is what used for Double list generation (Haskell Platform 2010):
 --
 numericEnumFromThenTo   :: (Ord a, Fractional a) = a - a - a - [a]
 numericEnumFromThenTo e1 e2 e3
    = takeWhile predicate (numericEnumFromThen e1 e2)
                                where
                                 mid = (e2 - e1) / 2
                                 predicate | e2 = e1  = (= e3 + mid)
                                           | otherwise = (= e3 + mid)
 --
 So normal C loop like for {double i = 1; i = 10; i += 1+2/3) {
 insert_list(i); } won't generate the same list, as Haskell does in
 [1,1+2/3..10].

 PS
 Rationals:
 Prelude [1,1+2/3..10] :: [Rational]
 [1 % 1,5 % 3,7 % 3,3 % 1,11 % 3,13 % 3,5 % 1,17 % 3,19 % 3,7 % 1,23 %
 3,25 % 3,9 % 1,29 % 3,31 % 3]

 Same result.
 ___
 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] Bug with [Double]

2010-05-19 Thread Roman Leshchinskiy
On 19/05/2010, at 19:24, Dmitry Olshansky wrote:

 Prelude [1,1+2/3..10]
 [1.0,1.6665,2.333,2.9996,3.666,4.332,4.998,5.664,6.33,6.9964,7.6625,8.329,8.995,9.66,10.327]
 
 -- It is a bug!

Unfortunately, it isn't. Section 6.3.4 of the Haskell report says:

For Float and Double, the semantics of the enumFrom family is given by the 
rules for Int above, except that the list terminates when the elements become 
greater than e3+i/2 for positive increment i, or when they become less than 
e3+i/2 for negative i.

In this case, i = 2/3 so the last value in the list is 10+1/3. The same applies 
to the other examples.

Personally, I consider the Enum class itself to be broken.

Roman


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Ivan Lazar Miljenovic
Roman Leshchinskiy r...@cse.unsw.edu.au writes:
 Personally, I consider the Enum class itself to be broken.

Oh?  In what sense?

It seems to work fine for data types representing bounded enumerable
values with a proper mapping to/from Int (it's not bijective since
there's no proper mapping from Int - Bool for example); the problem is
the fact that Double, etc. are made instances of Enum when this is not
the case for those data types.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Roman Leshchinskiy
On 19/05/2010, at 20:36, Ivan Lazar Miljenovic wrote:

 Roman Leshchinskiy r...@cse.unsw.edu.au writes:
 Personally, I consider the Enum class itself to be broken.
 
 Oh?  In what sense?

Firstly, the enumFrom* family of functions shouldn't be methods and the class 
itself should provide enough facilities for implementing them generically. GHC, 
for instance, specialises them for all primitive numeric types just to get 
foldr/build fusion to work. That shouldn't be necessary and doesn't help with 
overloaded code anyway. For instance, this generates an intermediate list:

foo :: Enum a = a - a - [Int]
foo a b = [fromEnum x | x - [a..b]]

It's even worse when you want to implement similar functionality for other data 
structures. In vector, I basically had to duplicate all those specialisations 
to get decent performance. The generic case is horribly inefficient:

enumFromTo x y = fromList [x .. y]

There is no other sensible definition.

Secondly, it should be possible to compute the length and the nth element of 
[a..b] in constant time. At the moment, it's impossible to distribute [a..b] 
efficiently across multiple threads - you have to generate the entire list 
first and then split it into chunks. It's completely unclear to me what [:a .. 
b:] should mean in DPH, for instance.

So basically, Enum only provides enough functionality to desugar [a..b] and 
friends and even here, it doesn't interact well with fusion. Of course, these 
concerns weren't relevant back when the class was designed. But it is really 
broken now, IMO.

Roman


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Numerical Analysis

2010-05-19 Thread Alberto G. Corona
SAGE is the kind of thing that I dreamed to have available online a few
years ago.

To recode everithing in haskell perhaps does not worth the pain, but
perhapts it would be nice to do something similar to SAGE in an advanced
environment such is Google Wave, with all the collaborative facilities for
free.

Perhaps  this  would attract some developers. The utility of the whole thing
perhaps would incentivate the integration of existing haskell math software
and to translate/integrate foreign code.

Cheers

2010/5/16 Pierre-Etienne Meunier pierreetienne.meun...@gmail.com

 Hello Cafe,

 Being a complete beginner in the field of numerical analysis, but anyway
 needing it to solve real problems, I wrote a few functions recently to
 solve systems of polynomial equations using the projected polyhedron
 method by Maekawa and Patrikakalis.
 This requires solving systems of linear equations precisely, thus the
 simple Gauss method was not enough, and I had to write also an algorithm for
 the SVD decomposition.

 Upon discovering the algol / fortran specifications of these :-( , heavily
 published in important journals, I thought it would be nice to provide the
 world with fast reliable implementation of these numerical methods (i.e. not
 simply bindings to lapack). Moreover, writing numerical things in haskell is
 much more pleasant than I thought at first. Here are a few random thoughts
 on this :

 - The haskell 98 norm does not require enough about IEEE-754 compliance,
 thus C bindings are still needed to guess for instance the machine epsilons,
 or manipulating ULPs. Moreover, taking advantage of hardware rounding is not
 easy, even if the hardware is IEEE-compliant : calling a C function from
 haskell screws up the speed advantages of hardware rounding, for instance.
 Maybe the new LLVM backend will make this possible ?

 - The current Array library is definitely not adapted to production code.
 It makes debugging tricky, requires a heavy use of Debug.Trace to actually
 see what happens, and does not seem as fast as one could expect. It seems
 that each algebra library on hackage redefines part of it, but a unified
 version would be nice : a discussion within the haskell community seems to
 be needed...

 - A numerical analysis library should really take advantage of the
 parallelism in GHC, especially with the arrival of hardware such as fermi
 (anyway, I do not know how much haskell is compilable to fermi code). The
 love for loops and side-effects among this community is hard to understand,
 but that's more of a cultural problem.

 Finally, as stated by William Stein, the creator of SAGE, of course it
 would take thousands of man-years to rewrite these codes in python, but if a
 language like haskell, and a compiler do 90% of the work, how many man-years
 are left ?

 If anyone here has got the time, the team and the will to start such a
 project, I'd love to contribute !

 Cheers,
 PE

 ___
 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


[Haskell-cafe] Proof format

2010-05-19 Thread R J

Is this how a rigorous Haskeller would lay out the proofs of the following 
theorems?  This is Bird 1.4.6.
(i)   
Theorem:  (*) x = (* x)
Proof:
  (*) x  ={definition of partial application}  \y - x * y  =
{commutativity of *}  \y - y * x  ={definition of (* x)}  (* x)
(ii)
Theorem:  (+) x = (x +)
Proof:
  (+) x  ={definition of partial application}  \y - x + y  =
{definition of (x +)}  (x +)
(iii)
Theorem:  (-) x /= (- x)
Proof:
  (-) x  ={definition of partial application}  \y - x - y  /=   
{definition of prefix negation, which is not a section}  (- x)
  
_
Hotmail is redefining busy with tools for the New Busy. Get more from your 
inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] (no subject)

2010-05-19 Thread R J

This is another proof-layout question, this time from Bird 1.4.7.
We're asked to define the functions curry2 and uncurry2 for currying and 
uncurrying functions with two arguments.  Simple enough:
curry2 :: ((a, b) - c) - (a - (b - c))curry2 f x y   =  f 
(x, y)
uncurry2   :: (a - (b - c)) - ((a, b) - c)uncurry2 f (x, y)  =  f x 
y
The following two assertions are obviously true theorems, but how are the 
formal proofs laid out?
1.  curry2 (uncurry2 f) x y = f x y
2.  uncurry2 (curry 2 f) (x, y) = f (x, y)  
  
_
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccountocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Ben Millwood
On Wed, May 19, 2010 at 10:57 AM, Serguey Zefirov sergu...@gmail.com wrote:

 PS
 Rationals:
 Prelude [1,1+2/3..10] :: [Rational]
 [1 % 1,5 % 3,7 % 3,3 % 1,11 % 3,13 % 3,5 % 1,17 % 3,19 % 3,7 % 1,23 %
 3,25 % 3,9 % 1,29 % 3,31 % 3]

 Same result.

This sounds like a bug to me. The section of the Haskell Report that
deals with the Enum class mentions Float and Double, not Rational, and
there's really no sensible reason why Rationals would exhibit this
behaviour given that they don't have rounding error.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Lutz Donnerhacke
* Ben Millwood wrote:
 Prelude [1,1+2/3..10] :: [Rational]
 [1 % 1,5 % 3,7 % 3,3 % 1,11 % 3,13 % 3,5 % 1,17 % 3,19 % 3,7 % 1,23 %
 3,25 % 3,9 % 1,29 % 3,31 % 3]

 Same result.

 This sounds like a bug to me. The section of the Haskell Report that
 deals with the Enum class mentions Float and Double, not Rational, and
 there's really no sensible reason why Rationals would exhibit this
 behaviour given that they don't have rounding error.

Double is not better:

Prelude [9,9+2/3..10]
[9.0,9.666,10.332]
Prelude [7,9 .. 10]
[7,9]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug with [Double]

2010-05-19 Thread Roman Leshchinskiy
On 19/05/2010, at 23:44, Ben Millwood wrote:

 On Wed, May 19, 2010 at 10:57 AM, Serguey Zefirov sergu...@gmail.com wrote:
 
 PS
 Rationals:
 Prelude [1,1+2/3..10] :: [Rational]
 [1 % 1,5 % 3,7 % 3,3 % 1,11 % 3,13 % 3,5 % 1,17 % 3,19 % 3,7 % 1,23 %
 3,25 % 3,9 % 1,29 % 3,31 % 3]
 
 Same result.
 
 This sounds like a bug to me. The section of the Haskell Report that
 deals with the Enum class mentions Float and Double, not Rational, and
 there's really no sensible reason why Rationals would exhibit this
 behaviour given that they don't have rounding error.

From Section 12.1 of the Library Report:

instance  (Integral a)  = Enum (Ratio a)  where
succ x   =  x+1
pred x   =  x-1
toEnum   =  fromIntegral
fromEnum =  fromInteger . truncate  -- May overflow
enumFrom =  numericEnumFrom  -- These numericEnumXXX functions
enumFromThen =  numericEnumFromThen  -- are as defined in Prelude.hs
enumFromTo   =  numericEnumFromTo   -- but not exported from it!
enumFromThenTo   =  numericEnumFromThenTo

The numericEnum functions are defined in Section 8 of the Language Report and 
have semantics required for Float and Double.

Roman

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Intuitive function given type signature

2010-05-19 Thread Brent Yorgey
On Wed, May 19, 2010 at 04:27:14AM +, R J wrote:
 
 What are some simple functions that would naturally have the following type 
 signatures:
 f :: (Integer - Integer) - Integer

Well, this means f is given a function from Integer to Integer, and it
has to somehow return an Integer, (possibly) using the function it is
given.  For example, f could just ignore its argument:

  f _ = 6

Or it could apply it to a particular input value:

  f g = g 0

I'll let you think of some other possibilities.

 g :: (Integer - Integer) - (Integer - Integer)

g is given an Integer-Integer function and has to produce a different
one.  But as someone else pointed out, you can also think of this as

  g :: (Integer - Integer) - Integer - Integer

That is, g is given an Integer-Integer function as well as an
Integer, and must somehow use these things to produce another Integer.
There are lots of ways to do this--I'll let you figure this one out.

-Brent
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] (no subject)

2010-05-19 Thread Brent Yorgey
On Wed, May 19, 2010 at 01:37:49PM +, R J wrote:
 
 This is another proof-layout question, this time from Bird 1.4.7.
 We're asked to define the functions curry2 and uncurry2 for currying and 
 uncurrying functions with two arguments.  Simple enough:
 curry2 :: ((a, b) - c) - (a - (b - c))curry2 f x y   =  f 
 (x, y)
 uncurry2   :: (a - (b - c)) - ((a, b) - c)uncurry2 f (x, y)  =  f 
 x y
 The following two assertions are obviously true theorems, but how are the 
 formal proofs laid out?

There are lots of variations, I wouldn't say there's one right way
to organize/lay out the proofs.  But here's how I might do it:

  curry2 (uncurry2 f) x y 
=  { def. of curry2 }
  uncurry2 f (x,y)
=  { def. of uncurry2 }
  f x y

I'll let you do the other one.

By the way, are you working through these problems just for
self-study, or is it homework for a class?

-Brent
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal: problem building ffi shared library and significance of __stginit

2010-05-19 Thread Duncan Coutts
On Tue, 2010-05-18 at 17:31 -0400, Anthony LODI wrote:
 Hello,
 
 I'm trying to build some haskell code as a .so/.dll so that it can
 ultimately be used by msvc.  I have it working when I compile by hand
 (listed below) but I can't get the exact same thing built/linked with
 cabal.  On linux everything builds fine, but when I try to link the
 resulting .so file, I get an error about a missing
 '__stginit_CInterface' reference.  Indeed I couldn't find that name in
 any of the cabal-generated .dyn_o files.  I checked the output of
 'cabal build -v' and it seems to be executing about the same thing
 that I'm executing manually so I'm not sure what could be going wrong.
  On windows cabal won't even configure since '--enable-shared' seems
 to imply '-dynamic' (right?), and that's not currently supported.
 
 Also, when I remove the line 'hs_add_root(__stginit_CInterface);', and
 the corresponding forward declaration, the program runs fine!  Does
 ghc no longer need this call or are my toy programs just being lucky
 sofar?

For reference for other people, Anthony and I worked this out today.

full example:
http://pastebin.com/aLdyFMPg

The difference between doing it manually and building a library via
Cabal is the package name.

When building directly with ghc, the default package name is  aka the
main package. When building a ghc/Haskell package, the package name gets
set (ghc -package-name test-0.0). This package name gets encoded into
the symbol names. So we get:

   __stginit_testzm0zi0_CInterface
vs __stginit_CInterface

(testzm0zi0 is the Z-encoding of test-0.0)

What is bad here is that the __stginit stuff is even necessary. Anthony
is going to file a ghc ticket and/or complain on the ghc users list,
citing this example.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Ralph Hodgson
Thanks Malcolm,

 

Providing a 'String' type argument worked:

 

 type Bundle = [Tag String]

 

 extractTags :: Tag String - Tag String - Bundle - Bundle

 extractTags fromTag toTag tags = takeWhile (~/= toTag ) $ dropWhile (~/= 
 fromTag ) tags

 

 

 

From: Malcolm Wallace [mailto:malcolm.wall...@me.com] 
Sent: Wednesday, May 19, 2010 1:48 AM
To: rhodg...@topquadrant.com
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] TagSoup 0.9

 

Neil says that the API of TagSoup changed in 0.9.
All usages of the type Tag should now take a type argument, e.g. Tag String.
 
 
Regards,
Malcolm
 
 
On Wednesday, May 19, 2010, at 08:05AM, Ralph Hodgson 
rhodg...@topquadrant.com wrote:
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

Hello Neil ,

 

I was using TagSoup 0.8 with great success. On upgrading to 0.9 I have this 
error:

 

TQ\TagSoup\TagSoupExtensions.lhs:29:17:

`Tag' is not applied to enough type arguments

Expected kind `*', but `Tag' has kind `* - *'

In the type synonym declaration for `Bundle'

Failed, modules loaded: TQ.Common.TextAndListHandling.

 

where line 29 is the type declaration for 'bundle' in the following code:

 

 module TQ.TagSoup.TagSoupExtensions where 

 

 import TQ.Common.TextAndListHandling

 import Text.HTML.TagSoup

 import Text.HTML.Download

 import Control.Monad

 import Data.List

 import Data.Char

 

 type Bundle = [Tag]

 

[snip]

 

 tagsOnPage :: String - IO(String)

 tagsOnPage url = do

  tags - liftM parseTags $ openURL url

  let results = unlines $ map(show) $ tags

  return (results)

 

 extractTags :: Tag - Tag - [Tag] - [Tag]

 extractTags fromTag toTag tags = takeWhile (~/= toTag ) $ dropWhile (~/= 
 fromTag ) tags 

 

 extractTagsBetween ::  Tag - [Tag] - [Tag]

 extractTagsBetween _ [] = []

 extractTagsBetween markerTag tags = if startTags == []

  then []

  else [head startTags] ++ (takeWhile (~/= markerTag ) $ tail 
 startTags) 

  where

startTags = dropWhile (~/= markerTag ) tags

 

I need to repair this code quickly. I am hoping you can quickly help me resolve 
this. Thanks.

 

Ralph Hodgson, 

@ralphtq http://twitter.com/ralphtq 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Ralph Hodgson
Forgot to add: I now need to understand the following warnings on this line  
import Text.HTML.Download:

 

TagSoupExtensions.lhs:24:2:

Warning: In the use of `openItem'

 (imported from Text.HTML.Download):

 Deprecated: Use package HTTP, module Network.HTTP, getResponseBody

 = simpleHTTP (getRequest url)

 

TagSoupExtensions.lhs:24:2:

Warning: In the use of `openURL'

 (imported from Text.HTML.Download):

 Deprecated: Use package HTTP, module Network.HTTP, getResponseBody

 = simpleHTTP (getRequest url)

Ok, modules loaded: TQ.TagSoup.TagSoupExtensions.

*TQ.TagSoup.TagSoupExtensions

 

 

From: haskell-cafe-boun...@haskell.org 
[mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Ralph Hodgson
Sent: Wednesday, May 19, 2010 10:30 AM
To: 'Malcolm Wallace'
Cc: haskell-cafe@haskell.org
Subject: RE: [Haskell-cafe] TagSoup 0.9

 

Thanks Malcolm,

 

Providing a 'String' type argument worked:

 

 type Bundle = [Tag String]

 

 extractTags :: Tag String - Tag String - Bundle - Bundle

 extractTags fromTag toTag tags = takeWhile (~/= toTag ) $ dropWhile (~/= 
 fromTag ) tags

 

 

 

From: Malcolm Wallace [mailto:malcolm.wall...@me.com] 
Sent: Wednesday, May 19, 2010 1:48 AM
To: rhodg...@topquadrant.com
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] TagSoup 0.9

 

Neil says that the API of TagSoup changed in 0.9.
All usages of the type Tag should now take a type argument, e.g. Tag String.
 
 
Regards,
Malcolm
 
 
On Wednesday, May 19, 2010, at 08:05AM, Ralph Hodgson 
rhodg...@topquadrant.com wrote:
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

Hello Neil ,

 

I was using TagSoup 0.8 with great success. On upgrading to 0.9 I have this 
error:

 

TQ\TagSoup\TagSoupExtensions.lhs:29:17:

`Tag' is not applied to enough type arguments

Expected kind `*', but `Tag' has kind `* - *'

In the type synonym declaration for `Bundle'

Failed, modules loaded: TQ.Common.TextAndListHandling.

 

where line 29 is the type declaration for 'bundle' in the following code:

 

 module TQ.TagSoup.TagSoupExtensions where 

 

 import TQ.Common.TextAndListHandling

 import Text.HTML.TagSoup

 import Text.HTML.Download

 import Control.Monad

 import Data.List

 import Data.Char

 

 type Bundle = [Tag]

 

[snip]

 

 tagsOnPage :: String - IO(String)

 tagsOnPage url = do

  tags - liftM parseTags $ openURL url

  let results = unlines $ map(show) $ tags

  return (results)

 

 extractTags :: Tag - Tag - [Tag] - [Tag]

 extractTags fromTag toTag tags = takeWhile (~/= toTag ) $ dropWhile (~/= 
 fromTag ) tags 

 

 extractTagsBetween ::  Tag - [Tag] - [Tag]

 extractTagsBetween _ [] = []

 extractTagsBetween markerTag tags = if startTags == []

  then []

  else [head startTags] ++ (takeWhile (~/= markerTag ) $ tail 
 startTags) 

  where

startTags = dropWhile (~/= markerTag ) tags

 

I need to repair this code quickly. I am hoping you can quickly help me resolve 
this. Thanks.

 

Ralph Hodgson, 

@ralphtq http://twitter.com/ralphtq 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-install

2010-05-19 Thread Brandon S. Allbery KF8NH

On May 19, 2010, at 04:49 , Ivan Lazar Miljenovic wrote:

Serguey Zefirov sergu...@gmail.com writes:

export http_proxy=http://${username}:${passwo...@${proxy_url};


I tried it and it didn't work. I don't know reason, though, maybe it
was because my current password not entirely alphanumeric.


Shouldn't matter as long as you put it within quotes.


I imagine things will go wrong if it includes an @... urlencoding is  
probably a smart idea.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Daniel Fischer
On Wednesday 19 May 2010 19:46:57, Ralph Hodgson wrote:
 Forgot to add: I now need to understand the following warnings on this
 line  import Text.HTML.Download:



In Text.HTML.Download, there's the following:

{-|
/DEPRECATED/: Use the HTTP package instead:

 import Network.HTTP
 openURL x = getResponseBody = simpleHTTP (getRequest x)

This module simply downloads a page off the internet. It is very 
restricted,
and it not intended for proper use.

The original version was by Alistair Bayley, with additional help from
Daniel McAllansmith. It is taken from the Haskell-Cafe mailing list
\Simple HTTP lib for Windows?\, 18 Jan 2007.
http://thread.gmane.org/gmane.comp.lang.haskell.cafe/18443/
-}

and

{-# DEPRECATED openItem, openURL Use package HTTP, module Network.HTTP, 
getResponseBody = simpleHTTP (getRequest url) #-}


So, don't use Text.HTML.Download anymore, instead use the functions from 
the HTTP package.

Deprecated stuff will probably be removed in one of the next releases.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Don Stewart
Or use things from the download-curl package, which provides a nice
openURL function.

daniel.is.fischer:
 On Wednesday 19 May 2010 19:46:57, Ralph Hodgson wrote:
  Forgot to add: I now need to understand the following warnings on this
  line  import Text.HTML.Download:
 
 
 
 In Text.HTML.Download, there's the following:
 
 {-|
 /DEPRECATED/: Use the HTTP package instead:
 
  import Network.HTTP
  openURL x = getResponseBody = simpleHTTP (getRequest x)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: cabal: problem building ffi shared library and significance of __stginit

2010-05-19 Thread Anthony LODI
 I'm trying to build some haskell code as a .so/.dll so that it can
 ultimately be used by msvc.  I have it working when I compile by hand
 (listed below) but I can't get the exact same thing built/linked with
 cabal.  On linux everything builds fine, but when I try to link the
 resulting .so file, I get an error about a missing
 '__stginit_CInterface' reference.  Indeed I couldn't find that name in
 any of the cabal-generated .dyn_o files.  I checked the output of
 'cabal build -v' and it seems to be executing about the same thing
 that I'm executing manually so I'm not sure what could be going wrong.
  On windows cabal won't even configure since '--enable-shared' seems
 to imply '-dynamic' (right?), and that's not currently supported.

Okay after some help from Duncan on #haskell, the problem seems pretty
straightforward.  I've uploaded the details here:

  http://hackage.haskell.org/trac/ghc/ticket/3252#comment:4

Cheers.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Neil Mitchell
Hi Ralph,

 I was using TagSoup 0.8 with great success. On upgrading to 0.9 I have this 
 error:

 TQ\TagSoup\TagSoupExtensions.lhs:29:17:
`Tag' is not applied to enough type arguments
Expected kind `*', but `Tag' has kind `* - *'
In the type synonym declaration for `Bundle'
 Failed, modules loaded: TQ.Common.TextAndListHandling.

My change notes have this being a change between 0.6 and 0.8. As
Malcolm says, any old uses of Tag should become Tag String. The
reason is that Tag is now parameterised, and you can use Tag
ByteString etc. However, I should point out that Tag ByteString won't
be any faster than Tag String in this version (it's in the future work
pile).

  Forgot to add: I now need to understand the following warnings on this
  line  import Text.HTML.Download:

Everyone's comments have been right. I previously included
Text.HTML.Download so that it was easy to test tagsoup against the
web. Since I first wrote that snippet the HTTP downloading libraries
have improved substantially, so people should use those in favour of
the version in tagsoup - you'll be able to connect to more websites in
more reliable ways, go through proxies etc. I don't intend to remove
the Download module any time soon, but I will do eventually.

Thanks, Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-install

2010-05-19 Thread Serguey Zefirov
 I tried it and it didn't work. I don't know reason, though, maybe it
 was because my current password not entirely alphanumeric.
 Shouldn't matter as long as you put it within quotes.
 I imagine things will go wrong if it includes an @... urlencoding is
 probably a smart idea.

Thank you very much!

I'll definitely try that.

And, as I'm on it again, switch to just ignore proxy would be better. ;)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell for control system [was: [reactive] A pong and integrate]

2010-05-19 Thread Ben Franksen
David Leimbach wrote:
 I find it's often the most practical chapter that I hit a lot during
 writes and changes to my server process I have in Haskell in our control
 system code :-)

Are you actually saying that you use Haskell for a control system server?
Thta would be very interesting to me.

Could you tell what kind of control system?

Cheers
Ben

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Extensible Records and Functional References

2010-05-19 Thread Günther Schmidt

Hi all,

I just read Functional References  are a cheap and cheerful technique 
for working with the existing (non-extensible) record system, and may be 
of interest to extensible record implementers. A good implementation can 
be found on ... on


http://hackage.haskell.org/trac/ghc/wiki/ExtensibleRecords


Does this mean that there is a way to implement extensible records via 
functional references?


Günther


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: has-0.4 Entity based records

2010-05-19 Thread adam vogt
On Thu, May 13, 2010 at 7:16 PM, HASHIMOTO, Yusaku nonow...@gmail.com wrote:
 Sorry for spamming, what I wanted to write is I think `has' has better
 interface than other record packages in types.

 There are many libraries to write function takes an record has Foo
 and Bar and returns something. But writing type of the function is
 still difficult. I can't write such types using HList or records
 without reading documents. I think, using has, There's few effort to
 write such types.

In which manner do you need to read less documentation to write:

] f :: Has Foo r = r - ...

Instead when using HList:

] f :: HasField Foo record fieldType = ...


 I think `has' fits the needs of Haskellers who have the good habit of
 writing a type of a function before its definition.

What does this mean exactly in terms of the type inference possible?

--
Adam
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Henning Thielemann
Don Stewart schrieb:
 Or use things from the download-curl package, which provides a nice
 openURL function.

The openURL function from TagSoup is lazy, which the proposed
replacement 'getResponseBody = simpleHTTP (getRequest x)' is not. Is
the openURL function from download-curl lazy?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] TagSoup 0.9

2010-05-19 Thread Don Stewart
schlepptop:
 Don Stewart schrieb:
  Or use things from the download-curl package, which provides a nice
  openURL function.
 
 The openURL function from TagSoup is lazy, which the proposed
 replacement 'getResponseBody = simpleHTTP (getRequest x)' is not. Is
 the openURL function from download-curl lazy?
 

Yes, see:

Network.Curl.Download.Lazy.openLazyURI

though I think it is possible that I strictified the code. Have a play
around with it if it doesn't meet your needs -- should be /trivial/ to
ensure it is chunk-wise lazy.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Devices and Webcams, The Basics

2010-05-19 Thread Eitan Goldshtrom

Hi everyone,

I would like to start working on a program that requires access to a 
camera attached to the computer probably via USB or otherwise 
internally. Unfortunately I don't know anything about using devices in 
haskell. I tried looking up how to access the microphone one too and had 
little success. Could someone just point me in the direction of 
tutorials for learning the basics of both devices in general as well as 
the webcam more specifically? The webcam is a bit more of a priority.


-Eitan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Devices and Webcams, The Basics

2010-05-19 Thread aditya siram
Haskell has bindings to USB [1]. I don't know of any USB tutorials or
any webcam specific libraries.

-deech
[1] http://hackage.haskell.org/package/usb

On 5/19/10, Eitan Goldshtrom thesource...@gmail.com wrote:
 Hi everyone,

 I would like to start working on a program that requires access to a
 camera attached to the computer probably via USB or otherwise
 internally. Unfortunately I don't know anything about using devices in
 haskell. I tried looking up how to access the microphone one too and had
 little success. Could someone just point me in the direction of
 tutorials for learning the basics of both devices in general as well as
 the webcam more specifically? The webcam is a bit more of a priority.

 -Eitan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Devices and Webcams, The Basics

2010-05-19 Thread Ivan Lazar Miljenovic
aditya siram aditya.si...@gmail.com writes:

 Haskell has bindings to USB [1]. I don't know of any USB tutorials or
 any webcam specific libraries.

I don't know of any, but if using Linux then maybe writing a binding to
v4l (video for linux) might be the best/easiest approach.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Bird problem 1.6.2 -- is there an easier method?

2010-05-19 Thread R J

Bird problem 1.6.2 is:
If f :: (a, b) - c, then define a function swap such that:
flip (curry f) = curry (f . swap).
I'd very much appreciate if someone could tell me whether there's a rigorous 
solution simpler than mine, which is:
Since (.) :: (q - r) - (p - q) - (p - r), we have f :: q - r and swap :: 
p - q.  Type unification of f requires q = (a, b) and r = c.
Since f :: (a, b) - c and curry :: ((l, m) - n) - (l - m - n), 
typeunification requires l = a, b = m, and n = c.  Therefore,curry :: ((a, b) 
- c) - (a - b - c), and (curry f) :: a - b - c.
Since flip :: (s - t - u) - t - s - u, type unification requiress = a, t = 
b, and u = c.  Therefore, flip :: (a - b - c) - b - a - c,and flip (curry 
f) :: b - a - c.
Therefore, curry (f . swap) ::  b - a - c, and p :: b - a.  Therefore,swap 
:: b - a - (a, b), and:

swap   :: b - a - (a, b)swap x y   =  (y, 
x)

  
_
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Deducing a type signature

2010-05-19 Thread R J

Bird 1.6.3 requires deducing type signatures for the functions strange and 
stranger.
Are my solutions below correct?
(i)  strange f g = g (f g)
Assume g :: a - b.  Then f :: (a - b) - c.  But since g :: a - b,f g :: a, 
so c = a.  Therefore, f :: (a - b) - a, and g (f g) :: a.Therefore, strange 
:: ((a - b) - a) - (a - b) - a.
(ii)  stranger f = f f
Assume f :: a - b.  Since f f is well-typed, type unification requiresa = b. 
 Therefore, f :: a - a, and stranger :: (a - a) - a. 
  
_
Hotmail is redefining busy with tools for the New Busy. Get more from your 
inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Deducing a type signature

2010-05-19 Thread Richard O'Keefe


On May 20, 2010, at 11:03 AM, R J wrote:


stranger f = f f



This doesn't have a type in Haskell.
Suppose f :: a - b
Then if f f made sense, a = (a - b) would be true,
and we'd have an infinite type.

Type the definition into a file, and try loading it
into ghci:

Occurs check: cannot construct the infinite type: t = t - t1
Probable cause: `f' is applied to too many arguments
In the expression: f f
In the definition of `stranger': stranger f = f f

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Deducing a type signature

2010-05-19 Thread Dan Weston

 (i)  strange f g = g (f g)

 Assume g :: a - b.  Then f :: (a - b) - c.  But since g :: a - b,
 f g :: a, so c = a.  Therefore, f :: (a - b) - a, and g (f g) :: a.
 Therefore, strange :: ((a - b) - a) - (a - b) - a.

Almost. The return type of strange is the same as the return type of g 
(the outermost function), namely b.


So strange :: ((a - b) - a) - (a - b) - b.

Dan

R J wrote:
Bird 1.6.3 requires deducing type signatures for the functions strange 
and stranger.


Are my solutions below correct?

(i)  strange f g = g (f g)

Assume g :: a - b.  Then f :: (a - b) - c.  But since g :: a - b,
f g :: a, so c = a.  Therefore, f :: (a - b) - a, and g (f g) :: a.
Therefore, strange :: ((a - b) - a) - (a - b) - a.

(ii)  stranger f = f f

Assume f :: a - b.  Since f f is well-typed, type unification requires
a = b.  Therefore, f :: a - a, and stranger :: (a - a) - a.


Hotmail is redefining busy with tools for the New Busy. Get more from 
your inbox. See how. 
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Intuitive function given type signature

2010-05-19 Thread Richard O'Keefe


On May 20, 2010, at 3:18 AM, Brent Yorgey wrote:


On Wed, May 19, 2010 at 04:27:14AM +, R J wrote:


What are some simple functions that would naturally have the  
following type signatures:

f :: (Integer - Integer) - Integer


Well, this means f is given a function from Integer to Integer, and it
has to somehow return an Integer, (possibly) using the function it is
given.  For example, f could just ignore its argument:

 f _ = 6


That would NOT give f the right type.
The type would be
f :: Num r = a - r



Or it could apply it to a particular input value:

 f g = g 0


That would NOT give f the right type.
The type would be
f :: Num a = (a - b) - b



I'll let you think of some other possibilities.


The key point is the 'that would NATURALLY have', which I take
to mean as a result of type inference without any forcibly
imposed type signatures.

What kind of definition of f, *not* including :: anywhere,
would result in Haskell inferring the desired signature?

The key thing is that the types *must* be fully constrained
to Integer.  The simplest way to get something that is
guaranteed to be the specific type Integer, as far as I can
see, is to use something like toInteger 0.

If we have identityForA :: A - A
   identityForB :: B - B
then we can constrain a variable x to A using identityForA $ x
and we can constrain a variable g to A-B using
identityForB . g . identityForA.

This is, in a sense, equivalent to providing a type signature,
but it meets the formal requirements of these questions.

identityForInteger = (+ toInteger 0)

is an example.

f g = g z + z where z = toInteger 0

does the trick here.
m% ghci
Prelude let f g = g z + z where z = toInteger 0
Prelude :type f
f :: (Integer - Integer) - Integer


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bird problem 1.6.2 -- is there an easier method?

2010-05-19 Thread John Millikin
You've been asking a lot of very tutorial-ish questions on this list.
Although this isn't necessarily a *bad* thing, you may receive
responses more appropriate to your skill level on the
haskell-beginners list 
http://www.haskell.org/mailman/listinfo/beginners .

I don't own the Bird book, but while reading your problem the type f
:: (a, b) - c is throwing off huge warning signs. What sensible
implementation could such a function have? The only way I can think of
to implement it is f (_, _) = undefined.

Assuming this signature is somehow valid, your reasoning for the left
side of the equation flip (curry f) is correct. It's a bit verbose,
but you'll learn to see the types better as you become more
experienced.

However, your reasoning for the right side is incorrect. First, lets
look at the equalities again:

flip (curry f) :: b - a - c
flip (curry f) = curry (f . swap)
curry (f . swap) :: b - a - c

The first step is to remove the curry. Since (curry :: ((a, b) - c)
- a - b - c), there's only one possible type signature for (f .
swap):

f . swap :: (b, a) - c

The types for (.) and f are known already. There's only one reasonable
definition for (.), so we can reason that:

(.) f g x = f (g x)

f . swap :: (b, a) - c
f . swap = \x - f (swap x)

From this, it should be possible to derive the type of swap easily. Good 
luck.

2010/5/19 R J rj248...@hotmail.com:
 Bird problem 1.6.2 is:
 If f :: (a, b) - c, then define a function swap such that:
 flip (curry f) = curry (f . swap).
 I'd very much appreciate if someone could tell me whether there's a rigorous
 solution simpler than mine, which is:
 Since (.) :: (q - r) - (p - q) - (p - r), we have f :: q - r and swap
 :: p - q.  Type unification of f requires q = (a, b) and r = c.
 Since f :: (a, b) - c and curry :: ((l, m) - n) - (l - m - n), type
 unification requires l = a, b = m, and n = c.  Therefore,
 curry :: ((a, b) - c) - (a - b - c), and (curry f) :: a - b - c.
 Since flip :: (s - t - u) - t - s - u, type unification requires
 s = a, t = b, and u = c.  Therefore, flip :: (a - b - c) - b - a - c,
 and flip (curry f) :: b - a - c.
 Therefore, curry (f . swap) ::  b - a - c, and p :: b - a.  Therefore,
 swap :: b - a - (a, b), and:

 swap                       :: b - a - (a, b)
 swap x y                   =  (y, x)


 
 Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
 Learn more.
 ___
 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


[Haskell-cafe] Retrospective type-class extension

2010-05-19 Thread Tony Morris
We all know that class (Functor f) = Monad f is preferable but its
absence is a historical mistake. We've all probably tried once:

instance (Functor f) = Monad f where
...

However, is there a type system extension (even proposed but not
implemented) that allows me to retrospectively apply such a notion?

Ideally something like this would be handy if it could somehow be
retrospectively applied:
Monad - Applicative - Pointed - Functor


--
Tony Morris
http://tmorris.net/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe