Re[2]: [Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Bulat Ziganshin
Hello Olivier,

Thursday, May 15, 2008, 11:06:19 PM, you wrote:

 As I could not find a function to wait on a ThreadId I used a MVar to 
 synchronize both threads.

 Is this normal or have I missed the `waitOnThreadId` function?

yes, it's common idiom


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Fun with Darcs

2008-05-14 Thread Bulat Ziganshin
Hello Andrew,

Thursday, May 15, 2008, 12:49:32 AM, you wrote:

 touch. Now, let's see what this IDE actually looks li-- oh you have GOT
 to be KIDDING me! It can't find the right GTK DLL?!?

gtk2hs includes *developer* gtk2 environment. while it should work
fine (as far as it's in your path), you may try to install *runtime*
gtk2 environment from
http://sourceforge.net/project/showfiles.php?group_id=71914package_id=255391


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] FFI: newbie linking problem

2008-05-14 Thread Bulat Ziganshin
Hello Olivier,

Thursday, May 15, 2008, 1:26:28 AM, you wrote:

     RFC_RC _stdcall RfcUTF8ToSAPUC(const RFC_BYTE *utf8, unsigned 
 utf8Length,  SAP_UC *sapuc,
   unsigned *sapucSize, unsigned *resultLength, RFC_ERROR_INFO *info)

     foreign import ccall unsafe sapnwrfc.h RfcUTF8ToSAPUC
       f_RfcUTF8ToSAPUC :: RfcBytePtr - CUInt - SapUCPtr - Ptr

use stdcall instead of ccall in Haskell too. afair, depending on
calling conventions, different prefixes/suffixes are used when
translating C function name into assembler (dll) name

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] saner shootout programs

2008-05-13 Thread Bulat Ziganshin
Hello Richard,

Tuesday, May 13, 2008, 7:56:36 PM, you wrote:

 In July 2007 -O2 was documented in GHC as making no difference to
 the speed of programs :

 http://www.haskell.org/pipermail/haskell-cafe/2007-July/029118.html

it's because ghc is 15 years old and its documentation may be not
updated as things changes :)

 and from this thread

 http://www.haskell.org/pipermail/haskell-cafe/2008-April/042155.html

 it appears to be currently unused for splitAt.

i've read this thread. it was just assumption - don't believe it
before you have checked it


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Data.Dynamic over the wire

2008-05-13 Thread Bulat Ziganshin
Hello Jules,

Tuesday, May 13, 2008, 9:39:12 PM, you wrote:
 This is close, and works as far as it goes. It is a limited
 reimplementation of Dynamic which uses show/read instead of

there are gread/gshow funcs. don't know how these works, though :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Trying to avoid duplicate instances

2008-05-13 Thread Bulat Ziganshin
Hello Eric,

Tuesday, May 13, 2008, 10:16:48 PM, you wrote:

 -fallow-overlapping-instances doesn't convince GHC.  Is there a way
 around this other than manually writing out all the instances I want?

afaik, no. typeclasses are not the same as OOP classes. i suggest you
to look into http://haskell.org/haskellwiki/OOP_vs_type_classes and in
particular papers mentioned at the end - one describes implementation
of type classes and other emphasize differences between t.c. and
classes. these should shed the light :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Re: Parsec3 performance issues (in relation to v2)

2008-05-13 Thread Bulat Ziganshin
Hello Antoine,

Wednesday, May 14, 2008, 8:43:47 AM, you wrote:

 Is this expected?  I don't really understand why adding an extra layer
 of indirection should speed things up.

adding laziness may improve performance by avoiding calculation of
unnecessary stuff or moving into into later stage when it will be
immediately consumed


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Re: Order of Evaluation

2008-05-11 Thread Bulat Ziganshin
Hello Luke,

Sunday, May 11, 2008, 1:24:04 PM, you wrote:

 So.. what do you use unsafePerformIO together with?

when i call function that in general case depends on the execution
order (so it's type is ...-IO x), but in my specific case it doesn't
matter. typical example is hGetContents on config file, GetSystemInfo
just to get number of processors, string processing via C functions


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Type unions

2008-05-10 Thread Bulat Ziganshin
Hello Eric,

Saturday, May 10, 2008, 8:26:27 PM, you wrote:

 Thank you -- looking at Printf was very helpful.  My syntax is much
 happier as a result.

btw, i also recommend to look into HsLua[1] which uses type classes in
very smart and elegant way to automatically convert between Haskell
and Lua data types

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


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] seeking advice on my POSIX wrapper

2008-05-10 Thread Bulat Ziganshin
Hello Vasili,

Sunday, May 11, 2008, 12:47:52 AM, you wrote:

 . When I call this function (mqReceive), I get message too long.

you can divide-and-conquer the problem by trying
1) write the C code that calls mq_receive with the same params
2) call your own function instead of mq_receive and printf parameters it
receives


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] I am new to haskell

2008-05-09 Thread Bulat Ziganshin
Hello Giorgio,

Friday, May 9, 2008, 10:40:47 AM, you wrote:

 be the next one. Should I wait for Real world Haskell or do you think
 that the books you listed offer something new/different/more advanced
 than Programming in Haskell?

i recommend you to read papers from the 
http://haskell.org/haskellwiki/Learning_Haskell
page, in particular those in Advanced tutorials, Monads, Type classes,
Popular libraries sections



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] FFI: Creating a Storable for a C-struct composed of char arrays

2008-05-09 Thread Bulat Ziganshin
Hello Olivier,

Friday, May 9, 2008, 6:28:38 PM, you wrote:

 Thanks for your help, CString will work great for Char arrays, but
 what about the 16bit-Word arrays?

TString. they are used a lot for interfacing with Win32 API

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] (Num t) = [t] or [Int]

2008-05-09 Thread Bulat Ziganshin
Hello PR,

Saturday, May 10, 2008, 1:07:48 AM, you wrote:

 Okay, when it comes to 3.3:[1,2,3] (Num t) = [t] makes more sense.
 Is that the only reason?

the reason is that 1 as any other numerical constant, may be directly
used as Int, Integer, Double or any other Num value. if 1 is Int, you
will need to make more conversions

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] inserting values in a binary tree

2008-05-09 Thread Bulat Ziganshin
Hello PR,

Saturday, May 10, 2008, 3:10:59 AM, you wrote:

 in C you'd fiddle with pointers and Bob's your uncle. Here I'm not
 sure how to piece that tree back together again with the new element 
 after having expanded it recursively.

in Haskell, you just return new tree with element inserted. it's
constructed from the two subtrees, where you've inserted element in
one of these. and so on recursively:

data Tree a = Tree a (Tree a) (Tree a)
| EmptyTree
insert (Tree x t1 t2) y | xy  =  Tree x t1 (insert t2 y)
insert (Tree x t1 t2) y=  Tree x (insert t1 y) t2
insert EmptyTree  y=  Tree y EmptyTree EmptyTree


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell] [Haskell-cafe] Help with polymorphic functions

2008-05-08 Thread Bulat Ziganshin
Hello Wei,

Thursday, May 8, 2008, 11:10:08 PM, you wrote:

 test :: a - Int - a

 shift is defined as a - Int - a

not exactly ;)  this type signature is given inside class Bits, where
'a' isn't a free variable (as in standalone signature declaration),
but means 'a' from type class header:

class Num a = Bits a where
shift :: a - Int - a

so, this declaration is equivalent to the following standalone one:

shift :: (Bits a) =  a - Int - a


from the common sense POV, you can't shift *ANY* type 'a', but only
types that belong to the Bits class. so, shift cannot have signature
w/o class, and the same remains true for `test`


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Bulat Ziganshin
Hello Philip,

Friday, May 9, 2008, 2:17:41 AM, you wrote:

 Is there a way to write some of the functions in Haskell and then use
 them in my C code via some kind of interface?

http://haskell.org/haskellwiki/IO_inside#Interfacing_with_foreign_evil_.28under_development.29

and then entries 1,6,7 in 
http://haskell.org/haskellwiki/IO_inside#Further_reading


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Bulat Ziganshin
Hello Philip,

Friday, May 9, 2008, 3:09:33 AM, you wrote:

 Thanks for all the answers. I'm testing this right now and simples cases
 work as expected. However from what I've read it seems it'll get ugly 
 once I try to pass a C array to a Haskell function.

http://haskell.org/haskellwiki/Modern_array_libraries

read about foreign arrays

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] runInteractiveProcess and hGetLine on Windows

2008-05-07 Thread Bulat Ziganshin
Hello David,

Wednesday, May 7, 2008, 7:46:11 PM, you wrote:

 I don't see any reason to support text mode.  It's easy to filter by hand
 if you absolutely have to deal with ugly applications on ugly platforms.

you mean unix, of course? ;)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Using Template Haskell to make type-safe database access

2008-05-07 Thread Bulat Ziganshin
Hello Mads,

