[Haskell] Re: Type of y f = f . f

2005-02-28 Thread Jim Apple
Jon Fairbairn wrote:
If you allow quantification over higher
kinds, you can do something like this:
   d f = f . f
   d:: âa::*, b::*â*.(b a â a) â b (b a)â a
What's the problem with
d :: (forall c . b c -> c) -> b (b a) -> a
d f = f . f
to which ghci gives the type
d :: forall a b. (forall c. b c -> c) -> b (b a) -> a
Jim
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Type of y f = f . f

2005-02-28 Thread David Menendez
Jon Fairbairn writes:

> On 2005-02-28 at 18:03GMT Ben Rudiak-Gould wrote:
> > Pedro Vasconcelos wrote:
> >  >Jim Apple <[EMAIL PROTECTED]> wrote:
> >  >>Is there a type we can give to
> >  >>
> >  >>y f = f . f
> >  >>
> >  >>y id
> >  >>y head
> >  >>y fst
> >  >>
> >  >>are all typeable?
> >  >
> >  >Using ghci:
> >  >
> >  >Prelude> let y f = f.f
> >  >Prelude> :t y
> >  >y :: forall c. (c -> c) -> c -> c
> >  >
> >  >So it admits principal type (a->a) -> a->a. From this you can see
> >  >that (y head) and (y fst) cannot be typed, whereas (y id) can.
> > 
> > I think the OP's point is that all three of his examples make
> > sense, and the resulting functions would have Haskell types, yet
> > there doesn't seem to be a Haskell type which permits all three
> > uses of y.
> 
> The problem is that the type system needs to be checkable,
> so has to throw some information away.

There are type systems which can type this, but they have their own
quirks. For example, System E [1] would give us:

y :: (a -> b & b -> c) -> a -> c

where "a & b" is the intersection of types "a" and "b". The advantage of
System E over, say, System F, is that type inferencing is decidable. The
downside is that the inferred types can be pretty long.

[1] 
-- 
David Menendez <[EMAIL PROTECTED]> 
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Proposal: Allow "\=" for field update in record update syntax

2005-02-28 Thread Benjamin Franksen
On Thursday 24 February 2005 23:27, Keean Schupke wrote:
> Benjamin Franksen wrote:
> >>Well at the moment this would give an error, but remember the
> >>list is heterogeneous, so you can just not give the list a type, and
> >>simply append the specific function... admitedly this is not as
> >>type-safe.
> >>
> >>hUpdateAtLabel field2 someFunction myRecord
> >
> >That is an advantage of hLists as compared to normal records.
> >
> >A disadvantage is that each field access needs to traverse the list. I
> > wonder if this isn't rather less efficient than the random access
> > provided by normal records.
>
> Well, not quite true, because the type of the label is used to index the
> value, the selection happens at compile time. So at run time there is no
> instance selection left... it is simply the value. At least in theory!
> whether
> the particular compiler/interpreter does this is implementation dependant.
> This is why we decided that the simpler to implement list was better than
> a more complex tree structure.

Hmm. I haven't seen it from this perspective, yet! At first reading, I thought 
this is simply too good to be true. I mean, there is some sort of list 
structured thing representing the whole record, right? Then how can the 
function that selects an element *not* traverse through the list?

After thinking for some time about this, my head begins to spin badly! I tend 
to believe now, that it could indeed be possible that the compiler performs 
the traversal at compile time, but the thought still gives me headaches.

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


Re: [Haskell] Building a dynamic loadable Parsec parser

2005-02-28 Thread Donald Bruce Stewart
adam.turoff:
> Hi,
> 
> I've got a little parser written using Parsec that I want to link into
> some C code.  I start by compiling the Haskell sources like so:
> 
>   ghc -ffi -fglasgow-exts -main-is My_Init -c parse.hs
> 
> When linking parse.o and parse_stub.o against my (additional) glue code,
> I get the following errors:
> 
>   Main.o(.text+0xc): undefined reference to `__stginit_ZCMain'
>   Main.o(.text+0x14): undefined reference to `__stginit_ZCMain'
>   Main.o(.text+0x20): undefined reference to `ZCMain_main_closure'
>   Main.o(.text+0x24): undefined reference to `ZCMain_main_closure'
> 
> I'm trying to build a .so that I can load into another process (via Tcl,
> actually).  If I define a main function in my C glue code, these errors
> go away.  But I can't have a main function in this .so.
> 
> So, two questions:
>   - is it possible to compile and link these .o files into a .so
> (on Solaris, using ghc 6.2.2)?
>   - what do I need to do to create an entry point for this Haskell
> code that _isn't_ called main()?

