Re: functional graph

2003-07-29 Thread Eray Ozkural
On Wednesday 16 July 2003 00:02, Hal Daume wrote:
  But it looks the Graph class works on types a and b
  where a is the Node type where b is the Edge type, or
  just the other way around :), I don't have the code
  right now.

 Yes, 'Graph n e' is a graph whose nodes are labelled with elements of
 type n and whose edges are labelled with elements of type e.

I posted an imperative graph module on this list. You could try that instead 
of functional graphs. I'm going to write a functional wrapper for that in the 
future.

Regards,

-- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara  KDE Project: http://www.kde.org
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Combining Monads

2003-04-12 Thread Eray Ozkural
On Saturday 12 April 2003 23:52, Dominic Steinitz wrote:
 For the theory, look at
 Triples, Toposes and Theories by Barr  Wells. I think it's chapter 7 but I
 haven't got it in front of me.


This looks like it's quickly getting out of the realm of programming :)

Cheers,

-- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara  KDE Project: http://www.kde.org
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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


Re: Sets

2003-01-02 Thread Eray Ozkural
I had asked a similar question on haskell lists about how to implement 
hypergraphs efficiently, which are combinatorics of finite sets (sets of 
sets). As a matter of fact, I obtained a nice and small finite set 
implementation that works for me, let me see if it is worth posting.

If you are working with larger than trivial hypergraphs and expensive 
algorithms performance can be a problem, so it would be better to surpass a 
suboptimal approach.

Thanks,

On Friday 15 November 2002 10:31 pm, Mark T.B. Carroll wrote:
 Am I right in thinking that sets of sets don't really work with GHC's
 Data.Set because Set a things aren't instances of Ord? How should I do
 sets of sets with it?

 (e.g. Set.mkSet [Set.unitSet 1] gives No instance for (Ord (Set a)))

 -- Mark

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

-- 
Eray Ozkural [EMAIL PROTECTED]
Software Engineer, BICOM Inc.
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



Re: Record of STRefs better than STRef to a Record?

2002-12-27 Thread Eray Ozkural
On Thursday 14 November 2002 01:29 am, Jorge Adriano wrote:
 In some functions I might need only some pure fields, and none of the
 STRefs, but since I pass something of type 'E s' around, everything ends up
 beeing monadic. Is using two records (on with STRefs and one with pure
 fields) the only/best way to avoid this?
 I would like to use two records, doesn't seem natural, but I also don't
 like to end up using monadic functions when they are, in fact, pure...


Good question. In all Haskell codes I wrote, I ended up writing a lot of 
monadic functions which seemed to be unavoidable. Then you look at the code 
as it feels too much like an imperative code and start wondering why you are 
using a functional language :)

Happy new year to all Haskellers by the way.

Cheers,

-- 
Eray Ozkural [EMAIL PROTECTED]
Software Engineer, BICOM Inc.
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



RE: AW: slide: useful function?

2002-12-27 Thread Eray Ozkural
On Monday 02 December 2002 10:50 pm, Christopher Milton wrote:
  If there are any good ways in which non-mathematicians can get to grips
  with these terms from category theory, they would be well worth
  promoting. For example, despite having a good computer science degree (in
  which I was at least introduced to FP, proof, etc. and even learned to
  draw the dual graph of hypercubes) I'm really not equipped to understand
  catamorphisms in terms of algebras and homomorphisms, and don't currently
  have time to take the math degree I fear I'd need in order to do so. Last
  time I was looking at category theory books I think I came to the
  conclusion that Lawvere and Schanuel cover things kindly but Pierce
  seemed to get the syllabus right, so the right book wasn't quite out
  there.

Check Category Theory for Computing Science by Barr, one of the most 
coherent textbooks I've ever seen. I think there is almost _nothing_ 
unnecessary in that book :)