Thursday, May 8, 2008, 1:24:05 AM, you wrote:

 also because TH is difficult. At least TH was difficult for me. It might
 just be because I have never worked with anything like TH before (have

no, TH is dificult by itself. if you have spare time - read about
metalua, which implements the same idea in Lua environment. it's
simple and straightforward, and even allows to easily change syntax.
one possible reason of TH difficulty may be that Haskell is
strict-typed language

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Question related to Multi Param Type Classes

2008-05-05 Thread Bulat Ziganshin
Hello Sai,

Monday, May 5, 2008, 7:52:29 PM, you wrote:

 class MyString m c  where

it should be

class MyString m c | m-c where

so ghc will realize that same m means the same c. read about
functional dependencies in ghc user manual

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] castIOUArray and hPutArray redux

2008-05-02 Thread Bulat Ziganshin
Hello Ben,

Saturday, May 3, 2008, 5:13:48 AM, you wrote:

 have the issues with castIOUArray (and thus hGetArray, hPutArray) in
 Data.Array.IO discussed below been resolved?

there is alternative arrays library [1], where bounds are recalculated
when casting

[1] http://haskell.org/haskellwiki/Library/ArrayRef


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] force inlining in GHC

2008-04-29 Thread Bulat Ziganshin
Hello Henning,

Tuesday, April 29, 2008, 2:01:39 PM, you wrote:

 However, in the Core output 'doubleFunc' does not get the __inline_me tag
 and thus will not be inlined, too. :-(

ghc is so smart that sometimes it fool itself :D  i bet that in this case
generic and specific functions are considered as equivalent :)

ps: why you not wrote to ghc users list?


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Haskell as a general purpose programming language...

2008-04-28 Thread Bulat Ziganshin
Hello Martin,

Monday, April 28, 2008, 3:51:11 PM, you wrote:

 just a thought:  is it just me, or is Haskell really really really the
 coolest general-purpose programming language?

the only Haskell drawback is that it forces you to hate all other
programming languages (c) people :)

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] FFI Query: How to free a CString allocated in Haskell

2008-04-28 Thread Bulat Ziganshin
Hello Verma,

Monday, April 28, 2008, 4:11:51 PM, you wrote:

   newCString str

 Now once I call this function from C code, I am freeing the allocated
 memory using free function. I want to confirm that this is the right
 thing to do.

yes, i've traced this function down to mallocArray - mallocBytes -
malloc() calls


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] n00b circular dep question

2008-04-26 Thread Bulat Ziganshin
Hello Stuart,

Saturday, April 26, 2008, 1:57:47 PM, you wrote:

 Are you sure? I would be very interested in a switch that
 automatically generates hs-boot files, but I've been unable to find
 any mention of it.

no, i never used this function, so you should be informed better


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] n00b circular dep question

2008-04-25 Thread Bulat Ziganshin
Hello Jennifer,

Friday, April 25, 2008, 8:54:42 PM, you wrote:

 So, I have a circular dependency in my modules that I don't know
 how to resolve in Haskell.

1. haskell standard allows circular deps between modules

2. ghc supports this part of standard in a rather awkward way - you
need to generate .hs-boot files using some switch (look into docs).
which is like .h files generated automatic from .cpp. once these files
aregenerated, your circular deps will be ok


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: a faster, accumulating mapM (was Re: [Haskell-cafe] mapM vs mapM_ performance)

2008-04-24 Thread Bulat Ziganshin
Hello Ben,

Friday, April 25, 2008, 1:14:17 AM, you wrote:

mapM2 :: Monad m = (a - m b) - [a] - m [b]
 {-# INLINE mapM2 #-}
 mapM2 fn lst = mapM2accum fn lst []
 where mapM2accum _ [] accum = return accum
   mapM2accum fn (x:xs) accum = do
 r - fn x
 mapM2accum fn xs (r:accum)

it seems you forget to reverse accum before returning it?


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: a faster, accumulating mapM (was Re: [Haskell-cafe] mapM vs mapM_ performance)

2008-04-24 Thread Bulat Ziganshin
Hello Niklas,

Friday, April 25, 2008, 1:25:39 AM, you wrote:

 Not that it should matter for performance any, but you really ought to
 reverse the result list too, or compute the accumulator in the right
 order. :-)

unfortunately, this affects performance too. reverse costs one more scan
through the list and building lot of thunks has its own space and time
cost


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Storable class?

2008-04-22 Thread Bulat Ziganshin
Hello Evan,

Wednesday, April 23, 2008, 1:48:30 AM, you wrote:

 The FFI doc doesn't really talk about the alignment method at all, so
 I don't really understand how to write one or how it's used.

write: easy. just specify how much data shoulkd be aligned. for
primitive datatypes this usually equals to datasize, for complex
structures this should be the same as maximum alignment of elements
involved:

instance Storable Float
  alignment = 4

instance Storable (a,b)
  alignment = maximum [alignment a, alignment b]

use: just align memory blocks allocated to store this datatype. usual
alignment technique is:

alloc a = (allocBytes (sizeOf a + alignment a - 1) + (alignment a - 1)) .. 
(alignment a - 1)

well, many standard allocators such as C malloc, actually provide you
blocks with a maximum alignment required to store any (primitive)
type, so you don't need to worry about it


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Functional board games

2008-04-21 Thread Bulat Ziganshin
Hello Dougal,

Monday, April 21, 2008, 7:22:49 PM, you wrote:

 Does anyone know of functional-style implementations of
 chess/draughts/go/anything else that might give me ideas? I am writing

once we have seen 100-line chess published in this list

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[4]: [Haskell-cafe] C++ interface with Haskell

2008-04-20 Thread Bulat Ziganshin
Hello Don,

Saturday, April 19, 2008, 12:08:11 AM, you wrote:

 Would someone like to summarise the current approaches
 to combining Haskell  C++ on the Haskell wiki, even if just in bullet
 points?

started at 
http://haskell.org/haskellwiki/IO_inside#Interfacing_with_foreign_evil

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Parallel weirdness [new insights]

2008-04-20 Thread Bulat Ziganshin
Hello Andrew,

Sunday, April 20, 2008, 11:41:52 PM, you wrote:

yes, GC behavior has significant impact on any new language (i mean
java, c#, f# and so on)

 1. Does running the GC force all threads to stop? I know some GC designs
 do this, but I have no idea how the one GHC implements works.

yes

 2. Is the GC still single-threaded? (GHC 6.8.2 here.)

yes. multi-threaded GC is planned gor next ghc version, afair

 3. Is there any way for a running Haskell program to find out how much
 heap space is currently allocated / used / free?

i think it's possible by asking internal RTS vars. SM once suggested
to add to GHC library that provides official way to ask this info but
no volunteer was happen :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Parallel weirdness

2008-04-19 Thread Bulat Ziganshin
Hello Andrew,

Saturday, April 19, 2008, 6:56:10 PM, you wrote:

 OK, so just for fun, I decided to try implementing a parallel merge sort

coincedence - now i'm writing a parallel compression algorithm, very
much like parallel bzip2, but using ghc, of course

 Weird thing #1: The first time you sort the data, it takes a few
 seconds. The other 7 times, it takes a split second - roughly 100x 
 faster. Wuh?

this looks like disk caching effects. if data are read from disj on
first run and from disk cache on the next runs, this only means that
your algorithm works faster than reading its data from disk

 Weird thing #2: The parallel version runs *faster* than the sequential
 one in all cases - even with SMP disabled! (We're only talking a few 
 percent faster, but still.)

 Weird thing #3: Adding the -threaded compiler option makes
 *everything* run a few percent faster. Even with only 1 OS thread.

there are plenty of reasons: first, -threaded make i/o overlapped
with calculations. second, parallel version may exhibit better cpu
cache behavior - such as processing all data in cache before sending
it back to memory

 Weird thing #4: Adding -N2 makes *everything* slow down a few percent.
 In particular, Task Manager shows only one CPU core in use.

it's easy - your algorithm isn't really parallel, and you just forced
ghc to move it from one core to another. it's overhead of moving data
around :)

 Can anybody explain any of this behaviour? I have no idea what I'm 
 benchmarking, but it certainly doesn't appear to be the performance of a
 parallel merge sort!

there are many subtle effects making optimization much more interesting
than using simple schemas ;)  it's why i like it so much :))


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Parallel weirdness

2008-04-19 Thread Bulat Ziganshin
Hello Andrew,

Saturday, April 19, 2008, 7:50:30 PM, you wrote:

 this looks like disk caching effects. if data are read from disj on
 first run and from disk cache on the next runs, this only means that
 your algorithm works faster than reading its data from disk
   

 Negative. No data is ever *read* from disk, only *written* to disk. (And
 each test writes to a different file.)

 The data to be sorted is generated using a trivial LCG PRNG.

if you don't generate new data for each sorting run, this means that
data generation is much slower than sorting. don't forget about ghc
laziness :)

 there are plenty of reasons: first, -threaded make i/o overlapped
 with calculations.

 Not with -N1.

