Re: [Haskell-cafe] What *not* to use Haskell for

2008-11-11 Thread Krasimir Angelov
You can hire one Haskell programmer instead of 1,2,3... programmers in
your favorite imperative language.


On Tue, Nov 11, 2008 at 12:32 PM, Arnar Birgisson [EMAIL PROTECTED] wrote:
 Hi all,

 On Tue, Nov 11, 2008 at 11:38, Dave Tapley [EMAIL PROTECTED] wrote:
 Usually I'll avoid then question and explain that it is a 'complete'
 language and we do have more than enough libraries to make it useful and
 productive. But I'd be keen to know if people have any anecdotes,
 ideally ones which can subsequently be twisted into an argument for
 Haskell ;)

 I would not use Haskell if I were faced with the prospect of producing
 a huge system in short time (i.e. meaning I couldn't do it by myself)
 and all I had was a pool of regular programmers that have been
 trained in .NET, Java, C++, Python, your favorite imperative
 language.

 Yes, sad - but true. I'd very much like to see this twisted to an
 argument for Haskell :)

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

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


Re: [Haskell-cafe] Efficient parallel regular expressions

2008-11-05 Thread Krasimir Angelov
Hi Martijn,

If you are brave to start implementing DFA with all required
optimisations then you might want to look at:

http://www.ontotext.com/gate/japec.html

This is a compiler for language called JAPE. In the language you
define a set of rules where the right hand side
is a regular expression and the left hand side is a Java code. The
compiler itself is implemented in Haskell.
It includes code to build DFA from the set of regexps and then it does
determinization and minimization.

I wrote the compiler few years ago. You can decide to take and change
the code or to reimplement it yourself. Definitely DFA guarantees that
the performance is always linear while with Parsec you have to be
careful.

Regards,
   Krasimir



On Tue, Nov 4, 2008 at 6:05 PM, Martijn van Steenbergen
[EMAIL PROTECTED] wrote:
 Hello all,

 For my mud client Yogurt (see hackage) I'm currently working on
 improving the efficiency of the hooks. Right now several hooks, each
 consisting of a regex and an action can be active at the same time.
 Every time a line of input is available (usually several times a second)
 I run the line through all the available regexes and execute the first
 matching action.

 I figured this is not the cleverest approach and it'd be better if I
 |'ed all regexes into one big DFA. However, how do I then find out which
 of the original hooks matched and so which action to execute?

 As far as I know there's no way to do that with Text.Regex. Alex looks
 promising but is really only an executable and doesn't offer an API.
 I've also found mr. João Saraiva's HaLex but I don't know if that was
 meant to be used seriously.

 Does anyone have any experience with this? What's the best way to
 achieve this?

 Thanks much,

 Martijn.

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

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


Re: [Haskell-cafe] two problems with Data.Binary and Data.ByteString

2008-11-05 Thread Krasimir Angelov
On Wed, Aug 13, 2008 at 1:18 AM, Don Stewart [EMAIL PROTECTED] wrote:
instance Binary a = Binary [a] where
put l  = put (length l)  mapM_ put l
get= do n - get :: Get Int
replicateM n get

Of course I changed this as well. Now it is:

instance (Ord k, Binary k, Binary e) = Binary (Map.Map k e) where
put m = put (Map.size m)  mapM_ put (Map.toAscList m)
get   = liftM Map.fromDistinctAscList get

You don't have to convert the map to list just to compute its size.
The Map.size is a O(1) function.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] two problems with Data.Binary and Data.ByteString

2008-11-05 Thread Krasimir Angelov
I had the same problem (stack overflow). The solution was to change
the = operator in the Get monad. Currently it is:

  m = k   = Get (\s - let (a, s') = unGet m s
   in unGet (k a) s')

but I changed it to:

m = k   = Get (\s - case unGet m s of
 (a, s') - unGet (k a) s')

It seems that the bind operator is lazy and this caused the stack overflow.

I have also another problem. Every Int and Word is stored as 64-bit
value and this expands the output file a lot. I have a lot of integers
and most of them are  128 but not all of them. I changed the
serialization so that the Int and Word are serialized in a variable
number of bytes. Without this change the binary serialization was even
worse than the textual serialization that we had before. The file was
almost full with zeros.

I just haven't time to prepare a patch and to send it for review but
if other people have the same problem I will do it.


Best Regars,
   Krasimir




On Wed, Aug 13, 2008 at 1:13 AM, Tim Newsham [EMAIL PROTECTED] wrote:
 I have a program that read in and populated a large data structure and
 then saved it out with Data.Binary and Data.ByteString.Lazy.Char8:

   saveState db = B.writeFile stateFile =
   encode $ atomically (readTVar db)

 when I go to read this in later I get a stack overflow:

 loadState db = do
d - decode $ B.readFile stateFile
atomically $ writeTVar db d

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

 or from ghci:

d - liftM decode
  (Data.ByteString.Lazy.Char8.readFile
 savedState.bin) :: IO InstrsDb

fromList *** Exception: stack overflow

 The data type I'm storing is a Map (of maps):

   type DailyDb = M.Map Date Daily
   type InstrsDb = M.Map String DailyDb

 What's going on here?  Why is the system capable of building and saving
 the data but not in reading and umarhsalling it?  What is the proper way
 to track down where the exception is happening?  Any debugging tips?

 I also noticed another issue while testing.  If my program loads
 the data at startup by calling loadState then all later calls to
 saveState give an error:

  Log: savedState.bin: openFile: resource busy (file is locked)

 this does not occur if the program wasnt loaded.  My best guess here
 is that B.readFile isnt completing and closing the file for some
 reason.  Is there a good way to force this?

 Tim Newsham
 http://www.thenewsh.com/~newsham/
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


Re: [Haskell-cafe] Darcs / Git

2008-10-07 Thread Krasimir Angelov
I use darcs on Windows every day and it works well. The only problem
is that it is not very usable if you access your repository via SSH
and the authentication is via password.



On Mon, Oct 6, 2008 at 9:11 PM, Dominic Steinitz
[EMAIL PROTECTED] wrote:
 Not really a Haskell question but I'm not sure where else to go.

 What's the preferred method of converting a darcs repository to git? And
 is there a way of converting from git to darcs?

 The reason I ask is that my colleague cannot get darcs to work on his
 Windows box.

 Thanks, Dominic.

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

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


Re: [Haskell-cafe] Haskell versus F#, OCaml, et. al. ...

2008-09-30 Thread Krasimir Angelov
On Tue, Sep 30, 2008 at 8:46 AM, Don Stewart [EMAIL PROTECTED] wrote:
 There's almost 800 Haskell libraries on hackage.haskell.org (millions of
 lines of code). On average, 2 new libraries are released each day
 (though 12 new libs were released in the last 24 hours). That's 700 new
 libraries a year at the current rate.

This is missleading and depends on how you count the libraries. For
instance base is now split into arrays, containers, process,
parallel  etc. In the same time on platforms like Java and .NET
this might be only one package.

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


Re: [Haskell-cafe] Unboxing VT_VARIANT in hscom

2008-08-20 Thread Krasimir Angelov
Aha. I got it. You should compile with -fglasgow-exts option. The
extra type signatures doesn't matter.


On Wed, Aug 20, 2008 at 8:20 AM, Praki Prakash [EMAIL PROTECTED] wrote:
 Krasimir - thanks for your reply. I had tried explicit typing but I still
 get the same error. I have some code below and the error message.

 import Control.Exception
 import Foreign
 import Foreign.COM.Client
 import Foreign.COM.Automation
 import System.IO

 data WmiConnection =
   WmiConnection {
 execQuery :: String - IO ()
   }

 main = withCOM $ do
   conn - wmiconnect . root\\cimv2
   execQuery conn Select * From ...
   print done

 wmiconnect :: String - String - IO WmiConnection
 wmiconnect comp cimroot =
 do
   clsid - progid2clsid WbemScripting.SWbemLocator
   (bracket (createInstance clsid iidIUnknown) release $ \iunkn -
bracket (queryInterface iidIDispatch iunkn) release $ \idisp - do
dispId - getMethodID ConnectServer idisp
withBSTR comp $ \pComputer -
  withBSTR cimroot  $ \pCimRoot - do
(res,args) - invoke dispId InvokeMethod [Variant VT_BSTR
 pComputer,
  Variant VT_BSTR
 pCimRoot
] idisp
print res
let conn = WmiConnection{ execQuery = queryFunc res }
return conn)
  where
queryFunc :: Variant - String - IO ()
queryFunc (Variant VT_DISPATCH idisp) query = do
  dispId - getMethodID ExecQuery idisp
  return ()
{-
queryFunc (Variant vt idisp) query =
  if vt == VT_DISPATCH
  then do
dispId - getMethodID ExecQuery  idisp
return 
  else
  fail error

  return ()
  -}

 C:\ghc --make test.hs
 [1 of 1] Compiling Main ( test.hs, test.o )

 test.hs:35:47:
 Couldn't match expected type `IDispatch a'
against inferred type `a1'
   `a1' is a rigid type variable bound by
the constructor `Variant' at test.hs:34:22
 In the second argument of `getMethodID', namely `idisp'
 In a 'do' expression: dispId - getMethodID ExecQuery idisp
 In the expression:
 do dispId - getMethodID ExecQuery idisp
return ()

 Any further suggestions?

 Thanks,
 Praki

 On Tue, Aug 19, 2008 at 1:49 AM, Krasimir Angelov [EMAIL PROTECTED]
 wrote:

 This looks like a GHC bug to me. I am pretty sure that this worked
 before. Variant is defined like this:

 data Variant = forall a . Variant (VarType a) a

 data VarType a where
   
   VT_DISPATCH  :: VarType (IDispatch ())

 From this it clear that val is of type (IDispatch ()) because the
 VarType has value VT_DISPATCH. A workaround is to add explicit type
 singnature for val:

 someFunc (Variant VT_DISPATCH val) query = do
dispId - getMethodID MethodName  (val :: IDispatch ())

 I don't know why this doesn't work without the signature.

 Regards,
   Krasimir


 On Tue, Aug 19, 2008 at 7:09 AM, Praki Prakash [EMAIL PROTECTED]
 wrote:
  I am a Haskell newbie trying to do COM automation using Haskell. I am
  using
  hscom (Krasimir's implementation of COM automation). I have run into a
  problem
  and need some help.
 
  I have a Variant returned from a COM method invocation. When I print it,
  it
  shows up as below.
 
  Variant VT_DISPATCH interface 0x00039f00
 
  I need to invoke methods on the wrapped interface. My attempt to unbox
  it as
  below runs into 'rigid type' error.
 
  someFunc (Variant VT_DISPATCH val) query = do
   dispId - getMethodID MethodName  val
 
  The code above generates this error.
 
 Couldn't match expected type `IDispatch a'
against inferred type `a1'
   `a1' is a rigid type variable bound by...
 
  I am probably missing something pretty basic. Any help on this is
  greatly
  appreciated!
 
  Thanks
 
 
 
 
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 


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


[Haskell-cafe] Re: [Haskell] Compiler Construction course using Haskell?

2008-08-20 Thread Krasimir Angelov
Hi Johannes,

There is a similar course in Chalmers. The home page is here:

http://www.cs.chalmers.se/Cs/Grundutb/Kurser/progs/current/

There students were required to implement full parser, partial
typechecker and partial interpreter for C++ in either C++, Java or
Haskell. We used BNFC for the parser:

http://www.cs.chalmers.se/Cs/Research/Language-technology/BNFC/

which was easier for most students I think. In any way I would
recomend Happy+Alex or BNFC instead of Parsec but this is only my
personal preference.

Best Regards,
  Krasimir



2008/8/20 Johannes Waldmann [EMAIL PROTECTED]:
 Hello.

 I plan to give a course in compiler construction,
 using Haskell as the implementation language
 (not as source or target language).

 Something along these lines:
 1. combinator parsers (Parsec),
 2. simple interpreter (arithmetical expressions)
 3. add algebraic data types, functions
 4. type checker
 5. code generator.
 Ideally, 2..5 would be using the very same tree traversal code
 and just change the monad for evaluation.

 Any comments appreciated. Have you given such a course? Taken?

 If I really decide to do it,
 then slides (in German) will be made available.

 Best regards, J.W.


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


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


Re: [Haskell-cafe] Unboxing VT_VARIANT in hscom

2008-08-19 Thread Krasimir Angelov
This looks like a GHC bug to me. I am pretty sure that this worked
before. Variant is defined like this:

data Variant = forall a . Variant (VarType a) a

data VarType a where
   
   VT_DISPATCH  :: VarType (IDispatch ())

From this it clear that val is of type (IDispatch ()) because the
VarType has value VT_DISPATCH. A workaround is to add explicit type
singnature for val:

someFunc (Variant VT_DISPATCH val) query = do
dispId - getMethodID MethodName  (val :: IDispatch ())

I don't know why this doesn't work without the signature.

Regards,
   Krasimir


On Tue, Aug 19, 2008 at 7:09 AM, Praki Prakash [EMAIL PROTECTED] wrote:
 I am a Haskell newbie trying to do COM automation using Haskell. I am using
 hscom (Krasimir's implementation of COM automation). I have run into a problem
 and need some help.

 I have a Variant returned from a COM method invocation. When I print it, it
 shows up as below.

 Variant VT_DISPATCH interface 0x00039f00

 I need to invoke methods on the wrapped interface. My attempt to unbox it as
 below runs into 'rigid type' error.

 someFunc (Variant VT_DISPATCH val) query = do
  dispId - getMethodID MethodName  val

 The code above generates this error.

Couldn't match expected type `IDispatch a'
   against inferred type `a1'
  `a1' is a rigid type variable bound by...

 I am probably missing something pretty basic. Any help on this is greatly
 appreciated!

 Thanks





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

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


Re: [Haskell-cafe] ActiveX and COM

2008-08-05 Thread Krasimir Angelov
Hi Günther,

You can also consider the hscom library:

http://darcs.haskell.org/packages/hscom/

There is a simple demo that automates MS Agent. The library is not
completed but if you are interested only in controlling Excel via
automation it should provide what you need. I started hscom because I
was disappointed from HDirect while working on Visual Haskell. It
overcomes some problems and in addition it is designed to be more in
the style of the modern FFI library. The library is not under active
development but I can assist with simple fixes.

Regards,
  Krasimir



On Mon, Aug 4, 2008 at 11:47 AM, GüŸnther Schmidt [EMAIL PROTECTED] wrote:
 Hi,

 what is currently the recommend way to interface with COM from haskell?

 I need to create an Excel Sheet and thus need to use Excel via COM.

 Günther

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

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


Re: [Haskell-cafe] Scripting COM Components from Haskell - GreenCard on Hackage

2008-08-05 Thread Krasimir Angelov
No! Greencard is another story. The paper describes HDirect.

On Tue, Aug 5, 2008 at 3:02 PM, GüŸnther Schmidt [EMAIL PROTECTED] wrote:
 Hi,

 does anybody know if the Greencard package / lib is the same software that
 is mentioned in the paper Scripting COM Components from Haskell?

 http://research.microsoft.com/~simonpj/papers/com.ps.gz

 I managed to install the hackage Greencard package on XP with GHC 6.8.3 but
 it seems to be quite different from what the paper describes.

 Günther

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

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


Re: [Haskell-cafe] Implementing ParseChart with Data.Map

2008-06-03 Thread Krasimir Angelov
I actually made my own copy of Data.Map and added an extra:

alterLookúp :: Ord k = (Maybe a - (b,Maybe a)) - k - Map k a - (b,Map k a)

function. I also changed my data type to:

type ParseChart k v = Map k (Map v ())

so I don't have to copy the Data.Set module also. Unfortunately this
doesn't give much better performance - 5734 msec instead of 5828 msec.
Fortunately I found that there is a way to avoid to use Map at all in
one common case. This gave me time about 5024 msec.

Regards,
   Krasimir


On 6/3/08, Yitzchak Gale [EMAIL PROTECTED] wrote:
 Krasimir Angelov wrote:
  but notice that the set is still traversed twice.

 Neil Mitchell wrote:
  I don't see any way of reducing that

 Yeah, it looks like the Data.Set (and Data.IntSet) library
 is missing the functions

 insertMember :: Ord a = a - Set a - (Bool, Set a)
 deleteMember :: Ord a = a - Set a - (Bool, Set a)

 analagous to splitMember. It should be easy to write
 those functions. If you do that for yourself, consider
 making a patch of them and submitting the patch
 as a library proposal.

 But anyway, a set lookup is very cheap, even for a
 set that is quite large. You may want to try just doing
 the extra lookup, it might be good enough for you.
 At least you eliminated the Map lookup.

 Regards,
 Yitz

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


[Haskell-cafe] Implementing ParseChart with Data.Map

2008-06-02 Thread Krasimir Angelov
Hi,

I have to write ParseChart implementation with Data.Map/Set. The chart
is type like this:

type Chart k v = Map k (Set v)

now I need operation like:

insert :: k - v - Chart k v - Maybe (Chart k v)

where the result is (Just _) if the (k,v) is actually added to the
chart or Nothing if it was already there and nothing have to be done.
The straight forward implementation is:

case Map.lookup k chart of
  Nothing - Just (Map.insert k (Set.singleton v) chart)
  Just set | Set.member v set - Nothing
   | otherwise- Just (Map.insert k
(Set.insert v set) chart)

The problem with this is that both the Map and the Set are traversed
twice. The first time from lookup/member and the second time from
insert. Does someone have an idea how to do this with the current
libraries?

There are the Map.updateLookupWithKey and the Map.alter functions:

updateLookupWithKey :: Ord k = (k - a - Maybe a) - k - Map k a -
(Maybe a,Map k a)
alter :: Ord k = (Maybe a - Maybe a) - k - Map k a - Map k a

which are the closest that I need. The problem is that the first
doesn't allow the client function to be called if there isn't matching
key in the map and the second is doesn't allow to return value from
the client function. What I really need is an alterLookúp function:

alterLookúp :: Ord k = (Maybe a - (b,Maybe a)) - k - Map k a - (b,Map k a)

The chart manipulation is in the tight loop of my application so I
need fast code. Any other ideas?

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


Re: [Haskell-cafe] Implementing ParseChart with Data.Map

2008-06-02 Thread Krasimir Angelov
Not completely! This is a possible implementation:

case insertLookupWithKey (\_ - Set.union) k (Set.singleton v) chart of
  (Nothing, chart) - Just chart
  (Just set, chart) | Set.member v set - Nothing
  | otherwise - Just chart

but notice that the set is still traversed twice.

On Tue, Jun 3, 2008 at 12:07 AM, Neil Mitchell [EMAIL PROTECTED] wrote:
 Hi Krasimir,

 insert :: k - v - Chart k v - Maybe (Chart k v)

 where the result is (Just _) if the (k,v) is actually added to the
 chart or Nothing if it was already there and nothing have to be done.

 insertLookupWithKey :: Ord k = (k - a - a - a) - k - a - Map k
 a - (Maybe a, Map k a)

 This should provide the information you need, without the double
 traversal of the data structure.

 Thanks

 Neil

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


Re: [Haskell-cafe] Data.Tree.Zipper in the standard libraries

2008-05-31 Thread Krasimir Angelov
Hi again,

I was silent for some time but in this time I created QuickCheck tests
for Data.Tree.Zipper which achieve 100% coverage with HPC. I also
created a ticket for it: Ticket #2324

http://hackage.haskell.org/trac/ghc/ticket/2324

The attached file is the current implementation and it contains the
version updated from Iavor Diatchki. It has the advantage that it also
works with forests, not just with trees.

Initially I thought that complete testsuite for such a simple module
might be overkill but actually I found a bug :-) in the splitChildren
function which is now fixed.

The dead line for further considerations is one week.

Regards,
  Krasimir



On Sun, May 25, 2008 at 1:09 AM, Iavor Diatchki
[EMAIL PROTECTED] wrote:
 Hello,
 I think that the modified API (no state monad, and using Maybe) is
 quite nice!  I implemented a version of the the suggested API using a
 slightly different data structure, which makes the code a bit simpler,
 I think.   I put the code in the Haskell wiki:
 http://www.haskell.org/sitewiki/images/2/2d/RoseZipper.hs
 I also added a couple of extra functions that seemed useful, and
 renamed a few of the functions to be more consistent.

 As for how to distribute the code, it seems that Zipper should live in
 the same place as Data.Tree.  I think that Data.Tree is part of the
 containers package, so it would make sense to add the Zipper there
 as well.

 -Iavor



 On Sat, May 24, 2008 at 1:24 AM, Neil Mitchell [EMAIL PROTECTED] wrote:
 Hi,

 It doesn't use State monad anymore and it returns Maybe. This seems to
 be the common preference, is it? Feel free to vote against. Should we
 change Data.Map also? There is another proposal for changes in
 findMin/findMax so it is better to make this two breaking changes
 together rather than in a later release.

 The standard libraries proposal thingy is to go via the libraries
 list, create tickets etc. What reason is there to make this part of
 the base libraries, rather than a separate package on hackage? I can't
 see much reason to make Data.Tree part of the base libraries, other
 than the fact it already is, and it could easily get moved out at a
 future date.

 We've seen there is some advantage in leaving the implementation
 outside the base library, as its already changed several times in the
 past few days.

 Thnanks

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


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


Re: [Haskell-cafe] Data.Tree.Zipper in the standard libraries

2008-05-23 Thread Krasimir Angelov
Aha. I see the point. The current design was influenced from some
other implementation that I spot somewhere in the net. I will change
it but this reminds me of another problem. Most movement functions
raise error if they can't do the movement. This is convenient if you
somehow know that the direction in which you go always exists.
Alternatively I can use monad with failure. In other words, there are
two possibilities:

1. Use error .. and types like:   TreeLoc a - TreeLoc a
2. Use monad and type like:   Monad m = TreeLoc a - m (TreeLoc a)

In the second case some one have to do something like this to check
whether the operation is successful:

case left loc of
  Noting   - error something gone wrong
  Just loc - ...

In the first case there is no way to check for success but someone can
use precondition:

if isFirst loc
  then do_something (left loc)
  else i_cannot_go_left

In my opinion 1 looks nicer but 2 also have advantages. What do you think?

Regards,
   Krasimir




On Fri, May 23, 2008 at 12:33 AM, Conal Elliott [EMAIL PROTECTED] wrote:
 * Every definition of tp

 I meant of type, forgetting that my emacs abbrevs don't expand in gmail.

 On Thu, May 22, 2008 at 2:13 PM, Conal Elliott [EMAIL PROTECTED] wrote:

 Hi Krasimir,

 I had a long exchange with chessguy about this interface, suggesting a
 significant change in style, simplifying the type.  (Incidentally, the
 change removed the State and hence mtl dependence.)

 The conversation is on http://tunes.org/~nef/logs/haskell/08.05.17,
 starting with 12:08:11 chessguy w00t! and really picking up with
 conal chessguy: something smells funny 

 Here's a summary of the conversation, though I encourage you to read the
 whole thing:

 * Every definition of tp 'State (TreeLoc a) a', does a getLabel at the end
 (except getLabel).
 * Often users of those movement functions discard the result.
 * Simpler and more orthogonal would be remove the getLabel and return
 'State (TreeLoc a) ()' instead.
 * Now remove that return value altogether, simplifying the type of zipper
 movements to just 'TreeLoc a - TreeLoc a'.  Then they compose nicely with
 (.), having id as identity.
 * Simplify the type of getLabel to just 'TreeLoc a - a'.  Now no more
 State.

 Cheers,  - Conal


 On Thu, May 22, 2008 at 12:52 PM, Krasimir Angelov [EMAIL PROTECTED]
 wrote:

 Hello Guys,

 We have Data.Tree in the standard libraries for a long time but for
 some reason we still don't have standard implementation for Zipper. I
 wrote recently one implementation for Yi but there are many other
 versions hanging around. At least I know for some. I propose to add
 one in the standard libraries i.e. the containers package. The
 version that I use currently is here:

 http://code.haskell.org/yi/Data/Tree/Zipper.hs

 If you would like to do code review I will be happy to hear comments.
 After the API is settled down I will write test cases also. One thing
 that is worying me is that the current version uses State monad which
 is in the mtl package while the natural place for Data.Tree.Zipper
 is in containers. This will create an extra dependency. Is this
 acceptable?

 Regards,
  Krasimir
 ___
 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] Data.Tree.Zipper in the standard libraries

2008-05-22 Thread Krasimir Angelov
Hello Guys,

We have Data.Tree in the standard libraries for a long time but for
some reason we still don't have standard implementation for Zipper. I
wrote recently one implementation for Yi but there are many other
versions hanging around. At least I know for some. I propose to add
one in the standard libraries i.e. the containers package. The
version that I use currently is here:

http://code.haskell.org/yi/Data/Tree/Zipper.hs

If you would like to do code review I will be happy to hear comments.
After the API is settled down I will write test cases also. One thing
that is worying me is that the current version uses State monad which
is in the mtl package while the natural place for Data.Tree.Zipper
is in containers. This will create an extra dependency. Is this
acceptable?

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


Re: [Haskell-cafe] zipper for rose trees? (Data.Tree)

2008-04-23 Thread Krasimir Angelov
Hi Graham,

There is one implementation here:

http://code.haskell.org/yi/Data/Tree/

I wrote it for Yi but it is quite general. It is a pity that we don't
have it in the standard libraries. It is not completely tested but it
seems to work for me.

Regards,
  Krasimir


2008/4/23 Graham Fawcett [EMAIL PROTECTED]:
 Hi folks,

 Is there a common zipper implementation for the Tree a datatype, defined
 in Data.Tree?  The wiki gives examples for binary trees and B-trees, but not
 for these.

 Thanks,
 Graham




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


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


Re: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread Krasimir Angelov

There's a bit of a chicken-and-egg problem here; the COM tools are not well
maintained, so that discourages use, which in turn  makes it less rewarding
to work on them.  What I don't know is the level of suppressed demand: if
there were good tools, would lots of people start using them?


I think it will be beneficial for many Windows user if there was a
good Haskell to COM integration. HDirect can be a real nightmare for a
large projects. The first step could be to build a new COM library
designed in more FFI addendum fashion.
I already have started the first step with:

http://darcs.haskell.org/packages/hscom/

It is far from complete of course. The second step should be to
reimplement the IDL-Haskell translator. The existing translator often
generate code that isn't type correct and even if you change the code
by hand there is still a chance to have an implementation errors which
can't be captured from the typechecker. The whole task isn't that hard
but still requires a volunteer willing to spend 2-3 months of full
time work.

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


Re: [Haskell-cafe] Re: GHC throws IOError on Win32 when there is no console

2007-02-13 Thread Krasimir Angelov

On 2/13/07, Simon Marlow [EMAIL PROTECTED] wrote:

Sounds like a good idea.  You need to look at rts/RtsMessages.c, in particular
rtsErrorMsgFn(), which currently has cases for GUI and non-GUI.  I guess it
really should have 3 cases: GUI, console, and non-GUI.


The trick here is how to find whether the current application is GUI,
console or non-GUI. The distinction between GUI and Console
applications is easy because you can check subsystem OS type. This
doesn't work with Windows services because they can be either GUI or
Console. The OS is preventing them from showing any windows.

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


Re: [Haskell-cafe] How to serialize thunks?

2006-12-21 Thread Krasimir Angelov

Hi Joachim,

All those libraries really force the data because they all are written
in Haskell. If you want to serialize thunks then you will need some
support from RTS. This is something that is implemented in Clean but
this just uncovers a lot of other problems:

The serialization of thunk requires to store a reference to procedure
for thunk evaluation. After that it is tricky to do the deseriazation
because you will have to dynamically link the thunk evaluation code.
The program that do the serialization and the program that have to
read it aren't necessary one and the same program. In this case the
reading application should have some way to call code from the writing
application.

Another problem arises when you have to recompile the writing
application. After the recompilation the evaluation code for some
thunk may not exist any more. The solution that Clean is using is to
keep a copy of each executable after each compilation.

Cheers,
 Krasimir


On 12/21/06, Joachim Durchholz [EMAIL PROTECTED] wrote:

I have skimmed the serialization libraries on haskell.org (NewBinary,
SerTH, AltBinary, HsSyck, GenericSerialize).

I'm under the impression that these all force the data that they serialize.
Is that correct?
If yes: are there workarounds? I'd really like to be able to use
infinite data structures in the data that I serialize.

Regards,
Jo

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


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


Re: [Haskell-cafe] Re: How to serialize thunks?

2006-12-21 Thread Krasimir Angelov

On 12/21/06, Joachim Durchholz [EMAIL PROTECTED] wrote:

Krasimir Angelov schrieb:
 All those libraries really force the data because they all are written
 in Haskell. If you want to serialize thunks then you will need some
 support from RTS.

Good to hear that my conjectures aren't too far from reality.

Does any Haskell implementation have that kind of RTS support?


Not yet. I ever don't know of anyone planning to do that.

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


Re: [Haskell-cafe] Re: Haskell and .NET

2006-12-13 Thread Krasimir Angelov

The problem with Haskell for .NET is that the produced executables are
usually very slow. Good optimizing compiler like GHC has better chance
to produce code with reasonable performance. The major problem with
YHC is that it still doesn't have strictness analyzer. The consequence
is that the produced .NET code creates lots of unnecessary temporal
objects.

Cheers,
 Krasimir

On 12/13/06, Neil Mitchell [EMAIL PROTECTED] wrote:

Hi

Yhc also has a .NET generating capability, just pass the -dotnet flag.

http://haskell.org/haskellwiki/Yhc

Thanks

Neil

On 12/12/06, Monique Monteiro [EMAIL PROTECTED] wrote:
 Hi Justin,

   I've runned a research project about this topic (in fact, it was the
 subject of my MSc dissertation).  Please see the Haskell.NET Project
 (http://www.cin.ufpe.br/~haskell/haskelldotnet).  We have compiled a
 subset of the Haskell language to .NET, but we still don't have an
 available release (we don't support the full Haskell prelude yet).
 The compiler is an extension to GHC.

   In the future, we intend to provide full interoperability with .NET
 in this way.  There are some interesting references in the website
 about our compilation strategies.

   If you need further information about the project's status, please
 contact Prof. André Santos ([EMAIL PROTECTED]) and/or Guilherme Avelino
 ([EMAIL PROTECTED]).

 Best regards,

 --
 _
 Monique Monteiro, MSc
 http://www.cin.ufpe.br/~mlbm
 http://thespoke.net/blogs/moniquelouise/default.aspx
 [EMAIL PROTECTED]
 +55 81 34198137
 Project Manager
 Recife Microsoft Innovation Center
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


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


Re: [Haskell-cafe] Re: Haskell and .NET

2006-12-13 Thread Krasimir Angelov

On 12/13/06, Neil Mitchell [EMAIL PROTECTED] wrote:

Hi Krasimir,

 to produce code with reasonable performance. The major problem with
 YHC is that it still doesn't have strictness analyzer.

It does, or rather Yhc.Core does (see Yhc.Core.Strictness -
http://www.cs.york.ac.uk/fp/yhc/snapshot/docs/Yhc-Core-Strictness.html).
This was only done a few weeks ago, so the .NET translator has no
benefit from it.

And strictness is not the biggest problem, a complete lack of any
optimisations is, but I'm working on that one too!


It is great to hear that. Of course an optimiser will be beneficial
too but I guess that even the benefit that the code generator can have
from the strictness analyzer will make huge difference.

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


[Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell 0.2 final

2006-12-08 Thread Krasimir Angelov

It is already bundled with slightly newer version of GHC-6.6. There
was a bug that had to be fixed in order to have working Visual
Haskell. Visual Haskell is dependent of GHC API and you can't simply
use it with different GHC version.

Cheers,
 Krasimir


On 12/8/06, Bulat Ziganshin [EMAIL PROTECTED] wrote:

Hello Krasimir,

Friday, December 8, 2006, 11:12:26 AM, you wrote:

 The final version of Visual Haskell 0.2 is ready:
- distributed with a stable GHC version (6.6)

how about bundlng it with up-to-date GHC 6.6 build (which've fixes a lot of
problems) or, better, allow to use it with user-installed ghc 6.6.*
installation?


--
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



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


[Haskell-cafe] Re: Re[2]: [Haskell] ANNOUNCE: Visual Haskell 0.2 final

2006-12-08 Thread Krasimir Angelov

You can replace just libHSrts.a in your Visual Haskell directory and
it should work. I will release a new VSHaskell after GHC-6.6.1
release. If the .hi format is still the same in the last GHC-6.6
revision then you should safely replace everything.

Cheers,
 Krasimir


On 12/8/06, Bulat Ziganshin [EMAIL PROTECTED] wrote:

Hello Krasimir,

Friday, December 8, 2006, 4:30:31 PM, you wrote:

 It is already bundled with slightly newer version of GHC-6.6. There
 was a bug that had to be fixed in order to have working Visual
 Haskell. Visual Haskell is dependent of GHC API and you can't simply
 use it with different GHC version.

i mean newr 6.6.* versions, what fixed also other errors, not only
VH-related. if my project needs, for example, GC bugfix, i can't use VH
because this error was fixed only a few weeks ago


--
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: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2

2006-12-01 Thread Krasimir Angelov

Thanks. In the mail that I mentioned there was a sugesstion to use -s
option during dll linking. This has the advantage that the produced
dll will be smaller but still correct. I will try to build a new dll
again with this option this time. If it works I will prepare a new
installer with the updated dll.

Cheers,
  Krasimir

On 12/1/06, shelarcy [EMAIL PROTECTED] wrote:

Hi Krasimir,

On Fri, 01 Dec 2006 16:56:02 +0900, Krasimir Angelov [EMAIL PROTECTED] wrote:
 http://www.cygwin.com/ml/cygwin/1998-04/msg00133.html

 I wonder whether this may cause the problem. I have uploaded a new
 vs_haskell.dll here:

 http://www.haskell.org/visualhaskell/vs_haskell.zip

 It is the same dll but without stripped debug symbols. Could you try
 to replace it in your installation?

I tried to replace vs_haskell.dll after Windows Installer (MSI),
no error occur during devenv.exe /Setup command or using
Visual Haskell.

I can make new Haskell project.

 On Fri, 01 Dec 2006 03:48:49 +0900, Justin Bailey [EMAIL PROTECTED] wrote:
  I am having similar problems with the Visual Haskell install, and the
  commands given did not help. When I open Visual Studios Help | About 
dialog,
  I get an error about the package failing to initialize. I am installing to
  an English copy, however.

And I can open Studios Help | About dialog without any error.

After exit Visual Haskell, Microsoft Development Environment opened
error dialog about devenv.dll sometimes. Anyway, this error is
harmless and I reported to Microsoft by form.

Best Regards,

--
shelarcy shelarcycapella.freemail.ne.jp
http://page.freett.com/shelarcy/


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


Re: [Haskell-cafe] ANNOUNCE: Visual Haskell prerelease0.2

2006-12-01 Thread Krasimir Angelov

I will build these libraries for the final installer.

On 12/1/06, shelarcy [EMAIL PROTECTED] wrote:

Hi Alistair,

On Fri, 01 Dec 2006 18:13:45 +0900, Bayley, Alistair [EMAIL PROTECTED] wrote:
 It certainly is. Is it possible to configure VisualHaskell so that it
 uses the existing ghc-6.6 installation, rather than it's own?

I think you can install extra libraries by cabal (and
sometime you also need MSYS and MSYS Developer Tool Kit
(autotools) for configuration).

 cgi
 fgl
 GLUT (and GLUT_cbits)
 haskell-src
 html
 HUnit
 mtl
 network
 objectio
 OpenGL (and OpenGL_cbits)
 QuickCheck
 readline
 time
 xhtml

And I proposed to bundle OpenAL and ALUT packages.

http://www.haskell.org/pipermail/glasgow-haskell-users/2006-October/011283.html

These packages are in extra libraries. And I think that -
OpenAL library is LGPL and OpenAL package is BSD3, so
there is no reason avoiding to include this package.

OpenAL site notices that OpenAL can become Creative's
licese when using on Creative Device.

http://www.openal.org/platforms.html

But if you look at Creative's OpenAL SDK header files, you
can find al.h and eft.h are LGPL. So I think we can use
OpenAL library under LGPL on Windows, if we don't use
Creative specific extentions.

http://opensource.creative.com/pipermail/openal/2004-March/007309.html

Best Reagrds,

--
shelarcy shelarcycapella.freemail.ne.jp
http://page.freett.com/shelarcy/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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


Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2

2006-12-01 Thread Krasimir Angelov

The zip file is updated with .dll that is with stripped debug symbols
but with --optdll-s as it is recommended. Could some one try whether
it works? It is about two times smaller than the non stripped version.


  http://www.haskell.org/visualhaskell/vs_haskell.zip


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


Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2

2006-12-01 Thread Krasimir Angelov

Sorry. I was sleeping and I uploaded it to darcs.haskell.org instead
to haskell.org. Try it now.

Cheers,
 Krasimir

On 12/2/06, shelarcy [EMAIL PROTECTED] wrote:

Hi Krasimir,

On Sat, 02 Dec 2006 02:14:26 +0900, Krasimir Angelov [EMAIL PROTECTED] wrote:
 The zip file is updated with .dll that is with stripped debug symbols
 but with --optdll-s as it is recommended. Could some one try whether
 it works? It is about two times smaller than the non stripped version.

   http://www.haskell.org/visualhaskell/vs_haskell.zip

Is this file updated one?
I downloaded it from above url again. But file size is same.
So, I checked hash. It noticed that current and previous files
are same.

$ md5sum vs_haskell.dll
\a968ac130932a9b38bd0da50e9ae865a *C:\\Documents and Settings\\
Administrator\\My Documents\\vs_haskell\\vs_haskell.dll

$ md5sum C:\Doc\Haskell\vs_haskell\vs_haskell.dll
\a968ac130932a9b38bd0da50e9ae865a *C:\\Doc\\Haskell\\vs_haskell\\
vs_haskell.dll

Best Regards,

--
shelarcy shelarcycapella.freemail.ne.jp
http://page.freett.com/shelarcy/


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


Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2

2006-11-30 Thread Krasimir Angelov

VSHaskell isn't interfacing with .NET but is a COM server written in
Haskell. The VStudio IDE is actually implemented in C but is using COM
as an interface to the various plugins. That way you can implement the
plugin in C++/.NET/Haskell or what ever you want. For Eclipse you need
a bridge between JVM and Haskell. In addition you have find some way
to build .so library for Linux.

Cheers,
 Krasimir


On 11/30/06, Thiago Arrais [EMAIL PROTECTED] wrote:

On 11/30/06, Johannes Waldmann [EMAIL PROTECTED] wrote:
 The main advantage (Visual Haskell  over eclipsefp) at the moment
 is that VH uses incremental (on-the-fly) typechecking/compilation
 while eclipsefp calls the compiler for whole modules?

I would say this is one of the greatest advantages of VH, don't know if it is
the main one, but it surely is an advantage. I wonder how VH achieves that.
I imagine it manages to run GHC (it uses GHC, right?) inside the .Net VM
or at least access it through some programmatic interface using some kind
of native/VM data conversion. GHC code (and not VH code) do the
typechecking/compilation tricks. Is that right?

Eclipse is Java and I am pretty sure we can do something similar with it
and we actually did something like the second approach prior to version
0.9.1, but just for source code parsing. What do we need for that?

Cheers,

Thiago Arrais
--
Mergulhando no Caos - http://thiagoarrais.wordpress.com
Pensamentos, idéias e devaneios sobre desenvolvimento de software e
tecnologia em geral
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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


Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell prerelease0.2

2006-11-30 Thread Krasimir Angelov

Hi Alistair,

Visual Haskell is packaged with just the core libraries.
Control.Monad.* modules are part of mtl and Test.HUnit is part of
HUnit which aren't core libraries and aren't installed. It was long
time ago when I was using the official Windows installer for last
time. Is it still packaged with all libraries?

Krasimir


On 11/30/06, Bayley, Alistair [EMAIL PROTECTED] wrote:

(not sure if this is the best place for questions about VisualHaskell)

I've just installed VisualHaskell, and I've noticed that some of the
hierarchical libraries are missing/hidden:
 - Control.Monad.State (and other chunks of the Control.Monad hierarchy,
like Control.Monad.Error/Identity/List/Trans)
 - Test.HUnit (in fact Test.* is gone)

and I'm sure there's plenty more missing.

?

Alistair
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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


[Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2

2006-11-30 Thread Krasimir Angelov

Hi Shelarcy,

Could you check whether you have this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\InstallDir

and tell me its value? Typically its value should be such that the
following script to work.

Set shell = CreateObject(WScript.Shell)
vstudioPath  = shell.RegRead
 (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\InstallDir)
shell.Run (  vstudioPath  devenv.exe /Setup,0,true)

Cheers,
  Krasimir


On 11/30/06, shelarcy [EMAIL PROTECTED] wrote:

Hi Krasimir,

 On 11/30/06, shelarcy [EMAIL PROTECTED] wrote:
 But ... I can't install Visual Haskell prerelease 0.2. Near
 the end of install process, Microsoft Development Environment
 cause error.
On Thu, 30 Nov 2006 17:03:22 +0900, Krasimir Angelov [EMAIL PROTECTED] wrote:
 Could you tell me what error message you see during the installation?
 If it is in Japan then translate it in English ;-).

It's not good error message. Anyway, I translate it.

Near the end of install process, error dialog opened and says:

---
The problem happende, so exit Microsoft Development Environment.
I'm sorry for causing inconvenience to you.

(under its message, error dialog has form that send error report
for Microsoft or shows error detail. These messages are not
important, so I don't translate that.)
---

And click form that shows error detail, another dialog opened.
It shows:

---
:Error ditail:
An unhandled exception has been caught by the VSW exception filter.
:Error Signature:
AppName: devenv.exe  AppVer: 7.10.6030.0 ModName: unknown
ModVer: 0.0.0.0  Offset: 00bbbacc
:Report Detail:
(Below meassage attetion to user that error report send what.
So these messages are not important, too.)
---

 Also it can help
 if you run the installer with logging:

 $ msiexec VSHaskell71.msi /l log.txt

msiexec doesn't run its command. And error dialog noticed that
you forgot /i optio. So I used below command.

$ msiexec /i VSHaskell71.msi /l log.txt

I think log.txt is much more useful than previous messages.
log.txt also has Japanese messages. So I translated that part.

---
(snip)

Action 20:38:17: CA_RegisterHelpFile.3643236F_FC70_11D3_A536_0090278A1BB8.
   IHxRegisterSession::ContinueTransaction() returned 0.
   Helpfile: C:\Program Files\Visual Haskell\doc\alex.HxS was successfully 
registered to namespace vs_haskell.
elpfile: C:\Program Files\Visual Haskell\doc\building.HxS was successfully 
registered to namespace vs_haskell.
   Helpfile: C:\Program Files\Visual Haskell\doc\Cabal.HxS was successfully 
registered to namespace vs_haskell.
   Helpfile: C:\Program Files\Visual Haskell\doc\haddock.HxS was 
successfully registered to namespace vs_haskell.
   Helpfile: C:\Program Files\Visual Haskell\doc\happy.HxS was successfully 
registered to namespace vs_haskell.
   Helpfile: C:\Program Files\Visual Haskell\doc\libraries.HxS was 
successfully registered to namespace vs_haskell.
   Helpfile: C:\Program Files\Visual Haskell\doc\users_guide.HxS was 
successfully registered to namespace vs_haskell.
   Helpfile: C:\Program Files\Visual Haskell\doc\vh.HxS was successfully 
registered to namespace vs_haskell.
Action 20:38:17: CA_RegisterPlugIn.3643236F_FC70_11D3_A536_0090278A1BB8.
   IHxRegisterSession::ContinueTransaction() returned 0.
   IHxPlugIn::RegisterHelpPlugIn() returned 0.
   Namespace: vs_haskell was successfully plugged into namespace 
MS.VSCC.2003.
Action 20:38:17: CA_CommitHelpTransaction.3643236F_FC70_11D3_A536_0090278A1BB8.
Action 20:38:17: RegisterProduct. Registering product
RegisterProduct: {FEC3263A-9034-49C5-8C5D-902231009894}
Action 20:38:18: PublishFeatures. Publishing Product Features
PublishFeatures: Feature: Complete
Action 20:38:18: PublishProduct. Publishing product information
1: {FEC3263A-9034-49C5-8C5D-902231009894}
Action 20:38:18: RollbackCleanup. Removing backup files
   IHxRegisterSession::ContinueTransaction() returned 0.
   Registration session: {FEC3263A-9034-49C5-8C5D-902231009894} was 
successfully committed.
RollbackCleanup: File: C:\Config.Msi\fc3d12.rbf
RollbackCleanup: File: C:\Config.Msi\fc3d13.rbf
RollbackCleanup: File: C:\Config.Msi\fc3d14.rbf
RollbackCleanup: File: C:\Config.Msi\fc3d15.rbf
RollbackCleanup: File: C:\Config.Msi\fc3d16.rbf
Action ended 20:38:18: InstallFinalize. Return value 1.
Action 20:38:18: CA_HxMerge_VSCC.3643236F_FC70_11D3_A536_0090278A1BB8.
Action start 20:38:18: CA_HxMerge_VSCC.3643236F_FC70_11D3_A536_0090278A1BB8.
tion ended 20:40:09: CA_HxMerge_VSCC.3643236F_FC70_11D3_A536_0090278A1BB8. 
Return value 1.
Action 20:40:09: CA_RemoveTempHxDs.3643236F_FC70_11D3_A536_0090278A1BB8.
Action start 20:40:09: CA_RemoveTempHxDs.3643236F_FC70_11D3_A536_0090278A1BB8.
Action ended 20:40:09: CA_RemoveTempHxDs.3643236F_FC70_11D3_A536_0090278A1BB8. 
Return value 1.
Action 20:40:09: VSHaskellInstall. Register Visual Haskell Plugin
Action start 20:40:09: VSHaskellInstall.
Error 1720. There is a problem with this Windows Installer

[Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2

2006-11-30 Thread Krasimir Angelov

You can try to setup it manually using the following commands:

$ regsvr32 /i:8.0 /n vs_haskell.dll
$ regsvr32 /i:8.0 /n vs_haskell_babel.dll
$ regsvr32 /i:8.0 /n vs_haskell_dlg.dll
$ devenv.exe /Setup

On 11/30/06, Krasimir Angelov [EMAIL PROTECTED] wrote:

Hi Shelarcy,

Could you check whether you have this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\InstallDir

and tell me its value? Typically its value should be such that the
following script to work.

Set shell = CreateObject(WScript.Shell)
vstudioPath  = shell.RegRead
 (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\InstallDir)
shell.Run (  vstudioPath  devenv.exe /Setup,0,true)

Cheers,
  Krasimir


On 11/30/06, shelarcy [EMAIL PROTECTED] wrote:
 Hi Krasimir,

  On 11/30/06, shelarcy [EMAIL PROTECTED] wrote:
  But ... I can't install Visual Haskell prerelease 0.2. Near
  the end of install process, Microsoft Development Environment
  cause error.
 On Thu, 30 Nov 2006 17:03:22 +0900, Krasimir Angelov [EMAIL PROTECTED] 
wrote:
  Could you tell me what error message you see during the installation?
  If it is in Japan then translate it in English ;-).

 It's not good error message. Anyway, I translate it.

 Near the end of install process, error dialog opened and says:

 ---
 The problem happende, so exit Microsoft Development Environment.
 I'm sorry for causing inconvenience to you.

 (under its message, error dialog has form that send error report
 for Microsoft or shows error detail. These messages are not
 important, so I don't translate that.)
 ---

 And click form that shows error detail, another dialog opened.
 It shows:

 ---
 :Error ditail:
 An unhandled exception has been caught by the VSW exception filter.
 :Error Signature:
 AppName: devenv.exe  AppVer: 7.10.6030.0 ModName: unknown
 ModVer: 0.0.0.0  Offset: 00bbbacc
 :Report Detail:
 (Below meassage attetion to user that error report send what.
 So these messages are not important, too.)
 ---

  Also it can help
  if you run the installer with logging:
 
  $ msiexec VSHaskell71.msi /l log.txt

 msiexec doesn't run its command. And error dialog noticed that
 you forgot /i optio. So I used below command.

 $ msiexec /i VSHaskell71.msi /l log.txt

 I think log.txt is much more useful than previous messages.
 log.txt also has Japanese messages. So I translated that part.

 ---
 (snip)

 Action 20:38:17: CA_RegisterHelpFile.3643236F_FC70_11D3_A536_0090278A1BB8.
IHxRegisterSession::ContinueTransaction() returned 0.
Helpfile: C:\Program Files\Visual Haskell\doc\alex.HxS was 
successfully registered to namespace vs_haskell.
 elpfile: C:\Program Files\Visual Haskell\doc\building.HxS was 
successfully registered to namespace vs_haskell.
Helpfile: C:\Program Files\Visual Haskell\doc\Cabal.HxS was 
successfully registered to namespace vs_haskell.
Helpfile: C:\Program Files\Visual Haskell\doc\haddock.HxS was 
successfully registered to namespace vs_haskell.
Helpfile: C:\Program Files\Visual Haskell\doc\happy.HxS was 
successfully registered to namespace vs_haskell.
Helpfile: C:\Program Files\Visual Haskell\doc\libraries.HxS was 
successfully registered to namespace vs_haskell.
Helpfile: C:\Program Files\Visual Haskell\doc\users_guide.HxS was 
successfully registered to namespace vs_haskell.
Helpfile: C:\Program Files\Visual Haskell\doc\vh.HxS was successfully 
registered to namespace vs_haskell.
 Action 20:38:17: CA_RegisterPlugIn.3643236F_FC70_11D3_A536_0090278A1BB8.
IHxRegisterSession::ContinueTransaction() returned 0.
IHxPlugIn::RegisterHelpPlugIn() returned 0.
Namespace: vs_haskell was successfully plugged into namespace 
MS.VSCC.2003.
 Action 20:38:17: 
CA_CommitHelpTransaction.3643236F_FC70_11D3_A536_0090278A1BB8.
 Action 20:38:17: RegisterProduct. Registering product
 RegisterProduct: {FEC3263A-9034-49C5-8C5D-902231009894}
 Action 20:38:18: PublishFeatures. Publishing Product Features
 PublishFeatures: Feature: Complete
 Action 20:38:18: PublishProduct. Publishing product information
 1: {FEC3263A-9034-49C5-8C5D-902231009894}
 Action 20:38:18: RollbackCleanup. Removing backup files
IHxRegisterSession::ContinueTransaction() returned 0.
Registration session: {FEC3263A-9034-49C5-8C5D-902231009894} was 
successfully committed.
 RollbackCleanup: File: C:\Config.Msi\fc3d12.rbf
 RollbackCleanup: File: C:\Config.Msi\fc3d13.rbf
 RollbackCleanup: File: C:\Config.Msi\fc3d14.rbf
 RollbackCleanup: File: C:\Config.Msi\fc3d15.rbf
 RollbackCleanup: File: C:\Config.Msi\fc3d16.rbf
 Action ended 20:38:18: InstallFinalize. Return value 1.
 Action 20:38:18: CA_HxMerge_VSCC.3643236F_FC70_11D3_A536_0090278A1BB8.
 Action start 20:38:18: CA_HxMerge_VSCC.3643236F_FC70_11D3_A536_0090278A1BB8.
 tion ended 20:40:09: 
CA_HxMerge_VSCC.3643236F_FC70_11D3_A536_0090278A1BB8. Return value 1.
 Action 20:40:09: CA_RemoveTempHxDs.3643236F_FC70_11D3_A536_0090278A1BB8.
 Action

Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2

2006-11-30 Thread Krasimir Angelov

Hi Shelarcy,

On 12/1/06, shelarcy [EMAIL PROTECTED] wrote:

Why you always show 8.0 instead of 7.1?


Sorry, I thought that you are using VStudio 2005.


On Fri, 01 Dec 2006 03:48:49 +0900, Justin Bailey [EMAIL PROTECTED] wrote:
 I am having similar problems with the Visual Haskell install, and the
 commands given did not help. When I open Visual Studios Help | About dialog,
 I get an error about the package failing to initialize. I am installing to
 an English copy, however.

Their commands didn't help for my environment too.
I saw same error dialog that I sent previous mail.


I saw this message this morning:

http://www.cygwin.com/ml/cygwin/1998-04/msg00133.html

I wonder whether this may cause the problem. I have uploaded a new
vs_haskell.dll here:

http://www.haskell.org/visualhaskell/vs_haskell.zip

It is the same dll but without stripped debug symbols. Could you try
to replace it in your installation?

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


Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-29 Thread Krasimir Angelov

Hi Slavomir,

On 11/28/06, Slavomir Kaslev [EMAIL PROTECTED] wrote:

instance Num Float3 where
   .
   signum a | a == Float3 0 0 0 = 0
 | otherwise = 1


signum has a natural generalization for vectors.

signum v = vector with the same direction as v but with |v| = 1

where |v| is the absolute length of v. The problematic function in Num
is abs. Ideally abs should be defined as:

abs v = |v|

but its type is Float3 - Float while the Num class requires Float3 - Float3.

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


Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-29 Thread Krasimir Angelov

It is possible of course but your definition doesn't correspond to any
operation in the usual vector algebra. By the way how do you define
(*)? Isn't it 3D vector multiplication?

Krasimir

On 11/29/06, Slavomir Kaslev [EMAIL PROTECTED] wrote:

You mean signum = normalize? What do you think of my comments here:

 After giving some thought on signum, I got to the point, that signum
 should be defined so that abs x * signum x = x holds. So it can be
 defined as signum (Vec2 x y) = Vec 2 (signum x) (signum y).

 It turns out that all the functions in Num, Floating, etc. classes can
 be given meaningful definitions for vectors in this pattern. That is f
 (Vecn x1 x2 .. xn) = Vecn (f x1) ... (f xn). And all expected laws
 just work. One can think of that like the way SIMD processor works, it
 does the same operations as on floats but on four floats at parallel.

I think this is the way to define vector instances for Num, Floating,
etc. For vector specific operations, such as normalize, len, dot,
cross, etc. are declared in class Vector.

--
Slavomir Kaslev


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


Re: [Haskell-cafe] windows file locking

2006-10-11 Thread Krasimir Angelov

Hi Stefan,

Haskell I/O systems implements single writer-multiple readers file locking. See

http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#8

Cheers,
 Krasimir

On 10/11/06, Stefan Aeschbacher [EMAIL PROTECTED] wrote:

Hi

I need to open a file and keep it open for writing (a log file). Another
process has
to read from this file. On windows the second process (e.g. tail -f) can not
open the file.
How can I open a file without this locking?

regards

Stefan

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




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


Re: [Haskell-cafe] How can I redirect stdout?

2006-10-02 Thread Krasimir Angelov

Hi Matthew,

On Windows stdout/stderr/stdin exists only when your application is
using the Console OS subsystem. All GUI applications doesn't have
console window and they don't have stdout/stderr/stdin. When you are
building DLLs then the subsystem is determined from the type of the
application that is loading your DLL. In your particular case the DLL
is loaded from Matlab which is definitely a GUI application. When you
are trying to load the DLL from other C application then probably it
is Console application and all print statements simply works. The
solution that you can use is to replace all your print statements with
Debug.Trace.trace or Debug.Trace.putTraceMsg. When you are using these
functions from Console application then the output is redirected to
stderr but when they are used from GUI application then the output
goes to the debugger. You can see the output in the Debug pane in the
Visual Studio IDE while you are running MatLab from the debugger.

Cheers,
 Krasimir

On 9/29/06, Matthew Bromberg [EMAIL PROTECTED] wrote:

I'm reposting this in it's own new thread since I think it involves a
general issue beyond exporting Haskell DLLs.

I am having some problems with GHCs stdout when a Haskell program is
called from a windows program.



As I noted earlier I am calling some Haskell code from C as a bridge to
being able to
ultimately call Haskell from Matlab 6.5.

The Haskell code is compiled into a .DLL file on a windows machine.
Matlab calls some C code which then calls the Haskell code.

As soon as it gets into the Haskell code I get this run time error in
ghcDLL.dll

stdout: hPutChars: invalid argument (Bad File Descriptor)

The Haskell code seems to work correctly if called from a stand-alone C
program. Moreover, if I scrub all print statements from the Haskell
code, it appears to run correctly from Matlab.

Matlab does not properly redirect stdout so any printf calls from the C
code simply fail to print.
However Haskell's behavior is to halt after generating a runtime error.

The C code used to generate the Haskell .dll is of course mingw gcc, but
the C code used to create my Matlab mex file is Microsoft VC++ 6.0.  I
tried to redirect stdout using freopen() in C, but that never seems to
work with Microsoft.  At any rate it certainly doesn't effect Haskells
use of stdout.  I think in general for windows programs there is no
stdout defined, whereas it's always defined for console programs.

My question is, is there some way I can redirect stdout from inside
Haskell so that all output is sent to a file?  Is there an equivalent of
freopen() in Haskell that works?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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


Re: [Haskell-cafe] Greetings...

2006-10-01 Thread Krasimir Angelov

On 10/1/06, Seth Gordon [EMAIL PROTECTED] wrote:

I'm planning to use HSQL, since it's in Debian stable and the API
resembles what I'm already familiar with.  Database access is slower
than file access (which is one reason I want to move as much logic as I
can out of SQL), so if the speed of getting rows out of the database
turns out to be the bottleneck in my code, I'll either be happy that all
the other code is so efficient or peeved that HSQL is so inefficient.


Hi Seth,

HSQL is just a thin wrapper around the underlying database engine. The
performance in this case depends mainly on the database engine that
you are using.

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


Re: [Haskell-cafe] Re: Greetings

2006-10-01 Thread Krasimir Angelov

On 10/1/06, Seth Gordon [EMAIL PROTECTED] wrote:

Paul Johnson wrote:
 I've done some stuff with maybe 50k rows at a time.  A few bits and pieces:

 1: I've used HSQL
 (http://sourceforge.net/project/showfiles.php?group_id=65248) to talk to
 ODBC databases.  Works fine, but possibly a bit slowly.  I'm not sure
 where the delay is: it might just be the network I was running it over.
 One gotcha: the field function takes a field name, but its not random
 access.  Access the fields in query order or it crashes.

Thanks; that's certainly the sort of thing I like knowing in advance.


This behaviour depends on the underlying database. I remember that
MSSQL suffers from this disease. In addition with MSSQL you can't have
more than one opened dataset for a given connection. MySQL and
PostgreSQL doesn't have this problem. HSQL can't hide all differences
between the possible backends.


 2: For large data sets laziness is your friend.  When reading files
 getContents presents an entire file as a list, but its really
 evaluated lazily.  This is implemented using unsafeInterleaveIO.  I've
 never used this, but in theory you should be able to set up a query that
 returns the entire database as a list and then step through it using
 lazy evaluation in the same way.

I assume that the collectRows function in HSQL can produce this kind of
a lazy list...right?


No. collectRows collects all records eagerly. The problem with the
lazy fetching is that you can close the database connection while your
lazy data sets aren't fetched yet. It is getting worse if you can't
have multiple opened data sets. If you still want lazy fetching you
can write a custom function like collectRows but using
unsafeInterleaveIO.


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


Re: [Haskell-cafe] Re: ANN: System.FilePath 0.9

2006-07-26 Thread Krasimir Angelov

On 7/26/06, Neil Mitchell [EMAIL PROTECTED] wrote:

The main purpose of canoncialPath is to fix the case on Windows, so
c:\my documents\file.doc becomes C:\My Documents\file.doc if that
is the case correct version of the file. I think this function will
not actually change the file with relation to the underying file
system, so should be race free. (I will document more to make the
operation clearer)


Hi Neil,

   It seems like your canoncialPath function is already in the base
package. Look at System.Directory.canonicalizePath. I have added it
when I was working on the FilePath module for Cabal.
  The FilePath abstraction was discussed a number of times and it
seems that people prefer an ADT representation instead of plain
String. I tend to agree. Maybe such ADT based library can be
integrated with some new IO library like the Streams library.

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


Re: [Haskell-cafe] Windows PowerShell Monad

2006-07-15 Thread Krasimir Angelov

Mostly coincidence. It isn't a good choice for name, I think but the
same is true for .NET. Each time when I am googling for .NET I receive
lots of irrelevant results. The same will happen with Monad now.

On 7/14/06, Chad Scherrer [EMAIL PROTECTED] wrote:

Yep, that's its codename.

Now, I'm not much of a Windows person. Is the name just a weird
coincidence, or does it have anything to do with monads as we know
them?

http://en.wikipedia.org/wiki/MSH_(shell)
--

Chad Scherrer

Time flies like an arrow; fruit flies like a banana -- Groucho Marx
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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


Re: [Haskell-cafe] The History of Haskell

2006-07-15 Thread Krasimir Angelov

It was very interesting reading. Thanks! The slightly anecdotal style
of writing is making it even pleasant to read.

On 7/14/06, Simon Peyton-Jones [EMAIL PROTECTED] wrote:

Friends,

Phil Wadler, John Hughes, Paul Hudak and I have been writing a paper
about the

   The History of Haskell

We've submitted an earlier draft to the History Of Programming Languages
conference (HOPL'07), and it's been accepted. We have to submit a
more-or-less final draft by 1 September.

This message is to invite you to read it, tell us what you think, and
help us improve it.  Here it is, along with a Wiki page for you to write
comments:

   http://haskell.org/haskellwiki/History_of_Haskell

Enjoy!

Simon

PS: If you followed a link earlier today, and have a version dated Feb,
discard it.  The one you want is dated July 14th.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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


Re: [Haskell-cafe] Haskell I/O inside: down the rabbit's hole

2006-06-30 Thread Krasimir Angelov

In the last section you said that IO has the same definition in GHC
and Hugs. As far as I can remember in Hugs IO is defined as:

newtype IO a = IO ((a - IOResult) - (IOError - IOResult) - IOResult)

Of course this definition is builtin and cann't be seen in the Haskell
source code.

Cheers,
 Krasimir

2006/6/30, Bulat Ziganshin [EMAIL PROTECTED]:

Hello Haskell,

I'm just wrote exhaustive introduction to Haskell I/O titled

  HASKELL I/O INSIDE: DOWN THE RABBIT'S HOLE

Can you please help me (and Haskell community) by proof-reading this
text? Even if you will correct paragraph or two, it will advance the
work further. Also feel free to add more explanations, correct me and
ask (here) about new topics you need to be explained. The page is

http://haskell.org/haskellwiki/IO_inside



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

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


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


Re: [Haskell-cafe] Haskell and JVM

2006-02-02 Thread Krasimir Angelov
Questions about Haskell for JVM or .NET was asked quite often and it
is really interesting question. Since the JVM and .NET machines have a
lot of common if there was a compiler for one of them then it can
retargeted to the other quite easily. The major problem with such
compilers is the performance. Many attempts exists but no one has
managed to build a complete solution. There are several major
problems:

  - How to represent the G/STG machine stack in JVM/.NET? The naive
solution is to use an array but it is proven to be inefficient.
  - How to minimize the runtime typecasts? They are necessary because
the JVM/.NET type system is a lot weaker than the Haskell's one.
  - How to efficiently represent the IO monad and exceptions?
  - How to make the integration of Haskell with Java/C# easier?

Since usually the performance of all VM languages is worse than those
of the native compiled (C/C++), I think that it is acceptable for
Haskell for JVM/.NET to be slower than GHC for example. Even that if
the performance isn't so worse then it will be usable since it can be
used in existing Java/.NET projects.

Cheers,
  Krasimir

2006/2/2, Arnaud Bailly [EMAIL PROTECTED]:
 Hello,
 I stumbled upon your discussion on haskell-cafe and this theme seems to pop
 up one time or another. If someone is interested, I have some Java
 code for compiling Haskell98 to bytecode that I would be more than
 willing to share. It is not in the best shape and does not implement
 all of haskell but most low-level work to generate classes and
 bytecode from haskell code is implemented (patternmatching, data
 constructors, lazy functions, ...).
 This is a project I started some years ago and used for specification
 of simple functional behaviour (without complex type system) in Java.

 Regards,

 --
 Arnaud Bailly, Dr. - Ingénieur de Recherche
 NORSYS
 1, rue de la Cense des Raines
 ZAC du Moulin
 59710 ENNEVELIN
 Tel : (33) 3 28 76 56 76
 Mob : (33) 6 17 12 19 78
 Fax : (33) 3 28 76 57 00
 Web : http://www.norsys.fr

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

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


Re: [Haskell-cafe] Progress on shootout entries

2006-01-04 Thread Krasimir Angelov
2006/1/3, Chris Kuklewicz [EMAIL PROTECTED]:
  And finially, the haskel entry for
 http://shootout.alioth.debian.org/benchmark.php?test=fannkuchlang=all
  is currently the *slowest* entry out of 28 languages.  It is 813x
 slower than the c-code, 500x slower than OCaml.  Should be easy to make
 it faster...

In this particular case the flop function is very slow.

flop :: Int8 - [Int8] - Int8
flop acc (1:xs) = acc
flop acc list@(x:xs) = flop (acc+1) mangle
where   mangle = (reverse front) ++ back
(front,back) = splitAt (fromIntegral x) list


It can be optimized using a new mangle function:

mangle :: Int - [a] - [a]
mangle m xs = xs'
  where
(rs,xs') = splitAt m xs rs

splitAt :: Int - [a] - [a] - ([a], [a])
splitAt 0xs  ys = (xs,ys)
splitAt _[]  ys = ([],ys)
splitAt m (x:xs) ys = splitAt (m - 1) xs (x:ys)

The mangle function transforms the list in one step while the original
implementation is using reverse, (++) and splitAt. With this function
the new flop is:

flop :: Int8 - [Int8] - Int8
flop acc (1:xs) = acc
flop acc list@(x:xs) = flop (acc+1) (mangle (fromIntegral x) list)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: [Haskell] Making Haskell more open

2005-11-14 Thread Krasimir Angelov
2005/11/13, Gour [EMAIL PROTECTED]:
 Sven Panne ([EMAIL PROTECTED]) wrote:

   * DocBook XML can be transformed into a very rich collection of output
  formats: XHTML, HTML Help, DVI, PS, PDF, FO, plain text, etc. etc.

 txt2tags has the following backends: HTML, XHTML, SGML, LaTeX, Lout,
 man, Magic Point, Moin Moin, Page Maker 6.0  plain text.

I don't see PDF and HtmlHelp backends here. Of course PDF can be
created from LaTeX but this requires doble translation and you will
need both txt2tags  LaTeX installed. I spent some time to add support
for HtmlHelp in haddock and I am using the HtmlHelp output from
DocBook. I don't want to spend more time to learn a new markup and to
make the things working with the new tools. I can't see real reasons
to switch to new formats.

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


Re: [Haskell-cafe] lockFile: fd out of range

2005-10-28 Thread Krasimir Angelov
2005/10/28, Joel Reymont [EMAIL PROTECTED]:
 Understood. I had the same problem with Erlang on Mac OSX and had to
 edit system files to bring it up to the maxium allowed of 10240.
 Worked like a charm after recompiling.

 What do you do on Windows where there's no hard-coded FD_SETSIZE?

For quite a long time the file locking was broken on Windows and the
files were not locked at all. After the last major GHC release the
files are locked using the Win32 API and the lockFile hack isn't
required.

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


Re: [Haskell-cafe] FPS lib

2005-10-20 Thread Krasimir Angelov
2005/10/19, Simon Marlow [EMAIL PROTECTED]:
 On 19 October 2005 01:08, Donald Bruce Stewart wrote:
  Ah!! So what's going on on Linux, I wonder. Could it be something
  about
  6.4.1? Are we seeing the difference between ForeignPtrs from 6.4 to
  6.5? I will investigate.

 I bet that's the difference between ForeignPtrs in 6.4.1 and 6.5.  I'm
 very tempted to merge the ForeignPtr optimisations into 6.4.2, so we can
 benefit from this earlier.  The changes are all confined to one module
 (GHC/ForeignPtr.hs).

I made my benchmarking with ghc-6.5 and I am getting relatively the
same result as with ghc-6.4.1. I checked that the optimized ForeignPtr
implementation is in my source tree. Any thoughts?

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


Re: [Haskell-cafe] FPS lib

2005-10-19 Thread Krasimir Angelov
2005/10/19, Donald Bruce Stewart [EMAIL PROTECTED]:
 kr.angelov:
  Hello Guys,
 
  I tried my own version of PackedStrings and the results are very nice.
  It is entirely based on ByteArray# and Int#. I have made two tests:
 
  Elapsed time
  | | FastPackedString | PackedString |
  +-+--+--+
  |test1|   99.26s |3.81s |
  |test2|  175.88s |5.28s |
 
  Maximum Memory Residency
  | | FastPackedString | PackedString |
  +-+--+--+
  |test1|  40.60Mb |  36.25Mb |
  |test2|  91.58Mb |  33.94Mb |

 Wow. Now this is really surprising.

 Firstly, I would point out that only testing pack and concat may be
 slightly unrepresentative :)

Of course the representative benchmark needs more test cases.

 However, on my machine:

OpenBSD/Pentium-M 1.6G/ghc-6.5 -O
Elapsed time:FPS  Simon's PackedString   Krasimir's
test11.966s (40M)  2.151s (36M)  2.235s (36M)
test26.048s (24M)  3.160s (73M)  2.318s (39M)

 Which is basically what I expected. Though perhaps I need to improve
 concat (we currently do things a little strangely in concat, due to the
 darcs legacy), but pack itself is nice and fast.

Linux/Pentium 4 3.6G/ghc-6.4.1 -O
test1   35.37s30.97s 2.180s
test2   90.93s60.55s 1.916s

 Ah!! So what's going on on Linux, I wonder. Could it be something about
 6.4.1? Are we seeing the difference between ForeignPtrs from 6.4 to 6.5?
 I will investigate.

I wonder why the test results are so different. I made my benchmark on
WinXP on Celeron 3GHz with GHC from CVS HEAD.

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


Re: [Haskell-cafe] FPS lib

2005-10-19 Thread Krasimir Angelov
Hello Guys,

I tried my own version of PackedStrings and the results are very nice.
It is entirely based on ByteArray# and Int#. I have made two tests:

 --import StringUtils.PackedString as PS
 import Data.FastPackedString as PS

 main = test1 [] 100
 --main = test2 [] 100

 test1 xs 0 = return ()
 test1 xs n =
   let x = PS.pack (* ++ show n ++ *)
   in x `seq` test1 (x : xs) (n-1)

 test2 xs 0 = return ()
 test2 xs n =
   let x = PS.concat [PS.pack *, PS.pack (show n), PS.pack *]
   in x `seq` test2 (x : xs) (n-1)

The detailed statistics are attached. Basically the results are:

Elapsed time
| | FastPackedString | PackedString |
+-+--+--+
|test1|   99.26s |3.81s |
|test2|  175.88s |5.28s |

Maximum Memory Residency
| | FastPackedString | PackedString |
+-+--+--+
|test1|  40.60Mb |  36.25Mb |
|test2|  91.58Mb |  33.94Mb |

My PackedString implementation is attached too.

Cheers,
  Krasimir
test +RTS -stest1fs.stat 
566,400,800 bytes allocated in the heap
8,394,100,944 bytes copied during GC (scavenged)
 37,008 bytes copied during GC (not scavenged)
 42,578,884 bytes maximum residency (7 sample(s))

   1042 collections in generation 0 ( 95.94s)
  7 collections in generation 1 (  0.46s)

 84 Mb total memory in use

  INIT  time0.03s  (  0.00s elapsed)
  MUT   time2.83s  (  2.82s elapsed)
  GCtime   96.40s  ( 96.34s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time   99.26s  ( 99.16s elapsed)

  %GC time  97.1%  (97.2% elapsed)

  Alloc rate197,765,642 bytes per MUT second

  Productivity   2.9% of total user, 2.9% of total elapsed

test +RTS -stest1ps.stat 
552,632,612 bytes allocated in the heap
 96,049,260 bytes copied during GC (scavenged)
 82,350,516 bytes copied during GC (not scavenged)
 38,016,248 bytes maximum residency (7 sample(s))

   1061 collections in generation 0 (  0.66s)
  7 collections in generation 1 (  0.92s)

 74 Mb total memory in use

  INIT  time0.02s  (  0.00s elapsed)
  MUT   time2.21s  (  2.20s elapsed)
  GCtime1.58s  (  1.47s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time3.81s  (  3.67s elapsed)

  %GC time  41.5%  (40.1% elapsed)

  Alloc rate247,484,376 bytes per MUT second

  Productivity  58.0% of total user, 60.2% of total elapsed

test +RTS -stest2fs.stat 
412,700,712 bytes allocated in the heap
6,411,611,864 bytes copied during GC (scavenged)
 38,864 bytes copied during GC (not scavenged)
 96,029,672 bytes maximum residency (8 sample(s))

762 collections in generation 0 (169.31s)
  8 collections in generation 1 (  2.87s)

189 Mb total memory in use

  INIT  time0.01s  (  0.00s elapsed)
  MUT   time3.69s  (  3.58s elapsed)
  GCtime  172.18s  (171.91s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time  175.88s  (175.49s elapsed)

  %GC time  97.9%  (98.0% elapsed)

  Alloc rate111,450,367 bytes per MUT second

  Productivity   2.1% of total user, 2.1% of total elapsed

test +RTS -stest2ps.stat 
1,361,661,680 bytes allocated in the heap
 93,647,172 bytes copied during GC (scavenged)
 80,446,868 bytes copied during GC (not scavenged)
 35,585,988 bytes maximum residency (7 sample(s))

   2616 collections in generation 0 (  0.79s)
  7 collections in generation 1 (  0.83s)

 69 Mb total memory in use

  INIT  time0.02s  (  0.00s elapsed)
  MUT   time3.64s  (  3.59s elapsed)
  GCtime1.62s  (  1.58s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time5.28s  (  5.17s elapsed)

  %GC time  30.7%  (30.6% elapsed)

  Alloc rate372,445,754 bytes per MUT second

  Productivity  68.9% of total user, 70.4% of total elapsed



PackedString.hs
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FPS lib

2005-10-18 Thread Krasimir Angelov
I am curious why FPS is implemented on top of ForeignPtr. ByteArray#
based implementation should be faster and more space efficient.

Cheers,
  Krasimir

2005/10/18, Donald Bruce Stewart [EMAIL PROTECTED]:
 ekarttun:
  On 18.10 10:44, Bulat Ziganshin wrote:
   2) as i say you before, i need to sort filenames in windows fashion
   (case-ignoring), so if you will include case-ignoring comparision
   operators - i will be glad
 
  Case ignoring comparisons make only sense on characters - not on bytes.
  And fps is ignoring character set conversion issues. I think the proper
  way is to provide a layer on top of (and separate from) fps that does
  conversion into character strings where things like case make sense.

 Indeed, SimonM's packed string code, which I'm currently integrating
 into FPS, is such a layer.

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

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


Re: [Haskell-cafe] FPS lib

2005-10-18 Thread Krasimir Angelov
ByteArray# can be passed to C functions as well. The only problem is
with mmap which cann't be implemented with arrays. mmap returns a
pointer to the mapped file which is outside the Haskell heap.

Cheers,
  Krasimir

2005/10/18, Benjamin Franksen [EMAIL PROTECTED]:
 On Tuesday 18 October 2005 11:07, Krasimir Angelov wrote:
  I am curious why FPS is implemented on top of ForeignPtr. ByteArray#
  based implementation should be faster and more space efficient.

 I think the reason is C compatibility. A number of functions in FPS use
 ffi-bound C code (mmap, gz (de-)compression,...).

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

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


Re: [Haskell-cafe] FPS lib

2005-10-18 Thread Krasimir Angelov
   ForeignPtr requires more memory. Each ForeignPtr has
ForeignPtrContents structure attached. In the ForeignPtrContents there
is one IORef. Each finalizer adds one Weak# object in the heap. The
IORef is a reference to a list of finalizers, so each new finalizer
adds a new CONS cell. The finalizers require additional steps in GC
time. I haven't tried to measure the difference between ForeignPtr and
ByteArray# based implementations but it seems to me that the latter
might be better. Of course it will be GHC specific.
   mmap is valuable only for large string. Typically only when someone
wants to read the entire file in the memory. For this case a special
data structure might be provided.

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


Re: [Haskell-cafe] List of functions

2005-08-31 Thread Krasimir Angelov
2005/8/31, Sebastian Sylvan [EMAIL PROTECTED]:
 On 8/31/05, Dinh Tien Tuan Anh [EMAIL PROTECTED] wrote:
 
  Something like (untested)...
  
  xs - zipWith ($) forkIO (map (\f - f x y) funs)
  tids - sequence xs
  
 
 
  what does zipWith ($) do ?
 
 $ is function application, so zipWith ($) will zip a list of
 functions with a list of arguments, by applying the functions to the
 arguments pair-wise, producing a list of results.

But forkIO is function not a list of functions. The above example is
incorrect. I think it should be:

tids - sequence [forkIO (f x y) | f - funs]

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


Re: [Haskell-cafe] Re: Oracle + Haskell advice?

2005-08-18 Thread Krasimir Angelov
2005/8/18, John Goerzen [EMAIL PROTECTED]:
 I would suspect that you could find Oracle drivers for either unixODBC,
 or some custom ODBC system that is nearly API-compatible.  Once you have
 that, you have HSQL.

I am planing to add support for Oracle in HSQL since now I am using it
at office, but I will do that when I have enough time to hack with it.
If there is any volunteer to do the job then I will be pretty happy to
incorporate its work.

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


Re: [Haskell-cafe] Re: Visual Hashell Studio.NET 2005

2005-06-07 Thread Krasimir Angelov
Hi Maurício,

VSHaskell has nothing to do with .NET or Mono. This isn't Haskell for
.NET compiler. We are just developing programming environment for
Haskell in Visual Studio. The environement uses the normal GHC
compiler.

Cheers,
 Krasimir


On 6/6/05, Maurício [EMAIL PROTECTED] wrote:
 Brian Smith wrote:
  Hi,
 
  When will VHS support the Visual Studio.NET 2005 Beta? I'd like to
  volunteer to test VHS.NET 2005 when it is available. (Also, MS is
  giving away the VS.NET 2005 beta for free, and VS.NET 2003 costs a
  whopping $15.00 from my school's bookstore).
 
  Thanks,
  Brian
 
   Can we use Haskell with mono?
 
   [...],
   Maurício
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


Re: [Haskell-cafe] Visual Hashell Studio.NET 2005

2005-06-07 Thread Krasimir Angelov
Hi Brian,

Currently I have only VS.NET 2003 license and this is my main
development platform. I think it will not be much effort to upgrade
VSHaskell to VS.NET 2005 but I have no way to try it. I may try to
download Visual Studio.NET 2005 Beta but I am afraid that the download
will be too large.

Cheers,
  Krasimir

On 6/5/05, Brian Smith [EMAIL PROTECTED] wrote:
 Hi,
 
 When will VHS support the Visual Studio.NET 2005 Beta? I'd like to
 volunteer to test VHS.NET 2005 when it is available. (Also, MS is
 giving away the VS.NET 2005 beta for free, and VS.NET 2003 costs a
 whopping $15.00 from my school's bookstore).
 
 Thanks,
 Brian
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


Re: [Haskell-cafe] G machine in FORTH

2005-06-01 Thread Krasimir Angelov
Actually I am very impressed from the FORTH simplicity and efficiency.
I was developing one FORTH system for DOS a couple of years ago and I
think it is very useful for small programs that have to perform low
level/hardware tasks. Unfortunatelly it doesn't scale well for larger
applications. I don't know how well it can be used as G-machine
interpreter but its execution model has a lot of common with STG
machine. In STG each closure has a header word which is a pointer to
its entry code. In FORTH each procedure has a header word which also
points to some entry code. The entry code receives the address of the
entered procedure in special (usually EBX on x86) register just like
in STG (where the used register is ESI). The execution of any FORTH
program is a sequence of jumps from one entry code to another just
like in STG. Of course STG is much more complicated because the
closures are dynamically allocated and there is a garbage collector
too. Thanks to its simple execution model I still think that FORTH is
the fastest interpreted language, just like STG is the fastest virtual
machine for Haskell.

Cheers,
  Krasimir

On 6/1/05, Andrew Harris [EMAIL PROTECTED] wrote:
 Hi -
 
   Brace yourself... I work in an environment where FORTH is still used.
 
   I've been thinking about writing a G-machine interpreter in FORTH
 so that one could write Haskell like programs that would compile down
 and run graph-reduction style on the FORTH machine.
 
   Many developers think FORTH is nice, but the language is so, shall
 we say, terse.
 
   I'm curious about what people think about this; having the
 expressiveness of a Haskell-like language that compiles to this
 environment might provide the best of both worlds, simple hardware
 architecture and an advanced programming language.
 
 let me know what you think,
 -andrew
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


Re: [Haskell-cafe] Re: Type classes and definite types

2005-05-11 Thread Krasimir Angelov
Hi Bryn Keller,

The solution for your problem is very simple. You just have to fetch
all values as strings. In this way the library will do all required
conversions for you.

printRow stmt = do
  id - getFieldValue stmt ID
  code - getFieldValue stmt Code
  name - getFieldValue stmt Name
 putStrLn (unwords [id, code, name])


Cheers,
  Krasimir


On 5/6/05, Bryn Keller [EMAIL PROTECTED] wrote:
 Max Vasin wrote:
 
 Bryn Keller [EMAIL PROTECTED] writes:
 
 
 
 Hi Max,
 
 
 Hello Bryn,
 
 
 
 Thanks for pointing this out. It's odd that I don't see that anywhere
 in the docs at the HToolkit site:
 http://htoolkit.sourceforge.net/doc/hsql/Database.HSQL.html but GHC
 certainly believes it exists. However, this doesn't actually solve the
 problem. Substituting toSqlValue for show in printRow' gives the same
 compile error:
 
 Main.hs:22:18:
 Ambiguous type variable `a' in the constraint:
   `SqlBind a' arising from use of `getFieldValue' at Main.hs:22:18-30
 Probable fix: add a type signature that fixes these type variable(s)
 
 So, like with (show (read s)), we still can't use the function until
 we've established a definite type for the value, not just a type
 class.
 
 
 Yeah...
 Some more RTFSing shows that we have the
 
 getFieldValueType :: Statement - String - (SqlType, Bool)
 
 which allows us to write
 
 printRow stmt = do (id :: Int) - getFieldValue stmt ID
let (codeType, _) = getFieldValueType stmt Code
codestr - case codeType of
SqlChar _ - do (c :: String) - 
  getFieldValue stmt Code
return (toSqlValue c)
SqlInteger - do (i :: Int) - 
  getFieldValue stmt Code
 return (toSqlValue i)
-- etc for all SqlType data constructors
putStrLn (unwords [show id, codestr])
 
 At least it compiles. But it's ugly :-(
 
 
 Ah, good point! Ugly it may be, but at least it works. Thanks for the idea!
 
 Bryn
 ___
 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] Comparison with Clean?

2005-05-04 Thread Krasimir Angelov
If you want to compare Haskell and Clean then take a look at Object
I/O library. It is ported to Haskell and you can learn a lot comparing
both implementations. I spent a lot of time translating Clean
functions to Haskell and my own impression is that Haskell's do
notation is much more easier that uniqueness typing. In Clean you have
to explicitly maintain the state while in Haskell it is hidden. In
order to preserve uniquenes property of state, quite often you have
write uggly functions like:

getXYZ :: State - (XYZ, State)
getXYZ st = (f st, st)

while in Haskell the above function should be:

getXYZ :: State - XYZ
getXYZ st = f st

It is more clean and from the type signature you can see that this is
readonly access to the state.

Cheers,
 Krasimir

On 5/4/05, Daniel Carrera [EMAIL PROTECTED] wrote:
 Hi all,

 Anyone here familiar with the Clean programming language?

 http://www.cs.ru.nl/~clean/

 It looks /very/ similar to Haskell, both in functionality and syntax.

 I would be grateful for any sort of comparison. I'm trying to decide
 which language I should try to learn.

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

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


Re: [Haskell-cafe] File path programme

2005-01-28 Thread Krasimir Angelov
On Thu, 27 Jan 2005 16:31:21 -0500, robert dockins
[EMAIL PROTECTED] wrote:
  I don't pretend to fully understand various unicode standard but it
  seems to me that these problems are deeper than file path library. The
  equation (decode . encode)
  /= id seems confusing for me. Can you give me an example when this
  happen?
 
 I am pretty sure that ISO 2022 encoded strings can have multiple ways to
 express the same unicode glyphs.  This means that any sensible relation
 between IS0 2022 strings and unicode strings maps more than one ISO 2022
 string onto the same unicode string.  The inverse is therefore not a
 function.  To make it a function one of the possibly several encodings
 of the unicode string will have to be chosen.  So you have a ISO 2022
 string A which is decoded to a unicode string U.  We reencode U to an
 ISO 2022 string B.  It may be that A /= B.  That is the problem.
 
 The various UTF encodings do not have this particular problem; if a UTF
 string is valid, then it is a unique representation of a unicode string.
 However, decoding is still a partial function and can fail.
 
 A discussion about this problem floated around on this list several
 months ago.
 
  What can we do when the file name is passed as command line
  argument to program? We need to convert String to FilePath after all.
 
 Then we can parse the unicode and hope that nothing bad happens; the
 majority of the time, we will be OK.  Or we can make the RTS allow
 access to the raw bytes of the program arguments, env variables, etc,
 and actually do the right thing.

This means that all unicode languages, I have used before (Java,C#),
are broken too. In this case I agree that special data type might be
better. The development of the new FilePath should come together with
the new unicode aware I/O library.

I agree with David Roundy that the internal representation of FilePath
should be compact as mush as posible. PackedString uses UArray Int
Char to store strings and we can use  UArray Int Word8 or even
ByteArray#.

Under Windows nearly all API functions have two versions: ANSI and
Unicode (16-bit). Under WinNT+ each ANSI function is just a wrapper
around its Unicode friend and the wrapper simply converts the passed
strings. It was said that paths under Windows are [Word16] while in
Posix they are [Word8]. This is true but in order to take advantages
of this we need to use the native Windows API in the new I/O library.
Another advantage of this is that in such way we can use the native
non-blocking I/O under Windows.

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


Re: [Haskell-cafe] File path programme

2005-01-27 Thread Krasimir Angelov
Hello Guys,

Let me propose another solution which is simpler (at least from my
point of view)and will not break the existing. When I designed the API
of the original System.FilePath library I looked at OS.Path modules
from Python and ML. They both uses plain string to keep the file path
but does precise parsing/printing of the path when it is manipulated.
I haven't ever heard of any language that uses special FilePath type
instead of plain string. I don't want to do any parsing/printing each
time when I need to open file or create directory. In most cases the
file path is passed as string from the outside world to the
application and if we have special FilePath then we need each time to
parse it. What I propose is the following:

 - Keep the existing System.IO API the same. openFile, createDirectory
... will take the file path as string.
 - Introduce two new modules System.Posix.FilePath and
System.Win32.FilePath. Each of them will provide functions for
parsing/printing of paths to/from some platform specific type:
PosixFilePath and Win32FilePath. As you can see from Robert Dockins
examples, these types can be completely different.
 - Introduce third module System.FilePath which will do some basic
operations of path through parsing/printing. The API of this module
can be similar to this which I wrote but its implementation can be
more accurate if it works on some ADT instead of string. The module
will use #ifdef in order to import the right from the above two
modules.

 In most cases we do only simple manipulations on path and I don't
think it is required and easy to explicitly parse/print the path only
in order to change its extension. I prefer to invoke changeFileExt and
don't care how the function will do its job. If someone would like to
perform any more complicated operations on file path he can import the
system specific module and use PosixFilePath or Win32FilePath. This is
basically the way in which OS.Path is implemented in ML.

The type class solution doesn't work very well. As Simon said it may
require to have #ifdef-s in some places in order to choice the right
type. Another disadvantage is that this will complicate some data
types. Example:

data FilePath a = MyFileInfo a = MyFileInfo { path :: a; size :: Integer }

I don't want to add extra type parameters here only in order to
specify the right FilePath type.


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


Re: [Haskell-cafe] File path programme

2005-01-27 Thread Krasimir Angelov
I don't pretend to fully understand various unicode standard but it
seems to me that these problems are deeper than file path library. The
equation (decode . encode)
/= id seems confusing for me. Can you give me an example when this
happen? What can we do when the file name is passed as command line
argument to program? We need to convert String to FilePath after all.

 Even simple manipulations break in the presence of encoding issues, or
 even just of unusual paths.  What is the extension of \\.\TAPE0 ?  Its
 not \TAPE0.  BTW this is a valid path on Windows 2000 upwards.  If you
 don't care about corner cases, then you have no worries.  It would be
 nice to have correct handling for all valid paths on each supported OS
 though.

Yes it isn't. If the library makes proper parsing it will return no extension.

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


[Haskell-cafe] File path programme

2005-01-25 Thread Krasimir Angelov
Hello, Guys

The System.FilePath might not be perfect and might not handle some
unusual cases very well. Most of functions in this module are
collected from Cabal/Alex/Happy/Haddock. Some of these tools already
use their own functions for file path handling. Special care was taken
to make them more portable but probably there is still enough room for
optimizations.

 What about splitFileExt foo.bar.? (foo, bar.) or (foo.bar., )?

 The latter makes more sense to me, as an extension of the first case
 you give and splitting foo.tar.gz to (foo.tar, gz).

I will take a look at this. I also don't know which case is more natural.

  (Win32)

  splitFileName server\\share == (server,share)
(should probably be (server\\share,))

Why? server is the server name and share is the directory name
on this server.

  splitFileName foo:xyz == (foo:.,xyz)
(should be (.,foo:xyz) -- this refers to the named stream
 xyz of foo)

System.FilePath currently doesn't support NTFS streams. I don't care
much about them because they are rarely used but the things can be
improved. The trouble here is that in some cases the drive letter
cann't be easily distinguished. What does c:foo mean, file foo on
drive c or stream foo of file c?

  joinPaths c:\\ \\foo == \\foo
(should be c:\\foo. I realize that cd c:\\ on Windows doesn't
 actually make c:\\ the current directory, but ; doesn't
 separate shell commands either.)

On Windows there is current drive and current directory on each drive.
\\foo means top level directory foo on the current drive. If the
current drive is c then I can agree that the joined path is
c:\\foo but if the current drive is a then this is wrong. In both
cases \\foo is the right answer. If you want something like
c:\\foo you can use System.Directory.canonicalizePath.
canonicalizePath \\foo returns either c:\\foo or a:\\foo.

  (Posix)

  splitFileName /foo == (/,foo),
  splitFileName /foo/ == (/foo,)
(arguably makes sense, but why isn't it documented?)

OK

  splitFileName /foo/bar == (/foo,bar)
  splitFileName /foo//bar == (/foo/,bar)
(definitely a bug)

Is /foo//bar valid file path and what does // mean?

  pathParents /foo///bar == [/,/foo,/foo,/foo,/foo/bar]

Again what does /// mean?

  pathParents foo/../bar == [.,foo/../bar]
(what if foo doesn't exist and we wanted to create it?)

If foo doesn't exist then you can create it or raise an error

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


[Haskell-cafe] Re: File path programme

2005-01-25 Thread Krasimir Angelov
On Tue, 25 Jan 2005 13:32:29 +0200, Krasimir Angelov
[EMAIL PROTECTED] wrote:
  What about splitFileExt foo.bar.? (foo, bar.) or (foo.bar., )?
 
  The latter makes more sense to me, as an extension of the first case
  you give and splitting foo.tar.gz to (foo.tar, gz).
 
 I will take a look at this. I also don't know which case is more natural.

(foo.bar., ) is more natural for me because it eleminates the
special case for . and ... The original definition of splitFileExt
is:

splitFileExt :: FilePath - (String, String)
splitFileExt p =
  case pre of
[]  - (p, [])
(_:pre) - (reverse (pre++path), reverse suf)
  where
(fname,path) = break isPathSeparator (reverse p)
(suf,pre) | fname == . || fname == .. = (fname,)
  | otherwise = break (== '.') fname

The definition can be changed to:

splitFileExt :: FilePath - (String, String)
splitFileExt p =
  case break (== '.') fname of
(suf@(_:_),_:pre) - (reverse (pre++path), reverse suf)
_ - (p, [])
  where
(fname,path) = break isPathSeparator (reverse p)

The letter is simplier, it doesn't treat . and .. as special cases
and for it
splitFileExt foo.bar. == (foo.bar., )

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