I think that unless you use the -PIC stuff that Wolfgang committed
recently then you'll have to instead use hs-plugins to do the dynamic
loading on the Haskell side. I'm fairly certain the pic stuff won't work
on Solaris.

Essentially, you write a Haskell wrapper module over the parser that
calls hs-plugins to load your parser. Then, using the FFI, expose a hook
to this wrapper module, and call that from C. There's an example doing
this from Objective C in the hs-plugins paper.

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


Re: [Haskell] Type of y f = f . f

2005-02-28 Thread Jon Fairbairn
On 2005-02-28 at 18:03GMT Ben Rudiak-Gould wrote:
> Pedro Vasconcelos wrote:
>  >Jim Apple <[EMAIL PROTECTED]> wrote:
>  >>Is there a type we can give to
>  >>
>  >>y f = f . f
>  >>
>  >>y id
>  >>y head
>  >>y fst
>  >>
>  >>are all typeable?
>  >
>  >Using ghci:
>  >
>  >Prelude> let y f = f.f
>  >Prelude> :t y
>  >y :: forall c. (c -> c) -> c -> c
>  >
>  >So it admits principal type (a->a) -> a->a. From this you can see that
>  >(y head) and (y fst) cannot be typed, whereas (y id) can.
> 
> I think the OP's point is that all three of his examples make sense, and 
> the resulting functions would have Haskell types, yet there doesn't seem 
> to be a Haskell type which permits all three uses of y.

The problem is that the type system needs to be checkable,
so has to throw some information away.

if y f = f . f, the easiest way of losing information is to
require that the output type of f be the same as the
input. It certainly needs to be a type acceptable as input
to f.

if you put 

th f = f . f . f

the examples still make sense, but should the type of th be
different from the type of y?

> but I can't find a type which permits more than one.

Not in Haskell.  If you allow quantification over higher
kinds, you can do something like this:


   d f = f . f

   d:: âa::*, b::*â*.(b a â a) â b (b a)â a

Now we can type
   d id 

   id :: ât . t â t
   so id :: ât . (Ît.t) t â t
ie b is (Ît.t)
   so d id :: (Ît.t)((Ît.t) t) â t
:: ât . t â t

and
   d head
head:: ât.[t]ât
so b is []
so d head :: ât . [[t]] â t

and
   fst :: âx,y.(x,y)âx
   so b is Îx.(x,y)
   d fst :: ât,y . (Îx.(x,y))((Îx.(x,y)) t) â t
 :: ât,y . (Îx.(x,y))(t,y) â t
 :: ât,y . ((t,y),y) â t
   (oops, only one y)

but you would be expecting a bit much of a compiler to infer
any of this.

-- 
JÃn Fairbairn  Jon.Fairbairn at cl.cam.ac.uk


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


[Haskell] Building a dynamic loadable Parsec parser

2005-02-28 Thread Adam Turoff
Hi,

I've got a little parser written using Parsec that I want to link into
some C code.  I start by compiling the Haskell sources like so:

ghc -ffi -fglasgow-exts -main-is My_Init -c parse.hs

When linking parse.o and parse_stub.o against my (additional) glue code,
I get the following errors:

Main.o(.text+0xc): undefined reference to `__stginit_ZCMain'
Main.o(.text+0x14): undefined reference to `__stginit_ZCMain'
Main.o(.text+0x20): undefined reference to `ZCMain_main_closure'
Main.o(.text+0x24): undefined reference to `ZCMain_main_closure'

I'm trying to build a .so that I can load into another process (via Tcl,
actually).  If I define a main function in my C glue code, these errors
go away.  But I can't have a main function in this .so.

So, two questions:
- is it possible to compile and link these .o files into a .so
  (on Solaris, using ghc 6.2.2)?
- what do I need to do to create an entry point for this Haskell
  code that _isn't_ called main()?

Thanks,

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


Re: [Haskell] Type of y f = f . f

2005-02-28 Thread Ben Rudiak-Gould
Pedro Vasconcelos wrote:
>Jim Apple <[EMAIL PROTECTED]> wrote:
>>Is there a type we can give to
>>
>>y f = f . f
>>
>>y id
>>y head
>>y fst
>>
>>are all typeable?
>
>Using ghci:
>
>Prelude> let y f = f.f
>Prelude> :t y
>y :: forall c. (c -> c) -> c -> c
>
>So it admits principal type (a->a) -> a->a. From this you can see that
>(y head) and (y fst) cannot be typed, whereas (y id) can.
I think the OP's point is that all three of his examples make sense, and 
the resulting functions would have Haskell types, yet there doesn't seem 
to be a Haskell type which permits all three uses of y. I can come up 
with types which permit any one of the three:

  y :: forall a. (a -> a) -> a -> a
  y :: forall a f. (forall x. f x -> x) -> f (f a) -> a
  y :: forall a b c f. (forall x y. f x y -> x) -> f (f a b) c -> a