are you sure? :)  afaik, -threaded RTS uses dedicated i/o thread
despite of -N setting (which controls only amount of threads running
*user* code)

 second, parallel version may exhibit better cpu
 cache behavior - such as processing all data in cache before sending
 it back to memory
   

 Again, with -N1, it is *still* only using 1 CPU core.

parallel version is different from sequential one and it process data
in another order. for example, imagine tar+gzip algorithm which runs
sequentially and write intermediate results to the disk. the same
algorithm, being multithreaded, will compress data on the fly and
don't store intermediate data to the HDD despite using only one core.
the same effect applies to cpu cache usage


 Weird thing #4: Adding -N2 makes *everything* slow down a few percent.
 In particular, Task Manager shows only one CPU core in use.
 

 it's easy - your algorithm isn't really parallel.
   

 Fails to explain why the parallel version is faster than the sequential
 one (even with no parallelism), or why the sequential algorithm should
 slow down with more threads. (Surely the extra threads just sit idle?)

there are management overheads. with multiple worker threads you have
many OS threads which fights for the right to execute single Haskell
thread :))

 there are many subtle effects making optimization much more interesting
 than using simple schemas ;)  it's why i like it so much :))
   

 Well, based on the results I've seen so far, it seems that parallelism
 is a complete waste of time because it doesn't gain you anything. And 
 that doesn't make a lot of sense...

i made world fastest compression program using multithreading, so the
problem is definitely on other side ;)

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Parallel weirdness

2008-04-19 Thread Bulat Ziganshin
Hello Brandon,

Saturday, April 19, 2008, 8:24:03 PM, you wrote:

 contention.  (Note that resource locking will be done by the threaded
 runtime even with only one thread, so you will see some slowdowns  
 especially in I/O-related code.)

yes, i forget about this. Simon wrote once that locking decrease
performance by a few percents compared to single-threaded runtime

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Hackage being too strict?

2008-04-18 Thread Bulat Ziganshin
Hello Duncan,

Friday, April 18, 2008, 1:43:24 PM, you wrote:

 older Cabal versions). We can make it stricter again in the future when
 Cabal-1.4+ is much more widely deployed.

the problem, imho, is that such tools as Cabal, GHC, Hackage should be
built with forward and backward compatibility in mind. otherwise,
Haskell will still remain mostly a hacker tool

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] compressed pointers?

2008-04-18 Thread Bulat Ziganshin
Hello Ketil,

Friday, April 18, 2008, 10:44:53 AM, you wrote:

 This probably becomes too complicated, but I thought it was
 interesting that the Java people are making use of 32bit pointers on a
 64bit system, and are seeing a good performance benefit from it.

afaik, C compilers support this model too, so it shouldn't too hard to
compile GHC in such mode. it's a bit like small/large memory models of
those 16-bit x86 systems :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Bulat Ziganshin
Hello Miguel,

Friday, April 18, 2008, 7:06:07 PM, you wrote:

you may look into my freearc.org project

overall, nothing complex as far as you got it :) i use

ghc -c c_file.cpp
ghc --make main.hs c_file.o

in order to call from C++ to Haskell or vice versa you should define
function in C++ as having extern C linkage. i recommend you to
declare function in header file which is able to compile either in C++
mode (used in first step) or C mode (used in second step, when
compiling main.hs):

#ifdef  __cplusplus
extern C {
#endif
void myfunc(void);
#ifdef  __cplusplus
}
#endif


then you use either foreign import haskell statement to use C++ func
from haskell or foreign export for other way. i also recommend you
to use main procedure written in haskell and run from this procedure
your main C function - this is the simplest way to initialize Haskell
runtime system. that's all


 Thanks,

 I found on one site how to compile after creating the stub files with GHC:

 First step:
 ghc -c -ffi haskell_file.hs
 Second step - here it is important to know and write where are the ghc 
 libraries:
  gcc -I /usr/local/lib/ghc-5.04.3/include -c C_file.c 
 After that it is important to link my creted C_file with the stub file and 
 compile it:
 ghc -no-hs-main -o C_file C_file.o haskell_file.o haskell_file_stub.o
  
 The final result is C_file execution file...just enter C_file and the program 
 is running correctly.

 This information: how to compile and to link C with Haskell and to
 call a Haskell funtion from C was quite difficult.
  But here is my result of googling throw the internet and to find something 
 usefull.

 Next challange: link C++ with C and creating a usefull documentation and put 
 it online!

 Ciao,
 Miguel Lordelo.


  

 On Fri, Apr 18, 2008 at 3:33 PM, Alfonso Acosta [EMAIL PROTECTED] wrote:
  Although you could use gcc to link the code I wouldn't recommend it
  (mainly for the problems you are currently having)
  
  SImply call GHC to compile both the C and Haskell code. It will take
  care of finding the headers and supplying the necessary linker
  arguments.
  
  ghc -ffi -c   foo.hs myfoo_c.c
  
  BTW, you don't need to compile viaC
  
  2008/4/17 Miguel Lordelo [EMAIL PROTECTED]:
  
 Well Isaac...I became now a little bit smarter then yesterday!!!
 
  I show you the example that I found and on which I?m working with.
 
  File: foo.hs
  module Foo where
 
  foreign export ccall foo :: Int - IO Int
 
  foo :: Int - IO Int
  foo n = return (length (f n))
 
  f :: Int - [Int]
  f 0 = []
  f n = n:(f (n-1))
 
  To get the C wrapper you insert the following command:
  ghc -ffi -fvia-C -C foo.hs
 
   After execution you will have these following additional files:
 
  foo.hc
  foo.hi
  foo_stub.c
  foo_stub.h
  foo_stub.o
 
  What I did next was to create a file named: myfoo_c.c, where I will call the
  foo function (implemented in Haskell).
   (you can see this example on
  http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html )
  But the problem is to compile with gcc (must I put any flag or whatever set
  something)
 
  The gcc output is:
  myfoo_c.c:2:19: error: HsFFI.h: No such file or directory
 
  I downloaded this header file from: (I know that is not the correct way, but
  it was the only idea that occurs at the moment)
  http://www.koders.com/c/fidD0593B84C41CA71319BB079EFD0A2C80211C9337.aspx
 
  I compiled again and the following return error appears:
  myfoo_c.c:(.text+0x1c): undefined reference to `hs_init'
  myfoo_c.c:(.text+0x31): undefined reference to `foo'
  myfoo_c.c:(.text+0x50): undefined reference to `hs_exit'
   collect2: ld returned 1 exit status
 
  These functions are necessary to setup GHC runtime (see:
  http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html )
 
  What I want to know is how to compile myfoo_c.c?! Is it with GCC or GHC?!
 
  Chears,
  Miguel Lordelo.
 
 
 
 
  On Wed, Apr 16, 2008 at 9:16 PM, Isaac Dupree [EMAIL PROTECTED]
  wrote:
 
   perhaps
  
   haskell:
   foreign export foo_func foo :: Int - IO Int
   -- I forget the rest of the syntax here
  
   C++:
  
   extern C {
   int foo_func(int i);
   }
  
   int some_cplusplus_function() {
    int bat = 3;
    int blah = foo_func(bat);
    return blah;
   }
  
  
   Is that all you need to do?
  
  
   Miguel Lordelo wrote:
  
   
   
   
Hi all,
   
Well...somehow I'm a beginner in Haskell. But actually my interest in
Haskell will increase if it is possible to call a haskell function in
  C++.
Something like GreenCard ( http://www.haskell.org/greencard/ )
  simplifying
the task of interfacing Haskell programs to external libraries
  (usually).
But is there also a task to interface a foreign language with Haskell,
  but
calling Haskell functions. Or c2hs which is an interface generator that
simplifies the development of Haskell bindings to C libraries.
   
I want to know this, because in my company some guys are doing some
  testing
with 

Re[2]: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Bulat Ziganshin
Hello Isaac,

Friday, April 18, 2008, 7:27:56 PM, you wrote:

absolutely true! it's required if you use new/delete and other things
supported by c++ RTS

 if you'd normally be linking using g++, you'll need (IIRC) -lstdc++ 
 added to linking-ghc's command line

 Alfonso Acosta wrote:
 Although you could use gcc to link the code I wouldn't recommend it
 (mainly for the problems you are currently having)
 
 SImply call GHC to compile both the C and Haskell code. It will take
 care of finding the headers and supplying the necessary linker
 arguments.
 
 ghc -ffi -c   foo.hs myfoo_c.c
 
 BTW, you don't need to compile viaC
 
 2008/4/17 Miguel Lordelo [EMAIL PROTECTED]:
 Well Isaac...I became now a little bit smarter then yesterday!!!

 I show you the example that I found and on which I?m working with.

 File: foo.hs
 module Foo where

 foreign export ccall foo :: Int - IO Int

 foo :: Int - IO Int
 foo n = return (length (f n))

 f :: Int - [Int]
 f 0 = []
 f n = n:(f (n-1))

 To get the C wrapper you insert the following command:
 ghc -ffi -fvia-C -C foo.hs

  After execution you will have these following additional files:

 foo.hc
 foo.hi
 foo_stub.c
 foo_stub.h
 foo_stub.o

 What I did next was to create a file named: myfoo_c.c, where I will call the
 foo function (implemented in Haskell).
  (you can see this example on
 http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html )
 But the problem is to compile with gcc (must I put any flag or whatever set
 something)

 The gcc output is:
 myfoo_c.c:2:19: error: HsFFI.h: No such file or directory

 I downloaded this header file from: (I know that is not the correct way, but
 it was the only idea that occurs at the moment)
 http://www.koders.com/c/fidD0593B84C41CA71319BB079EFD0A2C80211C9337.aspx

 I compiled again and the following return error appears:
 myfoo_c.c:(.text+0x1c): undefined reference to `hs_init'
 myfoo_c.c:(.text+0x31): undefined reference to `foo'
 myfoo_c.c:(.text+0x50): undefined reference to `hs_exit'
  collect2: ld returned 1 exit status

 These functions are necessary to setup GHC runtime (see:
 http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html )

 What I want to know is how to compile myfoo_c.c?! Is it with GCC or GHC?!

 Chears,
 Miguel Lordelo.




 On Wed, Apr 16, 2008 at 9:16 PM, Isaac Dupree [EMAIL PROTECTED]
 wrote:

 perhaps

 haskell:
 foreign export foo_func foo :: Int - IO Int
 -- I forget the rest of the syntax here

 C++:

 extern C {
 int foo_func(int i);
 }

 int some_cplusplus_function() {
  int bat = 3;
  int blah = foo_func(bat);
  return blah;
 }


 Is that all you need to do?


 Miguel Lordelo wrote:



 Hi all,

 Well...somehow I'm a beginner in Haskell. But actually my interest in
 Haskell will increase if it is possible to call a haskell function in
 C++.
 Something like GreenCard ( http://www.haskell.org/greencard/ )
 simplifying
 the task of interfacing Haskell programs to external libraries
 (usually).
 But is there also a task to interface a foreign language with Haskell,
 but
 calling Haskell functions. Or c2hs which is an interface generator that
 simplifies the development of Haskell bindings to C libraries.

 I want to know this, because in my company some guys are doing some
 testing
 with Frotran and MatLab and I want to show them the power of haskell and
 the
 software which we are using is implemented in C++ (there is the reason
 to
 make Haskel - C++).

 I read somewhere that the only way for C++ calling a haskell function is
 to
 create a binding between Haskell and C and from C to C++, but a easy
 Hello
 World example was not there.
 Unfortunatelly I couldn't found anything usefull, like an complete
 example,
 or how to compile the code from haskell to C to C++.

 Can sombody help me, please :P

 Chears,
 Miguel Lordelo.



 


 ___
 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


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] announce: Glome.hs-0.3 (Haskell raytracer)

2008-04-18 Thread Bulat Ziganshin
Hello Jim,

Saturday, April 19, 2008, 12:10:23 AM, you wrote:

 The other problem I had with concurrency is that I was getting about a
 50% speedup instead of the 99% or so that I'd expect on two cores.  I 

2 cores doesn't guarantee 2x speedup. some programs are limited by
memory access speed and you still have just one memory :)

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Intro to functional dependencies in Haskell?

2008-04-17 Thread Bulat Ziganshin
Hello Alexis,

Thursday, April 17, 2008, 9:21:16 AM, you wrote:

 i'm having some trouble 'getting' functional dependencies in the Haskell

ghc 6.8 manual contains good introduction into FDs

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] GC'ing file handles and other resources

2008-04-16 Thread Bulat Ziganshin
Hello Abhay,

Wednesday, April 16, 2008, 9:30:34 AM, you wrote:

i think it will not work with current ghc GC - it scans entire
memory/nursery when garbage collected so anyway you will need to wait
until next GC event occurs

 Your mail gives me an idea, though I am not an iota familiar with
 compiler/garbage collector internals. Can we have some sort of
 internally maintained priority associated with allocated objects?
 The garbage collector should look at these objects first when it
 tries to free anything. The objects which hold other system
 resources apart from memory, such as file handles, video memory, and
 so on could be allocated as higher priority objects. Is such a thing possible?
  
 2008/4/16 Conal Elliott [EMAIL PROTECTED]:
  Are Haskell folks satisfied with the practical necessity of
 imperatively  explicitly reclaiming resources such as file handles,
 fonts  brushes, video memory chunks, etc?  Doesn't explicit freeing
 of these resources have the same modularity and correctness problems
 as explicit freeing of system memory (C/C++ programming)?
   
 I wrote a lovely purely functional graphics library that used video
 memory to lazily compute and cache infinite-resolution images, and I
 found that I don't know how to get my finalizers to run anytime soon
 after video memory chunks become inaccessible.  Explicit freeing
 isn't an option, since the interface is functional, not imperative (IO).
   
 I guess I'm wondering a few things:

 * Are Haskell programmers generally content with imperative and
 bug-friendly interfaces involving explicit freeing/closing of resources?
 * Do people assume that these resources (or handling them frugally)
 aren't useful in purely functional interfaces?
  * Are there fundamental reasons why GC algorithms cannot usefully
 apply to resources like video memory, file descriptors, etc?
 * Are there resource management techniques that have the
 flexibility, efficiency, and accuracy of GC that I could be using for these 
 other resources?
   
 Thanks,
   - Conal

 2008/4/14 Abhay Parvate [EMAIL PROTECTED]:
  Hello,

 In describing the Handle type, the GHC documentation says (in the System.IO 
 documentation):

 GHC note: a Handle will be automatically closed when the garbage 
 collector detects that it has become unreferenced by the program. 
 However, relying on this behaviour is not generally recommended: 
 the garbage collector is unpredictable.  If possible, use explicit 
 an explicit hClose to close Handles when they are no longer 
 required.  GHC does not currently attempt to free up file 
 descriptors when they have run out, it is your responsibility to  ensure that 
 this doesn't happen.

 But one cannot call hClose on Handles on which something like
 hGetContents has been called; it just terminates the character list
 at the point till which it has already read. Further the manual says
 that hGetContents puts the handle in the semi-closed state, and further,
   
 A semi-closed handle becomes closed: 
  if hClose is applied to it;  if an I/O error occurs when reading
 an item from the handle;  or once the entire contents of the handle has been 
 read.
 So do I safely assume here, according to the third point above,
 that it's fine if I do not call hClose explicitly as far as I am
 consuming all the contents returned by hGetContents?

 Thanks,
 Abhay
   
 ___
  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
  


   


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[4]: [Haskell-cafe] GC'ing file handles and other resources

2008-04-16 Thread Bulat Ziganshin
Hello Abhay,

Wednesday, April 16, 2008, 10:51:07 AM, you wrote:

 I am not saying that it should claim it as soon as it is unused;
 all I am saying that as soon as a priority object becomes
 unreferenced, it should be the first choice for collecting in the next 
 collect.

on the GC, all unreferenced objects are collected. there is no
difference which ones will be collected first - anyway program is
stopped until whole GC will be finished

 Further I was under the impression (I may be wrong) that it uses a
 generational GC and therefore scans allocated memory incrementally;
 not the whole at a time. Please correct me if I am wrong.

yes, it uses generational GC. data are first allocated in small 256k block
and when it is filled, GC for this small block occurs. data that are
still alive then moved to the global heap. this minor GC doesn't scan
global heap. if it will do this, each minor GC will become as slow as
major ones

