[Haskell-cafe] Error during hlint install ?

2009-08-26 Thread Dusan Kolar

Hello all,

 Am I doing something wrong if I get the following error during cabal 
installation of hlint? Is there any way how to solve it?


I run on:
Linux pc 2.6.30-ARCH #1 SMP PREEMPT Fri Jul 31 07:30:28 CEST 2009 x86_64 
Intel(R) Core(TM)2 Quad CPU Q9300 @ 2.50GHz GenuineIntel GNU/Linux

The Glorious Glasgow Haskell Compilation System, version 6.10.4

Error:
cabal install hlint
Resolving dependencies...
Configuring hlint-1.6.5...
Preprocessing executables for hlint-1.6.5...
Building hlint-1.6.5...
[ 1 of 25] Compiling Paths_hlint  ( 
dist/build/autogen/Paths_hlint.hs, 
dist/build/hlint/hlint-tmp/Paths_hlint.o )
[ 2 of 25] Compiling Parallel ( src/Parallel.hs, 
dist/build/hlint/hlint-tmp/Parallel.o )
[ 3 of 25] Compiling HSE.Generics ( src/HSE/Generics.hs, 
dist/build/hlint/hlint-tmp/HSE/Generics.o )
[ 4 of 25] Compiling HSE.NameMatch( src/HSE/NameMatch.hs, 
dist/build/hlint/hlint-tmp/HSE/NameMatch.o )
[ 5 of 25] Compiling Util ( src/Util.hs, 
dist/build/hlint/hlint-tmp/Util.o )
[ 6 of 25] Compiling HSE.Util ( src/HSE/Util.hs, 
dist/build/hlint/hlint-tmp/HSE/Util.o )
[ 7 of 25] Compiling HSE.Match( src/HSE/Match.hs, 
dist/build/hlint/hlint-tmp/HSE/Match.o )
[ 8 of 25] Compiling HSE.Bracket  ( src/HSE/Bracket.hs, 
dist/build/hlint/hlint-tmp/HSE/Bracket.o )
[ 9 of 25] Compiling HSE.Evaluate ( src/HSE/Evaluate.hs, 
dist/build/hlint/hlint-tmp/HSE/Evaluate.o )
[10 of 25] Compiling HSE.All  ( src/HSE/All.hs, 
dist/build/hlint/hlint-tmp/HSE/All.o )
[11 of 25] Compiling CmdLine  ( src/CmdLine.hs, 
dist/build/hlint/hlint-tmp/CmdLine.o )
[12 of 25] Compiling Type ( src/Type.hs, 
dist/build/hlint/hlint-tmp/Type.o )
[13 of 25] Compiling Hint.Naming  ( src/Hint/Naming.hs, 
dist/build/hlint/hlint-tmp/Hint/Naming.o )
[14 of 25] Compiling Hint.Bracket ( src/Hint/Bracket.hs, 
dist/build/hlint/hlint-tmp/Hint/Bracket.o )
[15 of 25] Compiling Hint.Lambda  ( src/Hint/Lambda.hs, 
dist/build/hlint/hlint-tmp/Hint/Lambda.o )
[16 of 25] Compiling Hint.Monad   ( src/Hint/Monad.hs, 
dist/build/hlint/hlint-tmp/Hint/Monad.o )
[17 of 25] Compiling Hint.ListRec ( src/Hint/ListRec.hs, 
dist/build/hlint/hlint-tmp/Hint/ListRec.o )
[18 of 25] Compiling Hint.List( src/Hint/List.hs, 
dist/build/hlint/hlint-tmp/Hint/List.o )
[19 of 25] Compiling Hint.Match   ( src/Hint/Match.hs, 
dist/build/hlint/hlint-tmp/Hint/Match.o )
[20 of 25] Compiling Settings ( src/Settings.hs, 
dist/build/hlint/hlint-tmp/Settings.o )
[21 of 25] Compiling Report   ( src/Report.hs, 
dist/build/hlint/hlint-tmp/Report.o )


src/Report.hs:49:22:
   Couldn't match expected type `String' against inferred type `Bool'
   In the second argument of `hscolour', namely `True'
   In the expression: hscolour False True 
   In the definition of `code': code = hscolour False True 
cabal: Error: some packages failed to install:
hlint-1.6.5 failed during the building phase. The exception was:
exit: ExitFailure 1


Regards

 Dušan


P.S.
Registered packages:
Cabal-1.6.0.3, HUnit-1.2.0.3, QuickCheck-1.2.0.0, array-0.2.0.0,
   base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, containers-0.2.0.1,
   cpphs-1.8, directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3),
   (dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3),
   (dph-seq-0.3), extensible-exceptions-0.1.1.0, filepath-1.1.0.2,
   (ghc-6.10.4), ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3,
   haskell-src-exts-1.0.1, haskell98-1.0.1.0, hpc-0.5.0.3,
   hscolour-1.15, html-1.0.1.2, integer-0.1.0.1, mtl-1.1.0.2,
   network-2.2.1.2, old-locale-1.0.0.1, old-time-1.0.0.2,
   packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1,
   pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1,
   regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3,
   rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1,
   time-1.1.4, uniplate-1.2.0.3, unix-2.3.2.0, xhtml-3000.2.0.1

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


[Haskell-cafe] Library function for map+append

2009-08-18 Thread Dusan Kolar

Hello all,

 During a small project I'm trying to develop a small application. It 
becomes quite often that I need a function mapapp:


mapapp _ [] ap = ap
mapapp f (a:as) ap = f a : map f as ap

 I tried hoogle to find such a function with no success. Is there any 
function/functions built-in standard libraries that could easily 
satisfy the functionality with the same or even better (?) efficiency?


 Of course, 

(map f list) ++ append  


 would do the same as

mapapp f list append

 but with less efficiency. Or am I wrong?

 Thanks

   Dusan

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


Re: [Haskell-cafe] Library function for map+append

2009-08-18 Thread Dusan Kolar
Dlists maybe good it all the app is written using them. Probably not 
good idea to switch to them in the middle of project...


I know it is lazy, but I don't think it is able to eliminate operations, 
is it?


At least intuitively, the map f list takes n*C ticks (C is for 
application of f and list creation, n is the list length, f is of no 
importance, it is always the same, but list probably must be created due 
to ++).


Then, (++) take n*K ticks (K for list creation - I want to write out the 
list at the end, so that it is created).


In my case (mapapp), it is n*CK, where CK stands for f and list 
creation... the CK is very similar to C... Thus, I should save the n*K, 
or at least its large portion... shouldn't I?  If not, how the compiler 
can eliminate the operations?


Dusan

Bulat Ziganshin wrote:

Hello Dusan,

Tuesday, August 18, 2009, 2:50:38 PM, you wrote:

  

  but with less efficiency. Or am I wrong?



probably wrong. haskell is lazy language

also there is differential lists (dlist) implementation on hackage


  


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


Is 78 characters still a good option? Was: [Haskell-cafe] breaking too long lines

2009-04-21 Thread Dusan Kolar

Dear all,

 reading that


according the several style guides, lines shouldn't be too long
(longer than 78 characters).

http://www.cs.caltech.edu/courses/cs11/material/haskell/misc/haskell_style_guide.html
http://www.haskell.org/haskellwiki/Programming_guidelines
  
I would like to know, whether 78 characters bound still makes a sense... 
Even if I connect to my linux box with text terminal, it is not a 80x24 
characters HW text terminal, but a window emulating this in whatever 
else OS, thus, I can usually extend this to see longer lines easily.


Or is the reason much deeper? Or, is the bound set to 78 characters just 
because it is as good number as any other?


Regards,

 Dušan

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


[Haskell-cafe] Re: Is 78 characters still a good option? Was: breaking too long lines

2009-04-21 Thread Dusan Kolar



The longer a line the more difficult it is to move the focus to the
beginning of the next line when reading.
  
Hmm, then I must be doing something wrong, I do not fully fill program 
lines... ;-)
Or my comments are too short. I do not think, this is an issue, to catch 
the next line, if the program text is well structured...

Nevertheless, I do understand this is a force to make the text structured...

Therefore wide news papers use columns. Also consider source code
printed on paper.
  

I do not remember when I did that. But if anybody does then it is a reason.
  

Or is the reason much deeper? Or, is the bound set to 78 characters just
because it is as good number as any other?



Unlimited length (as for plain text) would be an option if automatic
wrapping wouldn't destroy the layout.
  

Yes, yes...
Anyway, I don't like 1024 characters one-liners anyway. ;-) :-)

Dušan

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


Re: [Haskell-cafe] Memoization local to a function

2009-02-26 Thread Dusan Kolar
Thanks for all the hints and code provided, nevertheless, it implied 
another questions:


1) Am I right that MemoCombinators can be hardly ever used with hugs? If 
not, which guidelines to be used for installation...
2) Is there any paper/tutorial/wiki that describes, which local 
definitions/expressions are discarded/not shared after/to the next 
computation, that means separated closure is built for them?


Dusan

Henning Thielemann wrote:


On Wed, 25 Feb 2009, Luke Palmer wrote:

On Wed, Feb 25, 2009 at 10:38 AM, Dusan Kolar ko...@fit.vutbr.cz 
wrote:
   I have a function a computation of which is quite expensive, 
it is recursively
  dependent on itself with respect to some other function values 
- we can roughly
  model its behaviour with fib function (returns n-th number of 
Fibonacci's
  sequence). Unfortunately, it is not fib, it is far more 
complicated.
  Nevertheless, for demonstration of my question/problem I will 
use fib, it's quite

  good.


I suggest using data-memocombinators for this rather than rolling 
your own.  It accomplishes
the same thing, but makes the choice of memo structure independent of 
the code that uses it

(and Memo.integral has asymptotically better performance than a list).


Nice to know that there is a package for this purpose. See also
  http://haskell.org/haskellwiki/Memoization



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


[Haskell-cafe] Memoization local to a function

2009-02-25 Thread Dusan Kolar

Dear all,

 I have a function a computation of which is quite expensive, it is 
recursively dependent on itself with respect to some other function 
values - we can roughly model its behaviour with fib function (returns 
n-th number of Fibonacci's sequence). Unfortunately, it is not fib, it 
is far more complicated. Nevertheless, for demonstration of my 
question/problem I will use fib, it's quite good.


 I want to store results in a list (array, with its strong size limit 
that I do not know prior to computation, is not suitable) and then pick 
them up using (!!) operator. Well, if the list is global 
function/constant then it works quite well. Unfortunately, this is not, 
what I would like to have. Nevertheless, local version does not work.


 Could someone point me to some text that explains it? Memoization text 
on wiki does not seem to be helpful. Time/operation consumption is 
deduced from number of reductions reported by hugs and winhugs (tested 
both on Linux and Windows).


 Thank you for hints,

  Dusan


P.S.
Code I used for testing.

module Testmemo
   (  fibW
   ,  fibL
   ,  fibM
   )  where


fibW m = allfib !! m
 where
   allfib = 0:1:[allfib!!n + allfib!!(n+1) | n - [0..]]


fibL m =
 let
   allfib = 0:1:[allfib!!n + allfib!!(n+1) | n - [0..]]
 in allfib !! m


fibM n = myallfib !! n
myallfib = 0:1:[myallfib!!n + myallfib!!(n+1) | n - [0..]]

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


[Haskell-cafe] GHC 6.8.3 package for ArchLinux x86_64

2008-08-15 Thread Dusan Kolar

Hello all,

 Is there any plan to make a package for archlinux x86_64 with (more or 
less) complete GHC 6.8.3 binaries? I know I can download and install 
myself, usually I do so myself, but the reason is to prepare a list of 
packages for others. So far, the 6.8.2 is available.


 Is there any possibility I could help with it? Some guidelines, how to 
prepare such a package, submit to a right place, etc.


 Thanks,

   Dusan

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


Re: [Haskell-cafe] GHC 6.8.3 package for ArchLinux x86_64

2008-08-15 Thread Dusan Kolar



  Is there any plan to make a package for archlinux x86_64 with (more or
less) complete GHC 6.8.3 binaries? I know I can download and install myself,
usually I do so myself, but the reason is to prepare a list of packages for
others. So far, the 6.8.2 is available.



Hi, Arch ghc maintainer here.

We have opted to delay the upgrade of ghc because that version
includes some regressions that we're not so wild about, and because
upgrading ghc leads to lots of recompilations to prevent breakage.

Do you have a specific need for that version?
  
Well, just wanted to get ready some stuff for the coming academic year.  
So the main reason was to force everybody involved to use the version 
and, if possible, with not too much effort. If it is much effort to make 
the package, I can prepare a workaround, no problem, thanks.


Dusan

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


[Haskell-cafe] Bug in parallel GHC runtime?

2008-05-23 Thread Dusan Kolar

Hello all,

 The attached file was compiled by the following command:

ghc -O2 --make -threaded ltest1pl.hs -o alall

When run in a sequential mode, I get this result:
./alall
Starting ...
Lst1: 416665
Lst2: 4166916670
T1: 0m 1.0e-6s
36
End!


On the other hand, when run in a threaded mode, I get the following error:
./alall +RTS -N2
Starting ...
Lst1: 416665
Lst2: 4166916670
T1: 0m 0.0s
Segmentation fault

Is it fault of the GHC runtime, or is it something on my side?


My machine: uname -a
Linux pc 2.6.24-ARCH #1 SMP PREEMPT Sun Mar 30 10:50:22 CEST 2008 x86_64 
Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux


My ghc: ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.2


Thanks and regards
 Dusan

--import Control.Concurrent
--import Control.Concurrent.MVar
import System.Time

import Control.Parallel.Strategies

--import Data.List (foldl')
import qualified Data.ByteString as B


sumAllSums [] = 0
sumAllSums l@(_:xs) = sumlist 0 l + sumAllSums xs
  where  sumlist res [] = res   
 sumlist sr  (v:vs) = sumlist (sr+v) vs

wlist2wbs [] = B.pack []
wlist2wbs l@(_:_) = B.pack $ encode l
  where
encode :: Integral a = [Int] - [a]
encode [] = []
encode (x:xs) = 
  if x==0 then 0:0:encode xs
  else fromIntegral (x `mod` 256) : fromIntegral (x `div` 256) : encode xs

main = do
  putStrLn $ Starting ...
  let lst1 = [0..4]
  let lst2 = [0..5]
  let bs1 = wlist2wbs lst1
  let bs2 = wlist2wbs lst2
  tm1 - getClockTime
  let (v1:v2:_) = parMap rnf sumAllSums [lst1,lst2]
  tm1' - getClockTime
  putStrLn (Lst1:  ++ show v1)
  putStrLn (Lst2:  ++ show v2)
  let tdiff1 = diffClockTimes tm1' tm1
  --let tdiff2 = diffClockTimes tm2' tm2
  putStrLn $ T1:  ++ show (tdMin tdiff1) ++ m  ++ show (fromIntegral(tdSec 
tdiff1) + fromIntegral(tdPicosec tdiff1)/1e12) ++ s
  --putStrLn $ T2:  ++ show (tdMin tdiff2) ++ m  ++ show 
(fromIntegral(tdSec tdiff2) + fromIntegral(tdPicosec tdiff2)/1e12) ++ s
  putStrLn $ show $ {-ibs1 +-} B.index bs1 9 + B.index bs2 4 {-((bs1 + 
fromIntegral (B.index bs2 9)) :: Integer)-}
  putStrLn $ End!

{-
main = do
  tm1 - getClockTime
  putStrLn $ Starting ... 
  mv1 - newEmptyMVar
  mv2 - newEmptyMVar
  t1 - forkIO (putMVar mv1 $! sumAllSums [0..4])
  t2 - forkIO (putMVar mv2 $!  sumAllSums [1..5])
  v1 - takeMVar mv1
  v2 - takeMVar mv2
  killThread t1
  killThread t2
  putStrLn $ Result:  ++ show (v1+v2)
  tm2 - getClockTime
  let tdiff = diffClockTimes tm2 tm1
  putStrLn $ End!  ++ show (tdMin tdiff) ++ m  ++ show (fromIntegral(tdSec 
tdiff) + fromIntegral(tdPicosec tdiff)/1e12) ++ s
-}

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


Re: [Haskell-cafe] ByteString.pack behavior

2008-05-18 Thread Dusan Kolar

Thanks. I've realized that as soon as I was in my bed. ;-)

Nevertheless, a question comes to me - shouldn't compiler report a 
warning? I know it cannot in the current state, but it should. :-) Quite 
dummy C compilers tell me I'm loosing significant digits of number 
literals if I'm doing that. Maybe, already seen in some other thread 
some time ago, the compiler should be less general/should know more 
about data types...


Thanks and regards

Dusan

Don Stewart wrote:

kolar:
  

Hello all,

 Maybe there is something obvious I can't see, but I have this behavior 
for 6.8.2 ghci:


$ghci ttest1p.hs
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( ttest1p.hs, interpreted )
Ok, modules loaded: Main.
*Main encode' [1..100]
Loading package array-0.1.0.0 ... linking ... done.
Loading package bytestring-0.9.0.1 ... linking ... done.
[1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,... // deleted
*Main B.pack [0..100]
\NUL\SOH\STX\ETX\EOT\ENQ\ACK\a\b\t\n\v\f\r\SO\SI\DLE\DC1\DC2\DC3\DC4\NAK\SYN\ETB\CAN\EM\SUB\ESC\FS\GS\RS\US 
!\#$%'()*+,-./0123456789:;=[EMAIL PROTECTED]

*Main B.pack $ encode' [1..100]
*** Exception: divide by zero

where ttest1p.hs:

import qualified Data.ByteString as B

encode' [] = []
encode' (x:xs) =
 if x==0 then 0:0:encode' xs
 else (x `mod` 256) : (x `div` 256) : encode' xs


What is the difference, except list length and value structure? Where is 
my error?





ByteStrings take Word8 values as input, so x `div` 256 , where 256 ::
Word8, overflows to 0. 


-- Don
  


--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

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


[Haskell-cafe] True parallelism missing :-(

2008-03-25 Thread Dusan Kolar

Dear all,

 I've thought the following three (dummy) programs would run some of 
their parts in parallel (on dual core) if compiled with option threaded 
(smp). The truth is that only the first one exploits multicore CPU. Why?


 Moreover, using RTS option -sstderr makes runtime not to evaluate in 
parallel even for the first program. Why?


 Thanks for tips

   Dusan

My arch:
Linux pcx 2.6.24-ARCH #1 SMP PREEMPT Sun Feb 10 15:44:59 CET 2008 x86_64 
Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux


My ghc:
The Glorious Glasgow Haskell Compilation System, version 6.8.2
/64bit, binary distro for FC/



Prog 1:

module Main() where

import Control.Parallel
import Control.Parallel.Strategies

fibs :: Integer - Integer
fibs n | n  1  = fibs (n-1) + fibs (n-2)
  | n == 1 = 1
  | True   = 0

fib n = if n0 then error Negative input to fib!
   else f1+f2
 where
   [f1,f2] = parMap rnf fibs [(n-1),(n-2)]

main = do
 putStrLn Starting...
 putStrLn $ Fib 43:  ++ show (fib 43)
 putStrLn Done!



Prog 2:

module Main() where

import Control.Concurrent
import Control.Concurrent.MVar

fibs :: Integer - Integer
fibs n | n  1  = fibs (n-1) + fibs (n-2)
  | n == 1 = 1
  | True   = 0

fib n = if n0 then error Negative input to fib!
   else do
 v1 - newEmptyMVar
 v2 - newEmptyMVar
 h1 - forkIO $ putMVar v1 $ fibs (n-1)
 h2 - forkIO $ putMVar v2 $ fibs (n-2)
 f1 - takeMVar v1
 f2 - takeMVar v2
 killThread h1
 killThread h2
 return (f1+f2)

main = do
 putStrLn Starting...
 f - fib 43
 putStrLn $ Fib 43:  ++ show f
 putStrLn Done!



Prog 3:

module Main() where

import Control.Concurrent
import Control.Concurrent.MVar

fibs :: Integer - Integer
fibs n | n  1  = fibs (n-1) + fibs (n-2)
  | n == 1 = 1
  | True   = 0

fib n = if n0 then error Negative input to fib!
   else do
 v1 - newEmptyMVar
 v2 - newEmptyMVar
 h1 - forkOS $ putMVar v1 $ fibs (n-1)
 h2 - forkOS $ putMVar v2 $ fibs (n-2)
 f1 - takeMVar v1
 f2 - takeMVar v2
 killThread h1
 killThread h2
 return (f1+f2)

main = do
 putStrLn Starting...
 f - fib 43
 putStrLn $ Fib 43:  ++ show f
 putStrLn Done!


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


Re: [Haskell-cafe] True parallelism missing :-(

2008-03-25 Thread Dusan Kolar

I did use that option. :-)

Dusan

Bulat Ziganshin wrote:

Hello Dusan,

Tuesday, March 25, 2008, 3:47:50 PM, you wrote:

  

(smp). The truth is that only the first one exploits multicore CPU. Why?



+RTS -N2


  


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


Re: [Haskell-cafe] True parallelism missing :-(

2008-03-25 Thread Dusan Kolar

Yes, that's is. Thanks. My fault - missing wood seeing trees. ;-)

Best regards,

Dusan

Roberto Zunino wrote:

Dusan Kolar wrote:

Dear all,

 I've thought the following three (dummy) programs would run some of 
their parts in parallel (on dual core) if compiled with option 
threaded (smp). The truth is that only the first one exploits 
multicore CPU. Why?



 h1 - forkIO $ putMVar v1 $ fibs (n-1)


You are putting an unevaluated thunk in the MVar. Try:

h1 - forkIO (putMVar v1 $! fibs (n-1))

Zun.


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


[Haskell-cafe] Building HaXML 1.13.3 on Windows fails

2008-03-17 Thread Dusan Kolar

Hello all,

 I'm trying to build HaXML 1.13.3 on Windows using build.bat - I have 
modified it even on places referred as should work (SRCS and OBJS 
variables); now it works till the last command:


ghc-pkg register pkg.conf

The error is:
Reading package info from pkg.conf ... ghc-pkg.exe: Line 68: The field 
main-is was already defined on line 62


Taking a look into the pkg.conf says there are several lines main-is. 
I'm using ghc 6.6 to build the stuff. What shall I do?


Thanks and regards,

 Dusan

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


Re: [Haskell-cafe] Evolutionary Computing

2008-01-25 Thread Dusan Kolar

Hello,

I don't know about math, but a practical usage seems to be in the 
reconfigurable hardware (FPGA). See web-page of my colleague, where is 
list of his papers on the topic.


http://www.fit.vutbr.cz/~sekanina/pubs.php

Dusan

PR Stanley wrote:

Hi
What does the list think of EC? Genetic algorithm is apparently the 
latest thing.

Is EC mathematically reasonable?
Paul


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


Re: [Haskell-cafe] [OT] GHC uninstall on Linux

2007-11-09 Thread Dusan Kolar

Hello all,

 Thank you for your replies and tips. The idea of having several 
versions of GHC in parallel is nice, but I don't long for it even if 
space is not a problem.


 To post some resolution: the stuff is (if installed using default 
settings) in the directories /usr/local/bin, /usr/local/lib, and 
/usr/local/share/doc. It is easy to find and remove /usr/local/lib/ghc* 
and /usr/local/share/doc/ghc* directories. Nevertheless, in the 
/usr/local/bin directory, you should search not only for *ghc* but even 
for other stuff that may be part of installation if other components are 
installed as well, they are: hasktags, hp2ps, hpc, hsc2hs, runhaskell.


 From the proposed tools, I gave a try to GNU stow tool. I can 
recommend it as it is easy to use and it can detect conflicts (the way I 
have discovered other files than *ghc* in the /usr/local/bin).


 Thx and regards

   Dusan


 I use tar.bz2 binary distribution of GHC compiler as my distro does not 
use any supported packaging system. Everything is fine, but... I want to 
install the new version of the GHC compiler. Is there any (easy) way, how 
to get information about what was copied and where during installation? 
(./configure; make install) There seems to be no uninstall target in the 
Makefile. :-( And I want to uninstall the previous version of the compiler.



You don't need to uninstall GHC, ever, except for disk space reasons.
You can easily have thirteen versions of GHC installed and happily
coexisting:

[EMAIL PROTECTED]:~$ ghci-6.
ghci-6.4.2 ghci-6.7   ghci-6.7.20070223
ghci-6.7.20070402  ghci-6.7.20070502  ghci-6.7.20070601
ghci-6.7.20070712  ghci-6.7.20070829  ghci-6.6.1
ghci-6.7.20070213  ghci-6.7.20070323  ghci-6.7.20070413
ghci-6.7.20070518  ghci-6.7.20070612  ghci-6.7.20070826

Stefan
  


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


[Haskell-cafe] [OT] GHC uninstall on Linux

2007-11-07 Thread Dusan Kolar

Hello all,

 I use tar.bz2 binary distribution of GHC compiler as my distro does 
not use any supported packaging system. Everything is fine, but... I 
want to install the new version of the GHC compiler. Is there any (easy) 
way, how to get information about what was copied and where during 
installation? (./configure; make install) There seems to be no uninstall 
target in the Makefile. :-( And I want to uninstall the previous version 
of the compiler.


 Is it safe to delete files/folders just from /usr/local/lib/ghc-6.6.1 
and /usr/local/bin/gh* ?


 Thanks for any hint

   Dusan

P.S.
Tried google with no usable results.
D.

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


Re: [Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Dusan Kolar

Hello all,

 just to compare the stuff, I get quite other results being on other 
OS. Thus, the result of C++ compiler may not be that interesting as I do 
not have the one presented below.


My machine:
Linux 2.6.23-ARCH #1 SMP PREEMPT Mon Oct 22 12:50:26 CEST 2007 x86_64 
Intel(R) Core(TM)2 CPU  6600 @ 2.40GHz GenuineIntel GNU/Linux


Compilers:
g++ --version
g++ (GCC) 4.2.2
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.6.1

Measurement:
compiled with ghc -O2
time ./mainInteger
real0m4.866s
user0m4.843s
sys 0m0.020s

compiled with ghc -O2
time ./mainInt64
real0m2.213s
user0m2.210s
sys 0m0.003s

compiled with ghc -O2
time ./mainInt
real0m1.149s
user0m1.143s
sys 0m0.003s

compiled with g++ -O3
time ./mainC
real0m0.271s
user0m0.270s
sys 0m0.000s

I don't know what is the reason, but the difference between Int, Int64 
and Integer is not that dramatic as in example below, nevertheless, the 
difference between GHC and GNU C++ is very bad :-\


Dusan


Peter Hercek wrote:

Derek Elkins wrote:


Try with rem instead of mod.

(What the heck is with bottom?)


The bottom was there by error and I was lazy to redo
 the tests so I rather posted exactly what I was
 doing. I do not know the compiler that good to be
 absolutely sure it cannot have impact on result
 ... so I rather did not doctor what I did :-)

Ok, rem did help quite a bit. Any comments why it is so?

Here are summary of results for those interested. I run
 all the tests once again. Haskell was about 13% slower
 than C++.

MS cl.exe options: /Ox /G7 /MD
ghc options: -O2

C++ version:  1.000; 0.984; 0.984
Haskell version specialized to Int: 1.125; 1.125; 1.109
Haskell version specialized to Integer: 8.781; 8.813; 8.813
Haskell version specialized to Int64: 9.781; 9.766; 9.831

The code:

% cat b.hs
module Main (divisors, perfect, main) where
import Data.Int

divisors :: Int - [Int]
divisors i = [j | j-[1..i-1], i `rem` j == 0]

perfect :: [Int]
perfect = [i | i-[1..1], i == sum (divisors i)]

main = print perfect

% cat b.cpp
#include iostream
using namespace std;

int main() {
  for (int i = 1; i = 1; i++) {
int sum = 0;
for (int j = 1; j  i; j++)
  if (i % j == 0)
sum += j;
if (sum == i)
  cout  i   ;
  }
  return 0;
}

%

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


--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

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


Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Dusan Kolar

Hello all,

 // PLS, no flame

 I think the question was not whether there's a way, how to handle the 
problem of encryption of a binary number to anything suitable and, more 
or less, readable by a human and transforming it to a binary form, but 
whether there's such a literal or not and whether it is bad idea to have 
something like 0b10111011.


 From my point of view, the difference between 0b10111011 and 
(bin[1,0,1,1,1,0,1,1]) is 22-10 that is 12 characters. Moreover, 
allowing ADA features for all numeric literals we could have 0b1011_1011 
;-) where the type would be Num a = a, of course.


 So, i would expect only two answers: NO, it is ...,  or YES, in 
version 6.9.0 it is possible. ;-)


 Dusan


Ketil Malde wrote:

Don Stewart [EMAIL PROTECTED] writes:

  

Are there binary constants in Haskell, as
we have, for instance, 0o232 for octal and
0xD29A for hexadecimal?
  


  

No, though it is an interesting idea.



Presumably it is less common since octal and hexadecimal are more
compact and almost as easy to interpret as bit patterns?  Why would
you want them?

Prelude let bin = foldl...
Prelude 0o232
154
Prelude bin [0,1,0, 0,1,1, 0,1,0]
154
Prelude 0xD29A
53914
Prelude bin [1,1,0,1, 0,0,1,0, 1,0,0,1, 1,0,1,0]
53914

-k
  


--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

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


[Haskell-cafe] Bug in GHCi?

2007-08-08 Thread Dusan Kolar

Hello all,

 Maybe this is a wrong place to report, but I have repeatedly performed 
funny calculation in GHCi with strange time report. The version of 
GHCi is:


  ___ ___ _
 / _ \ /\  /\/ __(_)
/ /_\// /_/ / /  | |  GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Loading package base ... linking ... done.
Prelude

My machine: OS WinXP Pro SP2, Intel Core 2, 2GB RAM.

How to reproduce error:

:set +s
:set -02
:cd path to the file in the attachment
:l Primes
take 1 primes1
provides correct result and shows correct timing, about 636 seconds
take 1 primes2
provides correct result, BUT INCORRECT TIMING - about -326 seconds

Yes, that is not a typo. The report of time elapsed is: minus three 
hundred and twenty six seconds.



I'll try the newest version of the GHCi, but it is strange anyway and 
maybe it should be investigated...


Thanks,
 Dusan

module Primes (
  primes1
 ,primes2
 ,primes3
 ,primes2'
 ,primes3'
   ) where


candidates = map (\x - (True,x)) [2..]
candidates' =  [2..]

skipmap f toSkip list = domap toSkip list
  where
domap n (x:xs)
  | n  1  =  x : domap (n-1) xs
  | True   =  f x : domap toSkip xs
domap _ [] = []

primes1 = sieve candidates
  where
sieve (pp@(isp,p):xs) 
  | isp  =  p : (sieve $ skipmap (\(_,v) - (False,v)) p xs)
  | True =  sieve xs

primes1' = sieve candidates'
  where
sieve (p:xs) 
  | p  0  =  p : (sieve $ skipmap (\n - if n0 then (-n) else n) p xs)
  | True   =  sieve xs



sieve (p:xs) = p : sieve [y | y - xs, y `mod` p /= 0]
sieve' (p:xs) = p : sieve [y | y - xs, y `mod` p  0]

primes2  = sieve [2..]
primes3 = 2 : sieve [3,5..]

primes2'  = sieve' [2..]
primes3' = 2 : sieve' [3,5..]

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


[Haskell-cafe] List minimum - performance question

2007-07-20 Thread Dusan Kolar

Hello all,

 Inspired by exercise on the minimal value of a given list I tried 
myself produce several versions of such a function:


exercise: using just ($), head, filter, null, id, map, () without 
explicit recursion definition
direct-forward: direct implementation using forward recursion, 
if-then-else, ()
direct-backward: direct implementation using backward recursion, 
if-then-else, ()

foldl: using foldl, lambda abstraction, if-then-else, ()
foldr: using foldr, lambda abstraction, if-then-else, ()

 From a recursion point of view, I see a similarity between 
direct-forward and foldl. Of course, the same similarity is between 
direct-backward and foldr. Am I right? If yes, then there is something 
strange in the results I have gained (see below).


 I did my measurements in winhugs (Version: Sep 2006) for lists of 
length 10, 100, 1000 and 50 elements. I tested on list with the same 
constant, list where the first number is minimal (these two cases are 
from this point of view similar/the same), lists, where some element in 
the middle is minimal, and finally lists, where the last element is 
the minimal one. As for constant and first minimal element list I got 
the same result, we can join them and have just three categories of 
lists, let's call them first, mid, last.


 Even if I know that using number of reductions and number of cells 
does not provide exact results, I assume that impact of parameter and 
printing of the result is the same for all tested functions and is 
either constant for the result printing (always number 1 in the result) 
and at most linear in the parameter processing (I would assume no direct 
impact here, just algorithm influence, is that right?).


  Thus, the results may be compared. First of all, the time/reduction 
complexity (n is a length of the list):


first midlast
exercise 9n+34not evaluated4.5n^2+21.5n+17
direct-forward   7n+157n+15   7n+15
direct-backward  7n+157n+15   7n+15
foldl8n+148n+14   8n+14
foldr8n+148n+14   8n+14

There is nothing special on the results, the exercise solution was not 
evaluated for the middle element lists as the position of the minimal 
value in the list is a parameter of the function.


  Now, let me show results for number of used cells:

first midlast
exercise 10n+54   not evaluated  5n^2+29n+26
direct-forward   8n+248n+25   9n+23
direct-backward  9n+229n+22   9n+22
foldl11n+22   11n+22  11n+22
foldr10n+23   10n+23  10n+23

Again, roughly looking at the results, there is nothing special, average 
space complexity is as it may be expected. Looking at the exact 
formulas, there are two things that come strange to me:


1) From a recursion point of view, there are pairs direct-forward ~ 
foldl and direct-backward ~ foldr. Nevertheless, from a space 
consumption point of view, this doesn't hold and the pairs are swapped. 
Why? Is this a winhugs specialty? Is this due to reduction strategy? 
Laziness?


2) Direct-forward implementation provides three different formulas. Why? 
Why the mid formula is fixed no matter where the minimal value is?



 Thanks for any answers/hints/references. Especially, if this is RTFM 
one. ;-)


   Dusan

P.S.
I know, that sources may be helpful, but as this is an exercise I don't 
want to provide them directly to the list. ;-) But I can provide them, 
of course. :-)


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


[Haskell-cafe] GHC optimization changes evaluation strategy?

2007-03-13 Thread Dusan Kolar

Hello all,

 the following program changes behavior if translated using different 
options for ghc compiler. Is this correct or not? I used The Glorious 
Glasgow Haskell Compilation System, version 6.6. And I would expect in 
both cases behavior 1.


 But I may be wrong...

 Thanks for any resolution.

 Dusan


*Program:*

$ cat Test.hs
import System.IO.Unsafe
import System.IO

main = do
 putStr Start...\n
 putStr $ show $ falling' falling1
 putStr \n
 putStr $ show $ sorted' rising1
 putStr Stop...\n

sorted' [] = True
sorted' [_] = True
sorted' l = sx l 1
 where
   sx []  _ = True
   sx [_] _ = True
   sx (x:l@(y:ys)) n =
 if n==1000 then unsafePerformIO (putChar '.'  hFlush stdout) 
`seq` x=y  sx l 1

 else x=y  (sx l $! n+1)

falling' [] = True
falling' [_] = True
falling' l = sx l 1
 where
   sx []  _ = True
   sx [_] _ = True
   sx (x:l@(y:ys)) n =
 if n==1000 then unsafePerformIO (putChar '.'  hFlush stdout) 
`seq` x=y  sx l 1

 else x=y  (sx l $! n+1)

rising1 = [0..10]

falling1 = [10,9..0]

-- EOF



*Behavior 1:*

$ ghc Test.hs -o test
$ ./test
Start...
True
TrueStop...


*Behavior 2:*

$ rm test Test.o Test.hi
$ ghc -O2 Test.hs -o test
$ ./test
Start...
.True
.TrueStop...

--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

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


[Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Dusan Kolar

Hello all,

 I'm googling around haskell.org to get some deeper knowledge about 
Control.Parallel.Strategies than it is presented on 
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Parallel-Strategies.html 
BTW, could someone point me to some more deeper doc. about it?


 During googling I've discovered that since GHC 6.6, par, forkIO, and 
forkOS should make the stuff run in parallel if I have more than one CPU 
core. Is that right? I think not, because on my machine only par makes 
the things run in parallel and only during the computation (GC runs in a 
single thread). If it should work, how can I verify that my installation 
is correct? If it should not work, will it be working someday?


 Thanks for your patience, responses, and tips

   Dusan

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


Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Dusan Kolar
Yes, it works for operator /par/. That's what I've reported. But should 
it work for forkIO and forkOS? Could anybody give more detailed answer 
than yes, no? :-) (Link to the Web is OK.)


BTW, thanks for the link to the paper (moreover, I can see, that 
googling over haskell.org is not sufficient ;-) ).


Regards,

 Dusan


Pepe Iborra wrote:

On 13/03/2007, at 17:46, Jefferson Heard wrote:

Simon will probably chime in on it as well, but his paper on the 
subject is

the best there is:

http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz


It does work in GHC 6.6 very nicely.
You can try it with the following naive fib function, extracted from 
the paper mentioned above:


\begin{code}
import Control.Parallel
import System.Environment
import Fib

main = do
   (x:_) - getArgs
   print$ pfib (read x)

pfib 0 = 1
pfib 1 = 1
pfib n = n1 `par` n2 `seq` n1+n2+1
  where (n1,n2) = (pfib(n-1), pfib(n-2))
\end{code}

pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded

pep:~/code/snippets/Parallelism$ time src/Main 33
11405773

real0m1.444s
user0m1.343s
sys 0m0.020s

pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2
11405773

real0m0.764s
user0m1.367s
sys 0m0.030s



Got a speedup of 100%, and didn't use threads at all. Yay!

pepe

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


--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

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


[Haskell-cafe] seq - RTFM?

2006-07-21 Thread Dusan Kolar

Hello all,

 my question is probably dull. So answers to better investigate manual 
are welcome. Why is this correct?


  ___ ___ _
 / _ \ /\  /\/ __(_)
/ /_\// /_/ / /  | |  GHC Interactive, version 6.4.1, for Haskell 98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Loading package base-1.0 ... linking ... done.
Prelude putStr Ahoj\n
Ahoj
Prelude putStr Ahoj\n `seq` 3+3
6
Prelude :q
Leaving GHCi.

And not

Prelude putStr Ahoj\n
Ahoj
Prelude putStr Ahoj\n `seq` 3+3
Ahoj
6

???

Does it have something common with monads or is it a behavior of seq?

Thanks,

 Dusan


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


[Haskell-cafe] Re: GHC 6.4.1 x86-64 does not compile

2006-05-09 Thread Dusan Kolar

Well, thanks for kicking. :-)

Now, I have a 6.4.1 version compiling for 64bits. Nevertheless, if I try 
to build a 6.4.2 based on this ghc and 64bit gcc, I get this error 
during make (quite soon after make starts) - below my text.


Is there again a problem in mixing of 32/64-bit versions or is there a 
principial problem?


Any further kick is velcome :-)

Thx and regards
Dusan

P.S.
Curently produced executable by ghhc 6.4.1 has the following signature:
a.out: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for 
GNU/Linux 2.4.0, dynamically linked (uses shared libs), stripped

D.

--


/mnt/data/FLP/bin/ghc -H16m -O -cpp -Wall -fno-warn-name-shadowing 
-fno-warn-unused-matches -i../../lib/compat -ignore-package Cabal 
-Rghc-timing-c Version.hs -o Version.o  -ohi Version.hi


Version.hs:2:0: Warning: Definition but no type signature for `version'

Version.hs:3:0: Warning: Definition but no type signature for `targetOS'

Version.hs:4:0: Warning: Definition but no type signature for `targetARCH'
In file included from /tmp/ghc24730.hc:4:
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:42:21: termios.h: not a 
file or directory
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:81:23: sys/timeb.h: not a 
file or directory

In file included from /tmp/ghc24730.hc:4:
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:538: error: syntax error 
before __hscore_lflag
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:538: warning: struct 
termios declared inside parameter list
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:538: warning: its scope is 
only this definition or declaration, which is probably not what you want
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:538: warning: return type 
defaults to `int'

/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h: In function `__hscore_lflag':
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:538: error: dereferencing 
pointer to incomplete type

/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h: At top level:
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:541: error: syntax error 
before tcflag_t
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h: In function 
`__hscore_poke_lflag':
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:541: error: `ts' undeclared 
(first use in this function)
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:541: error: (Each 
undeclared identifier is reported only once
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:541: error: for each 
function it appears in.)
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:541: error: `t' undeclared 
(first use in this function)

/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h: At top level:
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:544: warning: struct 
termios declared inside parameter list
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h: In function 
`__hscore_ptr_c_cc':
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:545: error: dereferencing 
pointer to incomplete type
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h: In function 
`__hscore_sizeof_termios':
/mnt/data/FLP/lib/ghc-6.4.1/include/HsBase.h:551: error: invalid 
application of `sizeof' to incomplete type `termios'
ghc: 56820992 bytes, 12 GCs, 2392741/4898280 avg/max bytes residency 
(3 samples), 20M in use, 0.00 INIT (0.00 elapsed), 0.18 MUT (0.45 
elapsed), 0.18 GC (0.17 elapsed) :ghc

