Re: [Haskell-cafe] Help on using System.Win32.Com.Automation

2009-03-23 Thread Sigbjorn Finne

Hi Wilkes,

you may want to have a look at a simple example of how to
interop with Windows WMI using the COM package at --

 http://haskell.forkio.com/com-examples

Hope it is of some help to you.

--sigbjorn

On 3/19/2009 16:49, Wilkes Joiner wrote:

I'm playing around with the com package, but I'm having a hard time
understanding how to map a COM call to the appropriate methodN or
functionN call.  Does anyone have any example code that uses the
method1 or higher.  Any help or pointers would be appreciated.

Here's the code I have so far:


import System.Win32.Com
import System.Win32.Com.Automation


dsn = Provider=vfpoledb.1;Data Source=C:\\SomeDirectory\\
main = coInitialize 
   openConnection = \con -
   closeConnection con

openDSN :: String - IDispatch a - IO ()
openDSN dsn con = method0 Open [inString dsn] con

openConnection :: IO (IDispatch a)
openConnection = createObject ADODB.Connection = \con - openDSN
dsn con  return con

closeConnection :: IDispatch a - IO ()
closeConnection =  method0 Close []

{-
Wraps ADO Connection.Execute
http://msdn.microsoft.com/en-us/library/ms675023(VS.85).aspx
Set recordset = connection.Execute (CommandText, RecordsAffected, Options)

execute :: String - IDispatch a - IO a
execute cmd con = method1 Execute [inString cmd] (inEmpty,resWord64) con

-}


Thank You,
Wilkes
___
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] MissingH bracketCD (aka bracketCWD) bug -- this is the infamous lazy io, right?

2009-03-23 Thread Thomas Hartman
I got bitten by  a bug (well, I call it bug) in bracketCD from
HSH/MissingH demonstrated by the following code

bracketCD is very useful for sysadminny one-offs, I use it all the
time, but. I suspect that unless people are very careful, this
behavior will affect other users of bracketCD, in potentially very
subtle and tricky ways.

1) -- is there a more elegant way to deal with lazy io than the hack
below? (putStrLn the last character)
2) -- should MissingH function bracketCD be fixed, and if so how?

import System.FilePath.Find (find)
import System.Directory (getDirectoryContents, getCurrentDirectory,
setCurrentDirectory)
import System.Path (bracketCWD) -- from MissingH

-- the fixed function, a more restrictive type than bracketCWD which
lets you do any io, not just showables
myBracketCWD :: Show a = FilePath - IO a - IO a
myBracketCWD fp action =
do oldcwd - getCurrentDirectory
setCurrentDirectory fp
a - action
putStrLn $ show . last . show $ a -- force evaluation
setCurrentDirectory oldcwd
return a

-- rather than listing /, lists dir this module is in
tWrong = bracketCWD / $ return . take 2 = listCurrentWithFind

-- this lists filesystem root
tRight = myBracketCWD / $ return . take 2 = listCurrentWithFind

listCurrentWithFind = System.FilePath.Find.find (return True) (return True) .

-- for some reason, bracketCWD does the right thing with get
tGetContents = myBracketCWD / $ return . take 2 = getDirectoryContents .

Actual code for bracketCWD in MissingH:

-- this is from MissingH, seems there's a bug when attempt to wrap a
find command
bracketCWD :: FilePath - IO a - IO a
bracketCWD fp action =
do oldcwd - getCurrentDirectory
   setCurrentDirectory fp
   finally action (setCurrentDiurectory oldcwd)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Help on using System.Win32.Com.Automation

2009-03-23 Thread Alexandr N. Zamaraev

Sigbjorn Finne wrote:

Hi Wilkes,

you may want to have a look at a simple example of how to
interop with Windows WMI using the COM package at --

 http://haskell.forkio.com/com-examples

I try compile WMIDemo.hs but recive error:
[code]
c:\htestghc --make WMIDemo.hs
[2 of 2] Compiling WMIDemo  ( WMIDemo.hs, WMIDemo.o )

WMIDemo.hs:24:2:
Couldn't match expected type `[a]' against inferred type `(a1, b)'
In the pattern: (_, ls)
In a stmt of a 'do' expression: (_, ls) - is # enumVariants
In the second argument of `($)', namely
`do obj - Auto.getObject winmgmts:.\\root\\CIMV2
is - obj
# instancesOf
Win32_OperatingSystem
(Nothing :: Maybe Int)
(Nothing :: Maybe (IDispatch ()))
(_, ls) - is # enumVariants
case ls of {
  []
- fail Hmm..no OS information available; expected at 
least one.

  (wmi_os : _) - do ... }'
[/code]
ghc 6.10.1
com-1.2.1
Windows Vista Home Ru + sp1
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] MissingH bracketCD (aka bracketCWD) bug -- this is the infamous lazy io, right?

2009-03-23 Thread Nicolas Pouillard
Excerpts from Thomas Hartman's message of Mon Mar 23 09:08:41 +0100 2009:
 I got bitten by  a bug (well, I call it bug) in bracketCD from
 HSH/MissingH demonstrated by the following code
 
 bracketCD is very useful for sysadminny one-offs, I use it all the
 time, but. I suspect that unless people are very careful, this
 behavior will affect other users of bracketCD, in potentially very
 subtle and tricky ways.
 
 1) -- is there a more elegant way to deal with lazy io than the hack
 below? (putStrLn the last character)

Yes without changing the bracketCD function you can use a strict 'return'
function to help you avoid leaks.

return' :: (Monad m, NFData sa) - sa - m sa   
 
return' x = rnf x `seq` return x
 

 2) -- should MissingH function bracketCD be fixed, and if so how?

Not completely while staying in the full 'IO' monad.
Have a look at the strict-io package [1] that goes in this direction.

myBracketCWD :: (NFData sa, Show sa) = FilePath - SIO sa - IO sa
myBracketCWD fp action = do
oldcwd - getCurrentDirectory
setCurrentDirectory fp
a - SIO.run action
rnf a `seq` setCurrentDirectory oldcwd
return a

The same function could be more deeply in the 'SIO' monad by returning
in the 'SIO' monad. However this would require to first wrap
getCurrentDirectory and setCurrentDirectory in the 'SIO' monad.

Best regards,

[1]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/strict-io

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


Re: [Haskell-cafe] [ANN] Safe Lazy IO in Haskell

2009-03-23 Thread nicolas . pouillard
Excerpts from Henning Thielemann's message of Sun Mar 22 23:58:44 +0100 2009:
 
 On Sun, 22 Mar 2009, nicolas.pouillard wrote:
 
  It sounds like a nice idea, it would be great to have a straight-io package
  to play a bit more with explicit exceptions in things like 'IO'.
 
 Maybe I should then restrict lifting to LazyIO to SIO actions. That would 
 not make LazyIO safe, but reduces surprises.

By SIO you actually mean straight-io right? I was confused because I also
have an SIO monad in the strict-io package.

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


[Haskell-cafe] HSTringTemplate and syb-with-class

2009-03-23 Thread Kemps-Benedix Torsten
Hello all,

 

I'm trying to use the generic capabilities of HSTringTemplate. The
documentation claims that the package is able to automatically generate
instances of ToSElem if syb-with-class is installed but gives no further
details. I installed syb-with-class and then installed HSTringTemplate
with additional configure parameter syb-with-class=True. But when I
import Text.StringTemplate.GenericWithClass and then try deriving
ToSElem or $(derive ToSElem), I just get an error like Can't make a
derived instance of `ToSElem 

 

Any suggestions or pointer to further docs?

 

Kind regards

 

Torsten 

 

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


Re: [Haskell-cafe] [ANN] Safe Lazy IO in Haskell

2009-03-23 Thread Henning Thielemann


On Mon, 23 Mar 2009, nicolas.pouillard wrote:


Excerpts from Henning Thielemann's message of Sun Mar 22 23:58:44 +0100 2009:


On Sun, 22 Mar 2009, nicolas.pouillard wrote:


It sounds like a nice idea, it would be great to have a straight-io package
to play a bit more with explicit exceptions in things like 'IO'.


Maybe I should then restrict lifting to LazyIO to SIO actions. That would
not make LazyIO safe, but reduces surprises.


By SIO you actually mean straight-io right?


Yes

I was confused because I also have an SIO monad in the strict-io 
package.


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


Re: [Haskell-cafe] [ANN] Safe Lazy IO in Haskell

2009-03-23 Thread nicolas . pouillard
Excerpts from Henning Thielemann's message of Mon Mar 23 11:06:20 +0100 2009:
 
 On Mon, 23 Mar 2009, nicolas.pouillard wrote:
 
  Excerpts from Henning Thielemann's message of Sun Mar 22 23:58:44 +0100 
  2009:
 
  On Sun, 22 Mar 2009, nicolas.pouillard wrote:
 
  It sounds like a nice idea, it would be great to have a straight-io 
  package
  to play a bit more with explicit exceptions in things like 'IO'.
 
  Maybe I should then restrict lifting to LazyIO to SIO actions. That would
  not make LazyIO safe, but reduces surprises.
 
  By SIO you actually mean straight-io right?
 
 Yes

Then what do you mean by lifting to LazyIO to SIO actions?

Do you mean

  liftSIO :: SIO a - LazyIO.T a

which says that we only lift computations that explicitly throws exceptions.

In that case it be actually safer, but all of this greatly depends on how
reasonable is the explicit exception handling.

In particular in the case 'IO', using explicit exception is maybe too heavy.

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


Re: [Haskell-cafe] [ANN] Safe Lazy IO in Haskell

2009-03-23 Thread Henning Thielemann


On Mon, 23 Mar 2009, nicolas.pouillard wrote:


Excerpts from Henning Thielemann's message of Mon Mar 23 11:06:20 +0100 2009:


Yes


Then what do you mean by lifting to LazyIO to SIO actions?

Do you mean

 liftSIO :: SIO a - LazyIO.T a

which says that we only lift computations that explicitly throws exceptions.


Yes.


In that case it be actually safer, but all of this greatly depends on how
reasonable is the explicit exception handling.


If it does not fit, you can change it. :-) That's the advantage over 
built-in IO exceptions.



In particular in the case 'IO', using explicit exception is maybe too heavy.


I think it's precisely the best thing to do, given all the problems with 
asynchronous, imprecise and what-know-I exceptions.

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


[Haskell-cafe] ANNOUNCE: WinGhci, a GUI for GHCI on Windows

2009-03-23 Thread Pepe Gallardo
Hi, I am pleased to announce the first release of WinGhci.

WinGhci is a simple GUI for GHCI on Windows. It is closely based on WinHugs,
and provides similar functionality.


WinGhci project web page:
http://code.google.com/p/winghci/mhtml:{5097F7F7-AA40-4661-A7CF-D5EEC38F084A}mid://0003/!x-usc:http://code.google.com/p/winghci/

Binaries:
http://winghci.googlecode.com/files/WinGhci-1.0-bin.zipmhtml:{5097F7F7-AA40-4661-A7CF-D5EEC38F084A}mid://0003/!x-usc:http://winghci.googlecode.com/files/WinGhci-1.0-bin.zip

Sources:
 
http://winghci.googlecode.com/files/WinGhci-1.0-src.zipmhtml:{5097F7F7-AA40-4661-A7CF-D5EEC38F084A}mid://0003/!x-usc:http://winghci.googlecode.com/files/WinGhci-1.0-src.zip


Acknowledgements
Much of the code in WinGhci was taken from the Winhugs project. Many thanks
to Neil Mitchell for giving us permission to use his code.


mhtml:{5097F7F7-AA40-4661-A7CF-D5EEC38F084A}mid://0003/!x-usc:http://winghci.googlecode.com/files/WinGhci-1.0-bin.zip


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


[Haskell-cafe] Hackage upload problems?

2009-03-23 Thread Sebastiaan Visser

Hello,

Currently I'm trying to upload a minor update of Salvia to Hackage to  
fix some dependency issues but Hackage times out all the time? Both  
the CLI tool and the web-interface do not react to my upload request.


Any known problems here?

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


[Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-23 Thread Xiao-Yong Jin
Hi,

I just feel it is not comfortable to deal with exceptions
only within IO monad, so I defined

 tryArith :: a - Either ArithException a
 tryArith = unsafePerformIO . try . evaluate

and it works quite good as

 map (tryArith . (div 5)) [2,1,0,5]

evaluates to

 [Right 2,Right 5,Left divide by zero,Right 1]

However, I guess unsafePerformIO definitely has a reason for
its name.  As I read through the document in
System.IO.Unsafe, I can't convince myself whether the use of
'tryArith' is indeed safe or unsafe.

I know there have been a lot of discussion around
unsafePerformIO, but I still can't figure it out by myself.
Can someone share some thoughts on this particular use of
unsafePerformIO?  Is it safe or not?  And why?

Thanks,
Xiao-Yong
-- 
c/*__o/*
\ * (__
*/\  
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: SoC idea: interactive profiling

2009-03-23 Thread Tomáš Janoušek
Hello,

On Sun, Mar 22, 2009 at 04:08:59PM +0100, Alex Ott wrote:
 May be providing profiling information for kcachegrind will be a good
 solution?  For example, there are tools for PHP, that allow to view
 collected information in kcachegrind, and get interactive zooming, etc.

This is really awesome idea, you're totally not alone who would want this!

-- 
Tomáš Janoušek, a.k.a. Liskni_si, http://work.lisk.in/

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


[Haskell-cafe] Re: Use unsafePerformIO to catch Exception?

2009-03-23 Thread ChrisK
You should ensure that the result of evaluate is in normal form, not just weak 
head normal form.  You can do this with the Control.Parallel.Strategies module:



import Control.Exception(ArithException(..),try,evaluate)
import Control.Parallel.Strategies(NFData,using,rnf)
import System.IO.Unsafe(unsafePerformIO)

tryArith :: NFData a = a - Either ArithException a
tryArith = unsafePerformIO . try . evaluate . flip using rnf

test :: [Either ArithException Integer]
test =  map (tryArith . (div 5)) [2,1,0,5]

testResult = [Right 2,Right 5,Left DivideByZero,Right 1]

withPair :: Integer - (Integer,Integer)
withPair x = (x,throw Overflow)

main = do
  print (test == testResult)
  print (tryArith (withPair 7))
   print (tryArith' (withPair 7))


in ghci


*Main main
main
True
Left arithmetic overflow
Right (7,*** Exception: arithmetic overflow



This rnf :: Strategy a ensures that the result of evaluate is in normal form. 
 This means it should not have any embedded lazy thunks, so any errors from 
such thunks will be forced while in the scope of the try.


Otherwise a complex type like the result of withPair can hide an error.


Xiao-Yong Jin wrote:

Hi,

I just feel it is not comfortable to deal with exceptions
only within IO monad, so I defined


tryArith :: a - Either ArithException a
tryArith = unsafePerformIO . try . evaluate


and it works quite good as


map (tryArith . (div 5)) [2,1,0,5]


evaluates to


[Right 2,Right 5,Left divide by zero,Right 1]


However, I guess unsafePerformIO definitely has a reason for
its name.  As I read through the document in
System.IO.Unsafe, I can't convince myself whether the use of
'tryArith' is indeed safe or unsafe.

I know there have been a lot of discussion around
unsafePerformIO, but I still can't figure it out by myself.
Can someone share some thoughts on this particular use of
unsafePerformIO?  Is it safe or not?  And why?

Thanks,
Xiao-Yong


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


[Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows

2009-03-23 Thread Benjamin L . Russell
This is wonderful--just what I was waiting for!  The application looks
beautiful, and I'm very happy that GHCi now has a matching GUI
application along the lines of WinHugs.

It would be even better if you could provide some
installation/uninstallation information.  I unzipped the contents of
WinGhci-1.0-bin.zip into the C:\Documents and Settings\username\My
Documents\ folder, but there was no README file.

Therefore, I simply ran Install.exe, and pressed Yes at the question
to associate file extensions with winghci.exe.

After some thought, I then decided that installing the application in
the C:\Program Files\ folder would be better, but could not find any
information on how to uninstall the application, so I just moved the
folder and then re-ran Install.exe, again pressing Yes at the
question to associate file extensions with winghci.exe.  Is this the
correct way to reinstall the application?

Then, I ran StartGHCI.exe, but nothing seemed to happen, so I then ran
winghci.exe, and the application started.  Is this the correct way to
start the application?

I tried to check the winghci Wiki at
http://code.google.com/p/winghci/w/list, but the project had no wiki
pages.

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. 
-- Matsuo Basho^ 

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


Re: [Haskell-cafe] least fixed points above something

2009-03-23 Thread Jens Blanck


 On Friday 20 March 2009 5:23:37 am Ryan Ingram wrote:
  On Fri, Mar 20, 2009 at 1:01 AM, Dan Doel dan.d...@gmail.com wrote:
   However, to answer Luke's wonder, I don't think fixAbove always finds
   fixed points, even when its preconditions are met. Consider:
  
f [] = []
f (x:xs) = x:x:xs
  
twos = 2:twos
 
  How about
 
   fixAbove f x = x `lub` fixAbove f (f x)
 
  Probably doesn't work (or give good performance) with the current
  implementation of lub :)
 
  But if lub did work properly, it should give the correct answer for
  fixAbove f (2:undefined).

 This looked good to me at first, too (assuming it works), and it handles my
 first example. But alas, we can defeat it, too:

  f (x:y:zs) = x:y:x:y:zs
  f zs   = zs

 Now:

  f (2:_|_) = _|_
  f _|_ = _|_

  fix f = _|_

  fixAbove f (2:_|_) = 2:_|_ `lub` _|_ `lub` _|_ ...
 = 2:_|_

 Which is not a fixed point of f. But there are actually multiple choices of
 fixed points above 2:_|_

  f (2:[]) = 2:[]
  forall n. f (cycle [2,n]) = cycle [2,n]

 I suppose the important distinction here is that we can't arrive at the
 fixed
 point simply by iterating our function on our initial value (possibly
 infinitely many times). I suspect this example won't be doable without an
 oracle of some kind.

 Ah well.
 -- Dan


Thanks for all comments on my question, especially those bashing my poor
code.

The above approach does not apply to my case. What I have is a monotone
function f on a partial order satisfying f x = x, for all x. Given that the
partial order is in fact a cpo this is enough to guarantee that a least
fixed
point can be found above any point in the partial order simply by iterating
f, although not necessarily in finite time. Taking the lub of x and the
fixed
point of f (over bottom) need not give a fixed point even if one exists.

Think of reachability in a graph from a starting set. Let S be some fixed
set, and let f return all points reachable in 0 or 1 step from the union
of S and the argument to f. Then fix f is the set of points reachable from
S,
which is a fixed point. But adding some point x outside fix f will in
general
not give me a fixed point, even though a unique fixed point exists (the set
reachable from the union of {x} and fix f).

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


[Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows

2009-03-23 Thread Benjamin L . Russell
Just another couple of thoughts for possible additional improvement:

1.  It would be even nicer if WinGhci added a menu entry to the
Start menu automatically, as WinHugs does.

2.  For the proposed menu entry, it would also probably be a good idea
if WinGhci added a folder for that menu entry, and included a link to
a README file in there, as WinHugs does also.

3.  In order to distinguish WinGhci from GHCi, it might also be
helpful if WinGhci had a different icon; the current WinGhci icon is
identical to the one for GHCi (perhaps use the forthcoming official
Haskell logo here?).

Just my two cents for now

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. 
-- Matsuo Basho^ 

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


Re: [Haskell-cafe] Re: Use unsafePerformIO to catch Exception?

2009-03-23 Thread Xiao-Yong Jin
ChrisK hask...@list.mightyreason.com writes:

 You should ensure that the result of evaluate is in normal form, not
 just weak head normal form.  You can do this with the
 Control.Parallel.Strategies module:

 import Control.Exception(ArithException(..),try,evaluate)
 import Control.Parallel.Strategies(NFData,using,rnf)
 import System.IO.Unsafe(unsafePerformIO)

 tryArith :: NFData a = a - Either ArithException a
 tryArith = unsafePerformIO . try . evaluate . flip using rnf

 test :: [Either ArithException Integer]
 test =  map (tryArith . (div 5)) [2,1,0,5]

 testResult = [Right 2,Right 5,Left DivideByZero,Right 1]

 withPair :: Integer - (Integer,Integer)
 withPair x = (x,throw Overflow)

 main = do
   print (test == testResult)
   print (tryArith (withPair 7))
print (tryArith' (withPair 7))

 in ghci

 *Main main
 main
 True
 Left arithmetic overflow
 Right (7,*** Exception: arithmetic overflow


 This rnf :: Strategy a ensures that the result of evaluate is in
 normal form. This means it should not have any embedded lazy thunks,
 so any errors from such thunks will be forced while in the scope of
 the try.

 Otherwise a complex type like the result of withPair can hide an error.


Thanks a lot.  I found it is much easier to deal with
Exception with this than convert all my code to monadic
style.
-- 
c/*__o/*
\ * (__
*/\  
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows

2009-03-23 Thread Andrew Butterfield

Benjamin L.Russell wrote:

This is wonderful--just what I was waiting for!  The application looks
beautiful, and I'm very happy that GHCi now has a matching GUI
application along the lines of WinHugs.
  

Indeed - me too !

It would be even better if you could provide some
installation/uninstallation information.  I unzipped the contents of
WinGhci-1.0-bin.zip into the C:\Documents and Settings\username\My
Documents\ folder, but there was no README file.
  
And version information - I tried it with GHC 6.4 and it died (Not 
Responding)


What version of GHCi does it require?

And no, I won't upgrade GHC just yet (this is the latest GHC/wxHaskell 
combo that works for me with GHCi...)


  



--

Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
Foundations and Methods Research Group Director.
School of Computer Science and Statistics,
Room F.13, O'Reilly Institute, Trinity College, University of Dublin
   http://www.cs.tcd.ie/Andrew.Butterfield/


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


Re: [Haskell-cafe] least fixed points above something

2009-03-23 Thread Holger Siegel
Am Montag, den 23.03.2009, 12:55 + schrieb Jens Blanck:

 The above approach does not apply to my case. What I have is a
 monotone function f on a partial order satisfying f x = x, for all x.
 Given that the partial order is in fact a cpo this is enough to
 guarantee that a least fixed point can be found above any point in the
 partial order

which implies that every total value is a fixed point.

  simply by iterating f, although not necessarily in finite time.

Since every total value is a fixed point of f, the infimum of all total
values above x is an upper bound for the least fixed point above x. This
upper bound can be found the following way:

1) Find a position p in x at which the value is bottom::T, such that
   type T has exactly one constructor. If there is no such position, you
   are ready.

2) If T has exactly one constructor, then replace the value at position
   p with that constructor, leaving the constructor arguments undefined
   for now. Go on with step 1.

Let's call this upper bound y and assume a function glb that calculates
the greatest lower bound of two values. Then you can 'frame' a value v
into the interval [x, y] via the expression ((v `glb` y) `lub` x). This
works, because y = x implies that (v `glb` y) and x have an upper bound
in the CPO.  Also, function

f' v = ((f v `glb` y) `lub` x)

is monotonic and expanding on the interval [x, y]. So we get:

fixAbove f x = fix f'
where f' v = (f v `glb` y) `lub` x
  y= ... -- see above

Regards,

Holger


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


Re: [Haskell-cafe] Sometimes I wish there was a global variable

2009-03-23 Thread Jake McArthur

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Rafael Cunha de Almeida wrote:
| Hello,
|
| I am writing a OpenGL program in haskell, it can be found in:
|   http://github.com/aflag/galo/tree/master
| But I hope this e-mail will be self-contained :).
|
| My main function goes like this:
| (...)
| rotX - newIORef (0.0::GLfloat)
| rotY - newIORef (0.0::GLfloat)
| pos - newIORef (0.0::GLfloat, 0.0, 0.0)
|
| displayCallback $= display (map f range) rotX rotY pos
|
| keyboardMouseCallback $= Just (keyboardMouse rotX rotY pos)
| (...)
|
| Notice that rotX, rotY and pos are meant to be used as comunication
| between the keyboardMouse and display functions. They need to be set as
| 0 first, so display won't do anything. Only when they user press a few
| buttons that those values change, so display behaves accordanly.
|
| In a state-based language I would place display and keyboardMouse in one
| module and let them communcate to each other like they want. In haskell,
| I'm not quite sure how to do it except by that parameter passing style.
|
| I thought about how state-monad may help with that. But I'm not sure how
| I'd make the state variable to be contained inside a
| display/keyboardMouse module.

Another way to do this would be something like this:

~main = do
~  ...
~  displayCallback $= initialDisplayFunction
~  keyboardMouseCallback $= keyboardMouseFunction
~  ...

~keyboardMouseFunction = do
~  rotX - ...
~  rotY - ...
~  pos - ...
~  ...
~  displayCallback $= display ... rotX rotY rotZ

You could even write your own state monad that does this callback
reassignment for you (perhaps by wrapping StateT s IO a), then you can
forget about all this explicit parameter passing.

- - Jake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknHq+kACgkQye5hVyvIUKnX3ACeMLD8FLOTEya8can6veyp6cT3
ClMAnRdfl/DyOshvzlBF8QCtYgTf87fd
=Bp4F
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hackage upload problems?

2009-03-23 Thread Don Stewart
sfvisser:
 Hello,

 Currently I'm trying to upload a minor update of Salvia to Hackage to  
 fix some dependency issues but Hackage times out all the time? Both the 
 CLI tool and the web-interface do not react to my upload request.

 Any known problems here?

Discussion taking place on libraries@
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Hackage download and popularity statistics

2009-03-23 Thread Don Stewart
For the first time, we've got download and popularity statistics from 
Hackage:

http://www.galois.com/blog/2009/03/23/one-million-haskell-downloads/

Find out if your package made the top 100, and when we reach our 1
millionth hackage download!

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


[Haskell-cafe] RE: [ANN] Safe Lazy IO in Haskell

2009-03-23 Thread Wei Hu
Nicolas Pouillard nicolas.pouillard at gmail.com writes:


 Hi folks,

 We have good news (nevertheless we hope) for all the lazy guys standing there.
 Since their birth, lazy IOs have been a great way to modularly leverage all 
 the
 good things we have with *pure*, *lazy*, *Haskell* functions to the real world
 of files.

 We are happy to present the safe-lazy-io package [1] that does exactly this
 and is going to be explained and motivated in the rest of this post.

Hi,

Please let me know if I understood your code correctly. So, the SIO
module is used only to ensure that the file processing is finished
before the finalizer closes the file, right?

In System.IO.Lazy.Input, run is defined as

 run :: NFData sa = LI sa - IO sa
 run = run' . fmap return'

Can I change it to

 run = run' . fmap return
?

I think the semantics is the same because run' will strictly force the
processing anyway?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Help on using System.Win32.Com.Automation

2009-03-23 Thread Sigbjorn Finne

Alexandr N. Zamaraev wrote:

Sigbjorn Finne wrote:

Hi Wilkes,

you may want to have a look at a simple example of how to
interop with Windows WMI using the COM package at --

 http://haskell.forkio.com/com-examples

I try compile WMIDemo.hs but recive error:
[code]
c:\htestghc --make WMIDemo.hs
[2 of 2] Compiling WMIDemo  ( WMIDemo.hs, WMIDemo.o )

WMIDemo.hs:24:2:
Couldn't match expected type `[a]' against inferred type `(a1, b)'

...

Hi,

please upgrade to the latest version - 1.2.2 - of the com package for 
this example,


  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/com

There's been some improvements to the lib, esp. the handling of enumerations
(which is where that type error is coming from.)

hth
--sigbjorn

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


[Haskell-cafe] A small display problem using Helium

2009-03-23 Thread Anonymous Anonymous
Hello,

I've written something simple:

main:: IO ()
main=  do lijn - getLine
  putStrLn lijn

Now if I import it in Helium it will do the following:

Test main
test -- (here I'm typing test)
test

it will be displayed two times, why? Because it displays my input and the
output of the function. Now I want to write a function that does NOT display
my input, any suggestions how I can achieve this?

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


[Haskell-cafe] System.Random.Shuffle fix

2009-03-23 Thread friggin friggin
I was looking for a shuffling algorithm to shuffle mp3-playlists so was very
happy to see System.Random.Shuffle:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/random-shuffle-0.0.2

However I get  errors,non-exhaustive patterns in function shufleTree or
extractTree depending how I call it. Errors are at the bottom.

I fixed it but I don't have the math skills to see if I perhaps broke it
statistically ...

Here is my fix, someone (don't remember who, helped me a little):
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2789#a2789
the shuffle at the end is with the fix.


*Freet S.shuffle [1..10] [1..3]
Loading package syb ... linking ... done.
Loading package base-3.0.3.0 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.1 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
Loading package random-shuffle-0.0.2 ... linking ... done.
[2,4,6*** Exception: src\System\Random\Shuffle.hs:(52,6)-(55,30):
Non-exhaustive patterns in function shuffleTree

*Freet S.shuffle [1..3] [1..10]
[2,*** Exception: src\System\Random\Shuffle.hs:(66,6)-(79,27):
Non-exhaustive patterns in function extractTree

*Freet :load c:/ghc/ghc-6.10.1/progs/Mp3Player/Shuffle.hs
[1 of 1] Compiling Shuffle  (
C:\ghc\ghc-6.10.1\progs\Mp3Player\Shuffle.hs, interpreted )
Ok, modules loaded: Shuffle.
*Shuffle shuffle [1..3] [1..10]
[2,1,3]
*Shuffle shuffle [1..10] [1..3]
[2,4,6*** Exception:
C:\ghc\ghc-6.10.1\progs\Mp3Player\Shuffle.hs:(27,13)-(31,30): Non-exhaustive
patterns in function shuffle'

*Shuffle shuffle [1..10] [1..10]
[2,4,6,8,10,3,9,7,5,1]
*Shuffle
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] System.Random.Shuffle fix

2009-03-23 Thread Manlio Perillo

friggin friggin ha scritto:
I was looking for a shuffling algorithm to shuffle mp3-playlists so was 
very happy to see System.Random.Shuffle:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/random-shuffle-0.0.2

However I get  errors,non-exhaustive patterns in function shufleTree or 
extractTree depending how I call it. Errors are at the bottom.




During building you should only get warnings.
Non exhaustive patterns are ok, you hit them only if the input data is 
incorret.


Probably in these cases, error should be used.

I fixed it but I don't have the math skills to see if I perhaps broke it 
statistically ...


Here is my fix, someone (don't remember who, helped me a little):
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2789#a2789
the shuffle at the end is with the fix.


*Freet S.shuffle [1..10] [1..3]


Your input is not correct.
If you read the source code (in a future version I'll add Haddock support):

-- Given a sequence (e1,...en) to shuffle, and a sequence
-- (r1,...r[n-1]) of numbers such that r[i] is an independent sample
-- from a uniform random distribution [0..n-i], compute the
-- corresponding permutation of the input sequence.

I have added a convenience function `shuffle'`, where you just need to 
supply a random number generator.


Note that the shuffle' function contains a bug;
it should return the new random generator:
shuffle' :: RandomGen gen = [a] - Int - gen - ([a], gen)

I'm going to fix it in next version.

 [...]



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


[Haskell-cafe] Hugs on iPhone

2009-03-23 Thread Kirk Martinez
I saw Miguel Mitrofanov (
http://www.nabble.com/Hugs-on-the-iphone-td19478992.html) successfully
ported Hugs to the iPhone.  I'm now wondering if anyone has tried to get
Apple's blessing to put this in the App Store?  It would be really great to
be able to try out little Haskell ideas as the mood strikes.  Of course,
it's kind of essential to have an editor of some kind for more significant
programs...

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


Re: [Haskell-cafe] Hugs on iPhone

2009-03-23 Thread Miguel Mitrofanov
1) You'll need a terminal application first, and I'm not sure if there  
is one in AppStore. In fact, I AM sure there isn't.


2) My iPod Touch is still running 1.1.4 firmware; I've heard it's not  
that easy on 2.0 and later.


3) Personally, I'd love to see ghc on iPhone. It could even persuade  
me to upgrade.