but I can't find a type which permits more than one. It can probably be 
done with type classes.

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


[Haskell] postgresql foreign function call segfaults

2005-02-28 Thread Edwin Eyan Moragas
Hi Group,

i'm trying to complete an haskell pgsql interface.
all compiles well when using ghc's generated executable
but it segfaults when i do a pqexec.

-- PGresult *PQexec(PGconn *conn, const char *query);
foreign import ccall "libpq-fe.h PQexec"
pqexec::X_PGconn->CString->IO X_PGresult

here's the offending code:

create conn=do
putStrLn "creating table products"
putStrLn ("\t"++screate)
q<- newCString screate
-- segmentation fault here!
rs<- pqexec conn q
stat<- pqcmdstatus rs
stats<-peekCString stat
putStrLn ("\tstatus is: "++ show stats)
ra<- pqcmdtuples rs
ras<-peekCString ra
putStrLn ("\trows affected is: "++ show ras)

screate=
"CREATE TABLE products ("
++  "product_no integer,"
++  "name text,"
++  "price numeric"
++")"

i'm using pgsql 7.4, gcc 3.3.4, ghc 6.2.2

i tried compiling with -fvia-C and it doesn't finish compiling.
i'm asking this question in the fear that i have done something wrong.

i have posted my code the code, makefile and generated .hc file here:
http://www.eyan.org/haskell/

-- 
kind regards,
eyan

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


[Haskell] Call for Tutorials - ICTAC05

2005-02-28 Thread Bernhard K. Aichernig
Call for Tutorials - ICTAC05
INTERNATIONAL COLLOQUIUM ON
THEORETICAL ASPECTS OF  COMPUTING
Hanoi, Vietnam - 17--21 October, 2005
http://www.iist.unu.edu/ictac05
=
BACKGROUND AND OBJECTIVES
ICTAC is an International Colloquium on Theoretical Aspects of
Computing founded by the International Institute for Software
Technology of the United Nations University (UNU-IIST). The aim of the
colloquium is to bring together practitioners and researchers from
academia, industry and government to present research results, and
exchange experience, ideas, and solutions for their problems in
theoretical aspects of computing.The colloquium is aimed particularly,
but not exclusively, at participants from developing countries.  We
believe that this will help developing countries to strengthen their
research, teaching and development in computer science and
engineering, improve the links between developing countries and
developed countries, and establish collaboration in research and
education. The first ICTAC (ICTAC'04) was held in Guiyang, China and
its proceedings were published as "ICTAC 2004: Theoretical Aspects of
Computing", LNCS 3407.
ICTAC'05 will have a technical program for five days
including two days for tutorials and three days for a conference, and a
training school for 5 days.
The topics of the conference include, but are not limited to:
- automata theory and formal languages
- principles and semantics of programming languages
- logics and their applications
- software architectures and their description languages
- software specification,  refinement, and verification
- model checking and theorem proving
- formal techniques in software testing
- models of object and component  systems
- coordination and feature interaction
- integration of formal and  engineering methods
- service-oriented development
- document-driven development
- models of concurrency,  security, and mobility
- theory of parallel, distributed, and  internet-based (grid)
computing
- real-time and embedded systems
- type and category theory in  computer science
SPONSORS AND ORGANISATION
ICTAC'05 will be organised jointly between the Institute of
Information Technology of the Vietnamese Academy of Sciences and
Technology (IoIT), the University of Technology of the Vietnam
National University in Hanoi (UoT-VNU) and UNU-IIST. UNU-IIST, IoIT
and UoT-VNU are also sponsors of ICTAC'05. There will be an
one-week training school during 10--14 October 2005 before the conference.
TUTORIAL SUBMISSION
You are welcome to submit a proposal for a tutorial on any subject
related to the topics listed above. All tutorial proposal submissions
should have a detailed description of the tutorial contents, the time
duration, and an extended abstract written in English. The extended
abstract should not not exceed 5 pages in LNCS format (see
http://www.springer.de/comp/lncs/authors.html for details). The
extended abstract of the accepted tutorials will be published in the
proceedings of the ICTAC05 conference which will be published by
Springer in the Lecture Notes in Computer Science series.
All queries and tutorial proposals should be sent to the program
committee co-chairs Dang Van Hung, e-mail: [EMAIL PROTECTED], or
Martin Wirsing, e-mail: [EMAIL PROTECTED]
The deadline for tutorial proposal submission is 11 July 2005, and the
notification of tutorial proposal acceptance is 25 July 2005.
The date for tutorials is 17-18 October, 2005.

ADVISORY COMMITTEE
Dines Bjorner, Singapore
Manfred Broy, Germany
Jifeng He, UNU-IIST
Mathai Joseph, India
Shaoying Liu, Japan
Zhiming Liu, UNU-IIST
Jim Woodcock, UK
Jose Luiz Fiadeiro, UK
Tobias Nipkow, Germany
PUBLICITY CHAIR
Bernhard K. Aichernig, UNU-IIST
ORGANISING COMMITTEE
Le Hai Khoi, IoIT (co-chair)
Ho Si Dam, UoT-VNU (co-chair)
Nguyen Tue, UoT-VNU
Bui The Duy, UoT-VNU
Nguyen Viet Ha, UoT-VNU
Vu Duc Thi, IoIT
Le Quoc Hung, IoIT
Do Nang Toan, IoIT
Ngo Quoc Tao, IoIT
PROGRAM COMMITTEE
Marc Aiguier, France
Keijiro Araki, Japan
J.O.A. Ayeni, Nigeria
Jay Bagga, USA
Hubert Baumeister, Germany
Michel Bidoit, France
Jonathan Bowen, UK
Victor A. Braberman, Argentina
Cristian S. Calude, New Zealand
Ana Cavalcanti, UK
Yifeng Chen, UK
Dang Van Hung, UNU-IIST (co-chair)
Jim Davies, UK
Janos Demetrovics, Hungary
Jin Song Dong, Singapore
Henning Dierks, Germany
Do Long Van, Vietnam
Marcelo F. Frias, Argentina
Wan Fokkink, Netherlands
Susanna Graf, France
Valentin Goranko, South Africa
Dimitar Guelev, Bulgaria
Michael R. Hansen, Denmark
Jozef Hooman, Netherlands
Purush Iyer, USA
Ryszard Janicki, Canada
Takuya Katayama, Japan
Maciej Koutny, UK
Xuandong Li, China
Antonia Lopes, Portugal
Antoni Mazurkiewicz, Poland
Hrushikesha Mohanty, India
Ngo Quang Hung, USA
Nguyen Cat Ho, Vietnam
Paritosh Pandya, India
Jean-Eric Pin, France
Narjes Ben Rajeb, Tunisia
R. Ramanujam, India.
Anders P. Ravn, Denmark
Gianna Reggio, Italy
Wolfgang Reif, Germany
Riadh Robbana, Tunisia
Mark Ryan, UK
Zaidi Sahnoun, Algeria
Augusto Sampaio, Brazi

Re: [Haskell] Type of y f = f . f

2005-02-28 Thread Till Mossakowski
The name y suggests that you want to define the fixpoint combinator.
This works as follows:
Prelude> let y f = f (y f)
Prelude> :type y
y :: forall t. (t -> t) -> t
Prelude> y (\fac n -> if n == 0 then 1 else n*fac(n-1)) 10
3628800
Prelude>
Till
Pedro Vasconcelos wrote:
On Mon, 28 Feb 2005 03:50:14 -0500
Jim Apple <[EMAIL PROTECTED]> wrote:

Is there a type we can give to
y f = f . f
y id
y head
y fst
are all typeable?

Using ghci:
Prelude> let y f = f.f
Prelude> :t y
y :: forall c. (c -> c) -> c -> c
So it admits principal type (a->a) -> a->a. From this you can see that
(y head) and (y fst) cannot be typed, whereas (y id) can. BTW, this
function is usually named 'twice'.
Best regards,
Pedro

--
Till Mossakowski   Phone +49-421-218-4683
Dept. of Computer Science  Fax +49-421-218-3054
University of Bremen   [EMAIL PROTECTED]
P.O.Box 330440, D-28334 Bremen http://www.tzi.de/~till
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Type of y f = f . f

2005-02-28 Thread Pedro Vasconcelos
On Mon, 28 Feb 2005 03:50:14 -0500
Jim Apple <[EMAIL PROTECTED]> wrote:

> Is there a type we can give to
> 
> y f = f . f
> 
> y id
> y head
> y fst
> 
> are all typeable?
> 

Using ghci:

Prelude> let y f = f.f
Prelude> :t y
y :: forall c. (c -> c) -> c -> c

So it admits principal type (a->a) -> a->a. From this you can see that
(y head) and (y fst) cannot be typed, whereas (y id) can. BTW, this
function is usually named 'twice'.

Best regards,

Pedro

-- 
Pedro Vasconcelos, School of Computer Science, University of St Andrews
---
"The difference between Theory and Practice 
is greater in Practice than in Theory."
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Type of y f = f . f

2005-02-28 Thread Jim Apple
Is there a type we can give to
y f = f . f
y id
y head
y fst
are all typeable?
Jim Apple
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell