[Haskell-cafe] local type denotation

2012-11-14 Thread Serge D. Mechveliani
Please, how to correctly set an explicit type for a local value in the body of a polymorphic function? Example (tested under ghc-7.6.1): data D a = D1 a | D2 a (a -> a) f :: Eq a => D a -> a f (D1 x) = x f (D2 x g) = let -- y :: Eq a => a y = g x in

[Haskell-cafe] correction

2012-05-07 Thread Serge D. Mechveliani
Correction to my last letter: Run on the second terminal > ./iface --> Run on the second terminal > ./a.out -- Sergei mech...@botik.ru ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell

[Haskell-cafe] unsafePerformIO usage

2012-05-06 Thread Serge D. Mechveliani
People, can anybody explain what incorrect may happen with the following program which uses exchange through two Unix pipes and unsafePerformIO ? The pipes are created by the Unix commands mkfifo toA; mkfifo fromA gcc iface.c compiles the C program to

Re: [Haskell-cafe] named pipe interface

2012-01-16 Thread Serge D. Mechveliani
To my question about safety of >> toA_IO = openFd "toA" WriteOnly Nothing defaultFileFlags >> fromA_IO = openFd "fromA" ReadOnly Nothing defaultFileFlags >> toA = unsafePerformIO toA_IO >> fromA = unsafePerformIO fromA_IO >> >> axiomIO :: String -> IO String >> axiomIO str = do >>

Re: [Haskell-cafe] named pipe interface

2012-01-14 Thread Serge D. Mechveliani
On Fri, Jan 13, 2012 at 12:19:34PM -0800, Donn Cave wrote: > Quoth "Serge D. Mechveliani" , > ... > > Initially, I did the example by the Foreign Function Interface for C. > > But then, I thought "But this is unnatural! Use plainly the standard > > Haskell I

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Serge D. Mechveliani
On Fri, Jan 13, 2012 at 04:34:37PM +0100, Chadda?? Fouch?? wrote: > On Thu, Jan 12, 2012 at 7:53 PM, Serge D. Mechveliani > wrote: > > [..] > > I need to organize a  string interface  for a Haskell function > > Main.axiom  and a C program > >                      

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Serge D. Mechveliani
On Fri, Jan 13, 2012 at 10:08:04AM -0800, Donn Cave wrote: > Quoth "Serge D. Mechveliani" , > [ ... why in Haskell instead of FFI ... ] > > > Because it is a direct and the simplest approach. Why does one need a > > foreign language, if all the needed functions a

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Serge D. Mechveliani
lbery wrote: > > > On Fri, Jan 13, 2012 at 12:25, Serge D. Mechveliani wrote: > > > >> On Fri, Jan 13, 2012 at 04:34:37PM +0100, Chadda?? Fouch?? wrote: > >> > Now that seems interesting, but just to be clear : did you choose > >> > this

[Haskell-cafe] named pipes interface

2012-01-13 Thread Serge D. Mechveliani
I thank people for the notes. People write that the example without unsafePerformIO is desirable. So I present the improved question and improved, "pure" code. -- I need to organize a string interface for a Haskell function

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Serge D. Mechveliani
On Fri, Jan 13, 2012 at 04:34:37PM +0100, Chadda?? Fouch?? wrote: > On Thu, Jan 12, 2012 at 7:53 PM, Serge D. Mechveliani > wrote: > > People, > > > > (I wonder: is this for  beginn...@haskell.org ?) > > I don't think so. > > > > > I need to or

[Haskell-cafe] named pipe interface

2012-01-12 Thread Serge D. Mechveliani
People, (I wonder: is this for beginn...@haskell.org ?) I need to organize a string interface for a Haskell function Main.axiom and a C program fifoFromA.c via a pair of named pipes (in Linux, UNIX). The pipes are created before running, by the commands

[Haskell-cafe] NewLines in string

2008-10-04 Thread Serge D. Mechveliani
People, Here is a certain naive question about string setting in a Haskell program. I have the functions parseProgram :: String -> Program apply:: Program -> Term -> Term-- interpreter, and try to build the example modules for them as in the following example: ---

[Haskell-cafe] sortBy2 for List library

2006-06-23 Thread Serge D. Mechveliani
Consider the following suggestions for the standard Haskell library `List'. import List (intersprerse, insertBy) compose :: [a -> a] -> a -> a -- just appropriate name compose = foldr (.) id insertBy2 :: (a -> b) -> Co

[Haskell-cafe] Re: Proposal for Number classes

2006-04-26 Thread Serge D. Mechveliani
Dylan Thurston <[EMAIL PROTECTED]> wrote on 17 Apr 2006 > On Sat, Apr 08, 2006 at 10:16:53PM +0400, Serge D. Mechveliani wrote: >> I think that without dependent types for a Haskell-like language, >> it is impossible to propose any adequate and in the same time plainly

[Haskell-cafe] Re: Proposal for restructuring Number classes

2006-04-08 Thread Serge D. Mechveliani
On Sat, Apr 08, 2006 at 02:39:39PM +0200, Andrew U. Frank wrote: > there has been discussions on and off indicating problems with the structure > of the number classes in the prelude. i have found a discussion paper by > mechveliani but i have not found a concrete proposal on the haskell' list of

[Haskell-cafe] Re: dummy variables

2004-12-29 Thread Serge D. Mechveliani
o warning, but variable can still be used. > > Keean. > > Duncan Coutts wrote: > > >In message <[EMAIL PROTECTED]> "Serge D. Mechveliani" > ><[EMAIL PROTECTED]> writes: > > > > > >>Dear Haskellers, dear GHC team, > >

Re: [Haskell-cafe] foldlWhile

2004-11-21 Thread Serge D. Mechveliani
To my question of >> foldlWhile :: (a -> b -> a) -> (a -> Bool) -> a -> [b] -> a >> foldlWhilefp abs = >>case >>(bs, p a) >>of >>([],_) -> a >>(_, False) -> a >>(b:bs', _) -> foldlWhile f p (f a b) bs' >> >> fol

[Haskell-cafe] foldlWhile

2004-11-20 Thread Serge D. Mechveliani
Is such a function familia to the Haskell users? foldlWhile :: (a -> b -> a) -> (a -> Bool) -> a -> [b] -> a foldlWhilefp abs = case (bs, p a) of ([],_) -> a (_, False) -> a (b:bs', _) -> foldlWhile f p (f a b) b

[Haskell-cafe] unneeded strictness

2004-10-20 Thread Serge D. Mechveliani
Dear Haskellers, I am still trying to find out how to organize naturally a `lazy' printing of an accumulated data field. People advised me no-buffering and also the tilde usage. But there is some more obstackle. The `trace' is accumulated in fl1 by repeating consD, where data D = D {

Re: [Haskell-cafe] Re: [Haskell] lazy constructors

2004-10-13 Thread Serge D. Mechveliani
I thank Jeremy Gibbons, Ben Rudiak-Gould, and other people, for their helpful explanations. On Wed, Oct 13, 2004 at 02:34:55PM +0100, Ben Rudiak-Gould wrote: > Serge D. Mechveliani wrote: > > > As the types are resolved before the computation, as the above > > prog

[Haskell-cafe] Re: [Haskell] lazy constructors

2004-10-13 Thread Serge D. Mechveliani
On Wed, Oct 13, 2004 at 09:23:43AM +0100, MR K P SCHUPKE wrote: > You can only return a list of pair's lazily, not > a pair of lists. If the two strings are independant, then > generate each in a separate function, and pair off the > results lazily. No, I have several labeled fields in a record,

[Haskell-cafe] Re: [Haskell] lazy constructors

2004-10-13 Thread Serge D. Mechveliani
On Wed, Oct 13, 2004 at 10:06:44AM +0200, Sander Evers wrote: > > >Question 2 > >-- > >How to arrange the above `lazy' output? > > > > > Your function addToSPair > > addToSPair :: Char -> (String, String) -> (String, String) > addToSPairc (xs, ys) = (c:xs, ys) >