[Haskell-cafe] Summer of Code idea: Haskell Web Toolkit

2012-03-07 Thread Dimitry Golubovsky
Hi,

Alejandro Serrano Mena wrote:

 My idea is to make a client-side Haskell Web Toolkit, in the spirit of
 Google Web Toolkit, which would allow to program in Haskell the client part
 of a web application, and would complement the web frameworks already
 existing for Haskell (such as Yesod and Snap).

http://www.haskell.org/haskellwiki/Haskell_web_toolkit - In memoriam ;)

Feel free to use these ideas. It would be nice if you could pick it up
and complete - I never did...

-- 
Dimitry Golubovsky

Anywhere on the Web

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


[Haskell-cafe] cpphs is missing from new Haskell.org server

2010-12-16 Thread Dimitry Golubovsky
Hi,

One more thing is missing after migration.

The link found on the cpphs package page at Hackage,

http://haskell.org/cpphs/

points to non-existing page.

Thanks.

-- 
Dimitry Golubovsky

Anywhere on the Web

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


[Haskell-cafe] Rendering of hask in new wiki (MSIE6)

2010-12-15 Thread Dimitry Golubovsky
Hi,

In MSIE6, hask tags are rendered like this (from the Monad_Transformers page):

transformers: provides the classes
MonadTrans
and
MonadIO
, as well as concrete monad transformers such as
StateT

... etc.

The Wiki source:

[http://hackage.haskell.org/package/transformers transformers]:
provides the classes haskMonadTrans/hask and haskMonadIO/hask,
as well as concrete monad transformers such as haskStateT/hask.

HTML (a small piece of it):

provides the classes div class=inline-codediv dir=ltr
style=text-align: left;div class=source-haskell
style=font-family: monospace;MonadTrans/div/div/div

Words MonadTrans, MonadIO, StateT etc are enclosed in hask tags.
They show up in monospace, each starting a new line. Is this only
MSIE6, or this is how it is supposed to render?

Thanks.

PS I am not attaching a screenshot to the mailing list; if anyone
needs to see it I'll send via personal e-mail.

-- 
Dimitry Golubovsky

Anywhere on the Web

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


[Haskell-cafe] Cabal and using a throw-away package database during distro package building

2010-11-05 Thread Dimitry Golubovsky
Magnus,

You might try Capri which operates Cabal-related stuff privately on a
local-to-project package database not touching global or user
databases.

http://hackage.haskell.org/package/capri

http://www.haskell.org/haskellwiki/Capri

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Is it possible to easily connect Haskell to JavaScript/JavaFX in the browser and use a browser as a Windows GUI? :)

2010-10-21 Thread Dimitry Golubovsky
Hi,

Atze Dijkstra wrote:


[skip]
but to provide a proper interface to XML/HTML DOM (see 
http://www.haskell.org/haskellwiki/Haskell_in_web_browser), or a GUI 
abstraction around it (perhaps a subset of wxHaskell?)
will take more work  time. I hope this can be done as part of a 
studentproject, or maybe picked up during a Hackathon.

I think a big portion of this task might be done using this package:

http://hackage.haskell.org/package/webidl

or its newer (not published on Hackage, but recommended) version split
into two (you need both):

http://code.haskell.org/yc2js/webidl/ -- lexer (FFI based),
parser, and a test program.*

http://code.haskell.org/yc2js/webidlsyn/-- just AST and pretty-printer

I must admit: I haven't touched this project for more than a year, and
have little plans to do so: it is up for grabs by anyone interested.

But if it can parse something like this:

http://es-operating-system.googlecode.com/svn/trunk/include/w3c/html5.idl

or

http://es-operating-system.googlecode.com/svn/trunk/include/w3c/svg.idl

it's likely still intact. Back in those days it could.

A WebIDL converter helps derive type signatures for DOM methods and
attributes (just like HSFFIG does this for C function prototypes).

Have fun ;) and don't hesitate to ask questions.

PS I'm glad that the idea lives on. With more GHC flrxibility on
backends than it was in 2006-2007, and with faster Javascript engines
in browsers, this can get a second life...

--
* the whole repo has to be downloaded: darcs get http://code.haskell.org/yc2js/

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] How to catch exception within the Get monad (the Binary package)

2010-09-07 Thread Dimitry Golubovsky
Hi,

Thanks to everybody who replied.

I see another solution: are there any hidden problems?

I found an interesting package, ChasingBottoms which contains a
function testing a value to be bottom and returning a Boolean (of
course it cannot be done without unsafePerformIO).

I borrowed the idea from that package, and wrote two functions:

unThrow :: (Exception e) = a - Either e a

unThrow a = unsafePerformIO $ (E.evaluate a = return . Right) `E.catch`
   (\e - return $ Left e)

-- or perhaps the right argument of catch could be just (return . Left)?

bm2mb :: a - Maybe a

bm2mb a = case unThrow a of
   Left (e::SomeException) - Nothing
   Right a - Just a

So, if there is a value inside the lazy list which is a bottom (binary
parse failure of the last received object in this case, catching any
possible exception) then the value can be converted to Nothing within
pure code, and then excluded from the result using catMaybes.

This solution seems to be working for me.

PS Maybe the way I am using the serialized data needs to be changed by
implementing some kind of an iterator over the binary stream, and then
by taking one object at a time and consuming it right there the
problem might be eliminated entirely...

Thanks again.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] How to catch exception within the Get monad (the Binary package)

2010-09-07 Thread Dimitry Golubovsky
Henning,

On Tue, Sep 7, 2010 at 12:51 PM, Henning Thielemann
schlepp...@henning-thielemann.de wrote:


 This solution looks very ugly to me. Catching 'error's is debugging, but
 parser failure is kind of exception handling. I guess, the errors you
 want to catch are caused by non-supported fail method, right? Can't you
 use a monad transformer like explicit-exception:Synchronous.Exception or
 transformers:ErrorT around the Binary parser?

Alexey already replied, but after looking at the way Binary processes
parser errors I came to the same conclusion: it is by design that it
falls hard when data cannot be deserialized (btw makes sense in many
cases, but not in mine).

I am beginning to realize that probably (de)serializing lazy
structures is not a good idea at all since such structure may be
consumed in pure code, and such parser errors are hidden inside, and
may fire at any moment. Any complications to the binary parser will
bring performance penalty. Or weird solutions like mine are needed.

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] How to catch exception within the Get monad (the Binary package)

2010-09-04 Thread Dimitry Golubovsky
Hi,

The following function* is supposed to decode a list of some
serialized objects following each other in a lazy Bytestring:

many :: Get a - Get [a]

many prs = many' [] where
  many' a = do
s - prs
r - isEmpty
case r of
  True - return (reverse a)
  False - many' (s:a)

prs is a parser to decode a single object.

If however something goes wrong, and prs fails, the whole function
fails (error is thrown). Since [a] (result of decoding) is a lazy
list, actual exception may be thrown at any moment the list is being
processed, and exception handler may not be properly set.

Is there any way to catch/detect failures inside the Get monad? It is
not an instance of MonadError, so catchError does not work.

Ideally, the function would keep decoding as long as it is possible,
and upon the first failure of the parser, return whatever has been
decoded.

Thanks.

---
* there is one intentional inaccuracy in this function: isEmpty is
called _after_ decoding is tried, so an empty ByteString would cause
parser failure and exception right away; this is used as a test case.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Haskell SVG path parser?

2010-05-24 Thread Dimitry Golubovsky
Hi,

Does there exist any Haskell package/library to parse the syntax of
SVG elements, esp. PATH?

That is, the syntax of the d attribute (e. g. M 100 100 L 300 100 L
200 300 z)?

Hackage doesn't seem to have any, and Google search yields very broad results.

Thanks.

PS It should not be hard to write such parser, I just don't want to
reivent the wheel ;)

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] Haskell SVG path parser?

2010-05-24 Thread Dimitry Golubovsky
Henning,

Thanks, I'll try to use your code.

BTW does it handle the syntax where repeated operation is omitted, per
SVG spec 8.3.1?

--
The command letter can be eliminated on subsequent commands if the
same command is used multiple times in a row (e.g., you can drop the
second L in M 100 200 L 200 100 L -100 -200 and use M 100 200 L
200 100 -100 -200 instead).
--

see http://www.w3.org/TR/SVG11/paths.html#PathDataGeneralInformation

On Mon, May 24, 2010 at 10:43 AM, Henning Thielemann
lemm...@henning-thielemann.de wrote:

[skip]
 Once I wrote such a function in order to convert an SVG path to PDF. See
 parsePath in
  http://code.haskell.org/~thielema/internetmarke/src/Main.hs




-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] Haskell SVG path parser?

2010-05-24 Thread Dimitry Golubovsky
Tillmann,

OK, I see: your code parses the glyph element which contains the
same kind of path definition that the path element does.

I think your code would be helpful for me as well.

And I think I'll use the same xml package to read in the SVG file (I
was thinking about this package earlier, and your code has a good
example of using it).

Thank you.

On Mon, May 24, 2010 at 12:20 PM, Tillmann Vogt
tillmann.v...@rwth-aachen.de wrote:

[skip]
 more fully. I have spent quite some time on a tricky function
 commandsToPoints in ReadFont.hs which is about parsing the d field and
 translating it into outline points. Are you looking for something like that?


 That is, the syntax of the d attribute (e. g. M 100 100 L 300 100 L
 200 300 z)?

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Number of CPUs/cores?

2010-04-27 Thread Dimitry Golubovsky
Hi,

Does there exist a Haskell library function that returns the number of
CPUs/cores (in portable way)  on a computer where the program calling
it runs?

Thanks.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] Number of CPUs/cores?

2010-04-27 Thread Dimitry Golubovsky
OK, makes sense.

Thank you.

On Tue, Apr 27, 2010 at 10:58 AM, Michael Lesniak
mlesn...@uni-kassel.de wrote:

[skip]
 numCapabilities, I think.


-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] GHC core packages: same core?

2009-10-13 Thread Dimitry Golubovsky
Max,

Thanks for the explanation. So, the extcore library is expected to
match the spec in
http://www.haskell.org/ghc/docs/6.10.4/html/ext-core/core.pdf and the
core itself can be produced with -fext-core, correct? I think it might
be interesting for people working on alternative backends (inlcuding
myself).

On Tue, Oct 13, 2009 at 4:53 PM, Max Bolingbroke
batterseapo...@hotmail.com wrote:
[skip]

 extcore is a library that parses external Core, which is an
 alternative format intended to be stable and hence a suitable target
 for consumption by non-GHC tooling. You can have GHC output external
 core instead of machine code / C. I don't believe this is widely used
 yet.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Any working example of using genericserialize?

2009-09-30 Thread Dimitry Golubovsky
Hi,

I am trying to use the genericserialize package
(http://hackage.haskell.org/package/genericserialize) but cannot get
things working.

While
buildList (sexpSerialize [1, 2, 3])

yields

(1 2 3)

as it might be expected, I cannot deserialize it back:

*Main (withList sexpDeserialize $ buildList (sexpSerialize [1, 2,
3])) :: Maybe [Integer]
Nothing

or

*Main (withList sexpDeserialize $ buildList (sexpSerialize [1, 2,
3])) :: Maybe [Int]
Nothing

while I would expect at least one of these cases result in Just [1, 2, 3]

What am I missing?

Thanks.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] Any generic serializer to String? was: Any working example of using genericserialize?

2009-09-30 Thread Dimitry Golubovsky
Hi,

On 9/30/09, Jason Dagit da...@codersbase.com wrote:

[skip]

 Seems like using withList is wrong or the deserializer is simply buggy.  It
 certainly doesn't work the way I would expect SExp reading to work.  I also
 notice from reading the source on hackage that there may not be any tests
 for this package and it is a 0.1 release.  I'd contact the author, as it
 seems there is a deficiency in the documentation or a bug in the
 implementation.

Thanks Jason for trying this. The genericserialize package is probably
not finished yet.

What else exists that could be used to serialize in generic way (i.
e., anything that is an instance of Data and Typeable) into a string?
It does not need to be very efficient as structures to be serialized
are not huge (but may be pretty complex), and serialization is a part
of an utility not to be used frequently. It only needs to just work.

One thing I thought of was to serialize to JSON (there is a generic
serializer in one of packages although I did not test it other way)
which has higher overhead than S-expressions though.

Any other thoughts?

Thanks.

-- 
Dimitry Golubovsky

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


Re: Re[2]: [Haskell-cafe] Any generic serializer to String? was: Any working example of using genericserialize?

2009-09-30 Thread Dimitry Golubovsky
Bulat,

OK, gread/gshow seem to be like the basis primitives. If they work
properly, then it is what is needed.

Thanks.

On 9/30/09, Bulat Ziganshin bulat.zigans...@gmail.com wrote:
 Hello Max,

 Wednesday, September 30, 2009, 5:53:37 PM, you wrote:

 afaik, SYB just provides gshow/gread functions what serialize any Data
 instance to String

  FWIW, writing your own is not hard. I wrote a serializer for GHC using
  Data in less than 150 (simple) LOC. It produces [Word8], but producing
  strings instead would be easy. You can check out the code here:

  http://darcs.haskell.org/ghc/compiler/utils/Serialized.hs

  Cheers,
  Max
[skip]
-- 
Dimitry Golubovsky

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


Re: Re[2]: [Haskell-cafe] Any generic serializer to String? was: Any working example of using genericserialize?

2009-09-30 Thread Dimitry Golubovsky
OK, I got it to work with gread/gshow.

However I have noticed this:

*Main (gread $ gshow $ FuncExpr 0 [] (EmptyStmt 0)) :: [(Expression
Int, String)]
[(FuncExpr 0 [] (EmptyStmt 0),)]

vs.

*Main (gread $ gshow $ FuncExpr () [] (EmptyStmt ())) :: [(Expression
(), String)]
[]

Or even narrower:

*Main (gread $ gshow 1)::[(Int, String)]
[(1,)]

vs.

*Main (gread $ gshow ())::[((), String)]
[]

that is, the unit type does not work well with gread/gshow, likely
because inner parentheses are not parsed as a constructor.

*Main gshow ()
(())

Is this a known bug?

Thanks.

On Wed, Sep 30, 2009 at 10:19 AM, Dimitry Golubovsky
golubov...@gmail.com wrote:
 Bulat,

 OK, gread/gshow seem to be like the basis primitives. If they work
 properly, then it is what is needed.

 Thanks.

 On 9/30/09, Bulat Ziganshin bulat.zigans...@gmail.com wrote:
 Hello Max,

 Wednesday, September 30, 2009, 5:53:37 PM, you wrote:

 afaik, SYB just provides gshow/gread functions what serialize any Data
 instance to String

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Externally derive instance of Data?

2009-09-11 Thread Dimitry Golubovsky
Hi,

Given a datatype defined somewhere in a third-party package, without
deriving (Data) specified.

Is it possible, in my module which is importing that datatype from
that package, to auto-derive instance of Data for the said datatype?
The goal is not to recompile the package just because an auto-derived
instance is needed.

Or no way other than to recompile the package?

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Re: HSH and IO ()

2009-06-13 Thread Dimitry Golubovsky
John,

Thanks for the reply.

In this case, would the body of my function run in a separate thread
via forkProcess (that's what is needed, maybe I didn't make it clear)?

In my previous project, I had to do like this (probably not very
portable, at least requires System.Posix):


  (fd1, fd2) - createPipe
  hscfd - fileToFd hscFile
  hscpid - forkProcess $ redirFd fd1 0 $
  redirFd fd2 (-1) $
  redirFd hscfd 1 $
  hsffigMain (fromJust $ gccPath dopt)
 (inclDirs dopt) minusD
  gccpid - forkProcess $ redirFd fd2 1 $
  executeFile (fromJust $ gccPath dopt)
  False
  ([-E, -dD] ++
   minusI ++ minusD ++
   [incFile])
  Nothing
  closeFd hscfd
  closeFd fd1
  closeFd fd2
  gccrt - getProcessStatus True False gccpid
  hscrt - getProcessStatus True False hscpid



where hscpid corresponds to a process that runs a Haskell function
(hsffigMain :: a - b - c - IO ()) defined within the same program,
and gccpid runs an external program (gcc), and they are piped
together. I am trying to avoid writing this mess using HSH.

I'm just trying to find out whether this was already done. If not,
what is the best way to write the above to be integrated into HSH (I'd
be glad to contribute).

Thank you.

On Sat, Jun 13, 2009 at 12:46 AM, John Goerzenjgoer...@complete.org wrote:

 You can replace it with a function that can take any Channel, and
 produce a result as a Channel of one particular sort.  In particular,
 this instance:

 instance ShellCommand (Channel - IO Channel) where


-- 
Dimitry Golubovsky

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


[Haskell-cafe] Re: HSH and IO ()

2009-06-13 Thread Dimitry Golubovsky
John,

On Sat, Jun 13, 2009 at 7:01 PM, John Goerzenjgoer...@complete.org wrote:
 where hscpid corresponds to a process that runs a Haskell function
 (hsffigMain :: a - b - c - IO ()) defined within the same program,
 and gccpid runs an external program (gcc), and they are piped
 together. I am trying to avoid writing this mess using HSH.

 OK, so I should have read more before starting to reply.  But why are
 you writing to me about HSH if you're trying to *avoid* HSH?  I'm confused.

Sorry, I should have written by using; Jason made the right
correction. I thought that forkProcess-based shell commands existed in
HSH thus I could avoid all these low-level manipulations with handles
that are usually done in C programming.

 Integraing hsffigMain into HSH directly will be difficult because it
 apparently already has its notions about where its input and output come
 from; the fact that its return type is IO () implies that its output

I'll try to write a wrapper for a forked process inside a Channel -
IO Channel typed function.

 Your best bet is to make this a separate executable.

That's not what was intended, but now I see the situation more clearly.

Thanks for the explanation. If I get any working code, I'll post a
link on the list.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] HSH and IO ()

2009-06-12 Thread Dimitry Golubovsky
John  all,

I use HSH in my project where several external programs and Haskell
functions need to be piped together: HSH is of great help here.

I however came across the situation when one of pipe-connected
functions has signature IO (), yet it reads from stdin* and writes to
stdout.

The documentation mentions instance ShellCommand (Handle - Handle -
IO ()) which could be of some help, but in the latest version of HSH
on Hackage this instance is commented out.

What was the reason of doing that? Is this to be expected in the
upcoming versions?

Thank you.


* I modelled that by calling getContents, but the actual program will
call a foreign library that contains a C function that reads from
stdin (that is, FILE *), and that cannot be changed easily.


-- 
Dimitry Golubovsky

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


[Haskell-cafe] hsffig and duplicate typedef declarations

2009-05-14 Thread Dimitry Golubovsky
Dean,

I am not sure how HSFFIG would deal with duplicate typedefs (I'm
afraid you get error from gcc when processing hsc2hs output).

In case you haven't seen this, I put a repo for HSFFIG here recently:

http://code.haskell.org/hsffig/

Before running cabal install run make at the toplevel of the repo first.

I have fixed some glitches recently, and adjusted both hsffig and
ffipkg to work with contemporary GHC and Cabal (at least 1.6.0.x).

I'd be glad to get any feedback on HSFFIG. E-mail me to golubovsky at
gmail dot com.

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Few Alex questions

2009-04-30 Thread Dimitry Golubovsky
Hi,

Q1: I am trying to create an Alex equivalent of the following flex file:

http://code.haskell.org/yc2js/es-idl/lexer.ll (lexer for Web IDL which
is a dialect of OMG IDL)

I haven't been able to find Alex equivalent for the following line:

PoundSign   ^{WhiteSpace}*#

that is any amount of whitespace at the beginning of line followed by '#'

I defined a @WhiteSpace macro some place earlier, but Alex gives me
parser error on the line I created:

@PoundSign =  ^...@whitespace*#

in the position 28 that is position of '@', next to caret, that is,
caret is not recognized by Alex.

Can beginning of line (caret) be recognized by Alex?

Q2: The original line says:

MultiLineComment\/\*(([^*])|(\*[^/]))*\*\/

basically same as comments in C or Java.

I had to prefix star and slash even within square brackets with
backslashes to make it compile.

So I got:

@MultiLineComment  =  \/\*(([^\*])|(\*[^\/]))*\*\/

Is this correct understanding that if we want to match any character
except for an asterisk, then Alex would like to see [^\*] rather than
[^*]? And [^\/] rather than [^/]?

Or would it be better to use a hex code for the asterisk and slash?

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread Dimitry Golubovsky
Jason and everybody interested,

Please check out a package I recently (just by coincidence: I haven't
seen this topic on the list until after I uploaded it) uploaded to
Hackage:

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

This is a basic monadic interface to Javascript code generator (based
on WebBits), providing sort of a macro (like in macro-assembler)
facility. HJScript was used as a (sort of) prototype, but I chose
slightly different notation for EDSL.

From here, I think two directions may be taken:

1. Some techniques are described in the GRIN thesis [1] how to convert
a Haskell core to monadic form. These may be explored for this case.

2. Similarly to how the Web Consortium defined interfaces to its
components using IDL *, Haskell modules converted to Javascript may
expose their interfaces same way, thus providing a basis for a
reusable component-based approach.

Any discussions and suggestions are welcome.

From my own impressions, EDSL approach is better for interactive/AJAX
parts of a Javascript application, as translation of non-strict
evaluation (like it was done in the Yhc/Javascript project) just
causes a lot of code generated, and does not improve the user
interaction performance at all. For other (internal) components,
translation from Haskell may be more appropriate, just to be able to
reuse the existing libraries.

One of experiments with Yhc involved a user-exposed form, and a parser
to validate user's input. With this hybrid approach, the user
interface part might be coded using an EDSL, and the parser could be
translated from Haskell core. An IDL might be generated for the parser
interface, thus making the parser module a reusable component. These
are of course just thoughts and ideas for now.


* See the DOM package: this is an auto-generated Haskel approximation
of IDL specs provided for the basic DOM components.

[1] http://www.cs.chalmers.se/~boquist/phd/index.html
[2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/DOM-2.0.1

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-26 Thread Dimitry Golubovsky
John wrote:

 I can't speak for Jason, but for me, this is not very useful. I don't
 want to write in a Haskell DSL, I want to write in Haskell. And not
 the whole program, either, just the parts that really lend themselves
 to functional programming (parsers, numeric computations, code
 generators, various algorithms).

What I presented is of course not a complete solution; this is just a
tool to construct Javascript expressions in haskellized type-safe
form.

What I also mentioned: this monadic form may be an end-point for some
other conversion, like GRIN. This answers the question how to
translate a true Haskell program (like a parser) into Javascript (or a
similar language). There are some experimental compilers with GRIN
backends, plus I did my own experiments with GRIN that gave me some
ideas.

So I would just look at it as a starting point of some new family of
tools which hopefully will end up opening possibility to translate
Haskell things to Javascript.

PS For now I am more concerned with the IDL part of it, but any
suggestions on GRIN are welcome.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] How to get program command line arguments in Unicode-aware way (Unix/Linux)?

2009-03-11 Thread Dimitry Golubovsky
Hi,

I am trying to process command line arguments that may contain Unicode
(cyrillic in this example) characters.

The standard GHC's getArgs seems to pass whatever was obtained from
the underlying C library
without any regard to encoding, e. g the following program (testarg.hs):

module Main where

import System.Environment

main = do
  x - getArgs
  mapM (putStrLn . show) x

being invoked (ghc 6.10.1)

runghc testarg -T 'привет'

prints the following:

-T
\208\191\209\128\208\184\208\178\208\181\209\130

(not correct, all bytes were passed without proper encoding)

Is there any way to get program arguments in GHC Unicode-aware? Or at
least assuming that they are always in UTF-8?
Something like System.IO.UTF8, but for command line arguments?

Thanks.

PS: BTW  runhugs testarg -T 'привет' prints:

