Re: [Haskell] reference to DoCon

2010-12-13 Thread Serge D. Mechveliani
On Mon, Dec 13, 2010 at 10:33:47AM -0800, Don Stewart wrote:
> mechvel:
> > Dear administration of   www.haskell.org,
> > 
> > (I am sorry for not finding a more appropriate list for this letter) 
> > 
> > In old days, my program system  DoCon
> > 
> > (computer algebra written in Haskell) had its copy on  
> >   www.haskell.org/docon/
> > -- if I remember correct.
> > Now, I need to set a certain reference, but do not find any DoCon
> > copy on the Haskell site.
> > 
> > Then, I searched just for any reference to DoCon at  www.haskell.org.
> > It mentions DoCon in the application section of "Computer Algebra",
> > but the reference does not work: "page not found".
> > 
> > On the other hand, each year someone of the Haskell site asks me to 
> > confirm the references to my Haskell applications, and I respond, 
> > and this always looked all right.
> > 
> > Now, if you decide to remove the DoCon directory from  haskell.org,
> > then, can you, please, inform me explicitly?
> > 
> > Also I ask you at least to provide in an appropriate place the 
> > reference
> >   http://botik.ru/pub/local/Mechveliani/docon/
> > 
> > to the home of DoCon; so far, this place is the most supported. 
> > 
> > Please, copy the respond to  mech...@botik.ru
> > 
> 
> 
> Community projects have moved to the machine:
> 
> code.haskell.org
> 
> It would be best to move DoCon there too.


It is all right.
But I do not know, when an application is "moved to the machine Foo", 
maybe, it is appropriate to somehow also set a link in the old place?
Because, the references to the web are set in many old places, for 
example, in old papers, in technical reports.
Somehow, to keep conservative, to avoid destroing.

Regards,
Sergey.

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


[Haskell] reference to DoCon

2010-12-13 Thread Serge D. Mechveliani
Dear administration of   www.haskell.org,

(I am sorry for not finding a more appropriate list for this letter) 

In old days, my program system  DoCon

(computer algebra written in Haskell) had its copy on  
  www.haskell.org/docon/
-- if I remember correct.
Now, I need to set a certain reference, but do not find any DoCon
copy on the Haskell site.

Then, I searched just for any reference to DoCon at  www.haskell.org.
It mentions DoCon in the application section of "Computer Algebra",
but the reference does not work: "page not found".

On the other hand, each year someone of the Haskell site asks me to 
confirm the references to my Haskell applications, and I respond, 
and this always looked all right.

Now, if you decide to remove the DoCon directory from  haskell.org,
then, can you, please, inform me explicitly?

Also I ask you at least to provide in an appropriate place the 
reference
  http://botik.ru/pub/local/Mechveliani/docon/

to the home of DoCon; so far, this place is the most supported. 

Please, copy the respond to  mech...@botik.ru

With kind regards, 

-
Serge Mechveliani
mech...@botik.ru

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


[Haskell] typo in Haskell definition

2010-11-18 Thread Serge D. Mechveliani
Looking into the  on-line  Haskell-2010 definition, 
I see in  the Library definition

 20.4.3 ...
iteratef (instead of "iterate f"),
repeatx  (instead of "repeat x").

Regards, 

-
Serge Mechveliani
mech...@botik.ru


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


[Haskell] DoCon soft announcement

2007-06-15 Thread Serge D. Mechveliani
Software Announcement
-

The Algebraic Domain Constructor  DoCon,  Version 2.09,

written in Haskell,

is available, together with its source program, on Internet at the
following addresses:

  http://www.botik.ru/~mechvel/  click at  docon-2.09  (Russian site),
  ftp.botik.ru/pub/local/Mechveliani/docon/(same site),
  http://www.haskell.org/docon/distrib/(USA site)

The difference to previous (2.08) release is small: 
* it is ported to the latest (on 2007) Glasgow Haskell version of 6.6.1,
* it has a simpler installation code, due to that it relies on the 
  commands `configure', `build', `install' of the Cabal support for 
  `making',
* several bugs are fixed,
* the implementation for decomposing to elementary symmetrics is improved.

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


[Haskell] `Dumatel' software announcement

2005-05-16 Thread Serge D. Mechveliani
  A N N O U N C E M E N T

   D u m a t e l

a prover program based on equational reasoning,  Version 1.02


is available, together with its source program and manual book,
at the following addresses:

  http://www.botik.ru/~mechvel/papers.html  click at `dumatel'
 (Russian site),
  ftp.botik.ru/pub/local/Mechveliani/dumatel/(same site),

  http://www.haskell.org/dumatel/distrib/(USA site)


Dumatel-1.02 is
---
a prover based on  many-sorted term rewriting (TRW)  and equational 
reasoning.
It is a program package written in a purely functional, `lazy' 
language Haskell.
It is presented as a library of functions and data structures. 
To use Dumatel-1.02, user needs to be familiar with Haskell
programming.

What it has. Abilities 
--
* TRW interpreter `reduce', subdued to an explicitly given partial 
  term ordering parameter.
* `Unfailing' Knuth-Bendix completion methods  ukb, ukbb,
  where the latter method extends the former with a certain 
  specialized completion for the Boolean connectives.
* The inductive prover `prove', including also the refutation
  procedure for the predicate calculus, using  ukbb. 
  The prover reasons about equational specifications, transforming 
  them dynamically.
* So far, it is able to solve in a real time only simple problems, 
  and not all of them. Examples of successful proof:
  (1) Prove  
  list |-inductive-  forall Xs ((reverse reverse Xs) = Xs),
  where "reverse" is defined recursively via the list 
  concatenation "+", and "+" defined recursively via ":"
  (`cons').
  (2) naturalNumbers |-inductive-  forall [n, m] (n+m = m+n),
  where "+" is defined via the "successor" operator by the 
  equations  [n+0 = 0,  n+(s m) = s (n+m)].
  Example of failure:
  (3) naturalNumbers |-inductive-  forall [n, m] (n*m = m*n),
  where the multiplication "*" is defined in (2) via "+":
  [n*0 = 0,  n*(s m) = n + n*m].

See the  book.ps  for further information.


Ports:Dumatel-1.02 was tested under  ghc-6.2.2, Linux.
--

Manual (`book'):  see  dm/book.ps  contained in the distribution.
---

Remarks are welcome:   [EMAIL PROTECTED]


Serge Mechveliani,
Program Systems Institute, 152020, Pereslavl-Zalessky, Russia.
e-mail  [EMAIL PROTECTED]
http://www.botik.ru/~mechvel






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


[Haskell] DoCon-2.08 announcement

2004-12-20 Thread Serge D. Mechveliani
Announcement


A Computer Algebra program DoCon-2.08 is released:

  http://www.botik.ru/~mechvel/  click at  docon-2.08
 (Russian site),
  ftp.botik.ru/pub/local/Mechveliani/docon/  (same),
  http://www.haskell.org/docon/distrib/  (USA site)

DoCon-2.08 is a library of Haskell functions and data structures.
It is written in an extension of  Haskell-98  including 
multiparametric classes,  overlapping instances and `undecidable' 
instances.
It was tested under the Glasgow Haskell system of 6.2.2,  
under Linux.
The main differences to the previous release of 2.06 are: 
* it is ported to a more recent system  ghc-6.2.2,
  the Manual is revised slightly,
* it includes some support for non-commutative polynomials over a 
  commutative ring,
* several bugs are fixed.

-
Serge Mechveliani
[EMAIL PROTECTED]




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


[Haskell] lazy constructors

2004-10-12 Thread Serge D. Mechveliani
Dear Haskellers,

I try to organize a `lazy' output in my program, so that the 
data are accumulated, step by step in a pair
 (String, String)
(a contrived simplified example).
And the first component is a `story' to be printed out in a `lazy'
manner, the first steps need to print without waiting for the whole
data field to be ready. 

If the program returns  String,  then I can arrange this.
But with  (String, String),  I do not know how to do.
And in the real progam, it is a more complex labeled record, carried
along through the program.
Probably, the obstackle is in the very Haskell language.
Consider a simple example:

---
bottomStr :: String
bottomStr = let xs = xs in xs

bottomSPair :: (String, String)
bottomSPair = let p = p in p

bound = 10^8  :: Int   -- some large number

f1, f2, g1, g2 :: Char

f1 = head ('a' :  (if last [1 .. bound] > 0 then "b" else "c"))

f2 = head ('a' : bottomStr)

g1 = head $ fst $ addToSPair 'a'
 (if  last [1 .. bound] > 0  then ("b", "") else ("c", ""))

g2 = head $ fst $ addToSPair 'a' bottomSPair

addToSPair :: Char -> (String, String) -> (String, String)
addToSPairc   (xs, ys) =  (c:xs,   ys)

main = putStr  [ f1,  '\n' ]
  -- f2
  -- g1, g2
---

g1 is similar to f1,  g2 similar to f2.

f1 and f2 are evaluated immediately to 'a';

g1 evaluates to 'a' after a long computation;
g2 evaluates to  Fail: <>

As g2 is similar to f2, should it have a value 'a' ?
In
   head $ fst $ addToSPair 'a' bottomSPair

bottomSPair  is of type  (String, String).
addToSPair   is declared as returning  (String, String).
Hence, the complier knows ab initio that after  addToSPair
the result is of kind
  ('a': _,  _) :: (String, String)

Hence, applying further   head $ fstyields  'a'.
This is in the air of a `lazy' computation.
In a more clear presentation, the computation should (?) be

   head $ fst $ addToSPair 'a' bottomSPair
   =
   head $ fst $ addToSPair 'a' (bottomStr, bottomStr)
   =
   head $ fst (`a':bottomStr, bottomStr)
   =
   head (`a':bottomStr)
   = 
   'a'

So, similarly as
  head ('a' : bottomStr)= 'a',   (1)
it should be
  head $ fst $ addToSPair 'a' bottomSPair   = 'a'(2)

Probably, Haskell-98 does not put so. Right?

Question 1
--
What may be the consequences for the language 
(let us call it HCLazy)  if it treats the data constructors like in 
(2), like more `lazy' ones?

For example,  fst (bottom :: (a,b)) =  (bottom :: a)


Question 2
--
How to arrange the above `lazy' output?
The whole result story is ready in several hours, or days,
and each step should be displayed immediately as it is ready.

So far, I see no other way as to compile the program together with 
the  Trace  library, inserting there the calls
\ step ... -> trace (show step) $ ...
(?)

Thank you in advance for the explanations.

Copy, please, the answer to  [EMAIL PROTECTED]

-
Serge Mechveliani
[EMAIL PROTECTED]




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


[Haskell] -allow-extension-for-bottom

2004-10-11 Thread Serge D. Mechveliani
Dear Haskell implementors,

Consider the compilation flag  -allow-extension-for-bottom

which changes the language meaning so that allows to ignore
the bottom value. For example, the programs

   (1)   (\ x -> (if p x then  foo (g x)  else  foo (h x)) )
and
   (2)   (\ x -> foo ((if p x then  g x  else  h x)) )

become equivalent, and many program transformations become 
possible.
I suspect that after compiling and running of a program under
-allow-extension-for-bottom  the user will discover many helpful
information about the original program.
For example, under  -allow-extension-for-bottom  it may run 1000 
times faster, and then, the user finds out what to change to have 
a 1000 times speed-up for the original program for the standard 
Haskell. 

Thus, in my particular practical example, it is evident to me that 
it is better to specify (2). But many similar effects are hard to 
find out without compiling under  -allow-extension-for-bottom.

Maybe, the compiler could issue the warnings like, say,

  "Consider factoring `if' in ...   This may improve ... "
?

Copy, please, the answer to  [EMAIL PROTECTED],

-
Serge Mechveliani
[EMAIL PROTECTED]
 



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


[Haskell] Re: factoring `if'

2004-10-11 Thread Serge D. Mechveliani
Thanks for the help!

People note that in my example of 

> > (1)   (\ x -> (if p x then  foo (g x)  else  foo (h x)) ...)
> > 
> > (2)   (\ x -> foo  ((if p x then  g x  else  h x)) )

p x  may be _|_, and this makes (1) not equivalent to (2).

-
Serge Mechveliani
[EMAIL PROTECTED]


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


[Haskell] factoring `if'

2004-10-11 Thread Serge D. Mechveliani
Dear Haskell implementors,

How do you think, is the program (1) equivalent to (2) 
in the meaning of Haskell-98 ?

(1)   (\ x -> (if p x then  foo (g x)  else  foo (h x))
  where
  p ... g ... h ... foo ...
  )

(2)   (\ x -> foo  ((if p x then  g x  else  h x)
where
p ... g ... h ... foo ...
   )
  )

If it is equivalent, then does it make sense for a compiler to 
convert (1) to (2):  to separate a common `factor' of the if-branches
?
The reason for this may be, for example, that the result printing
of  (f x)  is more `lazy' in (2) than in (1):
the part of  foo  may print immediately and  (g x) or (h x)  may print
long after.
This is a difference in behavior, it does not effect the computation
meaning.

I have a large program which is easily written in the style of (1),
(and in many places it sets `case' instead of `if').  
Annoyingly, it prints out in a not a lazy manner.
It can be rewritten in the form of (2), but with effort, and it will
look less plain.
So, maybe, this is a business of a compiler?

Copy, please, the possible answer to  [EMAIL PROTECTED]

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


Re: [Haskell] lazy printing

2004-09-10 Thread Serge D. Mechveliani
To my request

> > Can you tell me how to force Haskell to output the results in a
> > `lazy' way? 
> [..]
> > main = putStr (concat ["\n min1 = ", show min1,
> >"\n min2 = ", show min2,
> >"\n"
> >   ]
> >   )
> [..]
> > This prints   min1 = 1
> > 
> > and hangs silently -- probably, because  min2  takes long to compute.
> > But why does not it print immediately
> >   
> >   min1 = 1
> >   min2 = 


Keith Wansbrough <[EMAIL PROTECTED]>  writes

> 
> Haskell is outputting lazily, but by default stdout is set to 
> LineBuffering - for efficiency, a line is only written to stdout 
> once it is complete.  Try adding "\n" to the end of the "min2 =" 
> line to see what I mean.
> To get the behaviour you describe, add import IO  and 
> hSetBuffering stdout NoBuffering >>  to the start of your main function.
> 


( and what if it also aplies  writeFile "log"  ? )


Thank you. It helps with the contrived examples.

But I cannot do a real example, so far: 

  ---
  module Main
  where
  import IO
  import Test (test)

  main = hSetBuffering stdout NoBuffering >>
 test 

  ---
  type ProofTrace = [ProofTraceStep]
  ...
  instance Show ProofTraceStep
where
showsPrec _ step =

  ("\n-\n"++) .  sho step
  where
  sho (ProveGoal g rc) =
  ("Proving the goal\n "   ++) . shows (goalIndex   g) .
  ("\nwith the formula\n " ++) . shows (goalFormula g) .
  ("\ngiven the resource  "++) . shows rc
 
  sho ...  = ...
   ---
   
The trace data field is   ptrace :: ProofTrace -> ProofTrace
,
it is accumulated during the program like this:

  \ ... g ptrace ->  ptrace . ((BranchProved [g]) :)

It prints out by  show (ptrace []),  via the above Show instance
for  ProofTraceStep.

Of course, this information may be not sufficient, and probably,
I need further experimenting and investigation.

Copy, please, the answer, if any, to  [EMAIL PROTECTED]

-
Serge Mechveliani
[EMAIL PROTECTED]






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


[Haskell] lazy printing

2004-09-10 Thread Serge D. Mechveliani
Dear Haskellers,

Can you tell me how to force Haskell to output the results in a
`lazy' way? 
Consider, for example, the program

main = putStr (concat ["\n min1 = ", show min1,
   "\n min2 = ", show min2,
   "\n"
  ]
  )
   where
   min1 = minimum [1 .. 10 ]  :: Integer
   min2 = minimum [1 .. (10^10)]  :: Integer

I do not know whether the effect is due to implementation.
And I `make'-run the program under  GHC-6.2.2-pre  by commanding

ghc -O --make Main
./a.out 

This prints   min1 = 1

and hangs silently -- probably, because  min2  takes long to compute.
But why does not it print immediately
  
  min1 = 1
  min2 = 
?  

This is for the first time in my practice that a `lazy' printing is
essential.
The above example is contrived.
The real example is a program that searches for the proof and 
accumulates a certain
  ptrace :: ProofTrace,
  type ProofTrace = [Step]

The first steps are performed easily, and also they are informative. 
So, the user should see their results immediately -- when one applies
(show ptrace).
The whole proof may take long, the last steps in  ptrace  may be 
ready after a very long time.
And Haskell just holds until the  whole ptrace  is ready, which is
annoying.

Copy, please, the answer to   [EMAIL PROTECTED]

With kind regards,

-
Serge Mechveliani
[EMAIL PROTECTED]









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


Re: [Haskell] Re: sizeFM type

2004-04-26 Thread Serge D. Mechveliani
On Mon, Apr 26, 2004 at 10:09:18PM +0200, Ketil Malde wrote:
> "Serge D. Mechveliani" <[EMAIL PROTECTED]> writes:
> 
> > Alexander is right.
> > 
> > Also as  Integer  has more sense than  Int,
> > I would suggest for the future standard Haskell library to have  
> > Integer as default. For example:
> > length  :: [a] -> Integer
> > smallLength :: [a] -> Int
> 
> Hmm...isn't it possible to use a class here?  Perhaps even Num?
> 
> class Num a where 
> :
> length :: [b] -> a
> :
> 

I think, for many functions, like  length,  it is most natural to 
return  Integer  only.  
And it is also natural for many instances (domains) D to provide 
maps like  toInteger, fromInteger.
Just follow mathematics.

Example:   length xs:: (Rational, Rational)  
looks unnatural,
butfromInteger (length xs)  :: (Rational, Rational)  
looks natural.

-
Serge Mechveliani
[EMAIL PROTECTED]

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


Re: [Haskell] Re: sizeFM type

2004-04-26 Thread Serge D. Mechveliani
On Mon, Apr 26, 2004 at 04:06:22PM +0100, Philippa Cowderoy wrote:
> On Mon, 26 Apr 2004, Serge D. Mechveliani wrote:
> 
> > Alexander is right.
> >
> > Also as  Integer  has more sense than  Int,
> >
> 
> To ask a silly question, is Int defined as 32 bits or is it defined in a
> similar vein to C's int?
> 
> -- 
> [EMAIL PROTECTED]
> 


Probably, as in C. Anyway, the program using  Int  will run into
an overflow or not depending on the task and on the machine.  
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Re: sizeFM type

2004-04-26 Thread Serge D. Mechveliani
Alexander is right.

Also as  Integer  has more sense than  Int,
I would suggest for the future standard Haskell library to have  
Integer as default. For example:
length  :: [a] -> Integer
smallLength :: [a] -> Int
-
Serge Mechveliani
[EMAIL PROTECTED]


On Sun, Apr 25, 2004 at 03:18:20PM -0400, S. Alexander Jacobson wrote:
> 
>[..]
> Dell's Poweredge servers address up to 32GB of
> memory today!  There are already 5.7 billion
> people on the planet (>2^31) and 741 million phone
> lines.  In my mind, there is NO QUESTION that 2^31
> keys is a reasonable size for a FiniteMap or will
> be in the very very near future.
> 
> Moreover, it is not clear that the CPU/memory
> overhead of returning Integer rather than Int for
> sizeFM is sufficiently high to be worth bothering
> the programmer about.


On Sun, 2004-04-25  Serge D. Mechveliani wrote to
glasgow-haskell-users

> > > Dear GHC developers,
> > >
> > > Probably, it is better to provide   Integer
> > > or  Integral a => a
> > > instead of  Int
> > > in the function
> > > sizeFM :: FiniteMap k e -> Int

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


Re: data label overloading

2004-01-14 Thread Serge D. Mechveliani
To my recent suggestion on the field label overloading 

> > ...
> >   data Foo1 = Foo1 {size :: Int ...}
> >   data Foo2 = Foo2 {size :: Int ...}
> >   ...
> >   f x y z = let size = Foo1..size in
> >(size x)+(size y)+(Foo2..size z)  
> 

Hal Daume III wrote on Jan 13, 2004 

> How does this save you typing over:
> 
> data Foo1 = Foo1 { foo1_size :: Int }
> data Foo2 = Foo2 { foo2_size :: Int }
> 
> f x y z = let size = foo1_size
>   in
>   (size x) + (size y) + (Foo2..size z)
> 
> also, this would lead to highly ambiguous parses, i think.
> 


Here is an example with improved suggestion:

  data Foo1 = Foo1 {size :: Int, ...}
  data Foo2 = Foo2 {size :: Int, ...}
  data Foo3 a b = Foo3 {size :: a,   ...}

  f :: Foo1 -> Foo1 -> Foo2 -> Int
  fx   y   z=  let  n = (size x)+(size y)+(size z)
   in
   (g (x {size = n})) + 1  

  h v =  v {size = 0}  :: Foo3 _ _
  g u =  size (u :: Foo3 _ _)


Very often the type or argument is clear. In such a case the compiler 
solves the label version. And in a dubious case the programmer adds 
the type denotation.
Will this do?

Copy, please, the answer to  [EMAIL PROTECTED]

With kind regards,

-
Serge Mechveliani
[EMAIL PROTECTED]
 







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


data label overloading

2004-01-13 Thread Serge D. Mechveliani
Dear Haskellers,

It is desirable to have shorter names for the data labels.

Making a module out of a labeled data declaration does not look
convenient.
Providing the corresponding class operation is not always convenient.

Maybe, future Haskell language could apprehend some special construct, 
like, say, in the following example

  data Foo1 = Foo1 {size :: Int ...}
  ...
  data Foo2 = Foo2 {size :: Int ...}
  ...
  f x y z = let size = Foo1..size 
in
(size x) + (size y) + (Foo2..size z)  

?

"Foo.." is added when more than one type with the given label is
visible in the scope. 

Copy, please, the answer to  [EMAIL PROTECTED]

With kind regards,

-
Serge Mechveliani
[EMAIL PROTECTED]

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


let-where difference

2003-12-22 Thread Serge D. Mechveliani
The program 
f = [ 1,
  2,
  (a+b where a = 1
 b = 2
  )
]
is qualified by some compilers as a wrong syntax.
And 
f = [ 1,
  2,
  (let a = 1
   b = 2
   in  a+b
  )
]
is accepted.
What may be the reason for such difference, 
is this a `bug' in Haskell-98 ?

(Usually `let' and `where' are moved out of such a list construct, 
but for a large list with non-trivial expressions for the members, 
it may be natural to remain them).

Thank you in advance for the explanation.
Copy, please, the answer to   [EMAIL PROTECTED]

-
Serge Mechveliani
[EMAIL PROTECTED]




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


access to fields in nested records

2003-11-05 Thread Serge D. Mechveliani
Dear Haskellers,

My question is about a nice way to provide a getting/setting
access to the nested record fields.

Example:
  ---
  data House = House {houseNo:: Int, 
  diningRoom :: DiningRoom
 }  deriving (Show)
  data DiningRoom = DRoom {square   :: Int,
   height   :: Int,
   numOfWindows :: Int,
   diningTable  :: DTable  
  }   deriving (Show)
  data DTable = DTable {tableSquare  :: Int,
diningPlaces :: Int
   } deriving (Show)
  -- example:
  r1 = DRoom {square   = 50, 
  height   = 300,
  numOfWindows = 1,
  diningTable  = dt
 } 
 where  dt = DTable {tableSquare  = 16,
 diningPlaces = 12
}
  ---

Question 1:   how to change a field in a record?

I see the following way. For example,

  setSquare :: DiningRoom -> Int -> DiningRoom
  setSquarer n   = 
 DRoom {square   = n, 
height   = height r,
numOfWindows = numOfWindows r,
diningTable  = diningTable r
   }
Example of usage:setSquare r1 (square r2) 
 for 
 r1, r2 :: DiningRoom

Has indeed one to program the above functions, like  setSquare,  
for all the records,  
or there exist some Haskell annotations, or standard library 
function for such purpose, which allow to skip extra remaining 
fields in the data, like these three fields in  DiningRoom ?


Question 2:   how to get/update a field in a nested record?

For example, 
dtableSquareFromRoom  :: DiningRoom -> Int
dtableSquareFromHouse :: House  -> Int

dtableSquareFromRoom  = tableSquare . diningTable 
dtableSquareFromHouse = dtableSquareFromRoom . diningRoom

setDTableSquareToHouse :: House -> Int -> House
setDTableSquareToHousehn   = 
  House {
 houseNo= houseNo h,
 diningRoom = setDTableSquareToRoom (diningRoom h) n
}
where  setDTableSquareToRoom r n =  ...

Has indeed one to program such functions for each path to a
field in the record nesting hierarchy?
I see the main difficulty in a great number of functions to use 
for the same field access from different structures. 

I try to improve this by adding classes with  get_  and  set_
versions of operations for the record fields:

  class HouseLike a where  get_houseNo:: a -> Int
   get_diningRoom :: a -> DiningRoom

   set_houseNo:: a -> Int -> a
   set_diningRoom :: a -> DiningRoom -> a
  ...

Now, defining the instances, say, for   get_dtableSquare,
set_dtableSquare,

makes it a unique function pair to use for getting/setting of the
corresponding field starting from
 House or DiningRoom or DiningTable.

Is this all a reasonable design for a Haskell user program?

Thank you in advance for the respond.

Please, add  [EMAIL PROTECTED]  
to the reply list.

--
Serge Mechhveliani
[EMAIL PROTECTED]  


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


let (d,k) = (g x y, h x d) ..

2003-06-27 Thread Serge D. Mechveliani
Dear Haskellers,

Once I wrote a function 

  f' :: Int -> Int -> Int -> (Int, Int)

  f' n m l = let (d,k) = (gcd n m, quot n d)  in  (k, l*k)

(the simplified version of real program),
placing erroneousely  d  to both parts of the pattern matching 
(d,k) = ...

The intended program was

  f  n m l = let {d = gcd n m;  k = quot n d} in  (k, l*k)

But f' gives the intended results, at least in the GHC 
implementation. 
So that I did not notice the `error' for a long time.

Is really the Haskell pattern matching semantic so that f and f' 
are equivalent ?
Is it an occasional implementation feature that hide the `error'?

Thank you in advance for the explanation.

Answer, please, to  [EMAIL PROTECTED]

-
Serge Mechveliani
[EMAIL PROTECTED]





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


state of Standard

2003-03-14 Thread Serge D. Mechveliani
Dear Haskellers,

Could you, please, tell me what is the recent state of the 
Haskell Standard development?

I have a wish for the Standard Library:   FiniteMap, Set
(of GHC library).

And I have a question on the  function name  overloading,
and on the  record field name  overloading.

A language should support a natural naming of objects.
For example:

  data Operator = 
   Operator{opName:: String,
opWeight  :: Int,
opSortage :: ([String],[String],String),
opOrd :: Int,
opPrecedences :: (Int, Int)
   } 

is not good -- due to `op' prefix.
And many other data also have  name, weight, ord,  and so on.
So, one may try to introduce

  class WithName a   where  name   :: a -> String
set_name   :: a -> String -> a
  class WithWeight a where  weight :: a -> Int
set_weight :: a -> Int -> a
  ...
  trivialOperator = Operator{ ... some trivial setting ...} 
,

to change the names like  opName  to  opName__, opWeight__, ...
to show that the latter are local and not for usage,
to introduce

  instance WithName Operator where name = opName__
  ...
,
and then, use all this, for example, as follows:
let
nm   = name opr
opr' = set_name "foo" $ 
   set_weight 1   $ 
   set_ord 2  $ opr 
in  ...

This leads to following complications.

* Class declarations add.

* The Standard does not allow to define the instances like

   type BN = (String, Bool)
   instance WithName BN where name = fst

* There are many operations that should be synonymic but have
  different kind. For example,
   weight :: a -> Int
   weight :: Table -> a -> Int

  This leads to adventures with multiple parameter classes, 
  and so on.

Similar difficulties arise with the  function  names.

Is Haskell all right at this point?

Reply, please, to[EMAIL PROTECTED]

Thank you in advance for the explanation.


-
Serge Mechveliani
[EMAIL PROTECTED]








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


Re: GMP from haskell

2002-05-29 Thread Serge D. Mechveliani

> Hal Daume III <[EMAIL PROTECTED]> writes:
> 
> The gnu web page
> (www.gnu.org/manual/gmp-4.0.1/html_node/gmp_70.html) claims that Haskell
> (GHC) has bindings to GMP.  Is this true?  How can I access these
> routines?

Some Haskell systems mention that they use GMP to implement many 
functions for Integer.
There are open-source libraries: GMP, and some others
(do not remember the names), written in C, implementing a lot of 
mathematics, advanced algorithms and programs designed by expert 
mathematicians, like say Lenstra.
For example, the factorization function for Integer, and useful
functions for algebraic numbers (if I recall correct) are available,
not only for Integer. The advantage is also that these methods win 
many times in comparison to what the naive user writes in several
lines of one's Haskell program.
If the Haskell implementors take care of mathematician users, they 
could consider the possibility to arrange the interface to these 
functions and thus extend the library with many useful operations 
items (mainly, not of Haskell-98 standard).

-
Serge Mechveliani
[EMAIL PROTECTED]

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



Re: finding sublist

2002-05-06 Thread Serge D. Mechveliani

On Mon, May 06, 2002 at 09:30:02AM +0200, Ketil Z. Malde wrote:

> "Garner, Robin" <[EMAIL PROTECTED]> writes:
> 
> > See Dijkstra's 'Discipline of Programming' for an o(M + N) algorithm - naive
> > approches are o(MN) where M and N are the length of the list and substring
> > respectively.
> 
> > Essentially the algorithm calculates a sort of autocorrelation table of the
> > substring, showing where to resume the search after a failed match.
> 
> There's also the KMP (Knuth, Morris, Pratt) algorithm, which is
> similar.  See Dan Gusfield: "Algorithms of strings, trees and
> sequences" for lots of this stuff.
> 
> However: it is very hard to beat the naive implementation
> (i.e. something like '\p -> or . map isPrefixOf p . tails', untested)
> in the expected case, at least in my experience.  With an alphabet
>
> [..]


My suggestion was mainly to include this usable function 
(in its generic version) into Standard library. 
The possibility of clever algorithms for it is one more argument for 
such inlclusion.

-
Serge Mechveliani
[EMAIL PROTECTED]

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



e = exp 1

2002-05-02 Thread Serge D. Mechveliani

I wrote about  e :: Double  for the Library.

It can be obtained as  exp 1,  
but I wonder whether it is good for the library to add the `e' 
denotation.

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



e :: Double

2002-05-02 Thread Serge D. Mechveliani

Please, has Haskell  e :: Double  

( ~= limit (1 + 1/n)^n ) in its standard library? 

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



finding sublist

2002-05-02 Thread Serge D. Mechveliani

Thanks to people who helped me with the task

>> Import two space separated columns of integers from file.
 
Claus Reinke <[EMAIL PROTECTED]> recommends to exploit `lines'.

Indeed, it bocomes shorter now:

  main = readFile "data" >>= (putStr . show . twoIntLists)
where
twoIntLists str = case  span (not . null) $ dropWhile null $ lines str
  of
(lns, lns') -> (readInts lns, readInts lns')

readInts = map (\ str -> read str :: Integer) . dropWhile null


Another question:
has the Haskell Standard library a function for such a usable task
as finding of occurence of a segment in a list? Say 

 findSegmentBy (...) [2,2,3] [0,0,2,2,1,2,2,3,1,2,3] --> 

 ([0,0,2,2,1], [2,2,3,1,2,3])

I have heard, an efficient algorithm (for large lists) for this 
is not so simple.

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



read int lists

2002-04-30 Thread Serge D. Mechveliani

Dear Haskellers,

There is certain site (contact  [EMAIL PROTECTED] ) 

where some computer algebra programs are gathered and compared.
I submit here my CA program DoCon written in Haskell.
And they require certain large set of tests to fill in.
It appears also that many of the tests concern Haskell itself
(or its implementation libraries) rather than DoCon library.
In particular, they require the code for the task:
 
  Import two space separated columns of integers from file.

The suggestions are:
  \Axiom   & \\
  \Derive  & [Transfer Load daTa]  (from file.dat)
  \Macsyma & xy: read_num_data_to_matrix("file", nrows, 2)
  \Maple   & xy:= readdata("file", integer, 2): 
  \Mathematica & xy = ReadList["file", Number, RecordLists -> True]
  \MuPAD   & \\
  \Reduce  & \\
  \DoCon (Haskell) &  ??


We need   main = readFile "data" >>= (putStr . process)

If it was one integer list, then, something like

  process str = read ("[" ++ (map (\ '\n' -> ',') str) ++ "]") 
  :: [Integer]
would do.
But the file contains something like
---


1
2


3
4


---
, and it should convert to  ([1,2],[3,4]) :: ([Integer], [Integer])
 
Although I wonder whether other systems do the needed thing,
still, can people suggest any shorter/nicer program than the 
following one?
(use advanced lexical libraries, etc. ...)

  process :: String -> String
  process str = shows (firstList [] $ dropWhile (== '\n') $
   filter (/= ' ') str
  ) "\n"
  firstList :: [Integer] -> String -> ([Integer], [Integer])

  firstList ns ('\n':'\n':str) = (reverse ns, secondList str)
  firstList ns str = case  reads str :: [(Integer, String)]
 of
   [(n,str')] -> firstList (n:ns) str'
   _  -> (ns, [])
  secondList :: String -> [Integer]
  secondList str = case  reads str :: [(Integer, String)]
   of
 [(n,str')] -> n:(secondList str')
 _  -> []


Thank you in advance for the help.

-
Serge Mechveliani
[EMAIL PROTECTED]



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



docon-2.04 announcement

2002-04-09 Thread Serge D. Mechveliani

Announcement


The Algebraic Domain Constructor  DoCon-2.04,
a computer algebra program written in Haskell,
is available at 
  http://www.botik.ru/pub/local/Mechveliani/docon/2.04/
 ftp.botik.ru/pub/local/Mechveliani/docon/2.04/

What is new
---
* Performancec tests for comparison to popular Axiom and MuPAD
  computer algebra programs (`strict' and non-functional systems)
  are refreshed and extended (see manual.ps);
* DoCon was tested under the releases of  ghc-5.02.2, 5.02.3;
* Manual has become more readable, and it is in Postscript format;
* Manual explains the relation of DoCon to Aldor language and
  Axiom system.

DoCon-2.04 is a program package written in what we call
Haskell-2-pre  - certain functional extension of  Haskell-98.
Haskell-2-pre   includes the   multiparametric classes,  overlapping
instances, other minor features.

DoCon-2.04 was tested under  ghc-5.02.2, 5.02.3.
Probably, it can be ported (with some effort) to other implementations.

-
Serge Mechveliani
[EMAIL PROTECTED]












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



Re: sort inefficiency

2002-04-02 Thread Serge D. Mechveliani

Glenn G. Chappell <[EMAIL PROTECTED]> writes


> I am wondering about a design decision in the List module.
>
> To wit: "sort", in both the H98 library report and the Hugs file
> List.hs, is implemented using a quadratic sort (insertion sort).
>
> Using the name "sort" certainly suggests that this is a good function
> to use for sorting. I would think it is pretty obvious that "sort"
> should be implemented using an efficient algorithm. I am thinking
> primarily of merge sort, which has O(n log n) worst case behavior,
> is stable, and has an elegant and efficient functional implementation.
>
> Certainly insertion sort is good to have around, if one is sorting
> data that is nearly sorted already, but I would say insertion sort
> is clearly not the best choice (or even a good choice) for a general-
> purpose sorting algorithm.
>
> Or am I missing something?


The Standard library specifies only the  map  related to the name 
`sort'. This map can be described, for example, via sort-by-insertion
program.
And the algorithm choice is a matter of each particular
implementation. Implementation has right to change the algorithm.

For example, I tried once to argue with GHC for incorporating the 
mergeSort  algorithm for `sort'.
But they have some version of  quickSort  which is said faster on 
average and O(n^2) in the worst case. 
Disliking this n^2 hazard, I overload `sort' with  my_sort.

-
Serge Mechveliani
[EMAIL PROTECTED]



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



Reply: Z_n in Haskell

2002-03-31 Thread Serge D. Mechveliani

Hello, 

Hal Daume III <[EMAIL PROTECTED]>
writes about Z_n in Haskell:

> Suppose I want to define integers modulo n, I could do this something
> like:
>  data Zn = Zn Integer Integer   -- modulus, number
>
>  instance Num Zn where
>(Zn m1 n1) + (Zn m2 n2)
>  | m1 == m2 = Zn m1 (n1 + n2 `mod` m1)
>  | otherwise= error "differing moduli"
>...etc...
>
> However, I'd really like it if, say, addition on Zn-s of different
> "n" values were caught by the typechecker and disallowed.  One solution to
> this problem would be to do something like:
>
>  class Modulus m where modulus :: T m -> Integer
>   data Zn m = Zn (T m) Integer
> 
>  instance Modulus m => Num (Zn m) where
>(Zn m1 n1) + (Zn m2 n2) =
> (Zn m1 ((n1 + n2) `mod` (modulus m1)))
>
> [..]


[EMAIL PROTECTED]   responds with

| The Z_n problem doesn't seem to be different from the problem of 
| arrays or bitvectors of a statically-checkable size. 
| 
| [..]
|
| Both implementations work in any Haskell-98 system. Multi-parameter
| classes, existential types or other extensions are not needed.

Also someone advised to follow up the  haskell-cafe  list archive 
containing the proposal, probably, by Dylan Thurston (Spring 2001), 
to exploit existential types to express the constructs
like Z/(n) - residue domain of integers modulo n.

This whole subject interests me.
After maybe a month, I am going to investigate it and answer
what precisely is wrong about the approaches mentioned.

My previous impressions are as follows

* It is hard to believe that the thing can be done in Haskell without 
  existential types (properly implemented).
* Dependent types (Aldor, Cayenne) are the adequate instrument
  for the above task.
* The proposal from  haskell-cafe  (year ago) does not look 
  practicable. I tried certain simple example of using it to work
  with Z/(m), and it failed.

But I hope, we will return to the subject after a month.

-
Serge Mechveliani
[EMAIL PROTECTED]


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