On 23 Mar 2009, at 21:00, Kirk Martinez wrote:

I saw Miguel Mitrofanov (http://www.nabble.com/Hugs-on-the-iphone-td19478992.html 
) successfully ported Hugs to the iPhone.  I'm now wondering if  
anyone has tried to get Apple's blessing to put this in the App  
Store?  It would be really great to be able to try out little  
Haskell ideas as the mood strikes.  Of course, it's kind of  
essential to have an editor of some kind for more significant  
programs...


Thanks,
Kirk
___
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] Hugs on iPhone

2009-03-23 Thread Rick R
Unfortunately the developers agreement expressly forbids the use of
interpreters that load and run external programs. This is probably for the
simple reason that it would be almost impossible to secure, or even
guarantee that it wont exceed its space and mem usage bounds required by
AppStore apps.

Short answer: Jailbreak and install away :)


2009/3/23 Kirk Martinez kirk.marti...@gmail.com

 I saw Miguel Mitrofanov (
 http://www.nabble.com/Hugs-on-the-iphone-td19478992.html) successfully
 ported Hugs to the iPhone.  I'm now wondering if anyone has tried to get
 Apple's blessing to put this in the App Store?  It would be really great to
 be able to try out little Haskell ideas as the mood strikes.  Of course,
 it's kind of essential to have an editor of some kind for more significant
 programs...

 Thanks,
 Kirk

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




-- 
We can't solve problems by using the same kind of thinking we used when we
created them.
   - A. Einstein
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] SOC idea ticket: Rendering Engine

2009-03-23 Thread Csaba Hruska
Hi!

I've created a ticket for this idea:
http://hackage.haskell.org/trac/summer-of-code/ticket/1572
Please write your opinion.

I also put the source code here:
http://code.google.com/p/lambdacube/

svn checkout *http*://lambdacube.googlecode.com/svn/trunk/lambdacube-read-only


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


Re: [Haskell-cafe] Hugs on iPhone

2009-03-23 Thread David Leimbach
On Mon, Mar 23, 2009 at 11:22 AM, Miguel Mitrofanov
miguelim...@yandex.ruwrote:

 1) You'll need a terminal application first, and I'm not sure if there is
 one in AppStore. In fact, I AM sure there isn't.


There's SSH terminal programs like Putty based stuff that are in the
AppStore.  So that sort of thing has been done yes.




 2) My iPod Touch is still running 1.1.4 firmware; I've heard it's not that
 easy on 2.0 and later.


that's unfortunate.



 3) Personally, I'd love to see ghc on iPhone. It could even persuade me to
 upgrade.


 On 23 Mar 2009, at 21:00, Kirk Martinez wrote:

  I saw Miguel Mitrofanov (
 http://www.nabble.com/Hugs-on-the-iphone-td19478992.html) successfully
 ported Hugs to the iPhone.  I'm now wondering if anyone has tried to get
 Apple's blessing to put this in the App Store?  It would be really great to
 be able to try out little Haskell ideas as the mood strikes.  Of course,
 it's kind of essential to have an editor of some kind for more significant
 programs...

 Thanks,
 Kirk
 ___
 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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs on iPhone

2009-03-23 Thread Miguel Mitrofanov


On 23 Mar 2009, at 21:38, David Leimbach wrote:




On Mon, Mar 23, 2009 at 11:22 AM, Miguel Mitrofanov miguelim...@yandex.ru 
 wrote:
1) You'll need a terminal application first, and I'm not sure if  
there is one in AppStore. In fact, I AM sure there isn't.


