Re: [Haskell-cafe] Compiler constraints in cabal

2010-11-05 Thread Reiner Pope
Ah, I hadn't thought of that. But doesn't the version of GHC change
much more often than the version of base does?

Reiner

On 6 November 2010 03:49, Ozgur Akgun  wrote:
> AFAIK, the way to do this is putting constraints on the base package.
>
> On 5 November 2010 14:59, Reiner Pope  wrote:
>>
>> Hi,
>>
>> I have a library, hmatrix-static, on Hackage. Version 0.3 (the current
>> version) compiles with ghc-6.12.
>>
>> Let's say I want to upgrade my library using new features in ghc-7.0,
>> and then release these upgrades as version 0.4. Is there any way to
>> state in my cabal file that this new version will no longer compile
>> under ghc-6.12? The reason I would like to state this is so that a
>> user with ghc-6.12 can do 'cabal install hmatrix-static' (or do a
>> cabal install of a program depending on hmatrix-static) and see that
>> cabal will install version 0.3 rather than attempt to install version
>> 0.4 and fail.
>>
>> Thanks for your help.
>>
>> Reiner
>> ___
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> --
> Ozgur Akgun
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What do you call Applicative Functor Morphism?

2010-11-05 Thread Dan Doel
On Saturday 06 November 2010 2:09:13 am Sebastian Fischer wrote:
> Is there a deeper reason why people use "morphism" and not
> "homomorphism" or is it just because it's shorter?

I don't really know. But that's (one) standard terminology in category theory. 
Objects and morphisms.

It may be due to there being multiple prefixes in category theory that you can 
add to that:

  isomorphism
  epimorphism
  monomorphism
  ...

In that light, it makes some sense to have the default be just "morphism," 
rather than the additional homo- prefix.

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


Re: [Haskell-cafe] What do you call Applicative Functor Morphism?

2010-11-05 Thread Sebastian Fischer

Hello,

I'm curious and go a bit off topic triggered by your statement:

On Nov 6, 2010, at 12:49 PM, rocon...@theorem.ca wrote:


An applicative functor morphism is a polymorphic function,
eta : forall a. A1 a -> A2 a between two applicative functors A1 and  
A2 that preserve pure and <*>


I recently wondered: why "morphism" and not "homomorphism"?

Wikipedia says:

"In abstract algebra, a homomorphism is a structure-preserving map  
between two algebraic structures"


and

"In mathematics, a morphism is an abstraction derived from structure- 
preserving mappings between two mathematical structures."


One difference is "absract algebra ... algebraic structures" vs  
"mathematics ... mathematic structures" another difference is the  
"abstraction derived from" part in the second phrase.


So for the `Monoid` class, I'd say "monoid homomorphism" but I'm  
unsure whether `Applicative` counts as an algebraic structure or calls  
for using "morphism" instead.


Is there a deeper reason why people use "morphism" and not  
"homomorphism" or is it just because it's shorter?


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


Re: [Haskell-cafe] Rigid types fun

2010-11-05 Thread Mitar
Hi!

On Fri, Nov 5, 2010 at 4:01 PM, Tillmann Rendel
 wrote:
> Note that newNerve does not take Axons, but rather monadic actions which
> create Axons. Now, you can use something like
>
>  nerve <- newNerve newAxon newAxonAny
>
> to create a concrete nerve.

Thanks! I decided for this approach. It seems to me the nicest. Simple
and allows me to later redefine Nerve and Axon without breaking stuff
around.


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


Re: [Haskell-cafe] What do you call Applicative Functor Morphism?

2010-11-05 Thread Conal Elliott
I like "C morphism" in general, where "C" is the class name, so I use
"Applicative morphism" or "applicative functor morphism" (as in
http://conal.net/papers/type-class-morphisms/).

  - Conal

On Fri, Nov 5, 2010 at 8:49 PM,  wrote:

> An applicative functor morphism is a polymorphic function,
> eta : forall a. A1 a -> A2 a between two applicative functors A1 and A2
> that preserve pure and <*>:
>
> eta (pure c) = pure c
> eta (f <*> x) = eta f <*> eta x
>
> What do you guys call such a thing?  My leading candidate is "idomatic
> transformation".
>
> --
> Russell O'Connor  
> ``All talk about `theft,''' the general counsel of the American Graphophone
> Company wrote, ``is the merest claptrap, for there exists no property in
> ideas musical, literary or artistic, except as defined by statute.''
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] What do you call Applicative Functor Morphism?

2010-11-05 Thread roconnor

An applicative functor morphism is a polymorphic function,
eta : forall a. A1 a -> A2 a between two applicative functors A1 and A2 
that preserve pure and <*>:


eta (pure c) = pure c
eta (f <*> x) = eta f <*> eta x

What do you guys call such a thing?  My leading candidate is "idomatic 
transformation".


--
Russell O'Connor  
``All talk about `theft,''' the general counsel of the American Graphophone
Company wrote, ``is the merest claptrap, for there exists no property in
ideas musical, literary or artistic, except as defined by statute.''
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Most popular haskell applications

2010-11-05 Thread Ivan Lazar Miljenovic
On 6 November 2010 12:20, Bulat Ziganshin  wrote:
> Hello Ivan,
>
> Saturday, November 6, 2010, 4:05:38 AM, you wrote:
>
>> Possible candidates:
>> * GHC
>> * XMonad
>> * Darcs
>
> for me, darcs and ghc are programmer's instruments. xmonad is real
> application, having some utility outside of programmers community.
> i'm looking for utility of haskell for "real world". i know that it's
> used in-house (as in Deutsche Bank) or to build some solutions. what
> i'm looking for is shareware or so, things that are usually written with
> Delphi-class languages

At the moment, Haskell seems to be very developer-oriented, in that
its main usages are for custom applications to solve problems rather
than writing "consumer" software.

>> Of course, it's hard to tell: do people actually use those packages
>> once they've downloaded them?  How do you measure downloads when some
>> people use downstream binaries?
>
> for windows application download counter is good enough measure, at
> least while we compare one program with another. unfortunately, xmonad
> isn't a windows app :D

Here's _some_ indications of download counts for XMonad:
http://qa.debian.org/popcon.php?package=xmonad


-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Most popular haskell applications

2010-11-05 Thread Bulat Ziganshin
Hello Ivan,

Saturday, November 6, 2010, 4:05:38 AM, you wrote:

> Possible candidates:
> * GHC
> * XMonad
> * Darcs

for me, darcs and ghc are programmer's instruments. xmonad is real
application, having some utility outside of programmers community.
i'm looking for utility of haskell for "real world". i know that it's
used in-house (as in Deutsche Bank) or to build some solutions. what
i'm looking for is shareware or so, things that are usually written with
Delphi-class languages

> Of course, it's hard to tell: do people actually use those packages
> once they've downloaded them?  How do you measure downloads when some
> people use downstream binaries?

for windows application download counter is good enough measure, at
least while we compare one program with another. unfortunately, xmonad
isn't a windows app :D


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] What is simplest extension language to implement?

2010-11-05 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/2/10 03:33 , Permjacov Evgeniy wrote:
> Forth is quite easy to implement, but can it be used as extension
> language? Wiki describes it as quite low level...

It's low level but rather easy to build up more complex stuff.  It's never
been that popular in general due to its RPN nature, but is quite popular for
extensions in low memory situations:  it's *extremely* compact when
"compiled" (that is, when source code consisting solely of word definitions
is executed, the result is quite tiny).

To give one example of the latter, look at FreeBSD's boot loader.

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]  allb...@kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university  KF8NH
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzUq3sACgkQIn7hlCsL25UxZwCePgTpKGFnxZB+AJHugIAkXSbd
FTUAnjl2FJEjyp9bxr3rh3Nmql3O0y22
=ncJH
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Most popular haskell applications

2010-11-05 Thread Ivan Lazar Miljenovic
On 6 November 2010 12:00, Bulat Ziganshin  wrote:
> Hello haskell,
>
> people, are you know haskell apps that has more than 50k downloads per
> month (or more than 25k users) ?

Possible candidates:

* GHC

* XMonad

* Darcs

Of course, it's hard to tell: do people actually use those packages
once they've downloaded them?  How do you measure downloads when some
people use downstream binaries?

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Most popular haskell applications

2010-11-05 Thread Bulat Ziganshin
Hello haskell,

people, are you know haskell apps that has more than 50k downloads per
month (or more than 25k users) ?

-- 
Best regards,
 Bulat  mailto:bulat.zigans...@gmail.com

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


[Haskell-cafe] Re: Re[2]: Rigid types fun

2010-11-05 Thread Mitar
Hi!

On Fri, Nov 5, 2010 at 12:12 PM, Bulat Ziganshin
 wrote:
> look into HsLua sources. it does something like you asking (converting
> return type into sequence of commands) so it mau be what you are
> looking for. it uses typeclasses for this effect. the same technique
> used in haskell printf implementation afaik

While reading the source code I found that in loadstring you do not
make sure that free is called even in a case of an exception. Is this
not necessary?


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


Re: [Haskell-cafe] Finding the contents of haskell platform?

2010-11-05 Thread Stephen Tetley
On 5 November 2010 21:31, Nick Bowler  wrote:

> Except that the "Symbol" font family is not available in all browsers.

Ah ha - indeed you are right and the puritans at W3C and Mozilla.org
seem to have dug their heels in.

Unfortunately arrows don't appear to be in either the Standard Latin
Character Set or the Expert Character Set for fonts, so whilst they
are clearly present in Unicode (U+2192 for right arrow seemingly)
there's still no guarantee they are present in any given font.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Finding the contents of haskell platform?

2010-11-05 Thread Nick Bowler
On 2010-11-05 21:05 +, Stephen Tetley wrote:
> On 5 November 2010 20:08, Andrew Coppin  wrote:
> > Would it be hard to replace "->" with a real Unicode arrow character?
> 
> It should be quite easy - whether a given font has an arrow readily
> available is a different matter. It might be be simpler to drop into
> the Symbol font (should be present for all broswers) and use
> arrowright - code 0o256.

Except that the "Symbol" font family is not available in all browsers.

-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cabal and using a throw-away package database during distro package building

2010-11-05 Thread Albert Y. C. Lai

On 10-11-05 06:43 AM, Magnus Therning wrote:

 runhaskell Setup register   --gen-script
 runhaskell Setup unregister --gen-script

[...]

Except
that the generated register/unregister scripts now also point to
my-temp-db, and there seems to be no way to prevent this.  I solved it
for now by using sed, but I'd love to leave sed out, if at all
possible.


Stealing from the scripts of Haskell Platform (source tarball): Don't 
use register --gen-script, use this instead:


runhaskell Setup register --gen-pkg-config=NAME

(You choose a suitable filename for NAME. If you omit =NAME, the default 
filename is "packagename-version.conf". Do play and customize.)


Registration script is just:

ghc-pkg update NAME
or
ghc-pkg register NAME

(add options and full pathname of ghc-pkg as you see fit)

Also don't bother with unregister --gen-script, the unregister script is 
just:


ghc-pkg unregister packagename-version

(add options and full pathname of ghc-pkg as you see fit)

Haskell Platform build scripts are in exactly the same shoe as yours, 
i.e., dilemma between interdependent packages and containment. (It wants 
to register absolutely nothing if some packages fail to build.) You may 
like to look into it for inspirations. Except for how to unregister and 
uninstall. Who wants to get rid of Haskell Platform, haha!

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


Re: [Haskell-cafe] Finding the contents of haskell platform?

2010-11-05 Thread Stephen Tetley
On 5 November 2010 20:08, Andrew Coppin  wrote:

> Would it be hard to replace "->" with a real Unicode arrow character?
>

It should be quite easy - whether a given font has an arrow readily
available is a different matter. It might be be simpler to drop into
the Symbol font (should be present for all broswers) and use
arrowright - code 0o256.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Finding the contents of haskell platform?

2010-11-05 Thread Andrew Coppin

On 05/11/2010 02:59 PM, Don Stewart wrote:


The changelog now lists all the versions:

 http://hackage.haskell.org/platform/changelog.html


This is quite optimal.

It would still be nice if one could easily answer the question "which HP 
release was the one that contained process-1.0.1.1", but this is a step 
in the right direction.


Would it be hard to replace "->" with a real Unicode arrow character?

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


Re: [Haskell-cafe] Compiler constraints in cabal

2010-11-05 Thread Ozgur Akgun
AFAIK, the way to do this is putting constraints on the base package.

On 5 November 2010 14:59, Reiner Pope  wrote:

> Hi,
>
> I have a library, hmatrix-static, on Hackage. Version 0.3 (the current
> version) compiles with ghc-6.12.
>
> Let's say I want to upgrade my library using new features in ghc-7.0,
> and then release these upgrades as version 0.4. Is there any way to
> state in my cabal file that this new version will no longer compile
> under ghc-6.12? The reason I would like to state this is so that a
> user with ghc-6.12 can do 'cabal install hmatrix-static' (or do a
> cabal install of a program depending on hmatrix-static) and see that
> cabal will install version 0.3 rather than attempt to install version
> 0.4 and fail.
>
> Thanks for your help.
>
> Reiner
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



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


[Haskell-cafe] Cabal and using a throw-away package database during distro package building

2010-11-05 Thread Dimitry Golubovsky
Magnus,

You might try Capri which operates Cabal-related stuff privately on a
local-to-project package database not touching global or user
databases.

http://hackage.haskell.org/package/capri

http://www.haskell.org/haskellwiki/Capri

-- 
Dimitry Golubovsky

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


[Haskell-cafe] Re: Haskell on ancient machines (Was: "Haskell is a scripting language inspired by Python.")

2010-11-05 Thread Malcolm Wallace
I haven't checked how much RAM nhc98 needs for bootstrapping  
recently, but the
Makefile suggests 16Mb of heap + 2Mb of stack is more than  
sufficient -

it could probably manage with less.


If it was possible to save resources in these days - why isn't it
possible today anymore?
Too many Haskell extensions? Too much auxiliary code for interfacing
with OS? Increased safety?


Simply that more people care about speed than about space.

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


Re: [Haskell-cafe] Re: "Haskell is a scripting language inspired by Python."

2010-11-05 Thread Malcolm Wallace

On 5/11/2010, at 8:54 AM, Andrew Coppin wrote:
Can you actually run something like Haskell with mere kilobytes of  
RAM?


I recall running Haskell-like programs (compiled by Gofer, the  
predecessor of Hugs) on a machine with 256Kb of memory, back in the  
early 1990s.  They were smallish programs of course.  The interpreter/ 
RTS was about 50Kb, the bytecode for the program took up a few Kb, and  
there was about 100Kb of stack and heap combined, so I was not even  
using the full capacity of the machine.


Regards,
Malcolm


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


Re: [Haskell-cafe] Who manages ?

2010-11-05 Thread Don Stewart
simons:
> Hi guys,
> 
> a while ago, I created an account on Trac. Now, it seems that I've forgotten
> both the password and the e-mail address that I used at the time. I cannot
> log in, and I cannot make Trac send me the password either. Clearly, I need
> the help of a human being with administrator privileges to figure that out.
> 
> Can someone give me a pointer about who I'd want to contact regarding that
> issue?
> 

Ian Lynagh manages these community resources as a member of the
Haskell.org infrastruture team.

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


Re: [Haskell-cafe] Rigid types fun

2010-11-05 Thread Tillmann Rendel

Hi,

Mitar wrote:

I would like to do that to remove repeating code like:

from<- newChan
for<- newChan
let nerve = Nerve (Axon from) (AxonAny for)

which I have to write again and again just to make types work out. Why
I cannot move that into the function?


One option is to write a little library of functions which create axons 
and nerves:


  newAxon :: Impulse i => IO (Axon (Chan i) i AxonConductive)
  newAxon = do
chan <- newChan
return (Axon chan)

  newAxonAny :: IO (Axon (Chan i) AnyImpulse AxonConductive)
  newAxonAny = do
chan <- newChan
return (AxonAny chan)

  newNoAxon :: Monad m => m (Axon (Chan i) i AxonNotConductive)
  newNoAxon = do
return NoAxon

  newNerve :: Monad m => m (Axon a a' b) -> m (Axon c c' d)
-> m (Nerve a a' b c c' d)
  newNerve newFrom newFor = do
from <- newFrom
for <- newFor
return (Nerve from for)

Note that newNerve does not take Axons, but rather monadic actions which 
create Axons. Now, you can use something like


  nerve <- newNerve newAxon newAxonAny

to create a concrete nerve.

  Tillmann

PS. It might be an interesting exercise to use either liftM and liftM2 
(from Control.Monad) or the (<$>) and (<*>) operators from 
Control.Applicative to implement these functions without do notation.


PPS. Crosspost removed. I don't want to post to mailing lists which I do 
not read.

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


[Haskell-cafe] Compiler constraints in cabal

2010-11-05 Thread Reiner Pope
Hi,

I have a library, hmatrix-static, on Hackage. Version 0.3 (the current
version) compiles with ghc-6.12.

Let's say I want to upgrade my library using new features in ghc-7.0,
and then release these upgrades as version 0.4. Is there any way to
state in my cabal file that this new version will no longer compile
under ghc-6.12? The reason I would like to state this is so that a
user with ghc-6.12 can do 'cabal install hmatrix-static' (or do a
cabal install of a program depending on hmatrix-static) and see that
cabal will install version 0.3 rather than attempt to install version
0.4 and fail.

Thanks for your help.

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


Re: [Haskell-cafe] Finding the contents of haskell platform?

2010-11-05 Thread Don Stewart
dons:
> magnus:
> > I know there's a .cabal file for the latest version of HP somewhere,
> > but I can't coerce Google into finding me a link that actually works.
> > Furthermore, the following page:
> > 
> > http://hackage.haskell.org/platform/contents.html
> > 
> > does list all the contents, but to my big surprise it doesn't link to
> > the specific versions of the packages for HP, instead it links to the
> > latest version found on Hackage.
> > 
> 
> I'll generate a spec page from the .cabal file this week sometime.
> 

The changelog now lists all the versions:

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


Re: [Haskell-cafe] Reference for technique wanted

2010-11-05 Thread Claus Reinke

I haven't the faintest idea what SML is doing with the third
version, but clearly it shouldn't.  


Those numbers are worrying, not just because of the third
version - should doubling the tree size have such a large effect?

I find your report that GHC doesn't do as well with the third 
version as the first two somewhat reassuring.


Well, I reported it as a performance bug;-) Also because 
GHC 6.12.3 had the second version as fast as the first while

GHC 7.1.x had the second version as slow as the third. You
can find my code in the ticket:

http://hackage.haskell.org/trac/ghc/ticket/4474


The difference makes me wonder whether there might be
performance consequences of the point-free style in more cases.


It would be good to know what is going on, as those
code transformations are not unusual, and I like to be
aware of any major performance trade-offs involved.


I'd still call both patterns difference lists,


I have been shouting about how bad a name "difference list" is
in >Prolog< for about 20 years.  


Ah, when you put it like this, I agree completely. The name
focusses on the wrong part of the idea, or rather on the
junk in one particular, explanatory representation of the idea.


It really is much more useful in Prolog
to think of list differences as a kind of *relationship*, because
then you are able to think "hey, why just two ends?  Why can't I
pass around *several* references into the same list?


Names have power - if you want to get rid of one as well
established as "difference lists", you'll have to replace it 
with another. How about 

   "incomplete data structures"? 

That is already used in connection with more general 
applications of logic variables, and it focusses on half of 
the interesting bit of the idea (the other part  being how 
one completes the structures).


Then logic programmers can think of logic variables,
functional programmers can think of parameterised
structures, operational semanticists can think of contexts
with hole filling, denotational semanticists can think of
partially defined structures, and so on..

Claus

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


[Haskell-cafe] Re: Rigid types fun

2010-11-05 Thread Mitar
Hi!

On Fri, Nov 5, 2010 at 12:50 PM, Alexey Khudyakov
 wrote:
> I'm not sure what do you exactly want. But what about applicative functors?
> They offer nice notation
>
>> Nerve <$> (Axon <$> newChan) <*> (AxonAny <$> newChan)

Ooo. That is nice.


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


Re: [Haskell-cafe] vector-space and standard API for vectors

2010-11-05 Thread Alexey Khudyakov



We already know that there are noncommutative modules/vectorspaces of
interest (e.g., modules over quaternions and modules over graph paths),
why not support them from the beginning? It seems like you're going out
of your way to exclude things that would be trivial to include. This is
exactly why this is my standard complaint against the various proposals
out there for new numeric hierarchies. People who are used to only using
R^n think the proposals are just fine, but none of the proposals capture
the structures I work with daily. Which means the new proposals are no
better than the Prelude for me.

Could you tell what data structures do you use? It's difficult to think 
about them without concrete examples.

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


[Haskell-cafe] Re: Rigid types fun

2010-11-05 Thread Alexey Khudyakov

On 05.11.2010 14:08, Mitar wrote:

So I know I can move some hard-coded combination into a function. But
I would like to cover all combinations and tell with arguments which
combination I want.

I'm not sure what do you exactly want. But what about applicative 
functors? They offer nice notation


> Nerve <$> (Axon <$> newChan) <*> (AxonAny <$> newChan)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re[2]: Rigid types fun

2010-11-05 Thread Bulat Ziganshin
Hello Mitar,

Friday, November 5, 2010, 2:08:52 PM, you wrote:

> I would like to call it like "create (Axon undefined) (AxonAny
> undefined)" and get in that case "Nerve (Axon a) (AxonAny b)" as a
> result. If I would call it like "create (AxonAny undefined) (AxonAny
> undefined)" I would get "Nerve (AxonAny a) (AxonAny b)" as a result.
> And so on.

look into HsLua sources. it does something like you asking (converting
return type into sequence of commands) so it mau be what you are
looking for. it uses typeclasses for this effect. the same technique
used in haskell printf implementation afaik

-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


[Haskell-cafe] Re: Rigid types fun

2010-11-05 Thread Mitar
Hi!

On Fri, Nov 5, 2010 at 10:49 AM, Bulat Ziganshin
 wrote:
> Friday, November 5, 2010, 12:45:21 PM, you wrote:
>
>> from <- newChan
>> for <- newChan
>> let nerve = Nerve (Axon from) (AxonAny for)
>
> create = do from <- newChan
>            for <- newChan
>            return$ Nerve (Axon from) (AxonAny for)
>
> main = do nerve <- create
>          ...

OK. It is necessary to check the attached file to understand. ;-)

I would like to call it like "create (Axon undefined) (AxonAny
undefined)" and get in that case "Nerve (Axon a) (AxonAny b)" as a
result. If I would call it like "create (AxonAny undefined) (AxonAny
undefined)" I would get "Nerve (AxonAny a) (AxonAny b)" as a result.
And so on.

So I know I can move some hard-coded combination into a function. But
I would like to cover all combinations and tell with arguments which
combination I want.


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


[Haskell-cafe] Cabal and using a throw-away package database during distro package building

2010-11-05 Thread Magnus Therning
Recently I experimented a little with putting several Hackage packages
into a single Linux distro package, but I ran into a slight problem
with registering Haskell packages temporarily.

These are the basic steps taken to configure, compile, and stage a
Haskell package in ArchLinux:

runhaskell Setup configure --prefix=/usr --docdir=/usr/share/doc/${pkgname}
runhaskell Setup build
runhaskell Setup haddock
runhaskell Setup register   --gen-script
runhaskell Setup unregister --gen-script
runhaskell Setup copy --destdir=${pkgdir}

This works fine for a single Hackage package, but if I want to compile
two or more of them into a single distro package, and there are
dependencies between them, then it won't do.  I also don't want to
fully install and/or register the Hackage packages during the build
for obvious reasons of containment and system contamination.  So,
looking at the Cabal help I found the --package-db flag for configure.
 The steps now become:

runhaskell Setup configure --prefix=/usr
--docdir=/usr/share/doc/${pkgname} --package-db=my-temp-db
runhaskell Setup build
runhaskell Setup haddock
runhaskell Setup register --inplace
runhaskell Setup register   --gen-script
runhaskell Setup unregister --gen-script
runhaskell Setup copy --destdir=${pkgdir}

That works and I can satisfy dependencies between the Hackage
packages, without affecting the system-wide database.  Great.  Except
that the generated register/unregister scripts now also point to
my-temp-db, and there seems to be no way to prevent this.  I solved it
for now by using sed, but I'd love to leave sed out, if at all
possible.

So, have I missed something, or is this a use case that wasn't
considered when developing Cabal?
Would it be worth raising a bug for this at all?

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Are newtypes optimised and how much?

2010-11-05 Thread Bertram Felgenhauer
> | Then we can define
> | 
> | safeCoerce :: (a ~~ b) => a -> b
> | safeCoerce = unsafeCoerce
> 
> Yes, that's right.  When I said "we have the technology" I meant that we 
> (will) have something similar to ~~.  See our paper "Generative Type 
> Abstraction and Type-level Computation" 
> http://www.cis.upenn.edu/~sweirich/newtypes.pdf.  No unsafeCoerce required.

The idea was to put safeCoerce into a library. The syntax extension
would be light-weight because contexts, unlike expressions, still have
plenty of room for extensions. The idea is is based on the assumption
that to the compiler, 'unsafeCoerce' looks like an artificial safe
coercion, so that after inlining safeCoerce, we get exactly the effect
of a safe coercion during type checking and further compilation. Perhaps
that assumption is wrong. I'll look at the paper.

Regards,

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


[Haskell-cafe] SBLP 2011 - call for papers

2010-11-05 Thread Simon Thompson

SBLP 2011: Call For Papers

15th Brazilian Symposium on Programming Languages

Sao Paulo, Brazil
September 26-30, 2010
http://www.each.usp.br/cbsoft2011/

IMPORTANT DATES

Paper abstract submission (15 lines): April 22nd, 2011
Full paper submission: April 29th, 2011
Notification of acceptance: May 30th, 2011
Final papers due: July 29th, 2011

INVITED SPEAKERS

Gary T. Leavens, Univ. of Central Florida
Jose Luis Fiadeiro, Univ. of Leicester 

INTRODUCTION

The 15th Brazilian Symposium on Programming Languages, SBLP 2011, will
be held in Sao Paulo, Brazil, between September 26th and 30th,
2011. SBLP provides a venue for researchers and practitioners
interested in the fundamental principles and innovations in the design
and implementation of programming languages and systems.

The symposium will be part of the 2nd Brazilian Conference on
Software: Theory and Practice, CBSoft 2011,
http://www.each.usp.br/cbsoft2011/, which will host four well-established 
Brazilian symposia: 

* XXV Brazilian Symposium on Software Engineering (SBES)
* XV Brazilian Symposium on Programming Languages (SBLP)
* XIV Brazilian Symposium on Formal Methods (SBMF)
* V Brazilian Symposium on Components, Software Architecture and
Software Reuse (SBCARS)

SBLP 2011 invites authors to contribute with technical
papers related (but not limited) to:

* Program generation and transformation, including domain-specific
 languages and model-driven development in the context of programming
 languages.

* Programming paradigms and styles, including functional,
 object-oriented, aspect-oriented, scripting languages, real-time,
 service-oriented, multithreaded, parallel, and distributed
 programming.

* Formal semantics and theoretical foundations, including
 denotational, operational, algebraic and categorical approaches.

* Program analysis and verification, including type systems, static
 analysis and abstract interpretation.

* Programming language design and implementation, including new
 programming models, programming language environments, compilation
 and interpretation techniques.

SUBMISSIONS

Submissions should be done using SBLP 2011 installation of the
EasyChair conference management system at
http://www.easychair.org/conferences/?conf=sblp2011.

Contributions should be written in Portuguese or English. We solicit
papers that should fall into one of two different categories: full
papers, with at most 15 pages, or short papers, with at most 5
pages. All papers should be prepared using the Easychair
template. (http://www.easychair.org/easychair.zip) In particular, we
encourage the submission of short papers reporting on master
dissertations or doctoral theses at early stages of their
development. All accepted papers will be published in the conference
proceedings.

As in previous editions, a journal special issue, with selected papers
from accepted contributions, is anticipated. From 2003 to 2008 there
were special issues of the Journal of Universal Computer Science,
published by Springer, with the post-proceedings of SBLP. The
post-proceedings of SBLP 2009 and 2010 are being edited as special
issues of Science of Computer Programming, published by Elsevier.

GENERAL CO-CHAIRS

Denise Stringhini FCI, Mackenzie
Alfredo Goldman IME, USP

PROGRAMME CHAIRS

Christiano Braga, UFF
Jose Luiz Fiadeiro, Univ. of Leicester 

PROGRAMME COMMITTEE 

* Alberto Pardo, Univ. de La Republica
* Alex Garcia, IME
* Alvaro Freitas Moreira, UFRGS (TBC)
* Andre Santos, UFPE
* Artur Boronat, Univ. of Leicester
* Carlos Camarao, UFMG
* Christiano Braga, UFF (co-chair)
* Edward Hermann Haeusler, PUC-Rio (TBC)
* Fernando Castor Filho, UFPE
* Fernando Pereira, UFMG
* Francisco Heron de Carvalho Junior, UFC (TBC)
* Giuseppe Castagna, Paris 7 (TBC)
* Jens Palsberg, UCLA
* Joao Saraiva, Universidade do Minho
* Johan Jeuring, Utrecht Univ.
* Jonathan Aldrich, Carnegie Mellon Univ.
* Jose Luiz Fiadeiro, Univ. of Leicester (co-chair)
* Lucilia Figueiredo, UFOP
* Luis Soares Barbosa, Univ. do Minho
* Marcelo A. Maia, UFU
* Marcelo d'Amorim, UFPE
* Marco Tulio Valente, UFMG
* Mariza A. S. Bigonha, UFMG
* Martin A. Musicante, UFRN
* Noemi Rodriguez, PUC-Rio
* Paulo Borba, UFPE (TBC)
* Peter Mosses, Swansea University
* Renato Cerqueira, PUC-Rio
* Ricardo Massa, UFPE
* Roberto S. Bigonha, UFMG (TBC)
* Roberto Ierusalimschy, PUC-Rio
* Sandro Rigo, UNICAMP
* Sergio Soares, UFPE (TBC)
* Sergiu Dascalu, Univ. of Nevada
* Simon Thompson, Univ. of Kent
* Sophia Drossopoulou, Imperial College (TBC)
* Varmo Vene, Univ. de Tartu (TBC)
* Vladimir Di Iorio, UFV (TBC)___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is Curry alive?

2010-11-05 Thread Ross Paterson
On Thu, Nov 04, 2010 at 06:06:40PM -0400, Dan Doel wrote:
> Implementing type inference can be very easy in a logic language,
> because most of the work in a non-logic language is implementing
> unification:

Provided the implementation includes the occurs check.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is Curry alive?

2010-11-05 Thread wren ng thornton

On 11/4/10 6:32 PM, Gregory Crosswhite wrote:

On 11/04/2010 03:06 PM, Dan Doel wrote:

Implementing type inference can be very easy in a logic language,
because most
of the work in a non-logic language is implementing unification:
[...]


Cool! Thank you very much; that is exactly the kind of thing I was
looking for. :-)


And for constraint languages just think of, er, constraint problems.

That is, I'm running a factory that needs to make a bunch of different 
widgets, but different workers/stations only know how to make certain 
widgets, or certain workers are only available for so many hours a day 
or certain days of the week, and certain widgets are needed in order to 
make other bigger widgets. What is the best scheduling of jobs to 
maximize my productivity?


Or to pick a less practical (but no less actual) example: you're a 
crossword puzzle designer. You have a big dictionary of words and you 
need to come up with a 32*32 board where all the words intersect in the 
right way. Oh, and it should be a pretty symmetric design too.


Some formalisms for parsing (or generating) natural language work by 
declaring a bunch of constraints on how words can interact, rather than 
postulating a grammar of tree structures. In certain ways it's a lot 
nicer, right? You just put down rules like "adjectives precede the nouns 
they modify", and that's that; no need to worry about left corner 
transforms, or making your grammar deterministic, or unary rule cycles, 
or the other traps awaiting an unwary CFG designer.


Or, I have a system of linear inequalities and I want to find the 
solutions. That is, the "interesting" ones: the boundary solutions.



In a language like ECLiPSe you just need to state whatever the 
constraints are and then hit the START button. In general you shouldn't 
have to worry about how the runtime searches for answers, though 
worrying about that is how you do optimization in constraint programming.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Rigid types fun

2010-11-05 Thread Bulat Ziganshin
Hello Mitar,

Friday, November 5, 2010, 12:45:21 PM, you wrote:

> from <- newChan
> for <- newChan
> let nerve = Nerve (Axon from) (AxonAny for)

create = do from <- newChan
for <- newChan
return$ Nerve (Axon from) (AxonAny for)

main = do nerve <- create
  ...


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] "Haskell is a scripting language inspired by Python."

2010-11-05 Thread Tillmann Rendel

Hi,

Albert Y. C. Lai wrote:

I also invite you to play with my:
http://www.vex.net/~trebla/humour/lmcify.html


http://www.vex.net/~trebla/humour/lmcify.html?t=this+is+not+an+authorative+source.

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


[Haskell-cafe] Rigid types fun

2010-11-05 Thread Mitar
Hi!

I have much fun with rigid types, type signatures and GADTs. And I
would like to invite also others in and share my joy. ;-)

Please see the attached file and chase a solution to how to make it
compile. I would like to have a function which I would call like:

createNerve (Axon undefined) (AxonAny undefined)

and it would return proper Nerve. Similar to how asTypeOf works.

I would like to do that to remove repeating code like:

from <- newChan
for <- newChan
let nerve = Nerve (Axon from) (AxonAny for)

which I have to write again and again just to make types work out. Why
I cannot move that into the function?

I am using GHC 6.12.3. Is this something which will work in 7.0?


Mitar


Test.hs
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Reference for technique wanted

2010-11-05 Thread Stephen Tetley
On 5 November 2010 06:40, Richard O'Keefe  wrote:
>
> On 4/11/2010, at 10:56 PM, Claus Reinke wrote:
>> Even in your SML code, the "boring old plain lists" seemed to be 
>> list_flatten, which uses difference lists in disguise, and won
>> your little test, right? Using Haskell notation:
>>
>> flat (LEAF x) ys = x : ys
>> flat (FORK(a,b)) ys = flat a (flat b ys)
>
> Measured time:
>    0.902 seconds (2**22 leaves)
>    2.716 seconds (2**23 leaves)
>> -->
>> flat (LEAF x)  = \ys->x : ys
>> flat (FORK(a,b)) = \ys->flat a (flat b ys)
>
> Measured time:
>    0.980 seconds (2**22 leaves)
>    7.999 seconds (2**23 leaves)
>> -->
>> flat (LEAF x)  = (x :)
>> flat (FORK(a,b)) = flat a . flat b
>
> Measured time:
>   10.189 seconds (2**22 leaves)
>  163.184 seconds (2**23 leaves)
>
> In all cases, the final result was a list, not a function.
> I was actually expecting the first and second versions to
> be the same code.
>
[SNIP]

Hello Richard

I'm not entirely convinced that your experiment is a case against Hughes lists.

The flattening of the bin-tree can use exactly _cons_ as it can go to
right-bottom leaf and then work backwards with the accumulator
cons-ing a single element at each step. I'd expect a plain list to be
better for this as I expect a constructor to be more efficient than a
function.

Figuratively speaking, I'd contend that the bin-tree (aka a join-list)
has already taken the weight of the concatenation. To show a Hughes
list as efficient or inefficient a test would need to compare a plain
list and a Hughes list doing the concatenation themselves - the common
exemplar being string building vis the ShowS type.

Best wishes

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


Re: [Haskell-cafe] Re: "Haskell is a scripting language inspiredby Python."

2010-11-05 Thread Ketil Malde
Luke Palmer  writes:

>  To us, scripting meant short, potent code that rolled off your
> fingers and into the computers mind, compelling it to do your job with
> reverence to the super power you truly are.

Just when I thought, oh, there are two definitions for "scripting
language", another one pops out.  So scripting languages can be three
things: 

1) A language for controlling ('scripting') an application (e.g. TCL, VBA)
2) A language for controlling the running of various applications
   (e.g. shell scripts)
3) An agile language for making short programs (e.g. Perl)

Although Haskell is quite expressive, programs tend to need a bit of
'wrap' (module declaration, imports, etc), making it a bit more
heavyweight than Perl or AWK for #3.  For #2, I think running other
programs are a bit too cumbersome, but perhaps this is just a library
problem?  I haven't really looke at #1, I think we lack a small, easily
embeddable interpreter.

So, I wouldn't really call Haskell a scripting language in its current
state in any of these senses, although it's close for #3.  I think you
see more of an advantage for slightly larger programs - ones that you
perhaps need to maintain - though.

More definitions of scripting language:

 a) too slow to do real work
 b) Also they "don't scale well"

I think Haskell can be fast enough to do 'real work', and although I
haven't really written any large programs in Haskell, I don't see why it
should scale worse than other languages.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: "Haskell is a scripting language inspired by Python."

2010-11-05 Thread Ketil Malde
"Richard O'Keefe"  writes:

> Automatically?  Probably not.

>> Like biologist can determine the distance between two genotypes, and
>> determine a hierarchy between species from that. 

I'm going to say the same as Richard, only differently.  For computer
languages, we can't observe the genotype, only the phenotype.  I.e. we
can look at what the language looks like on the surface, but not what
made it so - there are no "genes" available.

This is where biology was before DNA was discovered, and it led to
interesting taxonomies, starting with Genesis's division into animals by
habitat. 

> Until this year I taught some of that stuff.  The distance between two
> sequences depends hugely on *what* you choose to measure (which particular
> features) and *how* you measure distances (there are similarity matrices
> people use, but you have to choose).

I think you are referring to edit distance here, where you find
the optimum given penalties for substitutions and gaps - typically
an affine penalty for gaps (exepensive gap opening penalty, somewhat
cheaper gap extension), and a char x char cost matrix for substitution.

Especially the gap costs aren't well founded theoretically, so hopefully
the results aren't varying /hugely/.

> Then there are algorithms that give
> optimal results but blow up for anything much past 15 species, 

I.e, edit distance is O(n^k) for k sequences of length n.

> Then we turn to human designs, and suddenly THERE IS NO TREE.

Bacteria can also do horizontal gene transfer, so there is no (single)
tree there either.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "Haskell is a scripting language inspired by Python."

2010-11-05 Thread David Virebayre
<< Also they "don't scale well", which I guess means that they don't
make it inconvenient to design badly. >>
Luke Palmer

I nominate the above for quote of the week !
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Type inference algorithm in Prolog and Haskell

2010-11-05 Thread oleg

Dan Doel wrote:

> Implementing type inference can be very easy in a logic language,
> because most of the work in a non-logic language is implementing
> unification:

> http://muaddibspace.blogspot.com/2008/01/type-inference-for-simply-typed-lambda.html

Correctly implementing type inference in Prolog is much more
complicated. The cited code is elegant, but it is not correct.

Here's the code without Unicode embellishments:

GNU Prolog 1.3.0
By Daniel Diaz
Copyright (C) 1999-2007 Daniel Diaz
| ?- [user].
compiling user for byte code...
:- op(150, xfx, --).
:- op(140, xfx, :).
:- op(100, xfy, ->).
:- op(100, yfx, $).

Gamma --Term : Type   :- atom(Term), member(Term : Type, Gamma).
Gamma -- lam(A, B) : Alpha -> Beta :- [A : Alpha|Gamma] -- B : Beta.
Gamma --   A $ B : Beta   :- Gamma -- A : Alpha -> Beta, Gamma -- B : Alpha.

user compiled, 9 lines read - 1801 bytes written, 8746 ms

% We define a boolean and an integer constants -- only to make the examples
% smaller.

?- G0 = [i1:int, b1: bool], E = lam(f, lam(x, f $ (x $ i1))), G0 -- E : T.

  E = lam(f,lam(x,f$(x$i1)))
  G0 = [i1:int,b1:bool]
  T = (A->B)->(int->A)->B

% so far, so good.

?- G0 = [i1:int, b1: bool], E = lam(f, lam(x, f $ (x $ i1) $ (x $ b1))), 
 G0 -- E : T.
no

% Still good: we can't apply x both to a boolean and an integer.

?- G0 = [i1:int, b1: bool], 
 E = lam(f, lam(x, lam(x, f $ (x $ i1) $ (x $ b1, G0 -- E : T.

  E = lam(f,lam(x,lam(x,f$(x$i1)$(x$b1
  G0 = [i1:int,b1:bool]
  T = (A->B->C)->(bool->B)->(int->A)->C ? 

% What happened? How come we embedded an untypable term in a larger
% term, and it type-checked?
% Look at the type: why the first x has the type bool->B?
% Because two occurrences of x in the body of the term are
% different identifiers, one inner and one outer.
% The type checker does not understand lexical scoping!
% That is not Lambda-calculus!

% It gets worse:
| ?- E = lam(f, lam(x, (f $ (x $ lam(z,z))) $ (x $ (lam(u,lam(v,u)),
[] -- E : T.

% lopes forever, has to be aborted.

?- E = lam(x, x $ x), [] -- E : T.
Illegal instruction: 4

Finally we've got a segmentation fault. I submit that a type-checker
that accepts ill-typed terms, loops and causes segmentation faults is
not correct.

The member() predicate is (one of the) culprits.  In a real
type-checker, if we find the binding x:t in Gamma and we fail to
type-check, we should not look for another binding in Gamma. We have
to fail. But that is not how member works: it selects one element from
the list; if it is not good, it selects another.

It is also tempting to use Prolog variables for lambda-bound
variables. That brings another can of worms: generally speaking, we
need disequality constraints.

Prolog sure makes some things easier, but some things quite more
complicated.

Implementing type inference for simply-typed lambda-calculus
in Haskell is not that complex:
http://okmij.org/ftp/Computation/FLOLAC/TInfT.hs

However, we don't even have to do that. Haskell itself can do that for
us:
http://okmij.org/ftp/tagless-final/course/TTF.hs

It boils out to three lines:

class Symantics repr where
lam :: (repr a -> repr b) -> repr (a->b)
app :: repr (a->b) -> repr a -> repr b

That is it: the type system of simply-typed lambda-calculus (which we
can read as the implication fragment of minimal logic). Two rules,
implication introduction and elimination, is all it takes. Now, when we
try to typecheck the problematic term

*TTF> lam (\x -> app x x)

:1:17:
Occurs check: cannot construct the infinite type: a = a -> b
  Expected type: repr a
  Inferred type: repr (a -> b)
In the second argument of `app', namely `x'
In the expression: app x x

we actually get a type error -- with a good error message -- rather
than a segmentation fault.

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