-T
\1087\1088\1080\1074\1077\1090

which is correct.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Automatic instance constraints derivation: how?

2008-12-19 Thread Dimitry Golubovsky
Hi,

I am trying to understand, why do I need to place constraints with
class instance declaration while all the information seems to be
already available to the compiler.

I have placed the code in question here:

http://codepad.org/Akew0p2t

so anybody can play with it.

The code tries to model evaluation of GRIN-style thunks using Haskell
type classes instead of tag-based pattern matching, as in the GRIN
papers. That is, a thunk is represented as a datatype like

data Ffun a b c = Ffun a b c, and there is some eval function which
being applied to such data results in the call fun a b c. Such eval
function is a method of class Eval:

class Eval a b | a - b where
 eval :: (Monad m) = a - m b

which means that thunks of some type (a) evaluate to values of some
dependent type (b).

The code is monadic because GRIN is a monad, so the code looks similar to GRIN.

The ultimate goal is to make GRIN code understandable by Haskell compiler.

Everything is fine with simple types like Int, that is instance
Eval Int Int means that Int (and Char, and Bool) do not need in fact
evaluation at all.

instance Eval Int Int where
  eval = return

Everything is fine with thunks encoding calls to primitives. See
instances for FADD and FSUB. All type information for primitives
(primPlusInt, primMinusInt) is specified in the code.

Then, a function fun is defined that calls the primitives. The
main function illustrates its use, and everything works as expected,
as output shows.

But when I tried to define a thunk for fun (instance for Ffun) I was
only able to do that with all constraints on its parameters explicitly
set.

OTOH, even if I comment out the instance Eval for Ffun, and load the
code in Hugs (or GHCi, doesn't matter) then type signature of fun is
correctly derived by the compiler.

If I try to define instance for Ffun like this:

instance (Eval x x) = Eval (Ffun a b c) x where
  eval (Ffun a b c) = fun a b c

meaning only the fact that result of the function fun will be like
Int or Bool - evaluates to itself, and we don't care about the types
of arguments, I cannot use forall x. with instance declaration, so I
have to say something about x.

I get the error (Hugs):

Error occurred
ERROR line 51 - Instance is more general than a dependency allows
*** Instance : Eval (Ffun a b c) d
*** For class: Eval a b
*** Under dependency : a - b

So, is there a way to define such an instance  for a thunk without any
constraints? Wouldn't it be reasonable to expect that

eval (Ffun a b c) = fun a b c

would allow the compiler to retrieve constraints on a, b, c from those
already known for the called function?

Thanks.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] CouchDB module in Yhc source tree: clarification, and small problems with other packages

2008-08-21 Thread Dimitry Golubovsky
Don  All,

On 8/21/08, Don Stewart [EMAIL PROTECTED] wrote:

 I think the best result here would be to put a CouchDB binding
 on hackage.

 Is anyone in a position to do this?

As for myself, honestly, I did not plan to do this at this time as I
am busy with other stuff (Yhc Core conversion). I'd be glad to help
anyone who is willing to put CouchDB interface on Hackage.

I'd like to note though that this may be a bit premature at the
moment. CouchDB has been going through significant redevelopment
within Apache Incubator (I am not a developer, but just watch
silently), and what is available within the Yhc source tree may not
work properly with the current CouchDB: it was for 0.7.x while they
have 0.8.x in the incubator.

So I would wait for graduation of CouchDB from the incubator, or at
least checked with its core developers regarding API stability.

Besides, the CouchDB interface in question was written only to satisfy
the needs of the Yhc Web Service and may be missing some pieces,
although it may be good for a starting point.

Thank you.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Lines of code metrics

2008-08-21 Thread Dimitry Golubovsky
Hi,

Greg Fitzgerald wrote:

Does anyone know of a good case study comparing a project written in C
versus one written in Haskell?  I'm mostly looking for a comparison of lines
of code, but any other metric, such as time to market and code quality
metrics could also be

Just curious, has anybody tried to apply Halstead's code metrics (see
e. g. http://www.sei.cmu.edu/str/descriptions/halstead_body.html), but
there is a 70s' book titled Elements of Software Science to Haskell
and other functional languages vs. C and other imperative languages?

I myself played with these calculations in late 80s trying to estimate
code quality of Pascal programs on PDP-11, but that was a pain to
count functions' operands properly as they might come from global
variables. Application of these formulas to functional languages might
be mich cleaner, so has anybody tried?

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] External query interface to HackageDB?

2008-06-14 Thread Dimitry Golubovsky
Hi,

Is there any way to query the latest version of a particular package
stored on Hackage, that was successfully built?

I mean, not _how_ to do that (I have some ideas that I have to
download directory listings, looking for failure logs, etc.), but is
there any tool or interface already available that does similar
things?

Unfortunately, tarfiles provided on Hackage (like 00-index.tar.gz) do
not help, e. g. BerkeleyDB failed to build in all three versions, yet
its all cabal files are included in the tarball:

tar tvf 00-index.tar.gz
...
-rw-r--r-- www-data/www-data  1055 2007-04-06 13:03
./BerkeleyDB/0.1/BerkeleyDB.cabal
-rw-r--r-- www-data/www-data  1061 2007-04-06 16:59
./BerkeleyDB/0.2/BerkeleyDB.cabal
-rw-rw-r-- www-data/www-data  1236 2008-01-11 14:42
./BerkeleyDB/0.3/BerkeleyDB.cabal

I remember, in the past, HackageDB was expected to become a database
of some sort: is there any database-like backend that would accept
queries, other than just parsing Apache dir listings?

My final goal, given some master-list of package names, to be able to
retrieve latest succesfully built (not just uploaded) releases from
Hackage

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Parsec, updateState, and failure

2008-05-31 Thread Dimitry Golubovsky
Hi,

If a parser which updated user state fails, will such update be reverted?

Suppose we have two parsers combined with |

p = p1 | p2

p1 has the following:

p1 = try $ do
 ... -- getting something from the input stream
 updateState (\st - ...) -- updated state based on what gotten from the input
 x - p3 -- p3 should see updated state and return something
 updateState (\st - ...) -- updated state again (if p3 succeeded)
 return x

If p3 fails, p1 fails too (second updateState will not be reached).
But what will p2 (tried next) see in the user state? Will it be state
after the first updateState, or will failure of p1 roll the update
back?

Is there any bracket- or try-catch-finally-like mechanism for Parsec?

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Upd: Parsec, updateState, and failure

2008-05-31 Thread Dimitry Golubovsky
Hi,

So far, I figured it out like this:

updateState ...
mbx - (p3 = return . Just) | (return Nothing)
updateState ...
case mbx of
  Just x - return x
  Nothing - pzero

but this seems a bit clumsy - is there a more elegant solution?

-- Forwarded message --
From: Dimitry Golubovsky [EMAIL PROTECTED]
Date: Sat, May 31, 2008 at 10:12 AM
Subject: Parsec, updateState, and failure
To: haskell haskell-cafe@haskell.org


Hi,

If a parser which updated user state fails, will such update be reverted?

Suppose we have two parsers combined with |

p = p1 | p2

p1 has the following:

p1 = try $ do
 ... -- getting something from the input stream
 updateState (\st - ...) -- updated state based on what gotten from the input
 x - p3 -- p3 should see updated state and return something
 updateState (\st - ...) -- updated state again (if p3 succeeded)
 return x

If p3 fails, p1 fails too (second updateState will not be reached).
But what will p2 (tried next) see in the user state? Will it be state
after the first updateState, or will failure of p1 roll the update
back?

Is there any bracket- or try-catch-finally-like mechanism for Parsec?

Thanks.

--
Dimitry Golubovsky

Anywhere on the Web



-- 
Dimitry Golubovsky

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


[Haskell-cafe] Experimental compilation of Haskell to Erlang

2008-05-18 Thread Dimitry Golubovsky
Hi,

Some time ago I became interested in compilation of Haskell programs
(via Yhc Core) to Erlang to be able to run Haskell code in Erlang
environment.

This experiment seems to have been successful, so I'd like to publish
its results for everyone to read and criticize.

Results of the experiment are described in this Haskell Wiki article:

http://www.haskell.org/haskellwiki/Yhc/Erlang/Proof_of_concept

Any feedback is appreciated.

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Haskell in Web Browser: draft tutorial

2008-03-25 Thread Dimitry Golubovsky
Hi,

I have written a draft of the tutorial on Haskell programming for
client side of Web applications (related to Yhc/Javascript backend):

http://www.haskell.org/haskellwiki/Haskell_in_web_browser

Any feedback, suggestions, and additions (like your own code examples)
are welcome.

Thanks.

PS This part of the Tutorial does not cover XMLHTTP programming; this
is yet to be written, but there is Haddock documentation under
http://www.golubovsky.org:5984/_utils/yhcws/index.html

Yhc web service online (where you may experiment with your code):

http://www.golubovsky.org:5984/static/yhcws/MainGUI.html

Users guide:

http://www.haskell.org/haskellwiki/Yhc_web_service

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Hello World in Haskell for web browser

2008-03-06 Thread Dimitry Golubovsky
Hi,

I have noticed that some people tried to compile a traditional Haskell
program using IO monad to show Hello World using Yhc Web Service.

Thanks for your interest, and here are some clues.

The programming paradigm chosen for Haskell Web programming is not
based on monads. It is based on CPS-style calls to DOM functions by
Haskell code compiled to Javascript. Further on, additional layers may
stack up (such as Haskell Web Toolkit) to provide more convenient
APIs, but DOM is the basis.

So here is an example of Hello World program written this way:

-- begin pasteable code --

module HelloWorldDOM where

import CPS
import UnsafeJS
import CDOM.Level2.DomUtils
import DOM.Level2.Dom
import DOM.Level2.Html2
import DOM.Level2.HTMLElement
import DOM.Level2.HTMLDivElement

main = getHTMLDocument $ \doc -
   documentBody doc $ \body -
   mkText doc Hello World $ \txt -
   mkDiv doc $ \dv -
   addChild txt dv $ \_ -
   addChild dv body $ id

-- end   pasteable code --

The meaning of this:
  * get reference to the HTML document node first (it is the parent of
everything),
  * extract the BODY tag node, create at text element with Hello World,
  * create a DIV tag node,
  * insert the text node into div,
  * insert div into body

Or, same in HTML:

html
  body
div
  Hello World
/div
  /body
/html

but filled in dynamically.

Using Haskell Web Toolkit API, the same may be expressed in more
compact fashion:

-- begin pasteable code --

module HelloWorldHsWTK where

import DOM.Level2.HTMLDivElement
import Graphics.UI.HsWTK

main = docBodyC (mkDiv | textP Hello World)

-- end   pasteable code --

Here, docBodyC is roughly equivalent of the first two DOM calls, mkDiv
is same as above, | means insert into container, and textP is a
wrapper around mkText.

Earlier, I posted the link to Haddock-generated documentation which
also includes the Haskell DOM API. Here it is again:

http://www.golubovsky.org:5984/_utils/yhcws/index.html

Hopefully this example along with the documentation provided helps
shed some light on Haskell Web programming techniques.

Feel free to ask questions.

Thanks.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] Re: [Yhc] Yhc Web Service quietly opened for public testing

2008-03-05 Thread Dimitry Golubovsky
Justin,

On 3/5/08, Justin Bailey [EMAIL PROTECTED] wrote:

 Does this take a Haskell program and compile it to JavaScript? That's
 pretty amazing.

Yes, exactly. The two user interface programs, MainGUI and NewEntry
were written in Haskell and compiled into Javascript by the same
tools. With minimal changes they are pasteable/compilable by this
service as well. See
http://haskell.org/pipermail/yhc/2008-March/001194.html - anybody
wants to try?

I suggested this relatively simple program as a test example just to
make sure results would be similar for everybody. More complex issues
may arise e. g. with CSS interpreted differently by FF vs MSIE; this
needs to work on in the future.

Thanks for your interest.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Haddock Documentation for Yhc Web Service available online

2008-03-05 Thread Dimitry Golubovsky
Hi,

I have regenerated Haddock documentation for Haskell modules included
into the Yhc Web Service.

http://www.golubovsky.org:5984/_utils/yhcws/index.html

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] CouchDB module in Yhc source tree: clarification, and small problems with other packages

2008-01-05 Thread Dimitry Golubovsky
Hi,

Don asked:

 Are we likely to see the couchdb bindings released as a standalone
 library for the wider community?

Let me explain a little bit why the CouchDB module appears in the Yhc repo.

As the next stage of the Yhc/Javascript project, I am trying to set up
a web service where people might upload some Haskell code (or
reference to such code, these details haven't been clarified yet), and
get it compiled by background Yhc/ycr2js batch job, returning a HTML
page with Javascript in response.

CouchDB was picked* as intermediate storage for this project.
Therefore an interface module was needed, so I wrote one. This module,
`Database.CouchDB' is not 100% finished; it was coded up to satisfy
the needs of the first utility I wrote, `cdbup' which is currently
capable of uploading a text (utf-8 expected) or a binary file as a
document attachment to CouchDB. So some functionality hasn't been
coded yet, although it will definitely be, as the project develops.

Regarding packaging, I hope I will eventually put it on Hackage, but
there are some problems with another packages which I'll try to
explain here, so maybe those packages' developers  suggest something.

1. Text.JSON. This module was picked from Jun Mukai's haskellnet
package (http://darcs.haskell.org/SoC/haskellnet/). One problem with
this package, it needs too many dependencies (while JSON module relies
only on Packrat parser). I had to extract the JSON module into Yhc
tree; can the haskellnet package be split somehow into orthogonal
sub-packages, and maybe one toplevel package which would pull all
parts together if used?

2. Text.JSON again. I had to change the pNumber function (parser for
numeric nodes) replacing the '1'..'9' digits range with '0' .. '9'.
Otherwise it did not handle JSON-encoded numbers equal to zero. I am
not sure I was 100% right, so perhaps some JSON experts here might
correct me.

3. Packrat parser does not seem to be packaged anywhere else, does it?

4. The dataenc package (http://code.haskell.org/dataenc/devo/) from
which I pulled the Codec.Binary.Base64 module. The package may need
some adjustment to GHC 6.8.x packages structure as only base listed
in build-depends does not seem to be enough: when building it, Cabal
complains for hidden packages such as collections (which I had to add
manually to the cabal file), etc. Is it some problem with my GHC
setup, or does just the dataenc.cabal need to be updated?

So, in order to get things done quicker, I pulled the said pieces from
their packages into Yhc tree. For packaging the CouchDB interface,
definitely these duplicates need to be removed.

Other packages that CouchDB relies upon, are**:

base, network, HTTP, filepath, base64-string, utf8-string

Thanks for the interest in CouchDB interface, and feel free to ask any
questions.

---
* before support form IBM/Apache was announced, but this recent
development definitely increases interest to CouchDB

** Just from the -package options I used to compile it; I may have
something omitted here.


-- 
Dimitry Golubovsky

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


[Haskell-cafe] problems building ycr2js

2007-11-25 Thread Dimitry Golubovsky
Hi,

This is my stuff, and I am of course willing to fix this to make more
compatible. I am not really deep into this shell hell  (that is,
used anything that worked for me not seeing much difference between
shells in e. g.  Archlinux vs. Ubuntu), but if there are any
suggestions what could be fixed (if at all) please let me know.

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] problems building ycr2js

2007-11-25 Thread Dimitry Golubovsky
Hi again,

I'm thinking: if this all is about a small file, addtags.idl which is
generated in some unusual way, I might just add it to the
distributable source tree, and then nobody would have had problems
with ${var:m:n} substitution.

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] problems building ycr2js (hopefully fixed)

2007-11-25 Thread Dimitry Golubovsky
Hi,

I have made the file `addtags.idl' part of the repo. Please do scons
update and see if it compiles.

PS If there are any other problems with Yhc/Javascript backend, please
CC me, [EMAIL PROTECTED]

Thanks

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Re: problems building ycr2js (hopefully fixed)

2007-11-25 Thread Dimitry Golubovsky
Thomas,

On Nov 25, 2007 5:50 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
 Thanks Dmitri, I also had to fix an issue with System.FilePath,
 there's a message about this on haskell cafe.

In fact, takeDirectory is the right replacement for getDirectory in
older FilePath. I have pushed this change too.

Thanks.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] How to abort a computation within Continuation Monad?

2007-11-21 Thread Dimitry Golubovsky
Hi,

I finally was able to write a function which grabs the remainder of
the computation in Cont monad and passes it to some function, in the
same time forcing the whole computation to finish by returning a final
value.

I am not sure what kind of wheel I have reinvented, but here it is:


-- Home-grown continuation delimiter function. Passes remainder of the
-- whole computation to a given function and forces the whole computation
-- to complete by returning a final value. Something similar to returning
-- a final value in plain CPS instead of invoking the continuation.
--  f: function which the remainder of the program will be passed to.
-- Remainder will not be evaluated.
--  r: final value of the whole computation that the latter will be
-- terminated with.

delimit f r = Cont $ \c - runCont (return 0) $ \a - f (runCont (return a) c) r


I have created a simple (pseudo) concurrency demo that runs in a web
browser, see the wiki page:

http://haskell.org/haskellwiki/Concurrency_demos/Haskell-Javascript_concurrency

Thanks.
-- 
Dimitry Golubovsky

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


[Haskell-cafe] How to abort a computation within Continuation Monad?

2007-11-19 Thread Dimitry Golubovsky
Hi,

I have been using plain non-monadic CPS for a while in my web-browser
related stuff. Now I am tempted to switch from plain CPS to
syntactically sweetened monadic style based on Continuation Monad, but
I feel stuck with one important issue that I need an advice on.

In plain CPS, I may write:

type CPS x y = (y - x) - x

a :: x

a = f1 x $ \r -
  case r of
foo1 - bar  -- of type x
foo2 - f2 r $ \p - ...  -- something finally evaluating to a
value of type x

So, if at any time I return a value of a final type (x) instead of
doing something with given continuation,
I abort/suspend the whole computation. This can happen at any function
call depth. I can also save the continuation reference in some
persistent place, to resume the remainder of computation later.

Now, I am trying to do the same with a Continuation Monad. But does
anything similar exist in this monad? callCC is not exactly what I
need because it only helps abort the inner computation, and what is
returned, is a monadic value, not a final value. Besides, callCC
defines a name of the function corresponding to the current
continuation, and in order to use it, this name should be visible.

If I have

callCC $ \exit - do
  foo
...

I cannot jump to `exit' from within foo unless `exit' is given to foo
as an argument.

Any suggestions?

Thanks.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] New demo/test program for Yhc Javascript backend

2007-11-18 Thread Dimitry Golubovsky
Bit,

On Nov 18, 2007 8:41 AM, Bit Connor [EMAIL PROTECTED] wrote:

 Safari 3.0.2 for windows gives an error though:

   Maximum call stack size exceeded.
   http://darcs.haskell.org/yhc/web/jsdemos/HsWTKDemo.html Line: 87

This  is in fact a huge progress for Safari ;) Year ago, Safari on Mac
gave some weird error message Type Error line 1.

See http://osdir.com/ml/lang.haskell.yhc/2006-11/msg00033.html

The problem is, I am not sure how it enumerates lines.

Lines around 87 (ran with pr -n):

   83   var consStr = function (s) {
   84 if (s.length == 0) {
   85   return new HSEOL ();
   86 } else {
   87   var hdc = mkChar (s.charCodeAt (0));
   88   return new HSCons (hdc, s.length  1 ? s.substring (1) :
consStr ());
   89 };
   90   };

Nothing suspicious because mkChar is a wrapper around the Number constructor.

Line 314:

  312   function NEG_D(a) {
  313 return -(exprEval(a));
  314   }

and so on.


 Sometimes it gives the same error but instead of line 87 with line
 314, and other times line 224 or 422

But does it at least display the widgets? Or do these errors appear as
you press buttons/type anything?


 Are you aware of this issue?

Now I am ;) But to me not being an expert in Safari, these error
messages do little help (or if at least I knew what actual lines they
meant)...

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] New demo/test program for Yhc Javascript backend

2007-11-16 Thread Dimitry Golubovsky
Hi,

For those of you who are interested in using Haskell in client-side
web application programming:

I have added a new demo/test program to this Wiki page (Does it leak?):

http://haskell.org/haskellwiki/Yhc/Javascript

This demo program shows some progress made since the first
announcement of Yhc Javascript backend (Core to Javascript converter)
was made about a year ago. Please test the demo for functionality and
memory leaks in various browsers. Your feedback is appreciated.

The demo program is self-contained (does not require any Haskell
libraries beyond those included with Yhc). There is a darcs repo:
http://www.golubovsky.org/repos/wsptest/ from which this demo program
along with Makefile can be obtained if anybody wants to play with the
code.

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] placing modules in the module hierarchy

2007-10-29 Thread Dimitry Golubovsky
Hi,

Long ago (back in 2001), there was a message in the Haskell mailing
list, archived e. g. here:

http://www.mail-archive.com/[EMAIL PROTECTED]/msg08187.html

and what it refers to is here:

http://www.cs.york.ac.uk/fp/libraries/layout.html

which goes for Graphics.UI.  etc

I used this approach in my script to cabalize Fudgets: everything was
placed below Graphics.UI.Fudgets (original Fudgets library used
plain module space).

I am currently working on another stuff related to Haskell GUI for web
browser, and us the same approach: everything goes under
Graphics.UI.library name

So, I think, despite this creates longer paths in the hierarchy, the
more specialized the stuff is, the deeper in the hierarchy it should
be pushed.

Slightly off topic, this is IMHO the same problem that we have in
Linux packages/filesystem layout: every package containing binaries,
places them into say /usr/bin. Then, if the two packages have a binary
with the same name, this leads to conflict (HSSFFIG has a program
named splitter. Another package in Debian also had a binary with the
same name. they conflicted. To resolve it' I'd have to rename my
binary to say hsffig-splitter. Should every package be installed into
its own subtree, such conflicts wouldn't arise). So, to my personal
opinion (which is in agreement with the proposal mentioned) each
package has to have its own tree not crossing with other packages'
tree.

So, I'd suggest for the Grapefruit library: whatever is specific to
this library, goes under Graphics.UI.Grapefruit. Whatever may be
commonly used elsewhere (say some useful data structures) might go
under Data. So, if FRP signals are usable outside the Grapefruit,
they might go to Control.

Thanks.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Haskell-cafe] Haskell and a new web developement mailinglist?

2007-03-20 Thread Dimitry Golubovsky

Marco Weber wrote:


I've been talking to Chris Eidhof the last days and we'd like to suggest adding
another specialized haskell mailinglist: Haskell and web developement.


I support the idea to have such a mailing list.

Thanks.

--
Dimitry Golubovsky

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


[Haskell-cafe] Haskell source transformer?

2006-11-29 Thread Dimitry Golubovsky

Hi,

In order to automatize the creation of W3C DOM typesafe wrapper (this
is needed for my Haskell-Javascript stuff) I am processing the OMG
IDL files that contain interface definitions for DOM methods and
attributes with HDirect.

It works in general (for some reason it didn't like boolean type, so
I used a preprocessor to redefine it as Boolean), and outputs some
Haskell code full of foreign calls, yet it contains what I need: type
signatures.

For example, for the method appendChild it outputs:

appendChild :: Node a1
   - Node a0
   - Prelude.IO (Node ())
appendChild newChild iptr =
 do
   o_appendChild - Com.invokeIt (\ methPtr iptr -
Foreign.ForeignPtr.withForeignPtr newChild (\ new
   unmarshallNode o_appendChild

(above lines of code may be truncated, they are just for illustration)

This is almost it, but I need to replace the return type (using the JS
monad instead of IO), and replace the method implementation with
something else, based on unsafeJS.

In some other cases I may need to modify type declarations, etc.

I know there is a Haskell syntax parser around (maybe, more than one).
Does anybody know of any utility based on such parser that does things
I need, or rather a library on top of the parser? I just would like to
avoid reinventing the wheel.

Last thing I want to do is to change sources of HDirect.

Thanks.

--
Dimitry Golubovsky

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


[Haskell-cafe] YCR2JS Programmers Guide Draft available

2006-11-22 Thread Dimitry Golubovsky

Hi,

I have finished typing in the draft of low-level programming guide for
Yhc Core to Javascript converter. Everyone interested in future use of
this tool is encouraged to read and review the Guide. Its purpose is
to give some ideas about interaction of Haskell programs converted
into Javascript with a web browser on the lowest possible level,
without application frameworks and support libraries  (just because
these haven't been developed).

Any feedback and ideas are appreciated.

The document is located at:

http://haskell.org/haskellwiki/Yhc/Javascript/Programmers_guide

Thanks.

--
Dimitry Golubovsky

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


[Haskell-cafe] A possible use for HSFFIG (FFIPKG) was USB Drivers in Haskell

2006-08-25 Thread Dimitry Golubovsky

Bjorn Bringert wrote:


For cross-platform USB drivers, you may want to have a look at libusb
[1]. I have only used it under Linux, but it seems to support Linux,
*BSD and OS X. There also seems to be a win32 port [2]. A Haskell
binding to libusb would be very welcome.


I'm just wondering, would FFIPKG or HSFFIG help out? I just looked at
usb.h, and it does not seem to contain anything that would break
HSFFIG (mainly C functions that take/return structures rather than
pointers to structures, do).

I am not very much interested personally in interfacing USB, but if
anybody is, feel free to try FFIPKG out and ask questions.

PS Sorry for such self-advertising, but I believe that this tool
could be helpful at least for prototyping bindings, so I'd appreciate
any feedback.

--
Dimitry Golubovsky

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


[Haskell-cafe] [Haskell] AJAX applications in Haskell

2006-08-10 Thread Dimitry Golubovsky

Looks like the discussion is continuing in the Cafe, so I am reposting it here.

Hi,

Pasqualino 'Titto' Assini wrote:

===

Assuming that the balance is positive, this naturally raises the question:
why not doing the same generate Javascript/Ajax application code to
run in browser - DMG with our favourite language?

This would require to:

- Retarget one of the existing Haskell compilers to generate JavaScript
(other possible targets would be Flash or higher level UI languages such as
OpenLaszlo that in turn compiles down to either Flash or JavaScript/HTML)

===

Joel Björnson wrote:

===

I am currently working on a Google Summer of Code project relating to some
of this...
The project is more or less bound to Haskell Server Pages (
http://www.cs.chalmers.se/~d00nibro/hsp/),
enabling JavaScript code generation. The main difference compared to the
Google Web Toolkit approach
is that there are no special compiler magic added for compiling directly
into JavaScript.

===

Looks like the idea is picked up by more and more people ;) I saw some
notes on this (generation of Javascript from Haskell source) in Jared
Updike's blog, and I got this idea myself independently from Jared in
about the same time.

I am trying to add some code to nhc98 (contrary to GHC its code is
much smaller and better observable) to generate Javascript at the same
time when STG tree is converted into bytecodes*. I am in the very
beginning though, so I cannot show any results.

OTOH I do not feel like I have a lot of time to dedicate to this, so
if someone else is working on this, could we team up (possibly for a
different (if shown better) approach because one I chose is still
questionable optimization-wise, but generation of Javascript from
bytecodes does not seem better to me at the time)?


--
* Work in progress may be observed at

http://www.golubovsky.org/repos/nhc98/

in particular in
http://www.golubovsky.org/repos/nhc98/src/compiler98/STGJcode.hs

but at the moment there is virtually nothing done.

--
Dimitry Golubovsky

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


[Haskell-cafe] FFI Wiki Page (was: FFI question)

2006-02-09 Thread Dimitry Golubovsky
Bulat wrote:

 we need to establish FFI
 page on the wiki and give at least links to all this packages and
 small info about using FFI with ghc/hugs

There is such a page (to be more precise, a section of a page):

http://haskell.org/hawiki/LibrariesAndTools

section FFI Preprocessors

Also there are http://haskell.org/hawiki/FfiCookbook and
http://haskell.org/hawiki/FfiTutorial pages.

--
Dimitry Golubovsky

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


[Haskell-cafe] How to redirect a handle...

2006-01-18 Thread Dimitry Golubovsky
Thanks everybody who answered.

Indeed, forkProcess is something I completely overlooked...

--
Dimitry Golubovsky

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


[Haskell-cafe] XML Schema for Haskell parsing?

2005-12-19 Thread Dimitry Golubovsky
GCCXML defines some XML schema for the results of a C(++) program
parsing. Does there exist any agreed-upon XML schema to represent the
results of Haskell program parsing?

Thanks.

--
Dimitry Golubovsky

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


Re: [Haskell-cafe] Haskell GUI on top of Xlib?

2005-11-28 Thread Dimitry Golubovsky

Einar,

Are you talking about packet handling level only (i. e. same as I have 
now), or do you also have any of their transport algorithms (lazy 
request sending/response retrieval) implemented?


Einar Karttunen wrote:

I managed to parse the XCB XML protocol descriptions to
Haskell data structures, next I'll try to emit some
nice code from that. If it works well the end result
should be a pure Haskell X library.



Dimitry

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


[Haskell-cafe] Lazier I/O?

2005-11-28 Thread Dimitry Golubovsky

This may be a stupud question, but how to make I/O in Haskell really lazy?

Here is a simple program:



module Main where

import System.IO
import Foreign
import Data.Word
import Data.Char

s2c :: String - [Word8]

s2c s = map (fromIntegral . ord) s

sendstr :: Handle - String - IO Int

sendstr h s = do
  let c = s2c s
  ln = length c
  allocaBytes ln $ \buf - do
pokeArray buf c
hPutBuf h buf ln
return ln


main = do
  hSetBuffering stdout NoBuffering
  l1 - sendstr stdout abcde\n
  l2 - sendstr stdout defghij\n
  putStrLn $ sent  ++ (show l2) ++  bytes
  putStrLn $ sent  ++ (show l1) ++  bytes



It prints:

abcde
defghij
sent 8 bytes
sent 6 bytes

i. e. the first string is output first although the result from that 
output (how many bytes sent) is needed second.


What is desired is to have the IO actions perform as their results are 
needed. I am assuming some knowledge that those actions have only 
limited scope of side effects (e. g. order of outputs within a window is 
significant, but order of appearance of those windows on the screen may 
not be). I see some way to do this by writing regular non-monadic 
Haskell stuff, representing each side effects scope (i. e. where 
ordering of actions is necessary) with its own instance of an I/O like 
monad (but runnable from an outside non-monadic code), and then using 
unsafePerformIO as needed. But there may be some framework already 
developed (albeit with unsafePerformIO, but hiding it from application 
developers).


Any ideas, pointers?

Thanks

Dimitry


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


Re: [Haskell-cafe] Haskell GUI on top of Xlib?

2005-11-26 Thread Dimitry Golubovsky

Thanks Duncan for this link: a very interesting reading.

Duncan Coutts wrote:


Are you aware of the XCB library:
http://xcb.freedesktop.org/





Indeed they mention that Haskell would be an obvious target for this:

http://xcb.freedesktop.org/wiki/XCBToDo


I haven't looked at their API closely, but it would not be a problem to 
generate bindings using HSFFIG unless there are functions 
taking/returning whole structures, or things like arrays of function 
pointers which are not yet handled by HSFFIG reliably.


It might be worth trying to model their algorithms in Haskell though. 
They send requests to server semi-lazily (i. e. when request's result is 
needed, or eventually when the queue is flushed), and retrieve server 
replies lazily (i. e. on demand).


But I am not ready to tell yet, would Haskell's natural laziness be 
sufficient to implement that, or something involving mutable objects 
needs to be built on top of the standard I/O stuff.


Dimitry Golubovsky
Middletown, CT


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


[Haskell-cafe] Haskell GUI on top of Xlib?

2005-11-25 Thread Dimitry Golubovsky
Do there exist Haskell graphics/UI toolkits implemented on top of the 
X11 library (Xlib) without any intermediate C/C++ libraries (i. e. not 
WxHaskell for example)?


I have a very low level client-side interface to the X11 protocol 
implemented in pure Haskell (layout of protocol packets obtained from 
Xlib header files preprocessed by HSFFIG). As of now, I can open a 
display, build request packets manually and parse server responses (some 
of, but this is just a matter of writing more parsers), so this is more 
like a toolset for X11 protocol packets manipulations. I do not intend 
to implement a full analog of Xlib in Haskell. Instead, it might be 
interesting to create a fully functional GUI toolkit based on some 
already existing high-level interface.


Any ideas will be appreciated.

Dimitry Golubovsky
Middletown, CT

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


Re: [Haskell-cafe] records proposals list

2005-11-19 Thread Dimitry Golubovsky

David Roundy wrote:



4. Getters for multiple data types with a common field.



[skip]



4. Getters for multiple data types with a common field.

This basically comes down to deriving a class for each named field, or
something equivalent to it, as far as I can tell.  This also works with the
namespace issue, since if we are going to define getters and setters as
functions, we either need unique field labels or we need one class per
field label--or something equivalent to a class for each field label.


This is a problem similar to one I had to solve for HSFFIG to design a 
syntax to access fields of C structures (where different structures may 
have fields of same name but of different types).


I ended up with a multiparameter class parameterized by a C structure 
name, field name, field type, and for each occurrence of these in C 
header file I autogenerated an instance of this class.


See

http://hsffig.sourceforge.net/repos/hsffig-1.0/_darcs/current/HSFFIG/FieldAccess.hs

for the class itself, and a typical instance (autogenerated of course) 
looked like


instance HSFFIG.FieldAccess.FieldAccess S_362 ((CUChar)) V_byteOrder where
  z -- V_byteOrder = ((\hsc_ptr - peekByteOff hsc_ptr 0)) z
{-# LINE 5700 XPROTO_H.hsc #-}
  (z, V_byteOrder) -- v = ((\hsc_ptr - pokeByteOff hsc_ptr 0)) z v
{-# LINE 5701 XPROTO_H.hsc #-}

for a field `byteOrder' of type `unsigned char'.

This might work in general for what is proposed in the item 4 quoted 
above. A class with 3 parameters will be needed, and perhaps some 
syntactic sugar to autogenerate it and its instances. The only downside 
is GHC needs too much memory to compile all this: I had to add a 
splitter utility to HSFFIG otherwise GHC failed short of memory on even 
several tens of C structures.


Dimitry Golubovsky
Middletown, CT

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


[Haskell-cafe] Darcs and the Google Base

2005-11-17 Thread Dimitry Golubovsky
This may be just funny, but...

As the Google Base went live yesterday (11/16/2005), I tried to add
the information about my HSFFIG project to the Base. As the Base
allows to define arbitrary attributes (labels) for each item, I added
the two of Web URL type: CABAL and DARCS holding urls for the
project Cabal file and the Darcs repo respectively.

I was turned down on excessive capitalization of these labels. I
made them into Cabal and Darcs. The former was accepted. the
latter was turned down again as misspelled. I wrote an exemption
request explaining that Darcs is not a misspelling. However, it's
been more than a whole day since my attempt, it hasn't been resolved.

Interestingly, my item was published after I removed the Darcs
label, but shortly after I resubmitted the exemption request for Darcs
the item disappeared.

--
Dimitry Golubovsky

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


[Haskell-cafe] Records (was Re: [Haskell] Improvements to GHC)

2005-11-17 Thread Dimitry Golubovsky
Sebastian Sylvan wrote:

Personally I think that the dot is way to good of a symbol to be
wasted on function composition. I mean, how often do you really use
function composition in a way which doesn't obfuscate your code? I use
($) way more often than (.). Some people do use it more often than I

I found it useful to use (mainly for debugging purposes)

mapM (putStrLn . show) some list

if I want to print its elements each on a new line.

--
Dimitry Golubovsky

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


[Haskell-Cafe] DARCS and case of file name letters

2005-11-01 Thread Dimitry Golubovsky
I have a file in my repo (HSX11/Xauthority.hs) and I want to rename it 
changing just case of one letter:


bash$ darcs mv HSX11/Xauthority.hs HSX11/XAuthority.hs 



darcs failed:  A file or dir named HSX11/XAuthority.hs already exists in 
working directory.


bash$ ls HSX11/X[aA]*.hs 


HSX11/Xauthority.hs

bash$ darcs --version 


1.0.3 (release)

DARCS was compiled by GHC 6.2.2.

bash$ uname -a 


Linux dmghome 2.2.16 #9 Mon Sep 16 22:43:25 EDT 2002 i686 unknown

Is it DARCS that ignores the case of letters in filenames, or the 
Haskell runtime?


Dimitry Golubovsky
Middletown, CT

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


[Haskell-cafe] Papers from the 2005 Haskell Workshop (Tallinn)?

2005-10-05 Thread Dimitry Golubovsky
The papers presented at the Workshop are already available in the ACM
library which requires membership/subscription to read full text PDFs.
Are there any plans to make those papers available anywhere else on
the Web without subscription?

--
Dimitry Golubovsky

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


Re: [Haskell-cafe] Papers from the 2005 Haskell Workshop (Tallinn)?

2005-10-05 Thread Dimitry Golubovsky

Nils Anders Danielsson wrote:



 Most authors do put their papers on their web pages nowadays.


In particular, I would like to read the paper on halfs (haskell
filesystem). Googling for halfs haskell filesystem gave nothing but
the Workshop's schedule and ACM Library TOC.

Dimitry Golubovsky
Middletown, CT



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


[Haskell-cafe] [Announce] CabalFind 0.1

2005-09-10 Thread Dimitry Golubovsky
Some time ago, I expressed an idea that certain search engines may be 
used to collect information about existing .cabal packages whose 
developers made them indexable by those engines.


Finally, I have written an experimental library, CabalFind.

The library provides a generalized interface to search engines, and also 
sample implementations for Google and Yahoo*


I haven't set it up as a separate project, say, on SourceForge because I 
am not sure whether it is feasible to do so. Instead, I am suggesting 
that the developers of Haskell Library Infrastructure decide whether 
this library may serve as a basis for library infrastructure maintenance 
utilities.


The library may be downloaded at

darcs get http://www.golubovsky.org/repos/cabalfind/

or http://www.golubovsky.org/repos/cabalfind/cabalfind.tar.gz

The .cabal file for the package is tailored for GHC 6.2.2. For use with 
6.4, changes may be necessary, as the XML Toolbox for 6.4 no longer 
includes the HTTP module, so HTTP.cabal needs to be included in 
build-depends.


More information provided at http://haskell.org/hawiki/CabalFind

Any feedback is appreciated.

Dimitry Golubovsky
Middletown, CT

--
* Only these two search engines are found to be able to search by URI 
suffix (.cabal in our case); without this feature package search becomes 
very inefficient.


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


[Haskell-cafe] XML Toolbox Question

2005-08-20 Thread Dimitry Golubovsky

Hi,

How can I obtain a list of all a tags from the result of parseHtmlContent?

Unfortunately, the Haddock documentation coming with the package is not 
rich on examples.


Any suggestions will be appreciated.

Dimitry Golubovsky
Middletown, CT

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


[Haskell-cafe] Announce: HSFFIG 1.0 Stable Release

2005-08-01 Thread Dimitry Golubovsky
Dear List Subscribers,

I am pleased to announce the first stable release of HSFFIG, yet
another tool for autogeneration of FFI bindings from C include files.

The project is now hosted at Sourceforge: http://hsffig.sourceforge.net

Downloads page: http://www.sourceforge.net/projects/hsffig

Darcs repo: darcs get http://hsffig.sourceforge.net/repos/hsffig-1.0

Tutorial: http://www.haskell.org/hawiki/HsffigTutorial

The wiki page HsffigExamples has been separated from the Tutorial.
If anybody has an interesting example of using HSFFIG please update
the page with code samples.

Brief summary of changes:

- The distribution is now cabalized. Please read the INSTALL file.

- The multiparameter class and combinators to access members of
structures/unions are moved to separate library. It is necessary to
specify -package HSFFIG when compiling applications.

Thanks to everybody who participated in discussions related to HSFFIG
on this list, and privately. This helped me with implelentation of
some features and gave some ideas for future improvement.

Debian, RPM, and other packagers: if you create a HSFFIG package
please let me know the package URL so I can update the Freshmeat
project information page, and the project homepage.

For any problems related to this project feel free to contact me.

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


[Haskell-cafe] hssfig: Unresolved symbols when importing a foreign library: what is the preferred way of handling?

2005-07-27 Thread Dimitry Golubovsky
I would like to collect opinions from interested people on this matter.

Background:

Hsffig parses include files (.h) and generates FFI import declarations
for every function/external variable it encounters a prototype
declaration for. The result is a .hsc file which is converted into a
Haskell source and compiled into an object file and linked into an
executable along with other application source files using ghc as
frontend (so far, hsffig is targeted to ghc users only). This object
file will contain references to all foreign functions to be imported.

Problem:

In some cases, a include file may contain prototypes of functions not
existing in the library it corresponds to. In my case, unistd.h
(Linux, glibc2) contains prototypes for __ftruncate and pthread_atfork
which come up unresolved when linking the executable without
additional libraries specified.

pthread_atfork is resolved when linking with -lpthread. Where is
__ftruncate defined, I don't know, and I do not really want ot know
unless I need to use this function.

Possible solutions, sorted by expected amount of work necessary to
implement (please pick one you would prefer, or suggest yours):

- leave everything as is: the executable will not be linked until the
developer finds all the libraries to resolve all the missing symbols.
That's how it works (or doesn't work) now.

- tell ld only to warn about unresolved symbols: the executable will
be built anyway, but if the unresolved function is called from under
the hood it most likely results in segfault hard to explain (which
function caused it). Only special linker option is required.

- for each foreign function imported, generate a stub which, when
called, complains loudly and aborts the program. These stubs are
placed in a separate object file and linked after all possible
libraries, so library-defined symbols always take precedence. The
disadvantage is: the developer would not know which symbols remained
unresolved when the executable was linked, only will he know when the
application crashes. I am trying to implement this now, using the
hsc2hs' #def macro to define those stub functions.

- analyze the linker output and make auto-correction in the generated
.hsc file just by excluding FFI declarations for unresolved functions.
Non-elegant, requires second pass and highly platform and tool
dependent.

- instead of generation of a single object file referencing all the
functions, create one per funciton import and place them all in an
archive (.a). Then, when linking, only actually used functions will be
picked from the archive. I am not sure how would this interact with
ghc --make: I got an impression that a .hi file is necessary for all
modules (.hs/.hi/.o triple) imported unless they are gotten from a
package. If I have in my program:

import FOO_H

and there is no FOO_H.hi nor FOO_H.hs, only libFOO_H.a: how ghc would
live with this?

The latter approach does not take much to implement in hsffig itself
(I already have a splitter which splits into one object file per a
structure/union). I am more concerned how to make ghc live with this.
Creation of a package for each imported include file seems like
overkill.

PS I believe that hsffig will be an useful utility. I noticed several
people downloaded nightly tarballs or checked out from the DARCS repo.
If these persons have found this program useful, would they please
suggest something on the matter I described.

-- 
Dimitry Golubovsky

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


RE: [Haskell-cafe] Suggestions for #defines with FFI

2005-07-27 Thread Dimitry Golubovsky
John,

Could you please give an example of such constant definitions? Is it
possible to look at the include file?

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] hsffig issues (was: Suggestions for #defines with FFI)

2005-07-27 Thread Dimitry Golubovsky

John Goerzen wrote:



Incidentally, I looked at hsffig.  There were a couple issues with using
it for this:

1) It didn't declare types for the imported constants, so Haddock
wouldn't generate a list over it.


I never tried to make hsffig output documentable: the whole idea is just 
to write import FOO_H in Haskell as one would write #include foo.h 
in C.




2) It included all sorts of other #defined items, from other headers
(stdio.h maybe), making it unsuitable to re-export directly to the user.
(I'd have to re-key everything anyway)


I mentioned this in the Tutorial: hsffig gives the Haskell compiler the 
same look at information about the library to import as the C compiler 
would have. It is hard to separate such things: your header file that 
you include may include ten other headers, five of them related to the 
library, and the rest from /usr/include


And you do not need to reexport because wherever you need the bindings, 
you just import them there. You still have to have some library 
interface layer in your application, but you do not focus on type 
signatures of foreign functions.



3) It tried to list some of the GCC internal conditionals as constants,
making the .hsc not compile unless I manually removed some of them.


Can you provide an example of that? With (almost antique) egcs-2.91.66 I 
never had anything like this. What was in the .hsc file and what was the 
compilation error?




I really like the idea, though.  Autodetecting these is great, since
they could vary somewhat from implementation to implementation.


Exactly: the Haskell compiler gets the same information (e. g. from 
features.h) as the C compiler got when compiling the library.


Dimitry Golubovsky
Middletown, CT



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


[Haskell-cafe] Arbitrary files in a Cabal package: how to install

2005-07-24 Thread Dimitry Golubovsky
I am trying to use Cabal for buiding HSFFIG as a package. Among other 
files to install I have the special template for hsc2hs which is a C 
include file. If I specify it in the Includes: clause nothing happens: 
it is not copied anywhere during installation.


I need this file to be placed somewhere in the package instalation 
location, so when programs are compiled with my package could include 
that file.


Of course I may specify additional step in the Makefile, but it would be 
more consistent to do this in Cabal.


How can arbitrary files be declared parts of a package, and destination 
directories for them be specified?


I am using the simplified (?) version of Cabal that Ross suggested whrn 
I asked in this list whether it would be possible to use it with older GHC.


Dimitry Golubovsky
Middletown, CT

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


Unicode in GHC 6.2.2 and 6.4.x (was: Re: [Haskell-cafe] Unicode.hs)

2005-07-16 Thread Dimitry Golubovsky

Dear List Subscribers,

Simon Marlow wrote:

On 30 June 2005 14:36, Dimitry Golubovsky wrote:



It is in CVS now, and I believe will be in 6.4.1



Not planned for 6.4.1, but definitely in 6.6.



I have put those files that work for me in GHC 6.2.2 (Unicode support) 
for download. Please read the Wiki page:


http://haskell.org/hawiki/GhcUnicode

for instructions.

Any feedback will be appreciated. I believe, the code will work with GHC 
6.4.x as well. Please let me know if there are any problems.


Dimitry Golubovsky
Middletown, CT



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


[Haskell-cafe] Unicode.hs (was: RE: Re[2]: ANNOUNCE: GHC survey results)

2005-06-30 Thread Dimitry Golubovsky
Hi,

Vadim Konovalov wrote:

===
that file reads:

-- Based on the GHC.Unicode library, Copyright 2005, Dimitry Golubovsky.
-- See GHC's LICENSE file for the full license text.

That said, it is part of GHC?
===

Clarifying on Unicode stuff in GHC I contributed:

It is in CVS now, and I believe will be in 6.4.1

At least it shows up at:

http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/GHC/Unicode.hs?rev=1.14
(MAIN branch)

But this module is just an interface to another module, WCsubst.c:

http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/cbits/WCsubst.c?rev=1.3

which in turn was produced from UnicodeData.txt (? I believe this is
correct name of the file from www.unicode.org) by the shell script:

http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/cbits/ubconfc?rev=1.2

This API handles simple case conversions (Char - Char), and
categorization of characters according to what is in the
UnicodeData.txt file.

Before (i. e. up to and including 6.4), Unicode stuff was handled
through wc* locale based functions for wide chars conversion. Since
not every installation of Unix (or some other OS) has this set up
properly (mine was not: personal itch), this code was proposed for GHC
and finally made it there.

Hope this explains everything. In fact, Unicode.hs itself is not
completely mine ;)

PS: Autrijus (the guy who develops Pugs) included those files on his
own because 6.4 was just out, and Unicode stuff was not there yet.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Announce: Yet Another Tool to Generate FFI Bindings: hsffig

2005-06-25 Thread Dimitry Golubovsky
I am pleased to announce the very first alpha release of the (yet 
another) FFI binding autogeneration tool.


Some time ago, I asked the list subscribers about available bindings to 
Berkeley DB. Several people kindly shared their code with me.


One thing I noticed in all bindings: they required manually-written 
wrappers to accomodate for Berkeley DB indirect style of calling functions.


Considering large number of such functions in BDB, I attempted to write 
a tool which would automatically parse the BDB include file, and extract 
function prototypes to generate FFI declarations. Soon it became clear 
that an almost full C syntax parser would be necessary.


Finally it resulted in what I am presenting to the Haskell community 
with hope that this utility will be useful to many developers.


Of course there are many omissions and shortcuts, but before I move 
forward, I would like to get some feedback from potential users of this 
tool.


There is no detailed documentation. I have written a brief README file. 
More detailed documentation will follow.


I haven't created a homepage for this project yet: the only way to get 
it so far is the darcs repo:


darcs get http://www.golubovsky.org/repos/hsffig

Files in the repository may be browsed at:

http://www.golubovsky.org/repos/hsffig/

I will appreciate any feedback.

Dimitry Golubovsky
Middletown, CT

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


[Haskell-cafe] Generalized version of `words'?

2005-06-11 Thread Dimitry Golubovsky

Does there exist a generalized version of the `words' function i. e.
one that breaks an arbitrary list into parts by an arbitrary predicate?

splitAt is not what I need.

I had to write my own:

-- A version of words, but works with any lists on any predicate.

parts pred s = case dropWhile pred s of
 [] - []
 s' - w : parts pred s''
 where (w, s'') = break pred s'

(just by parameterizing `words' found in Data.List with a predicate 
passed as a parameter).


In case such a function already exists, what is its name?

In the opposite case, can such a function be added to the standard 
library? (or why didn't it exist?)


Dimitry Golubovsky
Middletown, CT

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


[Haskell-cafe] OT: http://www.cse.unsw.edu.au host name does not resolve

2005-06-08 Thread Dimitry Golubovsky
Sorry for this OT, but the server seems to be unaccessible.

And so is the Haskell-related stuff on it (like the FFI Addendum).

The requested URL could not be retrieved

Here's what the proxy says: (possibly a DNS problem)



While trying to retrieve the URL: http://www.cse.unsw.edu.au/~chak/haskell/ffi/ 

The following error was encountered: 

Unable to determine IP address from host name for unknown server name 
This means that: 
 The cache was not able to resolve the hostname presented in the URL. 
 Check if the address is correct. 



-- 
Dimitry Golubovsky

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


[Haskell-cafe] Infix operators naming conflicts (was: class Ref)

2005-06-07 Thread Dimitry Golubovsky
Gracjan Polak wrote:

 val = readIORef
 a=:b = writeIORef a b

Pretty shame := is already reserver :(. There is something alike 
Graphics.Rendering.OpenGL.GL.StateVar. The use $= for assignment. 
Generalizing variables (in respect to some monad) seems to be often 
reinvented idea :)

Indeed, has anyone tried to summarize possible conflicts between infix
operators as they are defined in many places to serve different
purpose?

e. g.

(!) :: Ix i = Array i e - i - e 
The value at the given index in an array.  (Data.Array)

(!) :: a - [HtmlAttr] - a (Text.Html)

so if a module imports both modules mentioned above simultaneously,
will the compiler complain about (!) and ask to use a qualified name?

I had the following experience: when trying to create a convenient
syntax to access fields of foreign C structures using appropriate Ptr
and field label, I tried to define a combinator for that, and to name
it (.) (dot, same as dot-composition defined in Prelude, to look
similarly to Java notation) Type signature for my (.) was totally
different than Prelude's (.), and semantically it is not composition
of functions. However the compiler (GHC) asked to use qualified name.

Finally I ended up with the name (--) which looks like C notation.
But who knows, whether someone wishes to use (--) for other purposes?

-- 
Dimitry Golubovsky

Anywhere on the Web
___
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 Dimitry Golubovsky

Andrew Harris wrote:


   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.



IMHO Koopman's TIGRE (http://www.ece.cmu.edu/~koopman/tigre/) might be 
a close approximation of what you want.


I had some (rather non-serious) experience with Forth, and I had great 
pleasure reading Koopman's paper on TIGRE. Unfortunately I couldn't find 
any further development on this topic (although I saw some later 
Koopman's publications on Forth itself). I guess, only someone thinking 
Forth (as in the Brodie's book) might develop such a thing.


Dimitry Golubovsky
Middletown, CT


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


[Haskell-cafe] RFE: Extensible algebraic user-defined data types?

2005-04-28 Thread Dimitry Golubovsky
Hi,

Is it possible to have such a feature in the future versions of the
Haskell language?

For example, there is an Either datatype which is Left a| Right b.

Suppose I want to extend this datatype to the one including
possibility of neither Left or Right (i. e. None). Currently I have to
use Maybe Either, so my options are:

Just (Left a)
Just (Right b)
Nothing

If I could extend the Either datatype I might have (syntax may be
different, this is just an example)

data NEither a b = Either a b | None

where datatype in angles is a parent datatype, and all its possible
data constructors are included, and their list is extended with None.

which gave me possibilities: Left a | Right b | None

Probably I wouldn't expect to be able to reuse Nothing here (although
I might want to) because Nothing already has been defined to be of the
type Maybe.

This is just a suggestion, that's why it is posted in the Cafe.

PS Or is there a similar feature in the language already?

Regarding reusing constructor names across several datatypes: is it
possible to qualify them with their enclosing datatype name, like
Maybe.Nothing where there is a name conflict? Then I might reuse
Nothing in my hypothetical data type, and it would be NEither.Nothing
if conflicting with Maybe.Nothing

PPS I may be missing something again, as always ;)

-- 
Dimitry Golubovsky

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


[Haskell-cafe] FFI and pointers to pointers

2005-04-22 Thread Dimitry Golubovsky
Hi,

I am trying to generalize my knowledge about FFI declarations when
dealing with pointers to pointers (import from C to Haskell). Maybe
these are silly questions, but It seems to me, I am missing some
understanding.

Per the FFI Addendum:

For a variable, we use  import:

int bar;

foreign import ccall  bar :: Ptr CInt

If we have int *pbar;, will Ptr (Ptr CInt) be correct? For arbitrary
level of pointer nesting, will nesting of the same number of Ptr's be
correct?

For a function, we use static import:

int system (char *str);

foreign import ccall static stdlib.h system :: Ptr CChar - IO CInt

but for a pointer to a function (i. e. a variable) we use:

int (*psystem) (char *str);

foreign import ccall dynamic
mkFun :: FunPtr (CInt - IO ()) - (CInt - IO ())

and then psystem should be declared as a variable with  import, I
believe. Or as a FunPtr?

And then (mkFun psystem) returns something to be called as a function.

Then (talking to myself) pointer to pointer to a function may be
imported as shown in the very beginning, i. e. by nesting Ptr's?

So indeed my question is: would nesting of Ptr's work if nested
pointers are imported?

I haven't experimented with this yet, but maybe someone has?

Thanks for any advice.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] Re: Closest analog to popen()

2005-04-13 Thread Dimitry Golubovsky
Peter Simons wrote:
Dimitry Golubovsky writes:
  Does there exist any analog of popen in the standard Haskell libraries?
Maybe System.Process.runInteractiveCommand is what you need?
http://haskell.org/ghc/docs/latest/html/libraries/base/System.Process.html
Is this available only in 6.4? In 6.2.2 I've got only 
System.Posix.Process, and this is just binding to Unix functions dealing 
with processes.

Thanks for pointing me out.
Dimitry Golubovsky
Middletown, CT

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


[Haskell-cafe] Re: [Haskell] URLs in haskell module namespace

2005-03-24 Thread Dimitry Golubovsky
Dear list members,

I'd like to share some sketchy ideas I have on the subject to address
some of the issues raised.

At 12:14 22/03/05 +, Malcolm Wallace wrote:

I cannot see any of the Haskell compilers ever implementing this idea
as presented.  It would introduce an enormous raft of requirements
(networking client, database mapping, caching, etc) that do not belong
in a compiler - they belong in separate (preprocessing/packaging)
tools.  Furthermore, these tools already exist, albeit they are young
and have a long maturation process still ahead of them.

An external program acting as an URI streamer might be the solution.
Such a program (identified via an environment variable or a compiler's
command line option, just like Hugs external editor) would take an URI
as its command line argument, and respond with a streamed contents of
that URI on its stdout. Like e. g. curl/wget -O -. All the compiler
has to do is popen() that program if an import statement contains an
URI.

Using curl/wget helps get around various issues with
proxies/encryption/etc. as those programs are specifically designed
for that. I do not believe this would result in significant overhead
comparing to regular fopen() used by the compiler for opening source
files.

On a non-networked system, such a program would be a not so
complicated shell script pretending it downloads from an URI, but
reading from local disk (flash, any other kind of storage) instead.

To address the problem of module/package URI changes over time, the
following may be suggested. Either purl.org is used (and then it is
responsibility of a package maintainer to keep its URL pointer valid).
Or, some kind of a purl server may be set up somewhere (at haskell.org
for example) which also supports mirroring. This means that for each
package/module registered with this server, multiple locations are
known (well, probably willing people might allocate their computer
resources for that, at least I would not object as long as I have my
own web server). The hypothetical purl server serves redirects as
usual, but shifting randomly to another mirroring location for each
new request for a module/package. So, if an attempt to retrieve a
module/package fails, it may be repeated, and other mirror location
will be tried. Mirrors will be synchronized behind the scenes.

Will such a centralized purl server a bottleneck or a single point of
failure? Probably not more than a centralized Hackage database (or is
it planned to be distributed?)
 
Also, some resolver might be part of the URI streamer which maps
module names to URIs. For example, the Prelude will most likely be
stored locally, but some other module will not. This means that the
resolver consults the local package database (cabal), and its own
cache, and either streams a local file or popens curl with some URI
constructed specifically based on the desired module name. Once
downloaded, a module may be cached with some TTL, so further
recompilations do not result in curl involvement (until the TTL
expires).

PS This all is written in the assumption that Haskell source files are
served. Binary distributions, of course would require different
techniques.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Parsec question: how to access parser state

2005-03-20 Thread Dimitry Golubovsky
Hi,
I am trying to develop a parser with the Parsec library. At some point I 
need to do something with parser state, say, convert it to a string.

I declared the type for the parser:
type TParser a = GenParser Token (FiniteMap String Declaration) a
The FiniteMap (which is the user state) is expected to be updated during 
parsing whus building some internal lookup table.

and in one of the parsing functions I want to call
show getState
assuming it will apply show to the FiniteMap and return some string of 
characters.

During compliation, I get:
No instance for (Show (GenParser tok st st))
  arising from use of `show' at (file location)
In the first argument of `', namely `(show getState)'
But GenParser is a newtype, not a data constructor, so attempt to write
instance Show (GenParser tok st t)
results in error message about missing constructor GenParser.
How could I extract actual user state from the result of getState?
The parser itself works as needed, but dealing with user state gets me 
in trouble.

Dimitry Golubovsky
Middletown, CT
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] invalid character encoding

2005-03-19 Thread Dimitry Golubovsky
Glynn Clements wrote:

To get a better idea, you would need to consult users whose language
doesn't use the roman alphabet, e.g. CJK or cyrillic. Unfortunately,
you don't usually find too many of them on lists such as this.

In Russia, we still have multiple one byte encodings for Cyrillic: KOI-8 
(Unix), CP1251 (Windows), and getting more and more obsolete CP866 
(MSDOS, OS/2). Regarding filenames, I am sure Windows stores them in 
Unicode regarding of locale (I tried various chcp numbers in a console 
window, printing directory containing filenames in Russian and in German 
altogether, and it showed non-characters as question marks when 
locale-based codepage was set, and showed everything with chcp 65001 
which is Unicode). AFAIK Unix users do not create files named in Russian 
very often, and Windows users do this frequently.

Dimitry  Golubovsky
Middletown, CT
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-Cafe] FFI and foreign function returning a structure

2005-03-01 Thread Dimitry Golubovsky
Hi,
If I have a C function returning a structure (not a pointer, but 
structure itself), can this be accomodated via FFI?

I re-read the FFI Addendum, and my conclusion is most likely No. I am 
asking just to make sure this is not only my finding.

Dimitry Golubovsky
Middletown, CT
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell binding to Berkeley DB?

2005-02-05 Thread Dimitry Golubovsky
Thanks everybody who answered.
 Dimitry Golubovsky
 Middletown, CT

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


[Haskell-cafe] Haskell binding to Berkeley DB?

2005-02-03 Thread Dimitry Golubovsky
Hi,
Has anyone tried/been successful on developing such a binding?
Google returns reference to a message written 2 years ago (on the gtkhs
mailing list) that someone developed it partially:
http://www.haskell.org/pipermail/gtkhs/2003-January/000317.html
and a description of a student's assignment:
http://www.cse.unsw.edu.au/db/thesis/topicinfo/MMTC13.html
The rest of links that Google returns are of little relevance.
Any ideas?
Dimitry Golubovsky
Middletown, CT
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Convert to unboxed value? How?

2005-01-27 Thread Dimitry Golubovsky
Hi,
What function should be used to convert an integer value to Int#?
A character to Char#?
Dimitry Golubovsky
Middletown, CT
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Hugs vs GHC (again)

2005-01-11 Thread Dimitry Golubovsky
Ketil,
Ketil Malde wrote:
Dimitry Golubovsky [EMAIL PROTECTED] writes:
(Did you intend this for the list?)
Yes, and I re-posted similar message on the list.

I think perhaps the answer is all of the above.  The functions could
be defined in multiple modules, so that 'ASCII.isSpace' would match
the normal space character only, while 'Unicode.isSpace' could match
all the weird and wonderful stuff in the standard.


And then there might be a bunch of (perhaps autogenerated)
locale-matching modules like ISO8859_1, KOI_8 etc.

Well - maybe.  Another option is for these to require conversion from
to Unicode.
Right, because input of encoding-specific functions will be Unicode 
anyway. And AFAIK conversion from/to unicode may be also contained in 
localedef files (or for instance in Java CharTo, XXXToChar classes) 
- I mean that there must be enough information around to build those 
modules automatically.

Except for Unicode itself which would be autogenerated from the Unicode 
database files like multiple examples of doing this (including mine) 
that were posted on this list.

Dimitry Golubovsky
Middletown, CT

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


Re: [Haskell-cafe] Unicode: Hugs vs GHC (again) was: Re: Some random newbie questions

2005-01-07 Thread Dimitry Golubovsky
Hi,
Lennart Augustsson wrote:
Simon Marlow wrote:
Here's a summary of the state of Unicode support in GHC and other
compilers.  There are several aspects:
 - Can the Char type hold the full range of Unicode characters?
   This has been true in GHC for some time, and is now true in Hugs.
   I don't think it's true in nhc98 (please correct me if I'm wrong).
I remember, it was in GHC. But any attempt to output Unicode characters 
using standard I/O functions always ended up outputting only low 8 bits. 
Has anything changed since then?

 - Do the character class functions (isUpper, isAlpha etc.) work
   correctly on the full range of Unicode characters?  This is true in
   Hugs.  It's true with GHC on some systems (basically we were lazy
   and used the underlying C library's support here, which is patchy).
Which basically means that one with older or underconfigured system 
where they do not have permissions/technical possibilities to configure 
locales in the C library properly is out of luck...

 - Can you use (some encoding of) Unicode for your Haskell source files?
   I don't think this is true in any Haskell compiler right now.
Well, Hugs from CVS accepts source code in UTF-8 (I am not sure about 
locale-based conversion) - at least on my computer. Another thing, 
string literals may be in UTF-8 encoding, but Hugs would not accept 
function/type identifiers in Unicode (i. e. one could not name a type or 
a function in Russian for instance - their names muct be ASCII).

I put an example of such a file in UTF-8 on my web-server:
http://www.golubovsky.org/software/hugs-patch/testutf.hs
Well, even if hbc is mostly dead I must point out that it has supported
this since Unicode was first added to Haskell.  As well as the point
above, of course.
If the GHC implementors feel lazy they can always borrow the Unicode
(plane 0) description table from HBC.  It is a 64k file.
Or in Hugs, there is a shell script (awk indeed, just wrapped in a shell 
script) which parses the Unicode data file and produces a C file (also 
about 64k), and compact set of primitive functions independent from C 
library - src/unix/mkunitable and part of src/char.c in the Hugs source 
tree respectively.

The reason I asked this question was: I am trying to understand, where 
is internationalization of Haskell compilers on their developers' list 
of priorities, and also how high is demand from users to have at least 
basic internationalization.

Dimitry Golubovsky
Middletown, CT

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


[Haskell-cafe] Hugs vs GHC (again) was: Re: Some random newbie questions

2005-01-06 Thread Dimitry Golubovsky
Hi,
Looks like Hugs and GHC are being compared again ;)
I am just interested to know, what is the current status of Unicode 
support in GHC? Hugs has had it for about a year (or more, in CVS) at 
least at the level of recognizing character categories and simple case 
conversions based on the Unicode database files. Also UTF-8 or 
locale-based I/O encoding conversion to internal Unicode is available. 
Does GHC has similar support?

Some time ago (about 1.5 years) I tried to play with Unicode I/O in GHC, 
and it looked like it did not have much Unicode support back then (at 
least on I/O level). Has anything progressed in this regard since then?

Most of this list subscribers seem to be GHC users, so can anybody answer?
BTW when answering the original post (brief quote below) different 
aspects were mentioned, but not internationalization ones. Is it really 
not that important?

Dimitry Golubovsky
Middletown, CT
Benjamin Pierce wrote:

* What are the relative advantages of Hugs and GHC, beyond the obvious (Hugs
  is smaller and easier for people not named Simon to modify, while GHC is a
  real compiler and has the most up-to-date hacks to the type checker)?  Do
  people generally use one or the other for everything, or are they similar
  enough to use Hugs at some moments and GHC at others?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell as data manipulation language?

2004-12-07 Thread Dimitry Golubovsky
Graham  All,
Graham Klyne wrote:
1. The lack of variables in Haskell isn't a problem so much as an 
opportunity to think in new and interesting ways.
What I was trying to say: where in imperative languages there is a 
boundary between in-memory computations and I/O, equivalent semantic 
boundary in functional languages is between stateful and stateless. I. 
e. functional programming is a stateless way to control stateful world 
(remember state-of-the-world-p? :)

2. I think that when you talk about versioning, you come close to a 
useful way of thinking about mutable data in Haskell.  My understanding 
is that the classical way (i.e. pre-monads) to think of mutable values 
in functional languages was to model them as a time-sequence of 
intermediate values, where a function to update a state returns the 
next value in that sequence.  Expressed this way, a practical problem 
arises that the intermediate values don't (necessarily) go away, 
creating a potential for exploding storage requirements.  (If, as with 
document versioning, you want to keep the intermediate values, then you 
need to figure a way to live with this;  value sharing in pure 
functional languages is a big help here.)  But often one is only 
interested in the latest or current value in the time-sequence.  
Monads provide a way of capturing this:  the state is implicitly 
threaded through a sequence of computations (e.g. the expressions in a 
do-list), with old versions thrown away as new ones are created (unless 
the state is explicitly saved, which is not always possible).
I was writing about the same, but applied to persistent storage.
I meant that to store a new version, it is sufficient just to store a 
seralized compiled expression which being applied to version N of an 
object evaluates to its version N+1. In other words, store updates 
lazily. If there are too many stored versions (or lazy evaluation takes 
too much time), then at some moment of time the whole expression 
(spanning down to the oldest stored version) may be deserialized, forced 
to evaluate, serialized, and stored. Older versions may be discarded 
after that (unless any other objects refer to them directly).

P.S. A question to those who needs mutable variables: has anybody tried 
Manuel Chakravarty's Haskell Ports Library?

http://www.cse.unsw.edu.au/~chak/haskell/ports/
I spotted it today, but had no time to look at the code and/or try it. 
According to its (rather sketchy) documentation, this library provides 
some mechanisms to simulate varying values as time-sequences (lazy streams?)

Can anyone tell wether it is more/less functional/efficient than IORefs?
Dimitry Golubovsky
Middletown, CT
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell as data manipulation language?

2004-12-03 Thread Dimitry Golubovsky
Hi,
I am probably not the first to think about this, yet I was unable to 
find any signs of activities in this direction, so maybe I will be able 
to know something from this list.

First of all, reading multiple messages about global and mutable 
variables desired in Haskell, I was thinking: isn't the root of the 
problem in the fact that there are no variables in Haskell at all?

Indeed (and my experience of digging in Hugs sources confirms) Haskell 
program (function) is just a description of some memory structure which 
being completed by the bindings of its arguments, is further transformed 
by the evaluator into some other data structure, etc.

Now imagine a data storage with structure similar to one of a Haskell 
program. I. e. a storage having metadata-objects like data constructor 
functions,  data types which are parents to data constructors (like in 
data X = Foo Int | Bar Float), classes, instances, modules, etc. Also 
data objects themselves, i. e. precompiled and serialized functions 
along with their type information. Data objects do not differ from 
functions i. e. they are stored the same way.

Now quoting Graham Klyne
Subject was: [HAskell-Cafe] Mutable and persistent values (was: Top 
Level TWI's again) posted 2004-11-23 05:11:25 PST:

(I tried to post reply via Google Groups, but it did not make it back to 
the list):

 It is my view that use a functional language effectively, it is 
necessary
 to think differently about its structure than one would for a 
conventional
 imperative program.  Global values become parameters and return
 values;  mutable values become input values and new (separate) return
 values.  If you're used to writing imperative programs that do not use
 global state, but rather use parameters to pass values, the difference
 isn't always quite as great as might be imagined.

 For complex values, this sounds horribly inefficient, but because values
 are pure (not mutable), very high levels of sharing can (sometimes, with
 good design!) be extensively shared.  Thus, a return value may well 
consist
 mostly of a copy of the input value, with differences, rather than 
actually
 being a complete new copy.  (Chris Okasaki's book shows well how to 
design
 to obtain these benefits.)

 Also, because Haskell is lazy, complex structures passed between 
functions
 don't necessarily ever exist in their entirety.  Sometimes, I think of a
 data structure as describing a computational traversal through some 
data,
 rathert than something that actually exists.  (This leads to very 
elegant
 expression of things like Prolog search-and-backtrack algorithms.)

So, if there is a data object (say, a list) stored with version number 
N, and another value is cons'ed to the list, then version N+1 will be 
stored as an application of cons to the value added, and the version N.

Thus, via versioning, some kind of mutability may be achieved (and of 
course these check-in and check-out must belong to IO monad).

These stored functions must be visible to the compiler, and when 
compiling some function f which calls g (compiled earlier and stored as 
version N), the code of this version of f (say, M) is built to call 
version N of g further on. So, all the type checks are done during 
compilation, and are not necessary during runtime, and yet the functions 
are compiled and stored separately (trying to address the issue with too 
large monolithic programs).

Newer version of f (say M+1) may be compiled against newer (at that 
time) version of g (N+1). So different versions of the same function may 
demonstrate different behaviors, but the history of development is 
preserved.

Put together, this gives some conceptual image of a programmable data 
storage with queries being calls to stored functions (with externally 
supplied agruments). All good things of Haskell like static type safety 
are preserved.

I am thinking of implementation of something like this using Hugs 
runtime as the basis. I realize, this may be very time consuming, so I 
am wondering, maybe someone already is developing something like this?

Or someone already tried, and found this inefficient or in some other 
way not feasible to implement?

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