There's SSH terminal programs like Putty based stuff that are in the  
AppStore.  So that sort of thing has been done yes.


You sure it can SSH to iPhone itself? Installing Hugs (or GHC) on a  
desktop PC and connecting to it via ssh is anything but impressive.


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


Re: [Haskell-cafe] Hugs on iPhone

2009-03-23 Thread John Van Enk
I think he means a program running on the iPhone which allows you to open a
terminal over an SSH session to other devices. The instance (I think) you're
thinking of is where the SSH *server* runs on the iPhone.

On Mon, Mar 23, 2009 at 2:46 PM, Miguel Mitrofanov miguelim...@yandex.ruwrote:


 On 23 Mar 2009, at 21:38, David Leimbach wrote:



 On Mon, Mar 23, 2009 at 11:22 AM, Miguel Mitrofanov 
 miguelim...@yandex.ru wrote:
 1) You'll need a terminal application first, and I'm not sure if there is
 one in AppStore. In fact, I AM sure there isn't.

 There's SSH terminal programs like Putty based stuff that are in the
 AppStore.  So that sort of thing has been done yes.


 You sure it can SSH to iPhone itself? Installing Hugs (or GHC) on a desktop
 PC and connecting to it via ssh is anything but impressive.


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




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


Re: [Haskell-cafe] SOC idea ticket: Rendering Engine

2009-03-23 Thread Roman Cheplyaka
* Csaba Hruska csaba.hru...@gmail.com [2009-03-23 19:24:19+0100]
 Hi!
 
 I've created a ticket for this idea:
 http://hackage.haskell.org/trac/summer-of-code/ticket/1572
 Please write your opinion.
 
 I also put the source code here:
 http://code.google.com/p/lambdacube/
 
 svn checkout *http*://lambdacube.googlecode.com/svn/trunk/lambdacube-read-only

Hi Csaba,

this looks very promising!

Correct command to checkout:
  
  svn checkout http://lambdacube.googlecode.com/svn/trunk/ lambdacube

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't let school get in the way of your education. - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs on iPhone

2009-03-23 Thread David Leimbach
On Mon, Mar 23, 2009 at 11:46 AM, Miguel Mitrofanov
miguelim...@yandex.ruwrote:


 On 23 Mar 2009, at 21:38, David Leimbach wrote:



 On Mon, Mar 23, 2009 at 11:22 AM, Miguel Mitrofanov 
 miguelim...@yandex.ru wrote:
 1) You'll need a terminal application first, and I'm not sure if there is
 one in AppStore. In fact, I AM sure there isn't.

 There's SSH terminal programs like Putty based stuff that are in the
 AppStore.  So that sort of thing has been done yes.


 You sure it can SSH to iPhone itself? Installing Hugs (or GHC) on a desktop
 PC and connecting to it via ssh is anything but impressive.


It sure can't... but you said a terminal application, not a terminal on the
iphone :-)  If you meant you wanted a shell on the iPhone for that, that's
something different, but if you wanted the ability to deal with terminal
sessions from a serial-like stream, that does exist.

I agree ssh'ng to another server isn't that interesting but someone just
committed a GHCI GUI for windows...

I thought Hugs had such a thing already.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hugs on iPhone

2009-03-23 Thread David Leimbach
On Mon, Mar 23, 2009 at 11:53 AM, John Van Enk vane...@gmail.com wrote:

 I think he means a program running on the iPhone which allows you to open a
 terminal over an SSH session to other devices. The instance (I think) you're
 thinking of is where the SSH *server* runs on the iPhone.


Yeah I was talking about a terminal capability that can deal with all the
lovely control codes of serial terminals.

I thought this could serve as a front-end for something running with curses
bindings, not that you need to open up the whole darned iphone to do this
stuff.

Dave




 On Mon, Mar 23, 2009 at 2:46 PM, Miguel Mitrofanov 
 miguelim...@yandex.ruwrote:


 On 23 Mar 2009, at 21:38, David Leimbach wrote:



 On Mon, Mar 23, 2009 at 11:22 AM, Miguel Mitrofanov 
 miguelim...@yandex.ru wrote:
 1) You'll need a terminal application first, and I'm not sure if there is
 one in AppStore. In fact, I AM sure there isn't.

 There's SSH terminal programs like Putty based stuff that are in the
 AppStore.  So that sort of thing has been done yes.


 You sure it can SSH to iPhone itself? Installing Hugs (or GHC) on a
 desktop PC and connecting to it via ssh is anything but impressive.


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




 --
 /jve

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


[Haskell-cafe] Re: SOC idea ticket: Rendering Engine

2009-03-23 Thread Achim Schneider
Csaba Hruska csaba.hru...@gmail.com wrote:

 svn checkout
 *http*://lambdacube.googlecode.com/svn/trunk/lambdacube-read-only
 
I think you mean
svn co http://lambdacube.googlecode.com/svn/trunk

I didn't do anything yet, except running the sample program. I get to
see an ogre head and this:

8

k...@solaris trunk % ./example1
[.,..,car,.svn,packs,materials,models]
[.,..,.svn,toonf2.frag,toonf2.vert,Example_CelShading.frag,Example_CelShading.vert,texturemapping.frag,texturemapping.vert,diffuse.frag,diffuse.vert,ambient.frag,ambient.vert]
 
[.,..,.svn,todo,Ogre.material,jaiqua.material,Scene.material,ogrehead.material,Robot.material,RZR-002.material]

   
load:
Ogre.material load:
jaiqua.material load:
Scene.material load:
ogrehead.material load:
Robot.material load:
RZR-002.material
[.,..,.svn,cel_shading_diffuse.png,r2skin.jpg,RZR-002.png,cel_shading_specular.png,cel_shading_edge.png,GreenSkin.jpg,spheremap.png,WeirdEye.png,dirt01.jpg,blue_jaiqua.jpg]
[.,..,.svn,Cube.mesh.xml,ogrehead.mesh.xml,athene.mesh.xml,ninja.mesh.xml,Suzanne.mesh.xml,RZR-002.mesh.xml,facial.mesh.xml,robot.skeleton.xml,robot.mesh.xml,jaiqua.mesh.xml]
[.,..,.svn,scooby_body.mesh.xml,scooby_body.material,ventanas.jpg,chasis.jpg,chasis_a.jpg]
load: scooby_body.material creating entity: OgreHead from mesh:
ogrehead.mesh.xml parsing XML
file
[Ogre/Tusks,Ogre/Earring,Ogre/Skin,Ogre/Eyes] compiling
material: Ogre/Eyes WeirdEye.png
loaded resolution = 256 x 256, 3 bytes per
pixel compiling material:
Ogre/Skin GreenSkin.jpg
loaded resolution = 256 x 256, 3 bytes per
pixel compiling material:
Ogre/Earring spheremap.png
loaded resolution = 256 x 256, 3 bytes per
pixel compiling material:
Ogre/Tusks dirt01.jpg
loaded resolution = 96 x 96, 3 bytes per
pixel
done creating entity: Robot from mesh:
robot2.mesh.xml parsing XML
file
[Examples/Robot] compiling material:
Examples/Robot r2skin.jpg
loaded resolution = 512 x 512, 3 bytes per
pixel Compiling program: (Just Examples/AmbientShadingVP,Just
Examples/AmbientShadingFP) Shader info log for
'Examples/AmbientShadingVP':


Shader info log for 'Examples/AmbientShadingFP':


Program info log:


 done
creating entity: Car from mesh: scooby_body.mesh.xml
parsing XML file
[Ac3d/Scooby_Body/Mat001_Tex03,Ac3d/Scooby_Body/Mat001_Tex02,Ac3d/Scooby_Body/Mat001_Tex01]
compiling material: Ac3d/Scooby_Body/Mat001_Tex01
chasis.jpg loaded
resolution = 512 x 512, 3 bytes per pixel
compiling material: Ac3d/Scooby_Body/Mat001_Tex02
ventanas.jpg loaded
resolution = 512 x 512, 3 bytes per pixel
compiling material: Ac3d/Scooby_Body/Mat001_Tex03
chasis_a.jpg loaded
resolution = 128 x 256, 3 bytes per pixel
 done
1 frames in 13.45548 seconds = 7.431916215549353e-2 FPS
zsh: abort  ./example1


8


I _think_ example1 is killed by SIGABRT, but I could be wrong, I've
never seen this before. Anyway, it's a strange thing.

OpenGL vendor string: NVIDIA Corporation 
OpenGL renderer string: GeForce 7600 GS/PCI/SSE2 
OpenGL version string: 2.1.2 NVIDIA 177.82 
OpenGL shading language version string: 1.20 NVIDIA via Cg compiler

X.Org X Server 1.5.3

Linux solaris 2.6.28-tuxonice-r1 #20 PREEMPT Tue Mar 10 19:07:36 CET
2009 x86_64 AMD Athlon(tm) 64 Processor 3200+ AuthenticAMD GNU/Linux

The Glorious Glasgow Haskell Compilation System, version 6.10.1

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


Re: [Haskell-cafe] Re: SOC idea ticket: Rendering Engine

2009-03-23 Thread Csaba Hruska
2009/3/23 Achim Schneider bars...@web.de

 Csaba Hruska csaba.hru...@gmail.com wrote:

  svn checkout
  *http*://lambdacube.googlecode.com/svn/trunk/lambdacube-read-only
 
 I think you mean
 svn co http://lambdacube.googlecode.com/svn/trunk

 I didn't do anything yet, except running the sample program. I get to
 see an ogre head and this:

 8

 k...@solaris trunk % ./example1
 [.,..,car,.svn,packs,materials,models]

 [.,..,.svn,toonf2.frag,toonf2.vert,Example_CelShading.frag,Example_CelShading.vert,texturemapping.frag,texturemapping.vert,diffuse.frag,diffuse.vert,ambient.frag,ambient.vert]

 [.,..,.svn,todo,Ogre.material,jaiqua.material,Scene.material,ogrehead.material,Robot.material,RZR-002.material]
 load:
 Ogre.material load:
 jaiqua.material load:
 Scene.material load:
 ogrehead.material load:
 Robot.material load:
 RZR-002.material

 [.,..,.svn,cel_shading_diffuse.png,r2skin.jpg,RZR-002.png,cel_shading_specular.png,cel_shading_edge.png,GreenSkin.jpg,spheremap.png,WeirdEye.png,dirt01.jpg,blue_jaiqua.jpg]

 [.,..,.svn,Cube.mesh.xml,ogrehead.mesh.xml,athene.mesh.xml,ninja.mesh.xml,Suzanne.mesh.xml,RZR-002.mesh.xml,facial.mesh.xml,robot.skeleton.xml,robot.mesh.xml,jaiqua.mesh.xml]

 [.,..,.svn,scooby_body.mesh.xml,scooby_body.material,ventanas.jpg,chasis.jpg,chasis_a.jpg]
 load: scooby_body.material creating entity: OgreHead from mesh:
 ogrehead.mesh.xml parsing XML
 file
 [Ogre/Tusks,Ogre/Earring,Ogre/Skin,Ogre/Eyes] compiling
 material: Ogre/Eyes WeirdEye.png
 loaded resolution = 256 x 256, 3 bytes per
 pixel compiling material:
 Ogre/Skin GreenSkin.jpg
 loaded resolution = 256 x 256, 3 bytes per
 pixel compiling material:
 Ogre/Earring spheremap.png
 loaded resolution = 256 x 256, 3 bytes per
 pixel compiling material:
 Ogre/Tusks dirt01.jpg
 loaded resolution = 96 x 96, 3 bytes per
 pixel
 done creating entity: Robot from mesh:
 robot2.mesh.xml parsing XML
 file
 [Examples/Robot] compiling material:
 Examples/Robot r2skin.jpg
 loaded resolution = 512 x 512, 3 bytes per
 pixel Compiling program: (Just Examples/AmbientShadingVP,Just
 Examples/AmbientShadingFP) Shader info log for
 'Examples/AmbientShadingVP':


 Shader info log for 'Examples/AmbientShadingFP':


 Program info log:


  done
 creating entity: Car from mesh: scooby_body.mesh.xml
 parsing XML file

 [Ac3d/Scooby_Body/Mat001_Tex03,Ac3d/Scooby_Body/Mat001_Tex02,Ac3d/Scooby_Body/Mat001_Tex01]
 compiling material: Ac3d/Scooby_Body/Mat001_Tex01
 chasis.jpg loaded
 resolution = 512 x 512, 3 bytes per pixel
 compiling material: Ac3d/Scooby_Body/Mat001_Tex02
 ventanas.jpg loaded
 resolution = 512 x 512, 3 bytes per pixel
 compiling material: Ac3d/Scooby_Body/Mat001_Tex03
 chasis_a.jpg loaded
 resolution = 128 x 256, 3 bytes per pixel
  done

Until this point it is OK. (sorry for the lots of debug info, i'll remove
them later)


 1 frames in 13.45548 seconds = 7.431916215549353e-2 FPS

The FPS calculation is wrong at first frame. I have a geforce 7300 GS and
its running at ~670 FPS in 640x480 sized window.
The example uses glsl shader. (if you remove robot from the scene then it
will be compatible with older graphic cards too)
Please press ESC to exit from example program instead of closing the window.

The screenshot (http://code.google.com/p/lambdacube/) is taken from
example1, you should get same one.


 zsh: abort  ./example1


 8


 I _think_ example1 is killed by SIGABRT, but I could be wrong, I've
 never seen this before. Anyway, it's a strange thing.

Does the program exit immediatly after the first rendered frame?


 OpenGL vendor string: NVIDIA Corporation
 OpenGL renderer string: GeForce 7600 GS/PCI/SSE2
 OpenGL version string: 2.1.2 NVIDIA 177.82
 OpenGL shading language version string: 1.20 NVIDIA via Cg compiler

 X.Org X Server 1.5.3

 Linux solaris 2.6.28-tuxonice-r1 #20 PREEMPT Tue Mar 10 19:07:36 CET
 2009 x86_64 AMD Athlon(tm) 64 Processor 3200+ AuthenticAMD GNU/Linux

 The Glorious Glasgow Haskell Compilation System, version 6.10.1

I've tested with ghc 6.10.1 on amd sempron 1800+ 32 bit gnu/linux geforce
7300gs.


 --
 (c) this sig last receiving data processing entity. Inspect headers
 for copyright history. All rights reserved. Copying, hiring, renting,
 performance and/or quoting of this signature prohibited.


 ___
 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] Re: SOC idea ticket: Rendering Engine

2009-03-23 Thread Achim Schneider
Csaba Hruska csaba.hru...@gmail.com wrote:

  I _think_ example1 is killed by SIGABRT, but I could be wrong, I've
  never seen this before. Anyway, it's a strange thing.
   
 Does the program exit immediatly after the first rendered frame?

Usually yes, sometimes I'm seeing the ogre being rotated before
SIGABRT. At first I thought it might be the app getting confused by
xmonad resizing it, but switching to twm or kwm didn't help. I'm going
to investigate a bit further as soon as I figured out why xmonad
doesn't use xinerama(again) after re-compilation.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


RE: [Haskell-cafe] Hugs on iPhone

2009-03-23 Thread Michael Giagnocavo
Doesn't Apple Store restrict applications (by policy) so they cannot generate 
or execute arbitrary code? (That's the reason there's no Flash for iPhone.) 
That restriction seems like it'd block any interpreter or compiler from being 
sold, no?

-Michael

From: haskell-cafe-boun...@haskell.org 
[mailto:haskell-cafe-boun...@haskell.org] On Behalf Of David Leimbach
Sent: Monday, March 23, 2009 12:59 PM
To: John Van Enk
Cc: haskell-cafe@haskell.org; Miguel Mitrofanov
Subject: Re: [Haskell-cafe] Hugs on iPhone


On Mon, Mar 23, 2009 at 11:53 AM, John Van Enk 
vane...@gmail.commailto:vane...@gmail.com wrote:
I think he means a program running on the iPhone which allows you to open a 
terminal over an SSH session to other devices. The instance (I think) you're 
thinking of is where the SSH *server* runs on the iPhone.

Yeah I was talking about a terminal capability that can deal with all the 
lovely control codes of serial terminals.

I thought this could serve as a front-end for something running with curses 
bindings, not that you need to open up the whole darned iphone to do this stuff.

Dave


On Mon, Mar 23, 2009 at 2:46 PM, Miguel Mitrofanov 
miguelim...@yandex.rumailto:miguelim...@yandex.ru wrote:

On 23 Mar 2009, at 21:38, David Leimbach wrote:


On Mon, Mar 23, 2009 at 11:22 AM, Miguel Mitrofanov 
miguelim...@yandex.rumailto:miguelim...@yandex.ru wrote:
1) You'll need a terminal application first, and I'm not sure if there is one 
in AppStore. In fact, I AM sure there isn't.

There's SSH terminal programs like Putty based stuff that are in the AppStore.  
So that sort of thing has been done yes.

You sure it can SSH to iPhone itself? Installing Hugs (or GHC) on a desktop PC 
and connecting to it via ssh is anything but impressive.

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



--
/jve

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


[Haskell-cafe] Re: Hugs on iPhone

2009-03-23 Thread Braden Shepherdson

Miguel Mitrofanov wrote:
3) Personally, I'd love to see ghc on iPhone. It could even persuade me 
to upgrade.


See the GHC-on-ARM page[1] for my work on it last summer, among others'. 
GHC is tough to port because bootstrapping to new architectures has been 
broken for a long time, since soon after 6.6.2. My attempts to 
cross-compile 6.6.1 using the development environment for my Nokia N810 
failed, as can be seen in [1].


I attempted several times to build Hugs for it: it would build 
successfully and then fail to run either on the device, in scratchbox, 
or natively compiled on x86 because it failed to find the Prelude. I 
suspect I was doing something wrong in building Hugs, something 
unrelated to the ARM platform.


The good news is that jhc's portable C code works perfectly well -- but 
of course that is simply running precompiled Haskell apps and not a 
compiler or interpreter running on the device. Since jhc is not 
self-hosting (yet?) but instead is built with GHC, that's the best we 
can do with that approach for now.



Braden Shepherdson
shepheb

[1] http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc

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


Re: [Haskell-cafe] Hugs on iPhone

2009-03-23 Thread Miguel Mitrofanov

http://www.readwriteweb.com/archives/confirmed_apple_and_adobe_coll.php

On 23 Mar 2009, at 23:29, Michael Giagnocavo wrote:

Doesn’t Apple Store restrict applications (by policy) so they cannot  
generate or execute arbitrary code? (That’s the reason there’s no  
Flash for iPhone.) That restriction seems like it’d block any  
interpreter or compiler from being sold, no?


-Michael

From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org 
] On Behalf Of David Leimbach

Sent: Monday, March 23, 2009 12:59 PM
To: John Van Enk
Cc: haskell-cafe@haskell.org; Miguel Mitrofanov
Subject: Re: [Haskell-cafe] Hugs on iPhone


On Mon, Mar 23, 2009 at 11:53 AM, John Van Enk vane...@gmail.com  
wrote:
I think he means a program running on the iPhone which allows you to  
open a terminal over an SSH session to other devices. The instance  
(I think) you're thinking of is where the SSH *server* runs on the  
iPhone.


Yeah I was talking about a terminal capability that can deal with  
all the lovely control codes of serial terminals.


I thought this could serve as a front-end for something running with  
curses bindings, not that you need to open up the whole darned  
iphone to do this stuff.


Dave


On Mon, Mar 23, 2009 at 2:46 PM, Miguel Mitrofanov miguelim...@yandex.ru 
 wrote:


On 23 Mar 2009, at 21:38, David Leimbach wrote:


On Mon, Mar 23, 2009 at 11:22 AM, Miguel Mitrofanov miguelim...@yandex.ru 
 wrote:
1) You'll need a terminal application first, and I'm not sure if  
there is one in AppStore. In fact, I AM sure there isn't.


There's SSH terminal programs like Putty based stuff that are in the  
AppStore.  So that sort of thing has been done yes.


You sure it can SSH to iPhone itself? Installing Hugs (or GHC) on a  
desktop PC and connecting to it via ssh is anything but impressive.


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



--
/jve

___
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] Hugs on iPhone

2009-03-23 Thread Michael Giagnocavo
Guess they ended up making an exception for Flash, finally. Will be interesting 
to see how they prevent 3rd party stores from running arbitrary Flash games and 
whatnot. Maybe they'll blacklist any popular sites that are stealing 
marketshare from the AppStore?

-Michael

-Original Message-
From: Miguel Mitrofanov [mailto:miguelim...@yandex.ru] 
Sent: Monday, March 23, 2009 2:52 PM
To: Michael Giagnocavo
Cc: David Leimbach; John Van Enk; haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Hugs on iPhone

http://www.readwriteweb.com/archives/confirmed_apple_and_adobe_coll.php

On 23 Mar 2009, at 23:29, Michael Giagnocavo wrote:

 Doesn't Apple Store restrict applications (by policy) so they cannot  
 generate or execute arbitrary code? (That's the reason there's no  
 Flash for iPhone.) That restriction seems like it'd block any  
 interpreter or compiler from being sold, no?

 -Michael

 From: haskell-cafe-boun...@haskell.org 
 [mailto:haskell-cafe-boun...@haskell.org 
 ] On Behalf Of David Leimbach
 Sent: Monday, March 23, 2009 12:59 PM
 To: John Van Enk
 Cc: haskell-cafe@haskell.org; Miguel Mitrofanov
 Subject: Re: [Haskell-cafe] Hugs on iPhone


 On Mon, Mar 23, 2009 at 11:53 AM, John Van Enk vane...@gmail.com  
 wrote:
 I think he means a program running on the iPhone which allows you to  
 open a terminal over an SSH session to other devices. The instance  
 (I think) you're thinking of is where the SSH *server* runs on the  
 iPhone.

 Yeah I was talking about a terminal capability that can deal with  
 all the lovely control codes of serial terminals.

 I thought this could serve as a front-end for something running with  
 curses bindings, not that you need to open up the whole darned  
 iphone to do this stuff.

 Dave


 On Mon, Mar 23, 2009 at 2:46 PM, Miguel Mitrofanov miguelim...@yandex.ru 
  wrote:

 On 23 Mar 2009, at 21:38, David Leimbach wrote:


 On Mon, Mar 23, 2009 at 11:22 AM, Miguel Mitrofanov miguelim...@yandex.ru 
  wrote:
 1) You'll need a terminal application first, and I'm not sure if  
 there is one in AppStore. In fact, I AM sure there isn't.

 There's SSH terminal programs like Putty based stuff that are in the  
 AppStore.  So that sort of thing has been done yes.

 You sure it can SSH to iPhone itself? Installing Hugs (or GHC) on a  
 desktop PC and connecting to it via ssh is anything but impressive.

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



 -- 
 /jve

 ___
 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] Function to cast types

2009-03-23 Thread Richard O'Keefe


On 23 Mar 2009, at 2:20 am, Anonymous Anonymous wrote:


Hello,

I'm new to haskell, I'm wondering how can you write a function that  
will do the following:


fromIntToString :: Int - String

this is a cast function to cast an Int to a String.


It cannot be.  What could it possibly mean to cast an Int
to anything, let alone a string?  Haskell isn't C.  (Nor is
it PL/I.)

What to do depends on what you _want_ to do.  For example,
fromIntToString n = replicate n 'I'
will convert 1 to I, 2 to II, 3 to III, and so on.

Assuming that you mean that you want a decimal representation
of the integer, Read The Fine Manual to find out what 'show'
will do.

This may well be a homework question, in which case consider:
  you want to construct an element of a recursively defined
  data type (list of character).
  do you *have* a recursively defined data type to start from?
  If you first distinguish between negative and non-negative
  integers, do you have a recursively defined data type then?
  How could you use `div` and `mod` to treat non-negative
  integers _as if_ they formed a recursively defined data type?
  What would the base case be?  What would the step case be?

 
  
___

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


Re: [Haskell-cafe] Re: Hugs on iPhone

2009-03-23 Thread John Meacham
On Mon, Mar 23, 2009 at 04:41:04PM -0400, Braden Shepherdson wrote:
 The good news is that jhc's portable C code works perfectly well -- but  
 of course that is simply running precompiled Haskell apps and not a  
 compiler or interpreter running on the device. Since jhc is not  
 self-hosting (yet?) but instead is built with GHC, that's the best we  
 can do with that approach for now.

I wondered what would happen if I submitted some jhc generated C for
approval, it _almost_ looks like it could have been hand written by
someone with an unusual penchant for gotos and their own inscrutable
hungarian notation.

John

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HSTringTemplate and syb-with-class

2009-03-23 Thread Sterling Clover
You don't need to derive ToSElem -- you get the instance for free if
you derive Data. Import GenericWithClass to get the instance for Data
from syb-with-class, and import GenericStandard for use with Data from
the vanilla syb that comes with GHC.

Cheers,
Sterl.

2009/3/23 Kemps-Benedix Torsten torsten.kemps-bene...@sks-ub.de:
 Hello all,



 I’m trying to use the generic capabilities of HSTringTemplate. The
 documentation claims that the package is able to automatically generate
 instances of ToSElem if syb-with-class is installed but gives no further
 details. I installed syb-with-class and then installed HSTringTemplate with
 additional configure parameter syb-with-class=True. But when I import
 Text.StringTemplate.GenericWithClass and then try deriving ToSElem or
 $(derive ToSElem), I just get an error like “Can't make a derived instance
 of `ToSElem …”.



 Any suggestions or pointer to further docs?



 Kind regards



 Torsten



 ___
 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] Re: Hugs on iPhone

2009-03-23 Thread Rick R
This is solely the reason for my interest in JHC.

The agreement doesn't specifically prohibit the use of interpreters (just
those than run external code). It also doesn't say anything about machine
generated code. The only thing one would have to ensure is that the
dependencies of JHC are all compiled in, or statically linked. Shared libs
are disallowed in any app. If it has a runtime dependency on gcc (is there
such a thing?) Then you would have to statically link it and therefore
couldn't sell your application. (gotta love GPL)

JHC also helps with another issue:
There is some concern about garbage collection schemes, Apple removed their
own garbage collector in the iPhone SDK and the docs mention that GC isn't
allowed. But there is nothing about that in the Developer Agreement. JHC's
region based memory management very closely reflects Apples own convention
for using memory pools for all allocation. I speculate that this would less
likely to be  rejected. .

There is also some discussion on both the GHC and JHC mailing list WRT this
a month or two ago.
I will attempt exactly this scheme later next month, will let you know how
it goes. :)

On Mon, Mar 23, 2009 at 5:45 PM, John Meacham j...@repetae.net wrote:

 On Mon, Mar 23, 2009 at 04:41:04PM -0400, Braden Shepherdson wrote:
  The good news is that jhc's portable C code works perfectly well -- but
  of course that is simply running precompiled Haskell apps and not a
  compiler or interpreter running on the device. Since jhc is not
  self-hosting (yet?) but instead is built with GHC, that's the best we
  can do with that approach for now.

 I wondered what would happen if I submitted some jhc generated C for
 approval, it _almost_ looks like it could have been hand written by
 someone with an unusual penchant for gotos and their own inscrutable
 hungarian notation.

John

 --
 John Meacham - ⑆repetae.net⑆john⑈
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
We can't solve problems by using the same kind of thinking we used when we
created them.
   - A. Einstein
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] generalized shuffle

2009-03-23 Thread Manlio Perillo

Hi.

I have implemented a generalized shuffle function, for the 
random-shuffle package

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/random-shuffle

I have not yet commited the change, before that I would like to receive 
some feedbacks (especially by the original author of the shuffle 
function, in Cc)


The new function is defined in this example:
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2808

Note that it make use of functions not exported by the 
System.Random.Shuffle module.


I have generalized the original shuffle function in two ways:

1) It is now possible to obtain a random sample from a sequence,
   by doing, as an example:
   shuffles [1..10] [2, 3, 4, 2, 1]

   Note that this is equivalent at taking the first 5 elements of the
   full shuffled sequence, and the performance are pratically the same.

2) It is now possible to pass an infinite r-sequence to the shuffle
   function, as an example:
   shuffles [1..10] $ cycle [9, 8 .. 1]

   The result is an infinite list, with elements cyclically extracted
   from the r-sequence.

   When the r-sequence contains random numbers, we get an infinite
   sequence containing all possible random choices of elements in the
   original sequence.

   Why I'm doing this?
   The reason is that in a project I need to extract random elements
   from a list (and I need to extract a lot of them), and using normal
   methods [1] seems to be rather inefficient.

   Using the `shuffles` function should be much more efficient, since it
   uses a tree, and this tree is built only once.

[1] by normal method I mean: extract a random number, in the range
[0, n] (where n is the length of the sequence), and get the element
indexed by that number.

Indexing for a list if very expensive.
And it is not very fast, even using arrays (unless you use
non portable unsafeRead).




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


Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-23 Thread Henning Thielemann


On Mon, 23 Mar 2009, Xiao-Yong Jin wrote:


Hi,

I just feel it is not comfortable to deal with exceptions
only within IO monad, so I defined


tryArith :: a - Either ArithException a
tryArith = unsafePerformIO . try . evaluate


and it works quite good as


map (tryArith . (div 5)) [2,1,0,5]


evaluates to


[Right 2,Right 5,Left divide by zero,Right 1]


However, I guess unsafePerformIO definitely has a reason for
its name.  As I read through the document in
System.IO.Unsafe, I can't convince myself whether the use of
'tryArith' is indeed safe or unsafe.


Try to never use exception handling for catching programming errors! 
Division by zero is undefined, thus a programming error when it occurs.

 http://www.haskell.org/haskellwiki/Error
 http://www.haskell.org/haskellwiki/Exception
  I'm afraid, a Maybe or Either or Exceptional (see explicit-exception 
package) return value is the only way to handle exceptional return values 
properly. Maybe in the larger context of your problem zero denominators 
can be avoided? Then go this way.

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


Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-23 Thread wren ng thornton

Xiao-Yong Jin wrote:

Hi,

I just feel it is not comfortable to deal with exceptions
only within IO monad, so I defined


tryArith :: a - Either ArithException a
tryArith = unsafePerformIO . try . evaluate

[...]

However, I guess unsafePerformIO definitely has a reason for
its name.  As I read through the document in
System.IO.Unsafe, I can't convince myself whether the use of
'tryArith' is indeed safe or unsafe.

I know there have been a lot of discussion around
unsafePerformIO, but I still can't figure it out by myself.
Can someone share some thoughts on this particular use of
unsafePerformIO?  Is it safe or not?  And why?


This use of unsafePerformIO is safe, because the original expression 
you're given is pure[1]. The evaluate lifts the pure value into IO in 
order to give evaluation-ordering guarantees, though otherwise has no 
effects. The unsafePerformIO voids those effects, since it makes the 
value pure again and thus it does not need to grab the RealWorld baton.


Note that the correctness argument assumes the value is indeed pure. 
Some idiot could have passed in (unsafePerformIO launchTheMissiles), 
which is not safe and the impurity will taint anything that uses it 
(tryArith, (+1), whatever). But it's the unsafePerformIO in this 
expression which is bad, not the one in tryArith.




tryArith is basically the same as a function I have in my personal 
utility code:

http://community.haskell.org/~wren/wren-extras/Control/Exception/Extras.hs

The safely function is somewhat different in that it's a combinator for 
making *functions* safe, rather than making *expressions* safe as 
tryArith does. This is necessary because exceptional control flow (by 
definition) does not honor the boundaries of expressions, but rather 
attaches semantics to the evaluation of functions. Thus safely is more 
safe because it ensures you can't force the exception prematurely via 
sharing:


 let x = 5`div`0 in
 ... seq x ... tryArith x  -- too late to catch it! oops.

Whereas with safely we'd have:

 let f y = safely (div y) in
 let x = 5 `f` 0 in
 ... seq x ... x  -- doesn't matter where f or x are used.



[1] Ha! If it were _pure_ then it wouldn't be throwing exceptions, now 
would it :)


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Learning Haskell

2009-03-23 Thread Tom.Amundsen

How long did it take you to become proficient in Haskell? By that, I mean -
how long until you were just as comfortable with Haskell as you were with
your strongest language at that time?
-- 
View this message in context: 
http://www.nabble.com/Learning-Haskell-tp22673552p22673552.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Learning Haskell

2009-03-23 Thread Rick R
I've been messing with Haskell since the Middle of January on evenings and
weekends. Just now I'm getting to the point where I can construct nontrivial
programs with little help from #haskell.

 It is by no means my most proficient language, I've been coding C++ and
other languages for over 10 years. It is by far my favorite, however, and if
I could do it full time I would.

On Mon, Mar 23, 2009 at 11:08 PM, Tom.Amundsen tomamund...@gmail.comwrote:


 How long did it take you to become proficient in Haskell? By that, I mean -
 how long until you were just as comfortable with Haskell as you were with
 your strongest language at that time?
 --
 View this message in context:
 http://www.nabble.com/Learning-Haskell-tp22673552p22673552.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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




-- 
We can't solve problems by using the same kind of thinking we used when we
created them.
   - A. Einstein
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Learning Haskell

2009-03-23 Thread Duane Johnson
I second that!  Haskell is a very fun and engaging language (with its  
accompanying corpus of theorems, and its great community)...


My timing is a little bit longer than Rick's... I've been eyeing  
Haskell for about 8 months, reading books, poking around etc.  I've  
started to feel comfortable enough in the last month to begin a  
serious(ish) project.  For my debut, I'm trying to build a game with  
HOpenGL.  I wouldn't take my 8-month timeline as much of a benchmark,  
however, since I have not been very deeply involved in studying the  
language (I have no projects that require day-to-day coding in Haskell).


Duane Johnson
http://blog.inquirylabs.com/

On Mar 23, 2009, at 9:13 PM, Rick R wrote:

I've been messing with Haskell since the Middle of January on  
evenings and weekends. Just now I'm getting to the point where I can  
construct nontrivial programs with little help from #haskell.


 It is by no means my most proficient language, I've been coding C++  
and other languages for over 10 years. It is by far my favorite,  
however, and if I could do it full time I would.


On Mon, Mar 23, 2009 at 11:08 PM, Tom.Amundsen  
tomamund...@gmail.com wrote:


How long did it take you to become proficient in Haskell? By that, I  
mean -
how long until you were just as comfortable with Haskell as you were  
with

your strongest language at that time?
--
View this message in context: 
http://www.nabble.com/Learning-Haskell-tp22673552p22673552.html
Sent from the Haskell - Haskell-Cafe mailing list archive at  
Nabble.com.


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



--
We can't solve problems by using the same kind of thinking we used  
when we created them.

   - A. Einstein
___
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] Learning Haskell

2009-03-23 Thread leledumbo

Still struggling after almost year (I learn it along with Prolog, Lua, and
many other non-C family languages), because I'm not very good at describing
solutions. My imperative background is quite strong, but I've been able to
switch more easily these days (after taking Functional Programming class at
college).
-- 
View this message in context: 
http://www.nabble.com/Learning-Haskell-tp22673552p22673952.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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