Anyway, if you are familiar with graph theory (proving simpler theorems at 
least, that is) learning category theory is not that hard. The introductory 
concepts are quite intuitive but it tends to get a little confusing after 
that (like all grad level math subjects!)

 
  My understanding of monads is already a matter of record. Does anyone
  know of a friendly text that might help new Haskellers to understand
  functors, etc. and what they mean for program design? I'm not averse to
  the formal language per se if it can be easily acquired; right now, I
  worry that I'm using Haskell suboptimally because, not only do I not know
  the terminology well, but I fear that I'm not even cognisant of the
  concepts that these terms represent.
 

In that book you will find sections on using category theory for denotational 
semantics of functional languages which I think is a good thing for those 
armchair neuroactivity sessions.

  In a nutshell: if these category theory concepts indeed have an important
  impact in Haskell land, how to introduce them to working Haskell
  programmers well enough that they can use them in engineering software
  that's at least half as good as it could be?
 
  (I'm making the assumption here that it would be good for Haskell to be
  much more widely used - it shouldn't solely be for researchers.)

 Here's some of what I've come across:

 Jonathan M. D. Hill, and Keith Clarke
 An introduction to category theory, category theory monads, and their
 relationship to functional programming
 ftp://ftp.dcs.qmw.ac.uk/cpc/jon_hill/qmw681.ps.Z
 http://www.dcs.qmul.ac.uk/SEL-HPC/Articles/GeneratedHtml/functional.monads.
html


Monad is one of the simpler category theoretical concepts and I think you 
don't even need to know too much about category theory to write monadic 
programs. Going beyond monads is more interesting on the other hand. I 
haven't been able to catch up with the developments in that area however the 
Arrow programming discussions in this list seems to be a promising 
direction for bringing more category theoretical elegance to Haskell 
programming language. I wonder if there is any available code that makes a 
good demonstration of such approaches.

Regards,

-- 
Eray Ozkural [EMAIL PROTECTED]
Software Engineer, BICOM Inc.
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



Re: Interpret haskell within haskell.

2002-12-26 Thread Eray Ozkural
On Friday 20 December 2002 03:16 pm, David Sankel wrote:

 I was referring to a haskell interpreter to be used
 within haskell code.  For instance:

 main = do
   user_configuration - parseHaskell
   title - resolveFunction user_configuration title

 :: String

   putStr title


My next language design will have such an uber-cool standard library that you 
will be able to evaluate all you want in the world. Now I've got some years 
of design work to be done if you will excuse me.

exa -- who found out that C++ was the worst PL in the world after giving 7 
years to it

exa -- He also ditched his C++ like imperative OO language design that he 
wasted valuable time with

-- 
Eray Ozkural [EMAIL PROTECTED]
Software Engineer, BICOM Inc.
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



Re: layout rule infelicity

2002-05-30 Thread Eray Ozkural

On Thursday 30 May 2002 13:43, Frank Atanassow wrote:

 Anyway, I have the feeling that, for every person on this list who
 complains about layout being unintuitive, there are 10 people who would say
 the opposite. Shall we take a poll?

It's not unintuitive, it's counter-intuitive. :) The errors resulting from 
layout mistakes are hard to spot and are annoying.

  On the other hand, it has a blend of intuition. If you are writing in a 
certain, not-so-clear-what style, it makes life easier. :)

 As you can see I've contradicted myself.

** Type error.

-- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



Space problem: reading a list of records from a binary database

2002-05-28 Thread Eray Ozkural

Hi there,

While trying to read a list of records from a binary database I think I've 
encountered a space leak but I'm not proficient enough to detect the cause of 
the error.

The culprit is the readSessionDB function in SessionDB module which I attach 
with other relevant code.

What I do in Session.readSession is using FFI to read a fixed size record from 
an input stream. That far, okay. (I have no idea if I'm doing it right, 
though)

The problem is, combined with my approach in Session.readSessionDB, it results 
in huge amounts of space allocation, about 1MB, whereas the raw data would 
consume about 50K. It would be a [Session] with about 3000 elements, each of 
which contains 3 Ints and 6 Floats.

I wonder if the following code in SessionDB is the proper way to read a list 
of records from a file. I get the feeling that the (s:rest) in the last 
return statement causes my problems. 

readSessionList :: Handle - IO [Session]
readSessionList h =
  do session - readSession h
 case session of
  Nothing - return []
  Just s - do rest - readSessionList h
   return (s:rest)

Comments appreciated,

-- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C


module SessionDB
where
import IO
import System
import IOExts
import Array
import Foreign
import CForeign
import SMA
import Session

readSessionDB :: String - IO [Session]
readSessionDB file =
  do loc - locateStock file
 case loc of
  Nothing - do return []
  Just fname - do h - openFileEx fname (BinaryMode ReadMode)
   putStrLn (reading  ++ (show fname))
   list - readSessionList h
   return list

readSessionList :: Handle - IO [Session]
readSessionList h =
  do session - readSession h
 case session of
  Nothing - return []
  Just s - do rest - readSessionList h
   return (s:rest)


module Session
where
import IO
import System
import IOExts
import Array
import Foreign
import CForeign

data Session = Session {stockId, date, sessionId :: Int,
lowestValue, highestValue, lastValue, averageValue,
lot, volume :: Float} deriving (Eq, Show)

emptySession = Session {
stockId = 0,
date = 0,
sessionId = 0,
lowestValue = 0,
highestValue = 0,
lastValue = 0,
averageValue = 0,
lot = 0,
volume = 0
   }

readSession :: Handle - IO (Maybe Session)
readSession h = 
 do eof - hIsEOF h
if eof then return Nothing else 
  do buf - mallocArray 73:: IO (Ptr CChar)
 readChars - hGetBuf h buf 73
--   putStrLn (read  ++ (show readChars))
 let sidptr = castPtr buf :: Ptr CShort
 dateptr = castPtr (plusPtr buf 2) :: Ptr CUInt
 sesptr = (plusPtr buf 6) :: Ptr CChar
 ptr = castPtr (plusPtr buf 7) :: Ptr CLLong
  in do stockid - peek sidptr
date - peek dateptr
sessid - peek sesptr
rec - peekArray 8 ptr
--  destructArray 73 buf
let list  = map (\x - (fromIntegral x) / 1) rec
  :: [Float]
vals = array (1,8) (zip [1..8] list)
in return (Just Session {stockId = (fromIntegral stockid),
 date = (fromIntegral date),
 sessionId = (fromIntegral sessid),
 lowestValue = vals!1,
 highestValue = vals!2,
 lastValue = vals!3,
 averageValue = vals!4,
 lot = vals!5,
 volume = vals!6
})



Re: toEnum with international chars

2002-05-28 Thread Eray Ozkural

On Tuesday 28 May 2002 13:32, Alastair Reid wrote:
 Can you explain your problem more clearly?  I'm struggling to
 understand what was wrong given only a fragment of the program, none
 of the input and only an indication of where the problem lies in the
 output but not what that problem is.

 [This probably won't affect the answer though - which will probably be
 an admission that most Haskell compilers don't support international
 characters properly.]

Oh, my bad, I think I gave a wrong list there. 66 is of course 'B', I was a 
little sleepless at the time of writing. Now having enjoyed a few hours of 
sleep I can express more eloquently :)

It seems to be the fourth character that is the problem, but then again that's 
my mistake. Thank you.

Still it attracts my attention that I cannot type þ in ghci while I can type 
it in bash. I think I can't type any of those international chars in ghc. 
Maybe some bug fix is in order.

Regards,

-- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



Re: Space problem: reading a list of records from a binary database

2002-05-28 Thread Eray Ozkural

On Tuesday 28 May 2002 15:24, Eray Ozkural wrote:
 Hi there,

 While trying to read a list of records from a binary database I think I've
 encountered a space leak but I'm not proficient enough to detect the cause
 of the error.


Thanks to dennisb from #haskell strict flags on Session type solves my problem 
to a great extent but I still feel a lot of space inefficiency. Somebody care 
to give some advice on the code?

Regards,

-- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



toEnum with international chars

2002-05-27 Thread Eray Ozkural

I have a code that reads a string from a list of CChar's

 shortName = map (toEnum.fromIntegral) shortname

When I have a turkish character like Ý the interpreter will:

StockList a - readStockInfo h
[66,105,108,105,-2,105,109,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32]
StockList a
*** Exception: Prelude.chr: bad argument

The problem is the 66 in the beginning of the list. I'm not giving the entire 
code, it's not needed...

What should I be using to work with such strings?

Thanks,

-- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



Re: SUGGESTION: haskell-announce mailing list

2002-05-21 Thread Eray Ozkural

On Monday 20 May 2002 23:36, Mark Carroll wrote:

 cafe has the pleasing connotation that people new to the Haskell fora
 should feel free to post their questions without fearing that they're
 bothering the important business of the list of whatever - it makes it
 very obviously a friendly, open forum.


I think the notion of a cyber cafe works well in project oriented mailing 
lists. It has worked well for KDE folks, too.

Thanks,

-- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

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



Re: Hiring Haskell programmers

2002-03-11 Thread Eray Ozkural

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 12 March 2002 01:17, Mark Carroll wrote:
 How easy is it to hire reasonable Haskell programmers? Of course, this may
 mean, hiring people with the aptitude and interest to quickly learn
 Haskell. Has anyone any experience of this that they can share?


I know it's easy. Try me. ;)

Sincerely,

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8jUqcfAeuFodNU5wRAt1/AKCaN881FMXqzpx+xh1EpnFa/b6k9ACeNuPX
aYrkL3CfiF2C6uBzH+3chPs=
=U7Xm
-END PGP SIGNATURE-

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



Re: Hiring Haskell programmers

2002-03-11 Thread Eray Ozkural

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 12 March 2002 03:05, Mark Carroll wrote:

 Be able to modify or add to the code base within a few weeks, in such a
 way that somebody doesn't have to come back later and repair your work.
 (-: So, no, not just the syntax: much harder, in my opinion, is to learn
 how to phrase even just simple algorithms in an efficient and functional
 way. When I first learned Standard ML, after years of imperative
 programming, my brain almost hurt for the first few weeks.


I think the practice of software engineering applies here as well as any other 
language. How hard was it for Cycorp to hire LISP programmers? (Not a good 
example I know) I would imagine one would have to be a little mathematically 
oriented for grokking the hack content of course. Any good programmer with a 
knowledge of declarative programming in the tradition of LISP and Prolog, 
IMHO, will do the job.

Also I'd think that knowledge of the application domain and methods matters 
more than the programming language. If you require one to write machine 
learning code, how would you expect him to write a single line without 
knowing the subject?

I'd imagine that persons who are experienced at any programming language which 
allows a reasonable level of abstraction (say C++), will be quite comfortable 
with Haskell. The type system of Haskell is a great win, and although the 
APIs are yet to be standardized (for common programming tasks) it will do a 
great job in many fields.

I wouldn't be particularly enthusiastic about using a language like Haskell to 
implement a simple thing such as a chatroom but I would imagine it would 
have great benefits in research where you have to try out a lot of 
mathematical ideas, in complex symbolic AI tasks, in compiler 
design/implementation, etc.

Therefore, ideally, I would look for somebody who has
  a) concrete programming experience
  b) knowledge of symbolic languages
  c) theoretical knowledge of your domain

If I were to find that person who would be really able to program in Haskell, 
I would look for somebody who has done a variety of things rather than 
focusing on a single technology/application (just pure mathematics wouldn't 
do ;). That kind of a person would be able to find his way in any maze.

Thanks,

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8jWnvfAeuFodNU5wRAk24AJkBv0bcIdzoBeSWhURsJyYar7GmxgCgor/M
k5LFIF6Fa9CWnyujr1de/D4=
=9pno
-END PGP SIGNATURE-

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



Re: Conversion/porting to mainstream languages

2002-03-11 Thread Eray Ozkural

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 12 March 2002 04:36, Ashley Yakeley wrote:

 How are others dealing with this? How big a project would it be to
 translate, say, from Haskell to C or Java?

 Huge. IMO, you'd probably need to rewrite everything. On the plus side,
 Haskell is typically excellent for exploring any problem domain. So you
 might end up with better designed and more maintainable Java or C code
 than you would if you started from scratch. Or not.

I would use the right programming language for the tasks at hand. You should 
not IMO consider porting from one language to another which has radical 
differences. You will find it almost impossible to make a faithful 
translation of code that is still comprehensible if you rewrite in C/Java.

If there are resource critical tasks, you write them in C/C++. But with 
Haskell you can pull many tricks which would be otherwise very expensive. 
Using Haskell at the right level may actually save you a lot of time and 
money. Especially if you are doing a lot of symbolic processing somewhere. I 
would almost certainly want to have a high level interpreted environment that 
runs with a language such as Haskell or ocaml for complex projects ;)

It all depends on the application. If you are going to be done with 10.000 
lines of C++ code, in a well written and comprehensible way using Haskell 
might not help you too much. In fact, you will find it quite hard to do some 
of the everyday tasks in a new language...

However, consider a project such as MONO developed by certain famous monkeys. 
(They like being called like that) How many lines of code? How many would it 
take if it were written in Haskell? That's exactly the kind of project where 
Haskell would save you a lot of resources.

Look at the applications on your computer. Something a little too complex and 
it becomes 10's of megabytes in source code That's surely not needed.

Thanks,

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8jWyPfAeuFodNU5wRApv9AJwILw5ND1I0pbe5sp59cMh5M0RPDACgjszi
aHF6DDW7tCc1csu2Xhyfp7I=
=vkgB
-END PGP SIGNATURE-

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



Re: Graphs

2002-02-21 Thread Eray Ozkural

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I used graphs in haskell, but I don't think you'll get anywhere the kind of
efficiency of a language like C++ where you have exact control over 
operations and structures

There is the graph code in functional algorithms book

Algorithms: a functional programming approach
   Fethi A. Rabhi, University of Hull, UK
   Guy Lapalme, Université de Montréal, Canada

The code is available online.

I recommend you to start with that one. Stay away from finite map stuff in 
edison if you can. (Although you can get it to implement graphs/hypergraphs 
after some amount of work)

If you're going to prototype an algorithm, you will eventually have to use 
monads which will be harder to write than the final C++/C implementation.

Why is that so? Because if you're writing the graph code in haskell, the 
really easier/better way is to use things like substitution, infinite graphs, 
etc. for an elegant and short code, in that it reflects the theoretical 
construction. But an algorithm designed for a serial machine is so much 
different. I've written graph algorithms from multilevel graph partitioning 
to graph clustering, so I think I know what I'm talking about :)

If you're using C++, you can prototype an algorithm fairly easily.

Here is how you can implement it.

use list vectorint  to store adjacency lists.
use a vector vectorint*  to index the adjacency lists.
use separate vectors to hold labels. I won't go into the reasons why those 
are the ones to start with, eventually your super-optimized code will be 
similar to the above.

Don't use a graph library. It will make your job harder! Avoid template 
libraries if you can (except stdlib...), and resist the temptation to 
templatize your code.

You will find that it's much more easier to write graph algorithms that way. 
And yes, although it would be in theory be a good idea to be able to 
prototype your algorithm in an easier-to-use language, such a language does 
not exist. Unless you can show me graph code side-by-side and prove it to me 
I will never believe it :)

For a start one would have to show me the implementation of non-trivial 
algorithms such as graph coarsening, all-to-all shortest paths, maximal 
cliques, etc. in the easier-than-C++ language contrasted with (good) C++ 
implementation.

I'm thinking maybe it would be more-possible in ocaml, but I'm a beginner in 
ocaml and I don't think I'm enough of a ocaml-hacker to talk about it.

Thanks,

On Thursday 21 February 2002 18:01, Wojciech Fraczak wrote:
 Hi everybody,

 I would like to ask you, if you do not know any graph library for
 haskell. I would like to use haskell for prototyping some of
 algorithms on graphs and finite state automata/transducers. In fact
 what I'm looking for is a good (efficient and easy readable) data type
 definition for labeled graphs.

 Thanks,

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8dSjSfAeuFodNU5wRAk8rAJ9CIwZUmEKHpttK2IwTXO0fnk8/egCeOV/A
y3yq4cDFx1mZQPC6SbK19JU=
=QoPG
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: a universal printer for Haskell?

2002-02-20 Thread Eray Ozkural

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Wednesday 20 February 2002 08:46, Bernard James POPE wrote:

 There are numerous ways to provide security for your data types.

(In)Visibility isn't security. I have more than often witnessed Java users 
who thought private keyword was for security.

I think it's obvious, with many years of worldwide experience of Internet 
security, why obscurity is *not* security.

Thanks,

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8dCTGfAeuFodNU5wRAjGsAJ4tq8Nqg5Vh4pANHbMZ0JT+u1iVpgCcDY7i
PI0TC9Y+DnVAV8AstF2ovmk=
=+xqN
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: A View of Monads (Re: performance of monads)

2002-02-19 Thread Eray Ozkural

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Richard,

On Tuesday 19 February 2002 06:57, Richard Uhtenwoldt wrote:

 This is a weak argument.

 First of all it is not the case that imperative coders always specify a
 total ordering: multitasking, threading and interrupts (and their
 projections into software as in Unix signals and asynchronous
 exceptions) are ways of specifying partial ordering when a total
 ordering would lose.

 Note that modern cpu designs use out-of-order execution strategies;
 so on micro-second timescales they
 ignore the total ordering when doing so suits them and
 when it preserves semantics.


I might add to the above points the obvious. Imperative programming languages 
in general do _not_ specify a total ordering. Each statement _can_ have a 
side effect[*] and the compiler is free to rearrange code such that it runs 
faster and preserves semantics. As written in any compiler textbook from 
1970's.

Sincerely,

[*] The compiler will know when this is possible, and when the statement is 
free of side effects. You can specify that no side effects occur in C++ for 
instance. And the compilers also know that certain expressions are always 
free of side effects, etc.

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8cmZSfAeuFodNU5wRAsG4AJ9ZXV6jVfbIRrRTCzl8YhO/AK1a7QCePCE3
/ST0chxaZYNobn2f32N94sw=
=3dOx
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: a universal printer for Haskell?

2002-02-19 Thread Eray Ozkural

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Wednesday 20 February 2002 03:35, Ashley Yakeley wrote:
 At 2002-02-19 09:56, Richard Uhtenwoldt wrote:
 This is reflection! I'd rather not have Haskell contaminated with such
 things;
 
 Can you say a little more about why you think reflection is bad?
 Does it make the language implementation run slower?

 It's ugly, and isn't part of the spirit of the language.

The above statement cannot be a basis for any argument against Bernard's 
proposal. Where Bernard makes a careful analysis of the matter, you introduce 
your prejudice.

Since you are defining the spirit of the language, perhaps you could make a 
list of the parts of that spirit so that people will not come up with any 
proposal that violates your understanding of aesthetics.

A general concept such as reflection cannot be deemed as worthless in itself. 
Any system that has a tiny bit of introspective powers can be said to be 
reflective to some extent, for instance a Haskell interpreter.

Thanks,

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8cysgfAeuFodNU5wRAuc2AJ9UW0VRcxSqs0dS/rIN7/YBaXBO2wCfRtbB
+5ZG8wk9nZH3Z7WEz7rNvqw=
=NevV
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



A View of Monads (Re: performance of monads)

2002-01-16 Thread Eray Ozkural (exa)

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Let me offer a differing view of Monads.

Monads are a way to write type-safe imperative programs within a functional 
framework. It's just an advanced version of PROGN kludge in LISP.

Since they are based on a linear flow of commands, they seem to necessitate 
sequential programming. Because of this reason I prefer not to use any monads 
whenever possible. It seems to eliminate the gist of functional programming.

OTOH, the nice thing about Monads is that they, I think, lift the semantics 
of an imperative language, to the language level. When I look at the analysis 
of Algol-like languages in Tennent's Semantics of Programming Languages 
book I see the same thing as Monads: a way to sequence commands, and pipe the 
effects.

Because of these reasons, I think the use of Monads are highly exaggerated. 
They are sort of like the over-use of template code in C++. In my 
experience, it doesn't work too well. You will end up writing monadic 
versions of everything, etc.

Of course, they are a nice way to abstact I/O. How else could you do it 
properly in a functional language? Monads effectively model the operation of 
a sequential machine (one I/O channel!) in a mathematical way.

It's similar to the problem of trying to retrofit a parallel system in a 
sequential system. Consider a sequential input source, and a parallel 
algorithm to compute it. You will need an interface between the two.

In that respect, whenever I use monads, I feel like going back to an 
imperative language because it will make my program much less concurrent. 
Wasn't the most important benefit of using a functional PL architecture 
independence? I think it has turned to ease of programming now, which isn't 
any more real. :)

Thanks,

On Wednesday 16 January 2002 17:05, you wrote:
  I see a lot of literature that says that monads simulate the effects of
  imperative programming concepts.

 I think that's just bad wording.  To take a rather trite
 point of view, in a language such as C /everything/ is done
 within a monad, and all types, even int, are really IO
 something (IO Int).

 In Haskell you may see costs associated with using Monads,
 but they are mainly to do with dealing with the difficulties
 that arise from having laziness everywhere.

   Jón

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8RcrAfAeuFodNU5wRAtSkAJ9dbVF4q33hCcwXedHDYA4MlAYv0wCeNb5p
shGjRg01VUmiGYTkW1LlmvM=
=mJDL
-END PGP SIGNATURE-

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



We need Documentation (Was: Re: Integer to String Conversion?)

2001-12-04 Thread Eray Ozkural (exa)

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 04 December 2001 02:51, you wrote:
 On Tue, 4 Dec 2001, Chris wrote:
  is there a function that converts Integers to Strings and vice versa?

 Prelude (reads 123 abc) :: [(Integer, String)]
 [(123, abc)]
 Prelude show 123
 123


That's the reason why I hadn't been able to join some famous programming 
contest :) When my brain had already melted I couldn't find how to do this in 
the documentation for 30 minutes. I had assumed there would have been a 
specific conversion facility... But I think there are other reasons than my 
sleepy state at the moment.

Why doesn't an author or two who have written Haskell books consider opening 
their books for public use on the Internet? The Craft Of ... especially 
seems great. I'm sure many coders would appreciate a non-dead-tree version of 
that book or a shortened version of the book.

The material we have is simply lacking. What we need is a good tutorial and a 
comprehensive reference book. The current state of documentation is far from 
that. The tutorial should be a tutorial, it should teach all that is needed 
for basic programming, and probably go beyond that, with examples explained 
in detail and such. (The tutorial on the web is not like that). The reference 
manual again must go ahead with examples, and a logical organization of 
programming concepts and language features. Otherwise Haskell is never going 
to find too much appeal in application programming; it will remain in 
obscurity in research centers and extreme hacker quarters.

For coders who have not written papers about Haskell, the documentation is 
maximally cryptic.

I could find only a single decent book in our university's library, it was a 
functional algorithms book that gave examples in Haskell. Without that book, 
I could never have written the code I wrote within a small amount of time. 
There was the Miranda version of The Craft Of.., but I didn't want to do 
too much guessing. So basically, I was left with that book which had an 
introductory chapter (I don't remember the exact name of the book) to Haskell 
and the online docs. The tutorial chapter of the book, which was an 
algorithms book, turned out to be much better than what the online docs had 
to offer although its purpose was to teach only a small subset of the 
language for algorithm design.

Thanks,

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8DJR0fAeuFodNU5wRAmksAJ4jUaj3zXZxzSFTnd06LTMk+E2TdACfVwBS
gwjbfyAbMs/VkSIQEChpw2I=
=+YDW
-END PGP SIGNATURE-

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