Generational garbage collection for Haskell
http://research.microsoft.com/~simonpj/Papers/gen-gc-for-haskell.ps.gz

  
 Regards,
 Abhay

 On Wed, Apr 16, 2008 at 11:55 AM, Bulat Ziganshin
 [EMAIL PROTECTED] wrote:
  Hello Abhay,
  
  Wednesday, April 16, 2008, 9:30:34 AM, you wrote:
  
  i think it will not work with current ghc GC - it scans entire
  memory/nursery when garbage collected so anyway you will need to wait
  until next GC event occurs
  

  Your mail gives me an idea, though I am not an iota familiar with
  compiler/garbage collector internals. Can we have some sort of
  internally maintained priority associated with allocated objects?
  The garbage collector should look at these objects first when it
  tries to free anything. The objects which hold other system
  resources apart from memory, such as file handles, video memory, and
  so on could be allocated as higher priority objects. Is such a thing 
  possible?
 
  2008/4/16 Conal Elliott [EMAIL PROTECTED]:
   Are Haskell folks satisfied with the practical necessity of
  imperatively  explicitly reclaiming resources such as file handles,
  fonts  brushes, video memory chunks, etc?  Doesn't explicit freeing
  of these resources have the same modularity and correctness problems
  as explicit freeing of system memory (C/C++ programming)?
 
  I wrote a lovely purely functional graphics library that used video
  memory to lazily compute and cache infinite-resolution images, and I
  found that I don't know how to get my finalizers to run anytime soon
  after video memory chunks become inaccessible.  Explicit freeing
  isn't an option, since the interface is functional, not imperative (IO).
 
  I guess I'm wondering a few things:
  
  * Are Haskell programmers generally content with imperative and
  bug-friendly interfaces involving explicit freeing/closing of resources?
  * Do people assume that these resources (or handling them frugally)
  aren't useful in purely functional interfaces?
   * Are there fundamental reasons why GC algorithms cannot usefully
  apply to resources like video memory, file descriptors, etc?
  * Are there resource management techniques that have the
  flexibility, efficiency, and accuracy of GC that I could be using for these 
  other resources?
 
  Thanks,
    - Conal
  
  2008/4/14 Abhay Parvate [EMAIL PROTECTED]:
   Hello,
  
  In describing the Handle type, the GHC documentation says (in the System.IO 
  documentation):
  
  GHC note: a Handle will be automatically closed when the garbage
  collector detects that it has become unreferenced by the program.
  However, relying on this behaviour is not generally recommended:
  the garbage collector is unpredictable.  If possible, use explicit
  an explicit hClose to close Handles when they are no longer
  required.  GHC does not currently attempt to free up file
  descriptors when they have run out, it is your responsibility to  ensure 
  that this doesn't happen.
  
  But one cannot call hClose on Handles on which something like
  hGetContents has been called; it just terminates the character list
  at the point till which it has already read. Further the manual says
  that hGetContents puts the handle in the semi-closed state, and further,
 
  A semi-closed handle becomes closed:
   if hClose is applied to it;  if an I/O error occurs when reading
  an item from the handle;  or once the entire contents of the handle has 
  been read.
  So do I safely assume here, according to the third point above,
  that it's fine if I do not call hClose explicitly as far as I am
  consuming all the contents returned by hGetContents?
  
  Thanks,
  Abhay
 
  ___
   Haskell-Cafe mailing list
  [EMAIL PROTECTED]
   http://www.haskell.org/mailman/listinfo/haskell-cafe
 
  
  
 
  ___
   Haskell-Cafe mailing list
  [EMAIL PROTECTED]
   http://www.haskell.org/mailman/listinfo/haskell-cafe
 
  
  
 
  
  
  
 --
  Best regards,
   Bulat                            mailto:[EMAIL

Re[2]: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-16 Thread Bulat Ziganshin
Hello Martin,

Wednesday, April 16, 2008, 7:06:07 PM, you wrote:

i'm not 100% sure that you'll find there appropriate examples but i
suggest you too look into http://haskell.org/haskellwiki/Library/Streams
where i've used very sophisticated (for me) FDs

 We're also looking for (practical) examples of multi-range functional
 dependencies

class C a b c | c - a b

 Notice that there are multiple (two) parameters in the range of the FD.

 It's tempting to convert the above to

class C a b c | c - a, c - b

 but this yields a weaker (in terms of type improvement) system.

 Thanks,
  Martin



 Tom Schrijvers wrote:
 Hello,

 I'm looking for practical examples of non-full functional dependencies 
 and would be grateful if anyone could show me some or point to 
 applications using them.

 A non-full functional dependency is one involves only part of the 
 parameters of a type class. E.g.

 class C a b c | a - b

 has a non-full functional dependency a - b which does not involve c.

 Thanks,

 Tom

 -- 
 Tom Schrijvers

 Department of Computer Science
 K.U. Leuven
 Celestijnenlaan 200A
 B-3001 Heverlee
 Belgium

 tel: +32 16 327544
 e-mail: [EMAIL PROTECTED]
 url: http://www.cs.kuleuven.be/~toms/
 ___
 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


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] monadic debugging

2008-04-15 Thread Bulat Ziganshin
Hello Vasili,

Wednesday, April 16, 2008, 2:53:32 AM, you wrote:

  I have an Linux executable of my Haskell library and test
 case. I see there are several debuggers, e.g. Buddha, Hat, etc.
 Which debugger is currently preferred for monadic (imperative) code? Thanks.

i use print mainly :)  btw, there is also built-in ghci debugger, i
suspect that it's closest one to the usual debuggers and most useful
one for imperative code (but i never tried anything, so don't trust me :)

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-12 Thread Bulat Ziganshin
Hello Miguel,

Saturday, April 12, 2008, 5:54:45 PM, you wrote:
 How come I haven't ever heard about such a thing?!

it's an overview of generic haskell programming systems:
http://dfa.imn.htwk-leipzig.de/~waldmann/draft/meta-haskell/second.pdf

ask here about final version of this paper

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[3]: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-12 Thread Bulat Ziganshin
Hello Bulat,

Saturday, April 12, 2008, 6:10:04 PM, you wrote:

 it's an overview of generic haskell programming systems:

found longer paper myself:

Comparing Approaches to Generic Programming in Haskell
http://www.cs.uu.nl/~johanj/publications/ComparingGP.pdf



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Haskell library install question

2008-04-10 Thread Bulat Ziganshin
Hello Vasili,

Thursday, April 10, 2008, 6:12:45 PM, you wrote:
 Registering unix-2.2.0.0...
 In what sense is it being registered? Can I query this registry information?

ghc-pkg

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[4]: [Haskell-cafe] deriving

2008-04-08 Thread Bulat Ziganshin
Hello Hans,

Tuesday, April 8, 2008, 12:17:38 PM, you wrote:

 deriving which I think is not used elsewhere. It will break a lot
 of code, but it is easy to change, and also easy to make a  
 compatibility mode.

it's also easy to replace all the books, update all code repositories
and reteach all the programmers if you ready to pay for it all :D


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] announcing the darcs 2.0.0 release

2008-04-07 Thread Bulat Ziganshin
Hello David,

Monday, April 7, 2008, 9:22:25 PM, you wrote:

  * I'm sure there are other new features, but this is all that comes to
mind at the moment.

there was some issues with efficiency of darcs 1.x. am i correctly
understood that these issues was not addressed by new release?

its hard to understand why darcs 2.0 is better than 1.x from your
announcement. afair from gsoc project your primary goal was to improve
patches flexibility?


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] deriving

2008-04-07 Thread Bulat Ziganshin
Hello Hans,

Tuesday, April 8, 2008, 2:28:53 AM, you wrote:

 At least Hugs complains if one does not indent deriving ..., but I
 do not know what the standard says. If is required, then it can be  
 changed.

deriving is a part of data clause and indentation just allows us to
continue clause from prev. line. if not indented, deriving will be
parsed as separate clause (and btw such clause, standalone deriving
was added to ghc 6.8)

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] ANNOUNCE: Well-Typed LLP - The Haskell Consultants

2008-04-06 Thread Bulat Ziganshin
Hello Ian,

Monday, April 7, 2008, 2:50:02 AM, you wrote:

 We (Bjorn Bringert, Duncan Coutts and Ian Lynagh) are pleased to
 announce that we have recently set up a Haskell consultancy company,
 Well-Typed LLP (http://www.well-typed.com/).

my congrats! seems you are first in this business :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Re: Function Precedence

2008-04-03 Thread Bulat Ziganshin
Hello Chris,

Thursday, April 3, 2008, 6:07:53 PM, you wrote:

 On the other hand, I have enough time already trying to explain Num,
 Fractional, Floating, RealFrac, ... to new haskell programmes.  I'm not
 sure it's an advantage if someone must learn the meaning of an additive
 commutative semigroup in order to understand the type signatures inferred
 from code that does basic math in Haskell.  At least in the U.S., very
 few computer science students take an algebra course before getting 
 undergraduate degrees.

we already need to learn Category Theory to say Hello, World :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] compile-time question

2008-04-03 Thread Bulat Ziganshin
Hello Galchin,

Friday, April 4, 2008, 2:50:42 AM, you wrote:

  3) runhaskell Setup.hs install 
   
  I write a small test case that references one of the new
 functions; however, when I build the test case, I get an Out of
 scope message indicated that at ghc(i) compile time the new function symbol 
 cannot be found. 
    
i think you should add -package to your ghci cmdline



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] FW: Haskell

2008-04-01 Thread Bulat Ziganshin
Hello Simon,

Tuesday, April 1, 2008, 2:18:25 PM, you wrote:

 How can one answer the question--why choose Haskell over Scheme?

1. static typing with type inference - imho, must-be for production
code development. as many haskellers said, once compiler accept your
program, you may be 95% sure that it contains no bugs. just try it!

2. lazy evaluation - reduces complexity of language. in particular,
all control structures are usual functions while in scheme they are
macros

3. great, terse syntax. actually, the best syntax among several
dozens of languages i know

4. type classes machinery, together with type inference, means that
code for dealing with complex data types (say, serialization) is
generated on the fly and compiled right down to machine code


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] [Newbie] Problem with Data.Map (or something else ?)

2008-03-31 Thread Bulat Ziganshin
Hello Bruno,

Monday, March 31, 2008, 7:51:43 PM, you wrote:

 I've written the following program... Which does not end in a reasonable time 
 :(
 My algorithm seems ok to me but I see that memory consumption is gigantic...
 Is this a memory problem with Data.Map ? Or an infinite loop ? (Where ?)
 In a more general way, how can I troubleshoot these kind of problem ?

first step is to reduce n and see whether program will finish and how
memreqs depends on value of n

 main =
 let n = 100


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] lexicographic order

2008-03-30 Thread Bulat Ziganshin
Hello Simeon,

Monday, March 31, 2008, 12:45:54 AM, you wrote:

 The latter specifies a lexicographic order: Constructors are ordered by the
 order of their appearance the data declaration, and the arguments of a
 constructor are compared from left to right.

 Although I have tried to make sense what lexicographic order means I haven't
 figured out. Maybe an example with a simple application of this would be
 helpful. To be honest I can't understand what the symbol = really means.

i'm not sire that i understood your question (are you really never
seen less-or-equal comparison? :), but i can say about lex. order:

if you can compare chars and 'a'  'b', then *lists* of chars compared
in lexicographic order will be

aaa  aab
aab  aba
baa  abb

and so on - i.e. it finds *left-most* pair of non-equal chars and returns
result based on it comparison

the same principle used for comparison of these trees - any Leaf
smaller than any Branch, if the same constructors are used then their
parameters are compared, from left to right

although the last alternative,

   (Branch l r) = (Branch l' r')  =  l == l'  r = r' || l = l'

seems suspicious to me. isn't it the same as

   (Branch l r) = (Branch l' r')  =  l = l'

?




-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] lexicographic order

2008-03-30 Thread Bulat Ziganshin
Hello Bulat,

Monday, March 31, 2008, 1:16:35 AM, you wrote:

 if you can compare chars and 'a'  'b', then *lists* of chars compared
 in lexicographic order will be

 aaa  aab
 aab  aba
 baa  abb

as it was mentioned by Niklas Broberg, the last sentence should be reversed:

abb  baa

sorry for +1 confusion :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


[Haskell-cafe] [gsoc] mingw64 ghc port

2008-03-28 Thread Bulat Ziganshin
Hello haskell-cafe,

it's probably a bit too late, but i recalled that there is one project
that will be very useful - it's porting ghc to mingw64 platform,
allowing it to generate 64-bit windows platforms. may be someone will
find it interesting

-- 
Best regards,
 Bulat  mailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] announce: Glome.hs raytracer

2008-03-27 Thread Bulat Ziganshin
Hello Andrew,

Thursday, March 27, 2008, 12:27:47 PM, you wrote:

 plus a b = unsafePerformIO (modifyIORef counter (+1)) `seq` a+b
 Erm... might it be better to use an MVar? (To avoid lost updates if
 there are multiple render threads.)

you are right, IORef is appropriate only for single-threaded program


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] MonadMemory class

2008-03-27 Thread Bulat Ziganshin
Hello Ariel,

Friday, March 28, 2008, 1:02:39 AM, you wrote:

class (Monad m) = MonadMemory m r | m - r where

there are more than one way to define such class. look at
http://haskell.org/haskellwiki/Library/ArrayRef for examples


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] No newlines in the whitespace for Parsec lexeme parsers

2008-03-26 Thread Bulat Ziganshin
Hello Paul,

Wednesday, March 26, 2008, 2:32:53 PM, you wrote:
  I'm looking to parse a Fortran dialect using Parsec, and was

afair, some months ago BASIC parsing was discussed here.

the first solution one can imagine is to add preprocessing stage
replacing line ends with ';'-alike


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Unboxed arrays

2008-03-26 Thread Bulat Ziganshin
Hello Andrew,

Wednesday, March 26, 2008, 3:37:53 PM, you wrote:

 type of your own, you just need to write your own instance. The thing
 that makes me suspicious of this logic is the absense of an instance for
 tuples.

 Any insights here?

and even insiders :)  i've rewrote arrays library to be more uniform
using ideas of Simon Marlow and Oleg Kiselyov

unboxed arrays implementation uses GHC primitives that fetches/stores
array element by its index. these primitives implemented for simple
types - from Word8 to Double but nothing more. they use *indexes*, not
*byte offsets* which means that you can use them for addressing array
of {Word8,Double}, for example

i believe that it should be possible to rewrite array machinery using
storable class (now it should not have any overheads compared to these
primitives). meanwhile i recommend you to use storable array together
with Storable instances for tuples


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Unboxed arrays

2008-03-26 Thread Bulat Ziganshin
Hello Jed,

Wednesday, March 26, 2008, 7:02:28 PM, you wrote:

 StorableArray.  Unfortunately there is a performance hit to using Storable
 versus the built in unboxed types.

are you sure? it was in ghc 6.4, now afair they should be the same.
look in http://haskell.org/haskellwiki/Modern_array_libraries



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] announce: Glome.hs raytracer

2008-03-26 Thread Bulat Ziganshin
Hello Jim,

Thursday, March 27, 2008, 12:33:20 AM, you wrote:

 -Multi-core parallelism is working, but not as well as I'd expect: I get
 about a 25% reduction in runtime on two cores rather than 50%.  I split

this may be an effect of limited memory bandwidth

 -Memory consumption is atrocious: 146 megs to render a scene that's a

standard answer: ByteString

 -Collecting rendering stats is not easy without global variables.  It
 occurs to me that it would be neat if there were some sort of write-only
 global variables that can be incremented by pure code but can only be 
 read from within monadic code; that would be sufficient to ensure that
 the pure code wasn't affected by the values.

the code is called *pure* exactly because it has no side-effects and
compiler may select either to call some function two times or reuse
already computed result. actually, you can make sideeffects with
unsafePerformIO, but there is no guarantees of how many times such
code will be executed. try this:

plus a b = unsafePerformIO (modifyIORef counter (+1)) `seq` a+b


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
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 Bulat Ziganshin
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


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] SoC project: Python-Haskell bridge - request for feedback

2008-03-24 Thread Bulat Ziganshin
Hello Michal,

Monday, March 24, 2008, 11:38:07 PM, you wrote:

 Python-Haskell bridge

seems interesting

 Benefits for Haskell

you forget about ability to use Python as scripting language inside
Haskell programs. look at HsLua library as example of this

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] SoC project: Python-Haskell bridge - request for feedback

2008-03-24 Thread Bulat Ziganshin
Hello Dan,

Tuesday, March 25, 2008, 1:29:51 AM, you wrote:

 you forget about ability to use Python as scripting language inside
 Haskell programs. look at HsLua library as example of this

 This is much less interesting for those (like me) who, once in Haskell,
 don't feel the least inclined to go back to Python. Missing libraries in
 Haskell (for my applications) are usually also missing in Python and 
 need FFI to some (usually numeric) library written in C/C++ anyway. Why
 do data marshalling twice?

Python, unlike Haskell, can be compiled on the fly



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] [GSoC] Plugins for GHC

2008-03-22 Thread Bulat Ziganshin
Hello Max,

Saturday, March 22, 2008, 1:23:37 AM, you wrote:

 around with modifying GHC itself. Potential use cases are:
 * And whatever clever ideas the community comes up with!

i'm interested in syntax macros feature like metalua


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Dynamic typing makes you more productive?

2008-03-18 Thread Bulat Ziganshin
Hello Justin,

Tuesday, March 18, 2008, 7:41:15 PM, you wrote:

 is probably the wrong thing to do. Static typing makes it harder to
 maintain software because it's harder to change it.

 Two years ago I would have agreed with that statement. Now - no way.

f few weeks ago i made a post to main haskell list about static duck
typing: type inference + flexible structure types created by use


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] floating point operations and representation

2008-03-17 Thread Bulat Ziganshin
Hello David,

Monday, March 17, 2008, 7:59:09 PM, you wrote:

 foreign import ccall unsafe math.h log10
 c_log10 :: CDouble - CDouble

 log10 :: Double - Double
 log10 x = realToFrac (c_log10 (realToFrac x))

 It's a bit sloppier, but shouldn't cause any trouble.  And I've no
 idea how realToFrac is implemented, but would worry about it behaving
 oddly... for instance when given NaNs.

it should be nop (no operation) in such cases


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Problem making a program in ghc

2008-03-14 Thread Bulat Ziganshin
Hello Sterling,

Friday, March 14, 2008, 7:06:24 AM, you wrote:

yes, it's another question. my own program also writes to logfile and
it got lock-free only when i've switched to using my own IO routines


 This answer may be way off base, but if differences appear between  
 ghci and compiled versions, I've often found its as simple as  
 remembering to compile with the -threaded flag. The ghci runtime is  
 threaded by default, as I understand it, while compiled binaries are  
 not, and IO operations will block in very different fashions (i.e. in
 their own thread, or stalling the entire app) depending on the runtime.

 Regards,
 sterl.

 On Mar 13, 2008, at 3:47 PM, Adam Langley wrote:

 web application),
 I have a log that confirms that the response arrives correctly.

 I hate to see any requests for help go unanswered here, but this one
 might be tough. I think you need to give some more information,
 otherwise the suggestions are going to be very general. Can you put
 the Haskell source code on a website somewhere and link to it. Since
 it's a network service, an example request and reply might be good to
 include.

 In general, you should check that you are correctly flushing your
 connection. If you are using Handles to interface to the network, they
 can buffer the response. hFlush[1] may need to be called when you have
 finished generating it.

 [1] http://haskell.org/ghc/docs/latest/html/libraries/base/System- 
 IO.html#v%3AhFlush

 AGL

 -- 
 Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
 ___
 Haskell-Cafe mailing list

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


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] File I/O question

2008-03-13 Thread Bulat Ziganshin
Hello Andrew,

Wednesday, March 12, 2008, 10:06:44 PM, you wrote:

 When I write to a file using System.IO, the file is locked for exclusive
 access. I gather this is as specified in the Haskell Report. Which is 
 nice, but... I'd actually prefer the file to *not* be locked. Anybody 
 know how to do that?

one (and only?) possible way is to use Streams library which happens
to not lock files:

http://haskell.org/haskellwiki/Library/Streams

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Re: (flawed?) benchmark : sort

2008-03-10 Thread Bulat Ziganshin
Hello Adrian,

Monday, March 10, 2008, 2:00:18 PM, you wrote:

 instance Ord Foo where
 compare (Foo a _) (Foo b _) = compare a b

 I would consider such an Ord instance to be hopelessly broken, and I

h. for example, imagine files in file manager sorted by size or date


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Graphical graph reduction

2008-02-25 Thread Bulat Ziganshin
Hello dainichi,

Monday, February 25, 2008, 2:46:20 AM, you wrote:

 Jersey. (Sorry, this will probably make me unpopular here on
 Haskell-cafe, but the ability to use references was just too tempting,
 and I'm not too experienced with purely functional data structures).

we have references, Data.IORef. there is also pretty-syntax library
for them, see http://haskell.org/haskellwiki/Library/ArrayRef


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] how to catch keyboard interrupts?

2008-02-23 Thread Bulat Ziganshin
Hello Uwe,

Saturday, February 23, 2008, 11:35:35 PM, you wrote:

 mysighandler =
   Catch (do hPutStrLn stderr caught a signal!
 fail Interrupt!)

 scheme calculation doesn't get interrupted at all! I see in the
 System.Posix.Signals documentation that the signal handler gets
 invoked in a new thread; is this the source of the problem?

yes, fail kills only this thread :)

you should store thread id of thread running interpreter and send
async exception to it. control.concurrent is probably contains all
required functions


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Graphical graph reduction

2008-02-22 Thread Bulat Ziganshin
Hello dainichi,

Friday, February 22, 2008, 6:55:54 PM, you wrote:

 If nothing similar exists, I was thinking about creating such a
 tool (i.e. an interpreter with additional graph-displaying features)

not exactly this, but now i'm reading introduction into Q language [1]
which says on p.11 The interpreter has a built-in symbolic debugger
which allows you to execute a reduction sequence step by step: ...,
so you may use it to demonstrate how reductions work. Q by itself is
rather interesting language - haskell-like syntax, dynamic, eager with
good support for laziness. btw, this manual is probably better than we
have for Haskell, i've seen programmers who thinks that Haskell is
hard to learn and Q is simple and may be it's just due to its manual
which takes into account typical learning problems and explains
obvious things (which are really obvious only for seasoned FP
programmers)

[1] http://switch.dl.sourceforge.net/sourceforge/q-lang/qnutshell-0.5.pdf


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] A little toy of Haskell Trivia

2008-02-21 Thread Bulat Ziganshin
Hello Wolfgang,

Thursday, February 21, 2008, 2:45:43 AM, you wrote:
 I proudly announce a little toy that lists the frequency of modules
 being imported by other modules. Do you know Control.Monad is the most
 frequently imported module? I did not!

 This doesn’t surprise me very much.  What surprises me more is that OpenGL
 stuff is that popular. :-) 

perhaps opengl library just contains too many modules that imports
each other :)))



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


[Haskell-cafe] Haskell + Windows Mobile?

2008-02-21 Thread Bulat Ziganshin
Hello haskell-cafe,

is there any haskell implementation for Windows Mobile? does they are
support creation of GUI apps and internet networking features?

-- 
Best regards,
 Bulat  mailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] question about STM and IO

2008-02-21 Thread Bulat Ziganshin
Hello Ryan,

Thursday, February 21, 2008, 5:02:52 AM, you wrote:

 values, determine that x = y, and just return (), but it's too late,
 the missiles have already been launched.

it seems that asymmetrical answer of mr.Putin is just to hire a bit
more Haskell Hackers :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] question about STM and IO

2008-02-20 Thread Bulat Ziganshin
Hello John,

Tuesday, February 12, 2008, 9:28:22 PM, you wrote:
 I was recently looking at the STM library, and I have a question about
 the function unsafeIOToSTM.  Can anyone explain to me what is unsafe
 about it, and what sort of use would be considered safe?

STM operations can be repeated if first transaction was unsuccessful.
so, you may se here only operations that may be safely repeated - say,
reading/writing memory areas, or reading/writing files, or even
sending network message as long as its duplication is ok

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Haddock documentation of Data.Array.* is confusing

2008-02-20 Thread Bulat Ziganshin
Hello Alfonso,

Tuesday, February 12, 2008, 11:32:20 PM, you wrote:

 Excuse me for the subject, but IMHO is absolutely true. Anyhow, the

of course, you are right, but for practical goals i may suggest just
to read module sources instead of reading [had]docs. seeing the
implementation is much more interesting, after all. especially when you
are so cool that you are going to add your own instance


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-08 Thread Bulat Ziganshin
Hello Tom,

Friday, February 8, 2008, 9:33:35 AM, you wrote:

 The process of converting an expression tree to a graph uses either Eq
 or Ord (either derived or a custom instance) to search and build a set
 of unique nodes to be ordered for execution.

in similar situation, i've added hash field to each node, initialized
by smart constructor:

data Expression = Add Hash Expression Expression | ...
type Hash=Int

add x y = Add (x*y+1234567) x y
...


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[4]: [Haskell-cafe] Signature for non-empty filter

2008-02-07 Thread Bulat Ziganshin
Hello Henning,

Thursday, February 7, 2008, 12:29:02 AM, you wrote:

 it's impossible to check for *arbitrary* function call whether it will be
 terminated. seems that you don't have formal CS education? :)

 so one can develop set of functions that are guaranteed to be
 terminated or guaranteed to be non-trivial. but it's impossible to
 check for arbitrary function whether it's trivial and even whether it
 will terminate for particular data

 If the type checker does not terminate because the checked function does
 not terminate on the example input, then the function does not pass the
 type check and as a compromise this would be ok.

how you can check that some code doesn't terminate? ;)  it may be just
a bit too slow. we again return to my original point - we can check
for *some* representations of trivial functions values, but we can't
*ensure* that some computation is non-trivial


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Mutable arrays

2008-02-07 Thread Bulat Ziganshin
Hello Jeff,

Thursday, February 7, 2008, 1:31:59 AM, you wrote:

 I noticed that
 GHC implements mutable arrays in the IO monad.  This seems odd to
 me.  Arrays aren't related to IO. 

IO monad isn't only about I/O but about imperative stuff in general.
there is also special monad limited to mutable vars and arrays, namely
ST. read also this:
http://haskell.org/haskellwiki/Modern_array_libraries
http://haskell.org/haskellwiki/IO_inside


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Signature for non-empty filter

2008-02-07 Thread Bulat Ziganshin
Hello Dan,

Thursday, February 7, 2008, 4:04:03 AM, you wrote:

 I.e., it's not necessary to restrict the class of functions you consider
 if you're willing to give up on full automation.  So I disagree with the
 only if below.

ok, read this as computer can ensure..., because it was exactly the
original question - can computer check that any given function in
turing-complete language is non-trivial?

 this means that answer to original question - one can ensure that
 argument for filter is non-terminating function only if these
 functions are written using some special notation which doesn't allow
 to write arbitrary turing-complete algorithms
 


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Mutable arrays

2008-02-07 Thread Bulat Ziganshin
Hello Jeff,

Thursday, February 7, 2008, 4:17:27 AM, you wrote:

 logical place for mutable arrays.  However, I don't understand the
 motivation for implementing it in IO.  Were mutable arrays added to
 IO because it would be difficult to write code that does both IO and 
 manipulates arrays otherwise?

yes. you can't perform separate ST actions in IO monad, you may call
only entire computations with pure results - the same as you can do
from pure code

IO monad implements idea of sequencing actions and it is used ro
import any actions written in other languages (C/C++ in most cases).
ST monad is just the same internally but it was directive limited to
only two types of actions - with variables and mutable arrays. this,
together with some type tricks ensures that its results are
referentially-transparent and therefore may be called from pure code


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Bulat Ziganshin
Hello Uwe,

Wednesday, February 6, 2008, 7:44:27 AM, you wrote:

 But after that, it sure seems to me as if I've taken data out of the
 IO monad...

this means that you can't use results of IO actions in pure functions.
your code works in some transformed version of IO monad, so you don't
escaped it

if we call pure functions as functions and non-pure ones as
procedures, the rule is functions can't call procedures, but all
other activity is possible. in your do_action you calls procedure (to
format current time) and call a function (to format given time).
do_action is procedure (because it works in transformed IO monad), so
you don't break any rules


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Signature for non-empty filter

2008-02-06 Thread Bulat Ziganshin
Hello Henning,

Wednesday, February 6, 2008, 5:09:56 PM, you wrote:

  Is Haskell's type system including extensions strong enough for describing
  a function, that does not always return a trivial value? E.g.
 (filter (\x - x==1  x==2))

 such things may be detected by (too) smart compiler, but in general
 it's undecidable: filter (if LifeHasMeaning then const True else odd) ;)

 As I said, if the programmer could specify an input on the type level for
 which the output is non-trivial, then this would solve the problem.

it's another question: you can describe trivial values using type
system, but can't prohibit them using it - it's impossible because you
can't check for arbitrary algorithm whether it will be finally stopped


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[3]: [Haskell-cafe] Signature for non-empty filter

2008-02-06 Thread Bulat Ziganshin
Hello Henning,

Wednesday, February 6, 2008, 6:09:28 PM, you wrote:

 it's another question: you can describe trivial values using type
 system, but can't prohibit them using it - it's impossible because you
 can't check for arbitrary algorithm whether it will be finally stopped

 I could consider the function buggy, if it does not terminate on the given
 example.

it's impossible to check for *arbitrary* function call whether it will be
terminated. seems that you don't have formal CS education? :)

so one can develop set of functions that are guaranteed to be
terminated or guaranteed to be non-trivial. but it's impossible to
check for arbitrary function whether it's trivial and even whether it
will terminate for particular data

this means that answer to original question - one can ensure that
argument for filter is non-terminating function only if these
functions are written using some special notation which doesn't allow
to write arbitrary turing-complete algorithms

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Haskell maximum stack depth

2008-02-05 Thread Bulat Ziganshin
Hello Matthew,

Monday, February 4, 2008, 11:45:51 PM, you wrote:

 That would be nice. But its only beneficial if there are programs
 which takes large amounts of stack at some point, but then shrink down
 to very little stack and continue for a reasonable amount of time.

 From the 'when I was a lad' department...

 Thinking back to when Java transitioned to a garbage collector that could give
 memory back to the OS, we got some unexpected benefits. Consider a machine

i would be also happy if ghc will return unused *heap* memory back to
OS - it's immediately required for my GUI program where users may open
huge files and then close them. but i personally don't have the same
need for *stack*

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] bimap 0.2

2008-02-05 Thread Bulat Ziganshin
Hello Neil,

Tuesday, February 5, 2008, 1:11:47 PM, you wrote:

 insert x y = delete  x
   deleteR y
   unsafeInsert x y

i use the following trick:

(.$) = flip ($)

insert x y it = it.$ delete  x
  .$ deleteR y
  .$ unsafeInsert x y


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Signature for non-empty filter

2008-02-05 Thread Bulat Ziganshin
Hello Henning,

Tuesday, February 5, 2008, 6:01:27 PM, you wrote:

 Is Haskell's type system including extensions strong enough for describing
 a function, that does not always return a trivial value? E.g.
(filter (\x - x==1  x==2))

such things may be detected by (too) smart compiler, but in general
it's undecidable: filter (if LifeHasMeaning then const True else odd) ;)

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Mutable arrays

2008-02-05 Thread Bulat Ziganshin
Hello Jeff,

Tuesday, February 5, 2008, 7:36:27 PM, you wrote:

 Changing the subject slightly, I once wrote code in Concurrent
 Clean that filtered a file that was larger than the available memory
 on my PC. 
 Is this possible with Monads in Haskell? 

google for simple unix tools

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Haskell maximum stack depth

2008-02-05 Thread Bulat Ziganshin
Hello Adrian,

Tuesday, February 5, 2008, 10:15:59 PM, you wrote:

 i would be also happy if ghc will return unused *heap* memory back to
 OS - it's immediately required for my GUI program where users may open
 huge files and then close them. but i personally don't have the same
 need for *stack*

 How do you know you don't or won't have the same need for stack?

i run my program with rather large datasets - it's happy with current
8m stack. i had problems with filterM function, though, and replaced
it with my own, tail-recursive but probably less efficient
implementation

i know that real problems for my programs will be solved by adding
heap releasing or, say, x64 support. are you have real problems with
stack management? if not, isn't it better to allow ghc developers to
solve real problems for me and other people? things will never be
ideal

from my own POV the only serious argument may be that current
situation limits usability of some programming techniques (CPS?) which
is able to increase programmer's productivity


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] A handy little consequence of the Cont monad

2008-02-01 Thread Bulat Ziganshin
Hello Conor,

Saturday, February 2, 2008, 1:29:02 AM, you wrote:

nest = ala Cont traverse id

 Third-order: it's a whole other order.

oh! i remember faces of my friends when i showed them something like
sortOn snd . zip [0..]. probably i have the same face now :)))


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: [Haskell-cafe] Implementing fixed-sized vectors (using datatype algebra?)

2008-01-31 Thread Bulat Ziganshin
Hello Henning,

Thursday, January 31, 2008, 5:49:23 PM, you wrote:

 I remember that type-level arithmetic is already implemented somewhere,
 certainly more than once, but certainly seldom in a nicely packaged form.

one more:
darcs get --partial --tag '0.1' http://www.eecs.tufts.edu/~rdocki01/typenats/



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: Cryptographic hash uniquness (was [Haskell-cafe] Simple network client)

2008-01-31 Thread Bulat Ziganshin
Hello Peter,

Thursday, January 31, 2008, 8:01:36 PM, you wrote:

 files with different content generating the same hash)... My
 intuition told me that the odds of two cryptographic hashes (on
 meaningful content) colliding was much less than the earth being
 destroyed by an asteroid... But this is just intuition... What does
 computer science tell us about this?

you may be interested to know that widely used rsync algorithms relies
on 128-bit hashes and its author speculated about its reliability:

http://samba.org/~tridge/phd_thesis.pdf


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] data and classes question

2008-01-29 Thread Bulat Ziganshin
Hello Chaim,

Tuesday, January 29, 2008, 7:26:25 PM, you wrote:

your approach is completely wrong (OOP-inspired, but haskell isn't OOP
language). type class is common interface to different types. just for
example:

data BinState = On | Off
data BinChange = OnToOff | OffToOn

class MinValue a where
  minvalue :: a
instance MinValue BinState where
  minvalue = On
instance MinValue BinChange where
  minvalue = OnToOff

here we define class with a function (class without functions hardly
can be used for anything useful) and provide implementation of this
function for different types. then, we can use it in any code:

main = print (minValue :: BinChange)

and in particular we can declare derived class. the advantage of
derived class is that it can use all functions of base class. but it
should add its own functions too, otherwise it will be again useless:

class (MinValue a) = BoundedValue a where
  maxvalue :: a
instance MinValue BinState where
  maxvalue = Off
instance MinValue BinChange where
  maxvalue = OffToOn

now, for values in BoundedValue class you can use both functions.
also, you can use functions from MinValue class in default
definitions of BoundedValue functions

but if you just need to use functions from MinValue class, you don't
need to declare one more class

type classes can be compared with Java interfaces. they aren't 100%
equal, though. read http://haskell.org/haskellwiki/OOP_vs_type_classes
and especially its further reading section

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re[2]: The programming language market (was Re: [Haskell-cafe] Why functional programming matters

2008-01-27 Thread Bulat Ziganshin
Hello Paul,

Saturday, January 26, 2008, 11:03:30 PM, you wrote:

 * Say computers are cheap but programmers are expensive whenever
   explaining a correctness or productivity feature.
 This is true only if talking to people in high-income nations.
 Even in low-income nations, its only false in the short term.  If you
 have skilled programmers with computers and Internet connections then 
 their wages inflate to the world norm.  IIRC India is seeing 20%/year 
 wage inflation for comp-sci graduates.

they know English. and Internet/modern computers are not so easily
available in poor countries. try for example to find programmers from
Uzbekistan on the net :D


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


<    4   5   6   7   8   9   10   11   12   13   >