make[4]: *** [Version.o] Error 1
make[3]: *** [boot] Error 2
make[2]: *** [boot] Error 1
make[1]: *** [boot] Error 1
make[1]: Leaving directory `/mnt/data/FLP/Downloads/ghc-6.4.2/ghc'
make: *** [build] Error 1


Simon Marlow wrote:


Dusan Kolar wrote:


Hello all,

 I've install universal binary for x86_64 of GHC 6.4.1. The 
installation was done on AMD dual core machine. Uname for the machine 
gives:


Linux machine name 2.6.16.5 #1 SMP Thu Apr 13 09:08:22 CEST 2006 
x86_64 x86_64 x86_64 GNU/Linux


While ghci was running some tests well, the ghc ended compilation 
with a long list of errors starting like this:


Chasing modules from: queen-main
Compiling QueensDK ( ./QueensDK.hs, ./QueensDK.o )
/tmp/ghc27286.s: Assembler messages:
/tmp/ghc27286.s:26: Error: bad register name `%r12'
/tmp/ghc27286.s:27: Error: bad register name `%r15'
/tmp/ghc27286.s:29: Error: bad register name `%r12)'
/tmp/ghc27286.s:30: Error: bad register name `%r12)'
/tmp/ghc27286.s:31: Error: bad register name `%r12)'
/tmp/ghc27286.s:32: Error: bad register name `%rax'
/tmp/ghc27286.s:33: Error: bad register name `%r13)'
/tmp/ghc27286.s:34: Error: bad register name `%rbp'
/tmp/ghc27286.s:37: Error: bad register name `%rbx)'
/tmp/ghc27286.s:38: Error: bad register name `%rbx)'
/tmp/ghc27286.s:45: Error: bad register name `%rbp)'
/tmp/ghc27286.s:46: Error: bad register name `%r14'
/tmp/ghc27286.s:48: Error: bad register name `%rbp)'
/tmp/ghc27286.s:49: Error: bad register name `%r13'


The list is quite long. I've truncated it.

Well, OK, the x386 version is running, but it won't compile GHC-6.4.2 
and, moreover, it's not optimized for the HW. ;-)


Is there any way out, or what may I be doing wrong way?



It appears

[Haskell-cafe] GHC 6.4.1 x86-64 does not compile

2006-05-04 Thread Dusan Kolar

Hello all,

 I've install universal binary for x86_64 of GHC 6.4.1. The 
installation was done on AMD dual core machine. Uname for the machine gives:


Linux machine name 2.6.16.5 #1 SMP Thu Apr 13 09:08:22 CEST 2006 
x86_64 x86_64 x86_64 GNU/Linux


While ghci was running some tests well, the ghc ended compilation with a 
long list of errors starting like this:


Chasing modules from: queen-main
Compiling QueensDK ( ./QueensDK.hs, ./QueensDK.o )
/tmp/ghc27286.s: Assembler messages:
/tmp/ghc27286.s:26: Error: bad register name `%r12'
/tmp/ghc27286.s:27: Error: bad register name `%r15'
/tmp/ghc27286.s:29: Error: bad register name `%r12)'
/tmp/ghc27286.s:30: Error: bad register name `%r12)'
/tmp/ghc27286.s:31: Error: bad register name `%r12)'
/tmp/ghc27286.s:32: Error: bad register name `%rax'
/tmp/ghc27286.s:33: Error: bad register name `%r13)'
/tmp/ghc27286.s:34: Error: bad register name `%rbp'
/tmp/ghc27286.s:37: Error: bad register name `%rbx)'
/tmp/ghc27286.s:38: Error: bad register name `%rbx)'
/tmp/ghc27286.s:45: Error: bad register name `%rbp)'
/tmp/ghc27286.s:46: Error: bad register name `%r14'
/tmp/ghc27286.s:48: Error: bad register name `%rbp)'
/tmp/ghc27286.s:49: Error: bad register name `%r13'
...

The list is quite long. I've truncated it.

Well, OK, the x386 version is running, but it won't compile GHC-6.4.2 
and, moreover, it's not optimized for the HW. ;-)


Is there any way out, or what may I be doing wrong way?

Regards,

 Dusan

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


[Haskell-cafe] Uses forkOS all CPUS on-board?

2005-11-23 Thread Dusan Kolar

Hello haskellers,

 in past few days, a lot of stuff on concurrency went through
the conference. I'm trying to use posted things and my own.
They work, even in a context switching regime, but I can't
exploit all the CPU's on my computer. Always is active
just one thread and, thus, the computation is even slower
than having a sequential version. Below, you can find
my code - it computes nothing useful, it's been simplified
to test parallelism, nothing else. Where's my error?

 Regards

   Dusan


import Control.Concurrent

-- computes nothing too much useful, but takes a long time ;-)
sumAllSums [] = 0
sumAllSums l@(_:xs) = sumlist 0 l + sumAllSums xs
   where sumlist res [] = res
 sumlist sr  (v:vs) = sumlist (sr+v) vs


main = do
 putStrLn Starting...
 mv1 - newEmptyMVar
 mv2 - newEmptyMVar
 t1 - forkOS $ mkSum1 mv1
 t2 - forkOS $ mkSum2 mv2
 tt mv1 mv2
 forkOS $ do killThread t1
 killThread t2
 putStrLn Done!
 where
   mkSum1 mv = do
 let res = sumAllSums [1..1]
 let ms1 = Sum1:  ++ show res
 seq (length ms1) (putMVar mv ms1)
   mkSum2 mv = do
 let res = sumAllSums [1..10001]
 let ms2 = Sum2:  ++ show res
 seq (length ms2) (putMVar mv ms2)
   tt mv1 mv2 = do
 yield
 mr1 - tryTakeMVar mv1
 case mr1 of
   Just r1 - do
 yield
 putStrLn r1
 yield
 r2 - takeMVar mv2
 putStrLn r2
   Nothing - do
 mr2 - tryTakeMVar mv2
 case mr2 of
   Just r2 - do
 yield
 putStrLn r2
 yield
 r1 - takeMVar mv1
 putStrLn r1
   Nothing - tt mv1 mv2
 


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


[Haskell-cafe] GHCi always optimizes?

2005-11-22 Thread Dusan Kolar

Hello all,

 My question is rather strange, maybe, even if simple:
Does ghci always translates with -O option set on?

 I've done some measurements on an application
using ghc and ghci.

ghc compiled with no opmitization = program running
real988m59.260s
user989m1.325s
sys 0m0.704s

ghc compiled with optimization set on = program running
real15m54.343s
user15m54.168s
sys 0m0.172s


ghci alaways:
951.97 secs, 7445117252 bytes (which is 15m51.97sec)

 To be honest, I don't mind ghci optimizes always
but saying it uses the same options as ghc is not
entirely true and, for optimization, it's quite painful
because one searches error where it is not. (/Understand,
I was wondering why program compiled by ghc crashes
and/or evaluates so long while running correctly
and fast in ghci./)


 Dusan

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


[Haskell-cafe] GHC ignores RTS options

2005-11-15 Thread Dusan Kolar

Hello,

 I wonder whether anybody could advise me how to pass
correctly RTS options to ghc? I've tried

 ghc +RTS -K4M --RTS -O program.hs -o aO.out
 ghc +RTS -K4M -RTS -O program.hs -o aO.out
 ghc -O program.hs -o aO.out +RTS -K4M
 ghc -O program.hs +RTS -K4M --RTS -o aO.out

and many others, with other sizes (10M, 12M), but program
always(!) stops with:

Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize' to increase it.

Even time of execution is always the same and thus the
RTS option on stack size is ignored.

What can I do so that the option IS taken into account?
My GHC version says:
ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.4.1


 Thanks  regards

   Dusan

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


[Haskell-cafe] Compiling hugs - stop on missing symbol

2005-11-03 Thread Dusan Kolar

Hello all,

 I don't know if this is the right place to ask about
how to compile hugs, but I'll try. :-)

My machine identifies this way:
Linux mymachine 2.6.14 #1 SMP Mon Oct 31 10:55:16 CET 2005 i686 athlon 
i386 GNU/Linux


I've downloaded this SRC package of hugs:
hugs98-Mar2005-patched.tar.gz

Download, unpack - OK

./configure --prefix=/mnt/data/FLP --enable-timer
does not complain, suggests to perform make; make install

Unfortunately, make stops with this error:

gcc  runhugs.o server.o builtin.o char.o compiler.o errors.o evaluator.o 
ffi.o goal.o input.o machdep.o machine.o module.o opts.o output.o 
plugin.o script.o static.o storage.o strutil.o subst.o type.o version.o  
-lreadline -lncurses -lm -ldl  -o runhugs

evaluator.o(.text+0x137): In function `evaluator':
/mnt/data/FLP/Downloads/hugs98-Mar2005-patched/src/evaluator.c:98: 
undefined reference to `updateTimers'

collect2: ld returned 1 exit status
make: *** [runhugs] Error 1

Well, yes, the symbol is definitely missing, as timer.c, which defines 
the symbol,
is included in hugs.c, which is not in the list of linked files. 
Nevertheless,
I don't think including the file manually would help. Moreover, probably 
configure

has produced a wrong Makefile.

Any suggestions how to make it work?

Dusan



--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

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


[Haskell-cafe] Compiled hugs - on overload crashes

2005-11-03 Thread Dusan Kolar

Hello again,

 without the --endable-timer option, I have managed to compile hugs. 
Nevertheless,

I was not successfull with doc. OK, I don't care about it, but anyway...

 I've run serveral tests. One of them is appended - for trial just type 
cesty (1,1) -
it's a kind of state-space search implementation (horse problem) made by 
a student long

time ago, without any optimization, for testing very good.

 My older hugs interpreter stops with error: ERROR - Control stack overflow
GHCi stops with the same error: *** Exception: stack overflow
That's OK, really, that's correct behavior after printing some results.

 Nevertheless, the new hugs compilation stops with this: Segmentation 
Fault(coredump)
And that's probably not the correct end. May I do something wrong? I've 
thought
that configure + make + make install_all_but_docs (no doc compiled) 
should work.


 Sorry for bothering if this is trivial or off topic.


 Regards, hoping for help,

   Dusan

--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

-
-- Bohuslav Krena (xkrena00)2 IVT 23
-- FLP - Funkcionalni a logicke programovani
-- Project 1 - Kun na sachovnici
--
-- Zadani:
-- ---
-- Ze zadaneho pole najdete cestu tak, abyste prosli vsechna pole,
-- ale na zadne pole nesmite vstoupit dvakrat.
--
-

type Pole = (Int,Int)
type Cesta = [Pole]

-- Test: z pole (1,1) - Pentium II Celeron 300 MHz.
--1,2,3,4 ...  1s
--5 ...   2 s
--6 ...  15 s
--7 ... 240 s
--30 ... do 30 minut neskoncil.
--50, 60, 61 ... control stack overflow po nekolika vysledcich.
--62, 65 ... control stack overflow ihned.
--
-- Vrati seznam vyhovujicich cest.
cesty :: Pole - [Cesta]
cesty (s,r) 
   | pridej (s,r) [] == [] 
   = error cesty: Zadane vychozi pole neni na sachovnici.
   | otherwise = hledej [[(s,r)]]

-- Test: jako cesty.
-- Hleda mozne cesty.
hledej :: [Cesta] - [Cesta]
hledej [] = []
hledej (xs:xss)
   | poli xs == 25 = xs : hledej xss
   | otherwise = hledej ( tahni xs (hledej xss) )

-- Test: OK.
-- Vygeneruje tahy na pole, ktera nejsou v dosavadni ceste.
tahni :: Cesta - [Cesta] - [Cesta]
tahni [] ass = ass
tahni (x:xs) ass = spoj (x:xs) (tah x) ass

-- Test: OK.
-- Propoji seznam moznych tahu s puvodni cestou.
spoj :: Cesta - Cesta - [Cesta] - [Cesta]
spoj _ [] ass  = ass
spoj xs (y:ys) ass
   | unikat xs y == [] = spoj xs ys ass
   | otherwise = (unikat xs y) : (spoj xs ys ass)

-- Test: OK.
-- Pokud pole neni v ceste, pak ho pridame.
unikat :: Cesta - Pole - Cesta
unikat xs y
   | clenem xs y == 1 = []
   | otherwise= y:xs

-- Test: OK.
-- Vrati 1, pokud je jiz pole v ceste, jinak vrati 0.
clenem :: Cesta - Pole - Int
clenem [] _ = 0
clenem (x:xs) y
   | x==y = 1
   | otherwise = clenem xs y

-- Test: Lze tahnout i z pole mimo sachovnici.
-- Vytvori seznam poli, na kteje je mozne tahnout.
tah :: Pole - [Pole]
tah (s,r) =  pridej (s+2,r+1)
(pridej (s+2,r-1)
(pridej (s+1,r+2)
(pridej (s+1,r-2)
(pridej (s-1,r+2)
(pridej (s-1,r-2)
(pridej (s-2,r+1)
(pridej (s-2,r-1) [])))

-- Test: OK.
-- Pokud je (s,r) pole sachovnice, tak je prida do seznamu xs.
pridej :: Pole - [Pole] - [Pole]
pridej (s,r) xs
 = if ((s0)  (s6)  (r0)  (r6))
   then (s,r):xs
   else xs

-- Test: OK.
-- Zjisti pocet poli v ceste.
poli :: Cesta - Int
poli [] = 0
poli (x:xs) = 1 + poli xs

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


[Haskell-cafe] Compiled hugs - on overload crashes

2005-11-03 Thread Dusan Kolar

Hello again,

 without the --enable-timer option, I have managed to compile hugs. 
Nevertheless,

I was not successful with doc. OK, I don't care about it, but anyway...

 I've run several tests. One of them is appended - for trial just type: 
cesty (1,1)
/(It's a kind of state-space search implementation (horse problem) made 
by a student long

time ago, without any optimization, for testing very good.)/

 My older hugs interpreter stops with error: ERROR - Control stack overflow
GHCi stops with the same error: *** Exception: stack overflow
That's OK, really, that's correct behavior after printing some results.

 Nevertheless, the new hugs compilation stops with this: Segmentation 
Fault(coredump)
And that's probably not the correct end. May I do something wrong? I've 
thought
that configure + make + make install_all_but_docs (no doc compiled) 
should work.


 Sorry for bothering if this is trivial or off topic.


 Regards, hoping for help,

   Dusan

--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

-
-- Bohuslav Krena (xkrena00)2 IVT 23
-- FLP - Funkcionalni a logicke programovani
-- Project 1 - Kun na sachovnici
--
-- Zadani:
-- ---
-- Ze zadaneho pole najdete cestu tak, abyste prosli vsechna pole,
-- ale na zadne pole nesmite vstoupit dvakrat.
--
-

type Pole = (Int,Int)
type Cesta = [Pole]

-- Test: z pole (1,1) - Pentium II Celeron 300 MHz.
--1,2,3,4 ...  1s
--5 ...   2 s
--6 ...  15 s
--7 ... 240 s
--30 ... do 30 minut neskoncil.
--50, 60, 61 ... control stack overflow po nekolika vysledcich.
--62, 65 ... control stack overflow ihned.
--
-- Vrati seznam vyhovujicich cest.
cesty :: Pole - [Cesta]
cesty (s,r) 
   | pridej (s,r) [] == [] 
   = error cesty: Zadane vychozi pole neni na sachovnici.
   | otherwise = hledej [[(s,r)]]

-- Test: jako cesty.
-- Hleda mozne cesty.
hledej :: [Cesta] - [Cesta]
hledej [] = []
hledej (xs:xss)
   | poli xs == 25 = xs : hledej xss
   | otherwise = hledej ( tahni xs (hledej xss) )

-- Test: OK.
-- Vygeneruje tahy na pole, ktera nejsou v dosavadni ceste.
tahni :: Cesta - [Cesta] - [Cesta]
tahni [] ass = ass
tahni (x:xs) ass = spoj (x:xs) (tah x) ass

-- Test: OK.
-- Propoji seznam moznych tahu s puvodni cestou.
spoj :: Cesta - Cesta - [Cesta] - [Cesta]
spoj _ [] ass  = ass
spoj xs (y:ys) ass
   | unikat xs y == [] = spoj xs ys ass
   | otherwise = (unikat xs y) : (spoj xs ys ass)

-- Test: OK.
-- Pokud pole neni v ceste, pak ho pridame.
unikat :: Cesta - Pole - Cesta
unikat xs y
   | clenem xs y == 1 = []
   | otherwise= y:xs

-- Test: OK.
-- Vrati 1, pokud je jiz pole v ceste, jinak vrati 0.
clenem :: Cesta - Pole - Int
clenem [] _ = 0
clenem (x:xs) y
   | x==y = 1
   | otherwise = clenem xs y

-- Test: Lze tahnout i z pole mimo sachovnici.
-- Vytvori seznam poli, na kteje je mozne tahnout.
tah :: Pole - [Pole]
tah (s,r) =  pridej (s+2,r+1)
(pridej (s+2,r-1)
(pridej (s+1,r+2)
(pridej (s+1,r-2)
(pridej (s-1,r+2)
(pridej (s-1,r-2)
(pridej (s-2,r+1)
(pridej (s-2,r-1) [])))

-- Test: OK.
-- Pokud je (s,r) pole sachovnice, tak je prida do seznamu xs.
pridej :: Pole - [Pole] - [Pole]
pridej (s,r) xs
 = if ((s0)  (s6)  (r0)  (r6))
   then (s,r):xs
   else xs

-- Test: OK.
-- Zjisti pocet poli v ceste.
poli :: Cesta - Int
poli [] = 0
poli (x:xs) = 1 + poli xs

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


Re: [Haskell-cafe] Hugs - evaluation statistics

2005-08-29 Thread Dusan Kolar

Well, I know I cannot calculate exact time statistics, but I cen get
information about the aproximate behavior - like the algorithm
is Theta(n), Theta(n*log(n)), etc. It's quite sufficient, I think.

According to your example - I don' know what you want to show,
both algorithms are linear in time consumption:

[reductions]
 lengthlength2
l(10) 91 28
l(100)   721 73
l(1000) 7021523
l(5000)35021   2523

For length we get: 7*n+21
For length2 we get: 1/2*n+23

Thus, for both length and length' we get: Theta(n)

And in my first e-mail, I wrote I knew it's not exact. But, if I expect
behavior like Theta(n^2) and I can't fit it then I'm asking
why - now I know answer even for that question (in my case) -
I can provide only too small input to test (otherwise out of memory)
and thus the curve is not curve-enough and is much closer to
line. But new settings for hugs compilation should allowed much
higher memory usage and I should get to more usable numbers. :-)

Dusan

Bulat Ziganshin wrote:


Hello Dusan,

Monday, August 29, 2005, 9:55:56 AM, you wrote:

 


Nevertheless, for the other algorithm the expected time complexity  (
quite well known in general :-) )  and measured values do no fit together.
   



number of reductions is not exact time statistics. try the following
alternative length definition ;)

length2 (_:_:_:_:_:_:_:_:_:_:xs) = (length2 xs)+10
length2 (_:xs)   = (length2 xs)+1
length2 _= 0

and compare number of reductions for:

length [1..5000]
length2 [1..5000]


 



--

Dusan Kolartel: +420 54 114 1238
UIFS FIT VUT Brno  fax: +420 54 114 1270
Bozetechova 2   e-mail: [EMAIL PROTECTED]
Brno 612 66
Czech Republic

--

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


Re: [Haskell-cafe] Hugs - evaluation statistics

2005-08-28 Thread Dusan Kolar




No, that is OK. :-) The matter is that I've implemented two
algorithms solving the same problem. For one of them, I can
easily derive the time complexity and even verify - by performing
several tests and then using the least squares fitting. Nevertheless,
for the other algorithm the expected time complexity  ( quite well known
in general :-) )  and measured values do no fit together. As I'm trying
to use as large inputs as possible as well as the short ones,
I was wondering, whether there might be some distortion due to
added values to the counter of reductions because of garbage
collection - now I know that not  ( verified such a way, so that
I changed the amount of allocated memory by hugs and run the
same command = once with GC, the other time without :-) ).

Sorry for distortion in the list.

Dusan

Daniel Fischer wrote:

  Am Mittwoch, 24. August 2005 16:55 schrieb Dusan Kolar:
  
  
Hello,

  Even if I know number of reductions should not be used
to anything important I'm quite confused with values I get.
Is garbage collection somehow affecting the number of
reductions? I have always thought not, but... ;-)

  Thx,

   Dusan


  
  
What is confusing you?
Different numbers of reductions for the same computation?
That would probably be due to the fact that named entities are stored and not 
re-evaluated.

Cheers,

Daniel
  


-- 

 Dusan Kolartel: +420 54 114 1238
 UIFS FIT VUT Brno  fax: +420 54 114 1270
 Bozetechova 2   e-mail: [EMAIL PROTECTED]
 Brno 612 66
 Czech Republic

--



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


[Haskell-cafe] Hugs - evaluation statistics

2005-08-24 Thread Dusan Kolar

Hello,

 Even if I know number of reductions should not be used
to anything important I'm quite confused with values I get.
Is garbage collection somehow affecting the number of
reductions? I have always thought not, but... ;-)

 Thx,

  Dusan

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


[Haskell-cafe] Forcing type conversion - probably FAQ(?)

2004-12-01 Thread Dusan Kolar
Hello,
 I'm trying to make work the following code (I'm using GHCi
with flags -fglasgow-exts -fallow-undecidable-instances):
infixl 6 :+, :-
infixl 6 .+, .-
data TMyExpr = TMyExpr :+ TMyExpr
| TMyExpr :- TMyExpr
| Val Int
| Id String
class MkExpr a b where
 (.+) :: a - b - TMyExpr
 (.-) :: a - b - TMyExpr
instance MkExpr Int Int where
 (.+) a b = (Val a) :+ (Val b)
 (.-) a b = (Val a) :- (Val b)
instance MkExpr Int TMyExpr where
 (.+) a b = (Val a) :+ b
 (.-) a b = (Val a) :- b
instance MkExpr TMyExpr Int where
 (.+) a b = a :+ (Val b)
 (.-) a b = a :- (Val b)
instance MkExpr TMyExpr TMyExpr where
 (.+) a b = a :+ b
 (.-) a b = a :- b
It compiles fine, no problem. Nevertheless, writing
(3::Int) .+ (4::Int)
seems to me quite clumsy, but 3 .+ 4 does not work. :-(
It says the 3 is from class Num and no variant is present
for it, I know, it is not present, but how to force it to
convert it to Int automatically?  When I try to incorporate
instance (Num a, Num b) = MkExpr a b where
 (.+) a b = (Val . round a) :+ (Val . round b)
 (.-) a b = (Val . round a) :- (Val . round b)
the situation is even worse. :-(
I tried several modifications, but they don't work either. :-\
I was trying to find the discussion (I wonder whether it
went on the similar topic through the list recently), but
failed. :-(
If someone can just point me to any resource I could study
the possible solutions - maybe I put wrong data to google. ;-)
Or just to stop me, if I'm trying to do impossible... :-\
Thx,
 Dusan
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Naive instantiation

2003-10-07 Thread Dusan Kolar
Hello,

 I've got (maybe a bit naive) question, whether it is possible
to have instance of class (already derived from another class)
if it uses more concrete type than instances of predecesing classes.
Let us assume the following example:
 class A a where...
 class (A a) = B a where...
 class (B a) = C a where...
 data MyData a = MD Int a

 instance A (MyData a) where...
 instance B (MyData a) where...
 instance C (MyData Int) where...
Hugs/GHCi produce errors, of course. Nevertheless, is there
any way to obtain such a feature? (In this example, classes
A and B represent abstract classes providing functions with
general algorithms, while class C cannot have a general implementation
and requires a concrete data type for MyData.)
 Thank you for any hints,

   Dusan

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Library for concurrent threads running

2002-12-16 Thread Dusan Kolar
Hello,

  My question/wish is maybe naive, but anyway:
Is there a library (not a language extension, like
Concurrent Haskell, Glasgow Parallel Haskell, ...) enabling
to run two functions in parallel, possibly in cascade?

Something like:

  testAll (threadStart f1 (threadStart f2 f3))

 where threadStart :: a - b - (WillBe a, WillBe b)
 where type WillBe is something like Maybe, but
 changing within a time (mutable values) ~ Processing, Just a, Nothing

 testAll (Nothing,p) = putStr No result for f1  testPair p
 testAll (l,(Nothing,r)) = putStr Noresult for f2  testPair (l,r)
 testAll (l,(ll,Nothing)) = putStr No result for f3  testPair (l,ll)
 testAll (Just a,p) = putStr (res of f1:  ++ show a)  testPair p
 ...

 testPair ~ about the same like testAll

Probably the explanation is not too clear and what I wish
is out of the language scope (not really functional), but
I would appreciate something like that. Is there something
like that for Haskell/Hugs?

 Thx for any ref.

Dusan

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe