Re: [Haskell-cafe] [web-devel] The promising world of Monadic formlets

2013-06-22 Thread Anton Tayanovskyy
 [("onclick","this.form.submit()")]
>>> radiob s n= text s ++> setRadio s n >>
>>> Here wform, getBool, getString , getRadio etc are formlet elements
>>>
>>> The first sentence is an applicative composition that generate a 2
>>> tuple, to show that applicative and monadic can be mixed.  the operations
>>> ++> add html to the formlet. the operatior >> element.. noWidget is a dumb formlet that does not validate.
>>>
>>> The second monadic statement is an election between two options. The
>>> beauty of the monadic instance is that the rest of the form can vary
>>> depending on the previous answers.  Since the formlets validate the input,
>>> unless the election is made, the radio will not validate, so the monadic
>>> execution will be aborted beyond any unanswered question, so nothing will
>>> appear after the question. The rest of the form will appear when the user
>>> choose one of the two options. once one or the other option is chosen, then
>>> another binary question is presented. (either he likes his work or where he
>>> study).  When the questions are finised, the results are presented.
>>> I hope that you get the idea. The benefit is not only the familiar
>>> coding and presentation of a sequential console application: Since the form
>>> encloses all the fields, At any time the user can change previous inputs
>>> and the form will reflect these changes. For example if the user change
>>> from work to study (second statements) the "where do you study will appear
>>> and the work related questions and answers will disappear. That is
>>> wonderfully useful for heavily interactive applications.
>>>
>>> There is  a problem however and it is the issue of the formlet
>>> identifiers. Unlike in an applicative presentation, now the number and type
>>> of the formlets will vary, so the response to a previous form create a new
>>> kind of form, and the post response can be misinterpreted. To avoid that ,
>>> the  pageFlow call creates fixed field labels for each branch of execution.
>>>
>>> I will release a version of MFlow that support this kind of monadic
>>> composition of fomlets, but In essence it is nothing but to add Monad
>>> instance to formlets. A single server procedure, that executes the formlet
>>> code can support all the interaction so any framework can do it. The
>>> usability of that is huge:It is possible to interact in a web page in a
>>> console style with questions and answers with the versatitly of a dynamic
>>> foms: Any modification in the form change the subsequent flow of
>>> interaction. Another application of this monadic style is to ease multistep
>>> processes such are registration, check-out and payment ad so on. Even a
>>> entire interactive dynamic application can be coded in a single page.
>>>
>>> And no javascript is needed!.
>>>
>>>
>>> To run this formlet in MFlow:
>>>
>>> main=do
>>>   addMessageFlows
>>>[("", transient $ runFlow  $ ask dynamicForm )]
>>>
>>>wait $ run port waiMessageFlow
>>>
>>>
>>> This video show how the presentation of this example vary with the user
>>> input:
>>>
>>> http://youtu.be/DryBQc9agFg
>>>
>>>
>>> I hope that you find the idea interesting.  If you want to experiment
>>> with this in MFlow, I have to say that the implementation of this feature
>>> is in an early stage. The code is in the head branch
>>>
>>> https://github.com/agocorona/MFlow/tree/head
>>>
>>>
>>>
>>> Alberto.
>>>
>>
>>
>>
>> --
>> Alberto.
>>
>
>
>
> --
> Alberto.
>
> ___
> web-devel mailing list
> web-de...@haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


-- 
Kind Regards,
Anton Tayanovskyy

WebSharper™ - type-safe JavaScript in F#
http://intellifactory.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] CFG specification and analysis directly in Haskell

2011-09-27 Thread Anton Tayanovskyy
> John Meacham's frisby library [1] did something similar, though the
> technique is not as well-known as it should be.

Looks like an excellent library, thank you!

> Note that you don't need to give explicit names to your rules anymore, the
> monad can do that for you.

I was using the names for a Show instance. I am assuming there is no
syntax sugar to recover the name of the variable used in a binder as a
String.

Thanks,

Anton

-- 
Kind Regards,
Anton Tayanovskyy

WebSharper™ - type-safe JavaScript in F#
http://intellifactory.com

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


[Haskell-cafe] CFG specification and analysis directly in Haskell

2011-09-25 Thread Anton Tayanovskyy
Hi,

As a weekend hack, I just realized that Haskell has this wonderful
DoRec syntax that among other things seems to be able to let the user
express context-free grammars together with their processing rules in
normal Haskell code, without template Haskell or anything like that,
just like parser combinators.

I am just wondering if this is this a known and useful result? Are
there libraries doing similar stuff?

I wrote up the Earley algorithm to demonstrate that one can in
principle analyze the complete grammar
(https://github.com/toyvo/haskell-earley). The result derivations
`cheat` by using Data.Dynamic, but the result is quite pleasing, for
example one can do:

grammar :: G.Grammar (G.Rule Char E)
grammar = do
  nat <- G.rule "NAT"
 [ fmap (\_ -> 0) (G.term '0')
 , fmap (\_ -> 1) (G.term '1')
 ]
  rec expr <- G.rule "EXPR"
  [ fmap Nat $ G.var nat
  , pure (\x _ y -> Add x y)
<*> G.var expr
<*> G.term '+'
<*> G.var expr
  ]
  return expr

Thanks,

Anton

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


Re: [Haskell-cafe] regex-applicative library needs your help! (algorithmic challenge)

2011-09-18 Thread Anton Tayanovskyy
Chris, Brandon, thank you for the input. I believe I understand what
you are saying; to reiterate, yes, in the *general case*, neither ML
nor Haskell types outrule nastiness such as non-termination. Yes I
know about and use Coq a bit. However, ML has an important *special
case*: not using functions. Chris, using bang patterns in Haskell do
not quite help to statically rule out recursive terms, do they? They
just make for a different runtime error. If I said:

data Regex =
  ...
  | Seq !Regex !Regex

Will it actually give the user who tries to construct a recursive
value a compile-time error? I suspect not, I'll try it myself to make
sure.

Roman, thanks, I will try to look that thread up - this is what I am
indeed curious about - how to enforce this at the type level.

Yes, with a vanilla interface sharing is not observable; some
libraries work with it and some do not. I am spooked out by this
though: performance guarantees are very different for regular terms
and terms with sharing. Consider the regex engine. The "infinite"
regular expressions (well, they are not really regular), may suddenly
produce an infinte NFA, so memory use may become linear in the input
string. Yes, a smart user will understand this, especially in an area
that is relatively well-understood such as regular expressions.
However I find it extremely disturbing that library designers do not
communicate requirements through the type system, and make performance
guarantees for all well-typed programs. ML makes it easy, I guess I am
just an ML convert :)


Thanks,

Anton

On Sun, Sep 18, 2011 at 11:28 AM, Brandon Allbery  wrote:
> On Sat, Sep 17, 2011 at 22:11, Anton Tayanovskyy
>  wrote:
>>
>> By the way, can Haskell have a type that admits regular expression and
>> only those? I mostly do ML these days, so trying to write up a regex
>> types in Haskell I was unpleasantly surprised to discover that there
>> are all sorts of exotic terms inhabiting it, which I did not have to
>> worry about in ML. Besides `undefined` you can have for terms that try
>> to define a grammar with nested parentheses. Using regex-applicative
>> syntax:
>>
>> expr = ... <|> pure (\ _ x _ -> x) <*> sym "(" <*> expr <*> sym ")"
>
> The general case for this is solving the Halting Problem, so neither Haskell
> nor any other language can do it.  You can disallow infinite values by
> encoding the length into the type, but (a) in Haskell this is painful and
> (b) runtime values now require runtime types, which you can accommodate but
> at the price of reintroducing the problems you are trying to prevent.
>  (Dependently typed languages work better for this, but I suspect the result
> is rather more draconian than you intend.)
> --
> brandon s allbery                                      allber...@gmail.com
> wandering unix systems administrator (available)     (412) 475-9364 vm/sms
>
>



-- 
Kind Regards,
Anton Tayanovskyy

WebSharper™ - type-safe JavaScript in F#
http://intellifactory.com

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


Re: [Haskell-cafe] regex-applicative library needs your help! (algorithmic challenge)

2011-09-18 Thread Anton Tayanovskyy
> I like the approach of Russ Cox[2]. One of the great ideas there (which I
> think he didn't emphasize enough) is to have a queue which allows O(1)
> testing whether an element is already there [3]. This solves the problem
> with priorities -- the states are guaranteed to be enqueued in the order
> of their priorities, and there are no repetitions.

Hm, this sounds great! So then the number of states is just the size
of the NFA, so the memory does not depend on the input string length?
Have you tried this approach yet? I wouldn't vouch for my code in that
gist, I kind of remember trying to eliminate the duplicates while
preserving order buy not sure if I did it correctly there.

>
> To be able to process the states in the proper order I'll have to give
> up Glushkov automaton and probably use something similar to your
> construction [4].
>
> [2] http://swtch.com/~rsc/regexp/regexp2.html
> [3] http://code.google.com/p/re2/source/browse/util/sparse_array.h
> [4] http://t0yv0.blogspot.com/2011/07/combinatory-regular-expressions-in.html
>
> --
> Roman I. Cheplyaka :: http://ro-che.info/
>



-- 
Kind Regards,
Anton Tayanovskyy

WebSharper™ - type-safe JavaScript in F#
http://intellifactory.com

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


Re: [Haskell-cafe] regex-applicative library needs your help! (algorithmic challenge)

2011-09-17 Thread Anton Tayanovskyy
By the way, can Haskell have a type that admits regular expression and
only those? I mostly do ML these days, so trying to write up a regex
types in Haskell I was unpleasantly surprised to discover that there
are all sorts of exotic terms inhabiting it, which I did not have to
worry about in ML. Besides `undefined` you can have for terms that try
to define a grammar with nested parentheses. Using regex-applicative
syntax:

expr = ... <|> pure (\ _ x _ -> x) <*> sym "(" <*> expr <*> sym ")"

Is this the so-called 'paucity of types' [1]? What do you do, as a
library designer? Return bottom or try to detect and error out for
these kind of values?

Thanks,

A

[1] http://existentialtype.wordpress.com/tag/recursion/

On Sat, Sep 17, 2011 at 9:46 PM, Anton Tayanovskyy
 wrote:
> So you want to encode priorities efficiently as far as I understand
> from [1]? Could bit-packing combined with prefix elimination do the
> trick? Choice boils down to binary choice. Attach a number N to every
> execution thread that sits in a given NFA state. When the thread moves
> through a binary choice state, it splits into two threads with
> N_{left} = 2 * N + 1 and N_{right} = 2 * N. When two threads arrive at
> the same NFA state, the machine picks one with greater N and discards
> the other, thus giving priority to early over late and left over
> right. This makes these numbers grow quickly, but at any point in the
> simulation one can identify the common binary prefix of all the thread
> numbers and remove it, because it will not be relevant for comparison.
> If this is too costly, amortize and do it every K steps instead of on
> every step.
>
> Anton
>
> [1] https://github.com/feuerbach/regex-applicative/wiki/Call-For-Help
>
> On Tue, Sep 13, 2011 at 1:40 AM, Roman Cheplyaka  wrote:
>> Please help make the regex-based parsing library efficient!
>>
>> https://github.com/feuerbach/regex-applicative/wiki/Call-For-Help
>>
>> --
>> Roman I. Cheplyaka :: http://ro-che.info/
>>
>> _______
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
>
>
> --
> Kind Regards,
> Anton Tayanovskyy
>
> WebSharper™ - type-safe JavaScript in F#
> http://intellifactory.com
>



-- 
Kind Regards,
Anton Tayanovskyy

WebSharper™ - type-safe JavaScript in F#
http://intellifactory.com

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


Re: [Haskell-cafe] regex-applicative library needs your help! (algorithmic challenge)

2011-09-17 Thread Anton Tayanovskyy
So you want to encode priorities efficiently as far as I understand
from [1]? Could bit-packing combined with prefix elimination do the
trick? Choice boils down to binary choice. Attach a number N to every
execution thread that sits in a given NFA state. When the thread moves
through a binary choice state, it splits into two threads with
N_{left} = 2 * N + 1 and N_{right} = 2 * N. When two threads arrive at
the same NFA state, the machine picks one with greater N and discards
the other, thus giving priority to early over late and left over
right. This makes these numbers grow quickly, but at any point in the
simulation one can identify the common binary prefix of all the thread
numbers and remove it, because it will not be relevant for comparison.
If this is too costly, amortize and do it every K steps instead of on
every step.

Anton

[1] https://github.com/feuerbach/regex-applicative/wiki/Call-For-Help

On Tue, Sep 13, 2011 at 1:40 AM, Roman Cheplyaka  wrote:
> Please help make the regex-based parsing library efficient!
>
> https://github.com/feuerbach/regex-applicative/wiki/Call-For-Help
>
> --
> Roman I. Cheplyaka :: http://ro-che.info/
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Kind Regards,
Anton Tayanovskyy

WebSharper™ - type-safe JavaScript in F#
http://intellifactory.com

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


Re: [Haskell-cafe] F# mailing list?

2009-06-27 Thread Anton Tayanovskyy
Hi Günther, I would be interested in one too. I'm a Haskeller
currently working for an F# shop. There's hubFS but I would absolutely
prefer a mailing list. --A

On Sat, Jun 27, 2009 at 8:31 PM, GüŸnther Schmidt wrote:
> Hi guys,
>
> is there a mailing list for haskellers that defected to F#?
>
> Not that I was I going to, just asking, absolutely hypothetically. Uhm.
>
> Günther
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Kind Regards,

Anton Tayanovskyy
F# Developer

IntelliFactory, Budapest - Hungary
www.intellifactory.com <http://www.intellifactory.com/>

DISCLAIMER AND CONFIDENTIALITY CAUTION:
This message and any of its attachments ("message") are intended
solely for the use of the addressees and contain information that is
legally privileged and confidential. Any unauthorized dissemination,
distribution or copying is strictly prohibited. If you received this
message in error you are obliged to delete it, destroy any printed
copies, and notify the sender.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2009-04-25 Thread Anton Tayanovskyy
For parsers, there is also a LALR(1) generator -
http://jscc.jmksf.com/ - though I have not had personal experience
with it.

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


Re: [Haskell-cafe] Re: Haskell Logo write-in candidate

2009-03-21 Thread Anton Tayanovskyy
> I propose to use concordet voting to appoint a new king from the 100
> aspiring candidates ... ;)

Good point.. Just noticed that I managed to misspell Don Stewart's
name :( Sorry! And thanks for pointing that out!

Speaking of Concordet voiting.. :)

Have you checked out Arrow's impossibility theorem?

http://en.wikipedia.org/wiki/Arrow%27s_impossibility_theorem

Dictatorship is the best!

And to help appoint a king, I suggest this procedure:

First, everyone who wants to be a king puts his name on a wiki page.

Then,

> king = candidates ! maxBound `mod` length candidates


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


Re: [Haskell-cafe] Re: Haskell Logo write-in candidate

2009-03-20 Thread Anton Tayanovskyy
Didn't Haskell have a syntax king? I vote for a logo king: let Don
Steward decide which logo is best. --A
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] can GHC build an executable from a C source file?

2009-03-17 Thread Anton Tayanovskyy
Works for me without the --make, as `ghc foo.c`

--A

On Tue, Mar 17, 2009 at 6:32 PM, Manlio Perillo
 wrote:
> Hi.
>
> I'm checking if it possible to build an executable from C source files only.
>
> As an example:
>
> #include 
>
> int main () {
>    printf("hello world\n");
>    return 0;
> }
>
>
> $ghc --make foo.c
>
>
> However this only produces the object file, foo.o; it does not build the
> executable file.
>
>
> What is the reason for this behaviour?
> I have tested with GHC 6.8.2.
>
>
>
> Thanks  Manlio
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] building c-callable shared objects and dlls with Haskell

2009-03-14 Thread Anton Tayanovskyy
Hello,

What's the current best practice to build shared objects / dlls to
call Haskell from C? I think I figured out the basics, but I would
like to understand the picture completely and document  the current
state of affairs in the Haskell wiki. In particular, I'd like to make
sure that the shared libraries are usable from multiple applications,
and ideally that applications can dynamically link to multiple shared
libraries built from Haskell.

I was trying to do that to call Pandoc from C, and the information was
rather scattered.

Here are two links that I used:

http://www.haskell.org/haskellwiki/Calling_Haskell_from_C
http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html

Based on that information, I was able to compile and run small
examples. However, I'm not sure I completely understand how it works
in production.

Specifically, for the UNIX version, I followed a recipe for loading
and unloading the Haskell runtime with library
constructors/destructors:

#include 

static void library_init(void) __attribute__((constructor));
static void library_init(void) {  hs_init(..); }

static void library_exit(void) __attribute__((destructor));
static void library_exit(void) {  hs_exit(); }

Does this work correctly? Another concern is that every library
compiled this way will include its own copy of the Haskell runtime.
Will there be problems when using multiple libraries?

For the Windows counterpart, there is this very suspicious code I
adapted from the GHC user guide:

#include 
#include 

extern void __stginit_LibPandoc(void);

BOOL STDCALL DllMain( HANDLE hModule, DWORD reason, void* reserved) {
 if (reason == DLL_PROCESS_ATTACH) {
   static char*  args[] = { "ghcDll", NULL };
   startupHaskell(1, args, __stginit_LibPandoc);
 }
 return TRUE;
}

It does not seem to unload the Haskell runtime, indeed the Guide warns
that it is unsafe to do so from DllMain. What are the implications of
this?

Thanks!


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


Re: [Haskell-cafe] Flexible instances

2008-10-15 Thread Anton Tayanovskyy
Thanks for the portable solution.

I'd also like to know how is the following different from
-XFlexibleInstances with [Char]? Stronger, weaker, same thing?

{-# OPTIONS -XTypeSynonymInstances #-}

class Stringable a where
toString :: a -> String

instance Stringable String where
 toString = id


--A

On Wed, Oct 15, 2008 at 10:16 AM, Ryan Ingram <[EMAIL PROTECTED]> wrote:
> So, the Haskell98 solution to this is:
>
> class StringableList a where
> listToString :: [a] -> String
>
> -- now [a] is of the proper form; T = [], a is a type variable
> instance StringableList a => Stringable [a] where
>toString = listToString
>
> -- now to make an instance for Stringable [Char]
> -- we just make an instance for StringableList Char
> instance StringableList Char where
>listToString = id
>
> I think "FlexibleInstances" just makes the compiler jump through these
> hoops instead of you.
>
>  -- ryan
>
> On Wed, Oct 15, 2008 at 3:20 AM, George Pollard <[EMAIL PROTECTED]> wrote:
>>
>> I'm a little confused. Why is this allowed:
>>
>>> data Blah = Blah
>>>
>>> instance Eq Blah where
>>> x == y = True
>>
>> But not this:
>>
>>> class Stringable a where
>>> toString :: a -> String
>>>
>>> instance Stringable [Char] where
>>> toString = id
>>
>> (Resulting in:)
>>
>>> Illegal instance declaration for `Stringable [Char]'
>>> (All instance types must be of the form (T a1 ... an)
>>>  where a1 ... an are distinct type *variables*
>>>  Use -XFlexibleInstances if you want to disable this.)
>>> In the instance declaration for `Stringable [Char]'
>>
>> 'Blah' isn't a type variable, is it? Is my brain just not working right
>> today?
>>
>> ___
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Interesting new user perspective

2008-10-13 Thread Anton Tayanovskyy
If you want to make Haskell more widely used, do pick a name for
Haskell Prime that starts with an A. I first heard of Haskell when
exploring the list of computer languages that Gedit could highlight.
Just imagine going through all those A,B,C,D,E,F,G before I came to
Haskell.

Those programmers who just want to earn their bread will not care if
Haskell tutorials are relevant or irrelevant. They would rather ask
how much a Haskell job pays and how many positions are there. The
Haskell audience is more likely to be people who are either interested
in programming languages in general or greatly dissatisfied with those
languages they work with. For them, the stranger the better.

My brain hurt a lot at first because of the compiler error messages
but I liked the challenge.

>> Trouble is, certain programmers expect to master everything in 20
>> seconds flat ("Learn C++ in 21 days", anyone?)

Just couldn't resist:

http://norvig.com/21-days.html

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


Re: [Haskell-cafe] Web application from the ground up

2008-10-09 Thread Anton Tayanovskyy
Hi Arnaud,

Here's a simple counter program. I mount this to /ws/ with mod_scgi,
and can then do requests http://localhost/ws/ or
http://localhost/ws/?amount=19 (increment by 19 not 1).

  http://hpaste.org/11033

I'm no expert but I'm also working on web applications in Haskell now.
If you are like me, not a big fan of monad transformers, the quick and
dirty way to share state between threads is through an MVar as
demonstrated above. Of course CGI is out of question as handles
requests in separate processes. So you would need FastCGI or SCGI or
(I guess that's the best) embedding a web server. Right now I am
playing with my own little pure Haskell SCGI implementation
(http://hpaste.org/11034) which does one forkIO per request, the
interface is:

runSCGI :: Timeout -> PortID -> CGIT IO CGIResult -> IO ()

forkProcess is only helpful to daemonize the program on UNIX.


Bests,

--A

On Thu, Oct 9, 2008 at 11:25 AM, Arnaud Bailly <[EMAIL PROTECTED]> wrote:
> Hello,
> I am trying to implement a complete web application from the ground
> up, with the objective to convince myself and others that 1) it is
> possible, 2) it is powerful and 3) it is more expressive to do such a
> thing in Haskell.
>
> I managed to get to the point where I can handle users lifecycle
> with DB handling, and I have a CLI application. I have a World that
> stores Session objects, containing a "continuation" of possible
> functions to call.
>
> The problem I am facing now is how to handle (Fast)CGI requests, given
> that each request seems to be served by a dinstinct invocation of a
> function, and share the World between all connections. I have a vague
> idea that this could be handled by creating some CGIT transformed
> monad operating on a TVar World (that's what is hinted at on haskell
> wiki), but I am not sure how to tackle this.
>
> I asked this question on #haskell but had to leave too quickly. Some
> people there seems to think this is something very common that has
> been resolved over a hundred times. Once would be enough for me, and I
> would be very happy if someone could point me to the right direction
> or provide some sample code for this.
>
> Best regards,
> --
> Arnaud Bailly, PhD
> OQube - Software Engineering
> http://www.oqube.com
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] mysql (hsql-mysql-1.7) on Linux with GHC 8.3 - cabal issues

2008-10-03 Thread Anton Tayanovskyy
John,

Thank you for your reply. I benchmarked HDBC.ODBC with MySQL and it is
indeed working well. So whatever slow results I used to get were due
to that particular setup. It looks that HDBC will suit my needs as
well.

Thanks,

--A

> What's more, HDBC has a stronger and more versatile API than HSQL,
> which permits even more speed improvements.  Features such as
> precompiled queries can be huge for many apps, as can referencing
> result columns as an ordered list instead of an association list or
> map.
>
> Personally, I spent the time to write the Sqlite3, ODBC, and
> PostgreSQL bindings for HDBC owing to existing needs.  I have no need
> for a MySQL binding because I avoid MySQL wherever possible, and where
> not possible, use ODBC.
>
> That said, the API is designed to make development of database
> backends easy.  FFI also is quite nice.  It should not be a
> significant task for an interested party to write a MySQL backend.  I
> think it has not happened yet because the ODBC backend is fully
> functional for MySQL.
>
> -- John
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] mysql (hsql-mysql-1.7) on Linux with GHC 8.3 - cabal issues

2008-10-02 Thread Anton Tayanovskyy
On Thu, Oct 2, 2008 at 6:39 PM, Duncan Coutts
<[EMAIL PROTECTED]> wrote:
> The problem here really is that HSQL has no maintainer and has not been
> updated for about two years if my memory serves me correctly. Some
> distros, Fedora, Gentoo etc have patched HSQL to keep it working with
> ghc-6.8.

I see. True, it was updated Apr 9, 2007. Well, it's a pity that
neither Hackage nor the Haskell wiki mentions those patches.

>
> The answer is to find someone to maintain it, take over maintenance
> yourself or switch to another lib like hdbc or takusen.

Hmm.. That's too bad. AFAIK hdbc and takusen do not have native MySQL
backends. Last time I tried working with MySQL through ODBC on Linux
it was quite slow to connect, compared to the native backend. Taking
over myself is out of question, it is beyond me. So by elimination
I'll have to find someone!


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


[Haskell-cafe] mysql (hsql-mysql-1.7) on Linux with GHC 8.3 - cabal issues

2008-10-02 Thread Anton Tayanovskyy
Hello,

I had some difficulty building hsql and hsql-mysql (native driver)
packages under GHC 8.3 on Fedora 9. Namely, they do not install with
cabal install, because of a few API changes. Is this considered all
right as GHC 8.3 is still experimental, or should the packages be
updated? If so, can somebody please do it. I love when things just
work with cabal install!

The problem looks very basic -- just some Cabal file
incompatibilities. However I am not experienced with the Cabal build
process, so I'll just write what I did to get it to work on my
platform, maybe it will help someone.

== hsql.cabal ==

name:   hsql
version:1.7
license:BSD3
author: Krasimir Angelov <[EMAIL PROTECTED]>
category:   Database
description:Simple library for database access from Haskell.
exposed-modules:
Database.HSQL,
Database.HSQL.Types
build-depends:  base, old-time
build-type: Simple
ghc-options:-O2
extensions: ForeignFunctionInterface, TypeSynonymInstances, CPP,
RankNTypes, DeriveDataTypeable


== hsql-mysql.cabal ==

name:hsql-mysql
version: 1.7
license: BSD3
author:  Krasimir Angelov <[EMAIL PROTECTED]>
category:Database
description: MySQL driver for HSQL.
ghc-options: -O2
build-depends:   base, hsql, Cabal, old-time
extensions:  ForeignFunctionInterface, CPP
include-dirs:Database/HSQL, /usr/include/mysql
build-type:  Simple
extra-source-files: Database/HSQL/HsMySQL.h
extra-libraries: mysqlclient
extra-lib-dirs:  /usr/lib/mysql
exposed-modules:
Database.HSQL.MySQL


== hsql-mysql*/Setup.lhs ==

#!/usr/bin/runghc

\begin{code}
import Distribution.Simple

main = defaultMain
\end{code}


Of course this hsql-mysql.cabal should not mention Fedora-specific
locations as /usr/lib/mysql and /usr/include/mysql but I don't know
how to make that generic. The original version had a big custom
Setup.lhs file which wouldn't compile with the new Cabal and which I
couldn't tweak myself.


Thanks,


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


[Haskell-cafe] SCGI module

2008-10-02 Thread Anton Tayanovskyy
Hello,

SCGI module from Hackage is not working for me with Apache mod_scgi, I
think because it uses LazyBytestring to hGetContents on a socket
handle and the Apache side does not close the socket. Also, looking at
the source I didn't see any fork* calls, so I assume it is not doing
concurrency.

So I ended up writing a replacement and would like to invite comments.
It does forkIO per request and, if asked to, timeouts those threads.
So far it works for me on simple examples from
http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell
giving roughly 800 requests a second versus 250 on plain CGI (both
through Apache).

  http://hpaste.org/10842

Thanks!

Also, in general, is there any interest in using SCGI, or FastCGI
(plain CGI, HappS, you name it) is vastly superior?


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


Re: [Haskell-cafe] number-parameterized types and heterogeneous lists

2008-06-23 Thread Anton Tayanovskyy
Alfonso,

Thanks! For didactic purposes I will defer looking into your code. It
does not always help to know the correct solution :)


Bests,

--A

On Mon, Jun 23, 2008 at 11:26 AM, Alfonso Acosta
<[EMAIL PROTECTED]> wrote:
> Inspired in Oleg's ideas, I implemented the packages type-level and
> parameterized-data (which includes number-parameterized vectors).
>
>
> To get an idea about how they work you might want to read their
> haddock documentation in hackage:
>
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/type-level
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/parameterized-data
>
> You can get their darcs repositories (including some minor updates) from:
>
> darcs get http://code.haskell.org/type-level
> darcs get http://code.haskell.org/parameterized-data
>
> On Fri, Jun 20, 2008 at 8:01 AM, Harald ROTTER <[EMAIL PROTECTED]> wrote:
>>
>> Dear Haskellers,
>>
>> after reading Oleg Kiselyov's paper on number-parameterized types I started
>> to play around with
>> the class Digits that encodes decimal numbers in types. The "typed number"
>> 10 would e.g. be defined as
>>
>>  D1 $ D0 $ Sz
>>
>> I wondered if it would be possible replace the expression above by a
>> heterogeneous list like
>>
>>  [D1,D0]
>>
>> so I tried to define
>>
>>  data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a)
>>
>> Loading this into ghci yields:
>>
>> :t Digit D0
>>
>> :1:0:
>>Ambiguous type variable `a' in the constraint:
>>  `Digits a' arising from a use of `Digit' at :1:0-7
>>Probable fix: add a type signature that fixes these type variable(s)
>>
>> Removing the type constraints in the definition of "Digit":
>>
>>  data Digit = forall a b.Digit (a -> b a)
>>
>> makes it work like this:
>>
>>  :t Digit D0
>>  Digit D0 :: Digit
>>
>>  :t [Digit D0, Digit D1]
>>  [Digit D0, Digit D1] :: [Digit]
>>
>> "Digit", however, is far too general (it also includes e.g. \x -> [x]), but
>> I would like it to be restricted to the Digit class.
>>
>> Any help is appreciated.
>>
>> Thanks
>>
>> Harald.
>>
>>
>> CODE:
>>
>> module Test where
>>
>> data D0 a = D0 a
>> data D1 a = D1 a
>> data D2 a = D2 a
>> data D3 a = D3 a
>> data D4 a = D4 a
>> data D5 a = D5 a
>> data D6 a = D6 a
>> data D7 a = D7 a
>> data D8 a = D8 a
>> data D9 a = D9 a
>>
>> class Digits ds where
>>d2num :: Num a => ds -> a -> a
>>
>> data Sz = Sz-- zero size
>> instance Digits Sz where
>>d2num _ acc = acc
>>
>> instance Digits ds => Digits (D0 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc)
>> instance Digits ds => Digits (D1 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+1)
>> instance Digits ds => Digits (D2 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+2)
>> instance Digits ds => Digits (D3 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+3)
>> instance Digits ds => Digits (D4 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+4)
>> instance Digits ds => Digits (D5 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+5)
>> instance Digits ds => Digits (D6 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+6)
>> instance Digits ds => Digits (D7 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+7)
>> instance Digits ds => Digits (D8 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+8)
>> instance Digits ds => Digits (D9 ds) where
>>d2num dds acc = d2num (t22 dds) (10*acc+9)
>>
>> t22 :: f x -> x
>> t22 = undefined
>>
>> --data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a)
>> data Digit = forall a b.Digit (a -> b a)
>>
>> -
>>
>>
>>
>> " Ce courriel et les documents qui y sont attaches peuvent contenir des 
>> informations confidentielles. Si vous n'etes  pas le destinataire escompte, 
>> merci d'en informer l'expediteur immediatement et de detruire ce courriel  
>> ainsi que tous les documents attaches de votre systeme informatique. Toute 
>> divulgation, distribution ou copie du present courriel et des documents 
>> attaches sans autorisation prealable de son emetteur est interdite."
>>
>> " This e-mail and any attached documents may contain confidential or 
>> proprietary information. If you are not the intended recipient, please 
>> advise the sender immediately and delete this e-mail and all attached 
>> documents from your computer system. Any unauthorised disclosure, 
>> distribution or copying hereof is prohibited."
>> ___
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-ca

Re: [Haskell-cafe] number-parameterized types and heterogeneous lists

2008-06-20 Thread Anton Tayanovskyy
Hi Harald,

Can you give a link to the paper? Interesting stuff. Thanks.

This is stretching my abilities a bit, but is this what you are after?

data Digit = forall b.(Digits (b Sz)) => Digit (Sz -> b Sz)

instance Digits [Digit] where
d2num []   acc = acc
d2num (Digit x:xs) acc = d2num xs (10*acc + d2num (x Sz) 0)

I assumed you only want D0..D9 as digits, maybe this is too narrow.

I've put this up on hpaste:

http://hpaste.org/8437#a1



Bests,

Anton



On Fri, Jun 20, 2008 at 3:01 PM, Harald ROTTER <[EMAIL PROTECTED]> wrote:
>
> Dear Haskellers,
>
> after reading Oleg Kiselyov's paper on number-parameterized types I started
> to play around with
> the class Digits that encodes decimal numbers in types. The "typed number"
> 10 would e.g. be defined as
>
>  D1 $ D0 $ Sz
>
> I wondered if it would be possible replace the expression above by a
> heterogeneous list like
>
>  [D1,D0]
>
> so I tried to define
>
>  data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a)
>
> Loading this into ghci yields:
>
> :t Digit D0
>
> :1:0:
>Ambiguous type variable `a' in the constraint:
>  `Digits a' arising from a use of `Digit' at :1:0-7
>Probable fix: add a type signature that fixes these type variable(s)
>
> Removing the type constraints in the definition of "Digit":
>
>  data Digit = forall a b.Digit (a -> b a)
>
> makes it work like this:
>
>  :t Digit D0
>  Digit D0 :: Digit
>
>  :t [Digit D0, Digit D1]
>  [Digit D0, Digit D1] :: [Digit]
>
> "Digit", however, is far too general (it also includes e.g. \x -> [x]), but
> I would like it to be restricted to the Digit class.
>
> Any help is appreciated.
>
> Thanks
>
> Harald.
>
>
> CODE:
>
> module Test where
>
> data D0 a = D0 a
> data D1 a = D1 a
> data D2 a = D2 a
> data D3 a = D3 a
> data D4 a = D4 a
> data D5 a = D5 a
> data D6 a = D6 a
> data D7 a = D7 a
> data D8 a = D8 a
> data D9 a = D9 a
>
> class Digits ds where
>d2num :: Num a => ds -> a -> a
>
> data Sz = Sz-- zero size
> instance Digits Sz where
>d2num _ acc = acc
>
> instance Digits ds => Digits (D0 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc)
> instance Digits ds => Digits (D1 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+1)
> instance Digits ds => Digits (D2 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+2)
> instance Digits ds => Digits (D3 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+3)
> instance Digits ds => Digits (D4 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+4)
> instance Digits ds => Digits (D5 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+5)
> instance Digits ds => Digits (D6 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+6)
> instance Digits ds => Digits (D7 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+7)
> instance Digits ds => Digits (D8 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+8)
> instance Digits ds => Digits (D9 ds) where
>d2num dds acc = d2num (t22 dds) (10*acc+9)
>
> t22 :: f x -> x
> t22 = undefined
>
> --data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a)
> data Digit = forall a b.Digit (a -> b a)
>
> -
>
>
>
> " Ce courriel et les documents qui y sont attaches peuvent contenir des 
> informations confidentielles. Si vous n'etes  pas le destinataire escompte, 
> merci d'en informer l'expediteur immediatement et de detruire ce courriel  
> ainsi que tous les documents attaches de votre systeme informatique. Toute 
> divulgation, distribution ou copie du present courriel et des documents 
> attaches sans autorisation prealable de son emetteur est interdite."
>
> " This e-mail and any attached documents may contain confidential or 
> proprietary information. If you are not the intended recipient, please advise 
> the sender immediately and delete this e-mail and all attached documents from 
> your computer system. Any unauthorised disclosure, distribution or copying 
> hereof is prohibited."
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe