Re: [Haskell-cafe] GHCi fails to load C++ object files (missing symbol)

2012-03-08 Thread Hans Aberg
On 8 Mar 2012, at 13:21, Mark Wright wrote:

 It might work without -fpic on x86 (32 bit):
 
 http://www.mail-archive.com/gentoo-dev@gentoo.org/msg01420.html

On OS X, it is always on; I tried the example on 10.7, Xcode 4.3. I had to add
  ln -s /Applications/Xcode.app/Contents/Developer /Developer
as ghc 7.0.4 looks for /Developer/usr/bin/gcc. For some funny reason ghc is at 
/usr/bin/ghc; since it is not a system distribution, it should be at 
/usr/local/bin/, which is also in the system path.

On x86-64, there special relative addressing support, so there is no reason 
having it turned off, but some other good reasons for having on, like the 
security reason mentioned here:
  http://stackoverflow.com/questions/7078253/pic-on-osxs-gcc

Hans



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


Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Hans Aberg
On 24 Jan 2012, at 11:06, Christopher Brown wrote:

 I have stumbled across language-c on hackage and I was wondering if anyone is 
 aware if there exists a full C++ parser written in Haskell? 

There is a yaccable grammar
  http://www.parashift.com/c++-faq-lite/compiler-dependencies.html#faq-38.11

You might run it through a parser generator that outputs Haskell code.
  http://www.haskell.org/haskellwiki/Applications_and_libraries/Compiler_tools

Hans



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


Re: [Haskell-cafe] black Wikipedia (Was: PhD program at Portland State accepting applications)

2012-01-18 Thread Hans Aberg
On 18 Jan 2012, at 18:49, Andrew Butterfield wrote:

 Just add ?banner=none to the url if you really have to read the page

Or stop the loading before the banner comes up.

Hans


 On 18 Jan 2012, at 17:37, Henning Thielemann wrote:
 
 
 On Wed, 18 Jan 2012, Nathan Collins wrote:
 
 - Portland is a very popular US city, known for beer, bikes, music,
 and street food:
 
 http://en.wikipedia.org/wiki/Portland_Oregon (wikipedia is blacked out 
 today)
 
 Maybe it is only a JavaScript trick. In Firefox (with JavaScript) I see the 
 complete a page before it is overwritten by the protest page. In Konqueror 
 of KDE 3 (with and without JavaScript) I can read the Wiki pages without 
 problems. Edit however is really disabled. Sometimes I am glad to have the 
 old technology available. :-)



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


Re: [Haskell-cafe] black Wikipedia

2012-01-18 Thread Hans Aberg

On 18 Jan 2012, at 19:32, John Meacham wrote:

 Not to mention ebay, craigslist, etc..
 http://www.techdirt.com/articles/20111005/10082416208/monster-cable-claims-ebay-craigslist-costco-sears-are-rogue-sites.shtml
 
 when there is no burden of proof for someone to take down a site then
 things get very complicated.
 
 for instance this package could be enough to get all of hackage taken
 down since astrolabe decided they own timezone data[1].
 
 http://hackage.haskell.org/package/timezone-olson-0.1.2

There is the Beastie Boys case, where the judge decided copyright protects what 
is creatively unique.

Hans


 in fact, SOPA and PIPA would make hackage pretty impossible to legally
 host. Unless the hackage maintainers want to do exhaustive patent and
 copyright searches on all uploaded code before they allow it to be
 posted.
 
 [1] 
 http://www.techdirt.com/articles/20111006/11532316235/astrolabe-claims-it-holds-copyright-timezone-data-sues-maintainers-public-timezone-database.shtml
 
   John
 
 
 
 On Wed, Jan 18, 2012 at 10:17 AM, Brandon Allbery allber...@gmail.com wrote:
 On Wed, Jan 18, 2012 at 13:11, Henning Thielemann
 lemm...@henning-thielemann.de wrote:
 
 On Wed, 18 Jan 2012, Andrew Butterfield wrote:
 
 Just add ?banner=none to the url if you really have to read the page
 
 
 Maybe the intention was to demonstrate that censorship (in this case
 self-censorship) is mostly a problem for average users but not for advanced
 users.
 
 
 There isn't going to be a disable-javascript or ?banner hack when anyone
 anywhere can force a website to be redirected to some DOJ page without
 providing any proof.  (Yes, really.)
 
 --
 brandon s allbery  allber...@gmail.com
 wandering unix systems administrator (available) (412) 475-9364 vm/sms
 
 
 ___
 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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] black Wikipedia

2012-01-18 Thread Hans Aberg
On 18 Jan 2012, at 23:11, Brandon Allbery wrote:

 There is the Beastie Boys case, where the judge decided copyright protects 
 what is creatively unique.
 
 But such judgments are rare, sadly.  And for every Beastie Boys case there's 
 at least one The Verve case.

I did not know that. But it was a UK case, wasn't it? - UK copyright laws are a 
lot more tight.

Hans



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


Re: [Haskell-cafe] black Wikipedia

2012-01-18 Thread Hans Aberg
Actually, it is a battle between the Hollywood and Silicon Valley industries.

Hans


On 19 Jan 2012, at 00:11, John Meacham wrote:

 And such a thing can take months or years for the courts to figure
 out, and unless your free site has a lawyer to fight for your side,
 under SOPA/PIPA you can be down the entire time with little recourse.
 For anyone hosting content lke hackage, github, etc. when you have
 thousands of packages, someone somewhere is going to be upset by
 something and will be able to take the site down. _regardless of the
 merit of their case_ the site will go down as they figure it out. Not
 only that, they would be able to take the site down if it contains a
 link to an objectionable site. for instance, if one of the homepage
 fields in some cabal file  somewhere pointed to a site that someone
 took offense too on it. we would not only be obligated to patrol the
 code uploaded, but the targets of any urls within said
 code/description... and retroactively remove stuff if said links
 change to contain objectional material. (for a very vauge definition
 of objectionable). it is a really messed up law.
 
John
 
 On Wed, Jan 18, 2012 at 2:46 PM, Hans Aberg haber...@telia.com wrote:
 On 18 Jan 2012, at 23:11, Brandon Allbery wrote:
 
 There is the Beastie Boys case, where the judge decided copyright protects 
 what is creatively unique.
 
 But such judgments are rare, sadly.  And for every Beastie Boys case 
 there's at least one The Verve case.
 
 I did not know that. But it was a UK case, wasn't it? - UK copyright laws 
 are a lot more tight.
 
 Hans
 
 


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


Re: [Haskell-cafe] GHC exceeding command line length limit with split-objs - and a possible fix

2012-01-11 Thread Hans Aberg
On 11 Jan 2012, at 13:38, John Lato wrote:

 I used https://github.com/kennethreitz/osx-gcc-installer/downloads to
 get a real gcc on Lion.  Biggish download, but it worked.  I've also
 seen reports of success by self-compiling gcc, or by installing XCode
 4 on top of an existing XCode 3 installation.

GCC 4.6.2 builds on OS X 10.7 with Xcode 4.2. Build GMP 5.0.2 with clang, and 
then GCC with /usr/bin/gcc - llvm-gcc-4.2. I think I saw someone guild GCC 
4.7, but this is highest stable.

Hans

 From: Eugene Kirpichov ekirpic...@gmail.com
 
 Oh well... looks like building ghc won't be easy, as it doesn't build with
 llvm-gcc and it's not easy to get a real gcc on Lion. But I don't stop
 trying :)



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-26 Thread Hans Aberg
On 26 Dec 2011, at 16:11, AUGER Cédric wrote:

 There is
  http://www.stixfonts.org/
 For typesetting with Xe[La]TeX or Lua[La]TeX, use XITS (in the
 TeXLive package).
 
 (And then we'll have to deal with folks trying to use the letter,
 because everyone knows the Roman alphabet is the only one that
 matters and of *course* Greek letters are symbol characters
 Pfeh.)
 
 This is the big problem right now: how to enter these symbols
 efficiently.
 
 Under Xorg, XCompose might be your friend! I have a whole bunch of
 them for Coq programing.
 
 Having something like:
 
 -8-
 # ~/.XCompose contents:
 
 # the Compose file of the xorg distribution to have a lot
 # of useful symbols such as ☭ ^^
 include /usr/local/lib/X11/locale/en_US.UTF-8/Compose
 # the Compose file that could be included in Haskell distributions
 include /usr/local/share/haskell/Compose
 # other personnal notations
 ---8---
 # /usr/local/share/haskell/Compose contents:
 
 # maybe to be downloaded via a Hackage cabal package?
 # of course Multi_key H should be replaced by a
 # user specified combo
 Multi_key H colon colon : ∷
 Multi_key H greater greater greater : ⋙
 Multi_key H less less less : ⋘
 Multi_key H less minus less : ↢ U2919
 Multi_key H greater minus greater : ↣ U291A
 Multi_key H minus less less : U291B
 Multi_key H greater greater minus : U291C
 Multi_key H a l l : ∀
 Multi_key H e x : ∃
 Multi_key H a n d : ∧
 Multi_key H o r : ∨
 Multi_key H a b s t : λ
 Multi_key H c o m p : ∘
 Multi_key H minus greater : →
 8--
 
 But if you are under Windows, or Mac OS, I cannot tell (as well as I
 cannot tell if you are under a POSIX system not running xorg, such as
 the tty1..ttyn consoles)

On OS X one can make ones owns key maps, like with the program on the link 
below, but it is very time consuming.

Hans


http://scripts.sil.org/cms/scripts/page.php?site_id=nrsiid=ukelele



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-26 Thread Hans Aberg
On 26 Dec 2011, at 19:29, AUGER Cédric wrote:

 Le Mon, 26 Dec 2011 18:20:55 +0100,
 Hans Aberg haber...@telia.com a écrit :
 
 On 26 Dec 2011, at 16:11, AUGER Cédric wrote:
 
 Under Xorg, XCompose might be your friend! I have a whole bunch of
 them for Coq programing.
 
 Having something like:
 
 -8-
 # ~/.XCompose contents:
 
 # the Compose file of the xorg distribution to have a lot
 # of useful symbols such as ☭ ^^
 include /usr/local/lib/X11/locale/en_US.UTF-8/Compose
 # the Compose file that could be included in Haskell distributions
 include /usr/local/share/haskell/Compose
 # other personnal notations
 ---8---
 # /usr/local/share/haskell/Compose contents:
 
 # maybe to be downloaded via a Hackage cabal package?
 # of course Multi_key H should be replaced by a
 # user specified combo
 Multi_key H colon colon : ∷
 Multi_key H greater greater greater : ⋙
 Multi_key H less less less : ⋘
 Multi_key H less minus less : ↢ U2919
 Multi_key H greater minus greater : ↣ U291A
 Multi_key H minus less less : U291B
 Multi_key H greater greater minus : U291C
 Multi_key H a l l : ∀
 Multi_key H e x : ∃
 Multi_key H a n d : ∧
 Multi_key H o r : ∨
 Multi_key H a b s t : λ
 Multi_key H c o m p : ∘
 Multi_key H minus greater : →
 8--
 
 But if you are under Windows, or Mac OS, I cannot tell (as well as I
 cannot tell if you are under a POSIX system not running xorg, such
 as the tty1..ttyn consoles)
 
 On OS X one can make ones owns key maps, like with the program on the
 link below, but it is very time consuming.

 http://scripts.sil.org/cms/scripts/page.php?site_id=nrsiid=ukelele
 
 I have heard of ukelele (but I didn't remembered the name as I am not
 a Mac OS user); I have heard it was a rather dirty solution, but that
 should work.

I think so, too.

 I guess that having a Haskell (or any script language by
 the way) patching the xml file (and able to unpatch if we want to
 uninstall) and make possible to get that patch via Hackage could be a
 solution (it would be time consuming for the patch writer, but then
 any Mac OS user would benefit it).
 
 Of course it would only work for the basic Haskell notations, for
 custom ones, I guess it would be interesting to have a program which
 reads a XCompose like file (which is quite easy to edit) and generate
 the xml file for ukelele.
 
 Note that the rest of the Haskell cafe mailing list won't be able to
 read my response since it seems that I cannot post on the list (I
 subscribed 2 years ago and never posted; waiting to learn and Haskell
 and then read the mailing list, but I learnt Haskell only about one
 month ago).

If one had a way to replace ASCII multicharacter symbols, that might be easier.

Hans



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-26 Thread Hans Aberg
On 26 Dec 2011, at 23:03, Brandon Allbery wrote:

  But if you are under Windows, or Mac OS, I cannot tell (as well as I
  cannot tell if you are under a POSIX system not running xorg, such as
  the tty1..ttyn consoles)
 
 On OS X one can make ones owns key maps, like with the program on the link 
 below, but it is very time consuming.
 
 System Preferences  Personal  Language  Text  Text  Use symbol and text 
 substitution

Cool. I have a vague memory of seeing it, but not paying much attention to it.

One can turn it on in Xcode 4.2 by Edit - Format - Substitutions - Show 
Substitutions and click Text Replacement or selecting it directly in the 
Substitutions menu. This popup windows allows one to apply it a text selection. 
(And similar in other programs, like Mail.)

For example, I set one entry so that typing x |- a becomes x ↦ a, the TeX 
\mapsto, in Unicode ↦ RIGHTWARDS ARROW FROM BAR U+21A6.

It might be tedious to make a lot of entries, though, but something to start 
with.

Hans



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-26 Thread Hans Aberg
On 27 Dec 2011, at 01:02, Donn Cave wrote:

 Quoth Hans Aberg,
 ...
 For example, I set one entry so that typing x |- a becomes x ↦ a, the
 TeX \mapsto, in Unicode ↦ RIGHTWARDS ARROW FROM BAR U+21A6.
 
 It might be tedious to make a lot of entries, though, but something to
 start with.
 
 Something to finish me with, too.  I wouldn't be able to do much
 in a programming world that used glyphs like that.

The symbol I chose is the one normally used in math. You can see it here:
  https://en.wikipedia.org/wiki/Function_(mathematics)

  My vision
 isn't perfect, but I think it's within a fairly normal range,
 and it isn't good enough to decode a lot of hieroglyphics at
 normal font size at reading speed.

Higher resolution displays might help, but larger ones are expected to come the 
next year.

 The ASCII limit of 100 or so normal characters may be a barrier
 to expression, but it's a boost to comprehension.


Common combinations tend to evolve in symbols. The ASCII combinations are just 
makeshift.

Hans



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-21 Thread Hans Aberg
On 21 Dec 2011, at 04:15, Brandon Allbery wrote:

 On Tue, Dec 20, 2011 at 21:05, Andrew Cowie and...@operationaldynamics.com 
 wrote:
 Now we just need λ to replace \, → to replace -, and ≠ to replace /=
 (which still looks like division assignment no matter how hard I squint
 my eyes. 25 years of C and C derived languages is hard to forget).
 Some of it is already supported.
 http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#unicode-syntax
 
 (≠ isn't in that list, but it doesn't need to be; just stick it in the 
 Prelude if it's not there already, since it's not special syntax, it's just 
 another operator.  The * *is* a special case, I suspect, though:  I bet it's 
 only supported in kinds, not as the multiplication operator.)

The one on the list is not a mathematical symbol. It should be ⋆ STAR OPERATOR 
U+22C6 or ∗ ASTERISK OPERATOR U+2217.

 The problem with λ is that it's a perfectly valid Unicode lowercase letter.  
 There is 훌
 MATHEMATICAL BOLD SMALL LAMDA U+1D6CC but font support is often lacking, and 
 it looks like Unicode categorizes *that* also as a lowercase letter.  If you 
 can convince the Unicode Consortium to add a lambda that is of class symbol, 
 Haskell can then make use of it — once there are fonts that support it.  

There is
  http://www.stixfonts.org/
For typesetting with Xe[La]TeX or Lua[La]TeX, use XITS (in the TeXLive package).

 (And then we'll have to deal with folks trying to use the letter, because 
 everyone knows the Roman alphabet is the only one that matters and of 
 *course* Greek letters are symbol characters  Pfeh.)

This is the big problem right now: how to enter these symbols efficiently.

Hans



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-21 Thread Hans Aberg
On 21 Dec 2011, at 04:27, Ashok Gautham wrote:

 On Tue, Dec 20, 2011 at 11:17:32PM +0100, Hans Aberg wrote:
 The monospace characters U+1D670-1D6A3 might be used for keywords. Font:
  http://www.stixfonts.org/
 
 I feel that monospace fonts should be used for all of programming. A
 language could use Unicode symbols, but if it enforces typography, it
 is destined to win an award for being really unusable

I have some books from the 1980s which does not use monospace; it seems to be a 
later movement. Using it for all symbols would be awkward.

Hans



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-21 Thread Hans Aberg
On 21 Dec 2011, at 11:03, Brandon Allbery wrote:

 On Wed, Dec 21, 2011 at 04:51, Hans Aberg haber...@telia.com wrote:
 The one on the list is not a mathematical symbol. It should be ⋆ STAR 
 OPERATOR U+22C6 or ∗ ASTERISK OPERATOR U+2217.
 
 ...except, at least in my current font, the former is microscopic and the 
 latter not a whole lot better. The advantage of the one they chose is it's 
 big and readable.  (That's part of why I assume it's intended for kinds, 
 actually.)

This problem is in my editor for unstyled text due to that if it a symbol is 
not available in the font selected, it just chooses a glyph from the next font 
available in alphabetical order.

Hopefully such problem will be resolved in the future.

Hans



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-21 Thread Hans Aberg
On 21 Dec 2011, at 11:09, Jesse Schalken wrote:

 IIRC, Scite's default configuration is with non-monospace font. I actually 
 found it quite appealing, and in fact forgot about it entirely after some 
 usage. It is much easier on the eyes to read. The difference is really 
 whether you care about aligning things mid-line or not, not to mention editor 
 support (i.e. not Vim or other terminal-based editor).

Right, ASCII code that relies on monospace for such midline alignments can be 
quite unreadable, but otherwise it has nothing really to contribute. 
Non-monospace might in fact be more readable, taking away the fact that it may 
take some time to get used to it, since monospace has been used so much.

For such alignments, one would either to write to code so it does not depend on 
it, or find some other means to do it.

Hans

 On Wed, Dec 21, 2011 at 8:58 PM, Hans Aberg haber...@telia.com wrote:
 On 21 Dec 2011, at 04:27, Ashok Gautham wrote:
 
  On Tue, Dec 20, 2011 at 11:17:32PM +0100, Hans Aberg wrote:
  The monospace characters U+1D670-1D6A3 might be used for keywords. Font:
   http://www.stixfonts.org/
 
  I feel that monospace fonts should be used for all of programming. A
  language could use Unicode symbols, but if it enforces typography, it
  is destined to win an award for being really unusable
 
 I have some books from the 1980s which does not use monospace; it seems to be 
 a later movement. Using it for all symbols would be awkward.
 
 Hans



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-21 Thread Hans Aberg
On 21 Dec 2011, at 11:22, Andrew Coppin wrote:

 On 21/12/2011 10:09 AM, Jesse Schalken wrote:
 IIRC, Scite's default configuration is with non-monospace font. I
 actually found it quite appealing, and in fact forgot about it entirely
 after some usage. It is much easier on the eyes to read. The difference
 is really whether you care about aligning things mid-line or not, not to
 mention editor support (i.e. not Vim or other terminal-based editor).
 
 SciTE's default binding /is/ proportional, not mono-space. I find it ever so 
 irritating. Then again, I'm sure this one comes squarely down to personal 
 preference, so it seems pointless to debate it.
 
 LaTeX offers the possibility of mid-line alignment even if you don't use 
 monospace - a feature which I haven't seen in any other text processing 
 system. It's a pitty this isn't more widespread...

Monospace isn't used in math (except in the days when one used typewriters), 
but alignments are of course used in matrices and multiline formulas, for 
example, which may correspond to uses in computer code.

A problem is that LaTeX is used for rendering typeset pages, and not really 
suitable for writing direct computer code, though Unicode characters can 
improve the readability of LaTeX source code. The link below shows an example.

Hans


http://www.charlietanksley.net/philtex/the-unicode-math-package-for-xelatex-and-the-stix-fonts/



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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-20 Thread Hans Aberg
On 20 Dec 2011, at 22:51, Chris Wong wrote:

 One thing that concerns me is the use of capital letters to distinguish type
 and class names and constructors from values.  If I was doing it over I
 would use a typographical distinction like italics for types, bold for
 classes.  That way we could have a constructor named ∅, a function named ∈,
 a class named ℝ.
 
 It's Algol all over again! Will we have to typeset our keywords in bold too?

There are in fact Unicode symbols for that, see
  http://unicode.org/charts/PDF/U1D400.pdf
The monospace characters U+1D670-1D6A3 might be used for keywords. Font:
  http://www.stixfonts.org/

Not hard to add.

Hans



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


Re: [Haskell-cafe] A Mascot

2011-11-16 Thread Hans Aberg
On 16 Nov 2011, at 05:18, John Meacham wrote:

 People tend to concentrate on the lambda which cooresponds to the
 functional aspect of haskell when designing logos. Not nearly enough
 attention is paid to the other striking feature, the laziness. The
 'bottom' symbol _|_ should feature prominently. The two most defining
 features of haskell are that it is purely functional and _|_ inhabits
 every type. The combination of which is very powerful.

The mascot already represents the lambda, so all that is needed is to show off 
its _|_.

Hans



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


Re: [Haskell-cafe] A Mascot

2011-11-16 Thread Hans Aberg
On 16 Nov 2011, at 23:49, heathmatlock wrote:

 I took Jerzy's suggestions into consideration and made the lamb skinnier, 
 maybe it looks less like a penguin now. 
 
 http://imgur.com/4oeJz

A formula that is Haskell specific is
  \x - ⊥ ≠ ⊥
It is mentioned in the Haskell 98 Report, sec. 6.2, Strict Evaluation, p. 82. 
The LHS and RHS are different, because they can be distinguished by seq.

Hans



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


Re: [Haskell-cafe] Lambda Calculus: Bound and Free formal definitions

2010-12-30 Thread Hans Aberg

On 30 Dec 2010, at 03:05, Mark Spezzano wrote:

... regarding formal definitions of FREE and BOUND variables he  
gives Defn 5.2 as


It is the occurrence of a variable that is free or bound. An  
occurrence of a variable is bound if it is in the scope of something  
that binds it; otherwise it is free.



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


[Haskell-cafe] Hugs Haskore loading

2010-08-21 Thread Hans Aberg
When trying to load Haskore in Hugs Sept 2006 (say by :l), it does not  
work because it is in a subdirectory Haskore/Src/, despite that the  
Hugs searchpath includes

  /usr/local/lib/hugs/packages/*

I could of course change this searchpath, but I'm curios about how to  
fix it without it - it seems to work for a lot of other packages.


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


Re: [Haskell-cafe] Hugs Haskore loading

2010-08-21 Thread Hans Aberg

On 21 Aug 2010, at 20:24, Henning Thielemann wrote:

When trying to load Haskore in Hugs Sept 2006 (say by :l), it does  
not work because it is in a subdirectory Haskore/Src/, despite that  
the Hugs searchpath includes

/usr/local/lib/hugs/packages/*

I could of course change this searchpath, but I'm curios about how  
to fix it without it - it seems to work for a lot of other packages.


Did you install Haskore with Cabal or is it a version of Haskore  
that is shipped with Hugs?


It is the version that comes with Hugs. It is the same as listed on http://haskell.org/haskore/ 
. What other version do you have in mind.



The -P option can be used to extend the search path.


Yes, but as said above, I wondered what was needed to fix the package.

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


Re: [Haskell-cafe] Hugs Haskore loading

2010-08-21 Thread Hans Aberg

On 21 Aug 2010, at 20:24, Henning Thielemann wrote:

When trying to load Haskore in Hugs Sept 2006 (say by :l), it does  
not work because it is in a subdirectory Haskore/Src/, despite that  
the Hugs searchpath includes

/usr/local/lib/hugs/packages/*

I could of course change this searchpath, but I'm curios about how  
to fix it without it - it seems to work for a lot of other packages.


Did you install Haskore with Cabal or is it a version of Haskore  
that is shipped with Hugs? The -P option can be used to extend the  
search path.


I think the problem is that Haskore is written for an older version of  
Hugs that just searches all subdirectories without extra requirements,  
but in the current version, a module Foo in Haskore/Src must be named  
Src.Foo.


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


Re: [Haskell-cafe] Hugs Haskore loading

2010-08-21 Thread Hans Aberg

On 21 Aug 2010, at 20:57, Henning Thielemann wrote:

Did you install Haskore with Cabal or is it a version of Haskore  
that is shipped with Hugs?


It is the version that comes with Hugs. It is the same as listed on http://haskell.org/haskore/ 
. What other version do you have in mind.


There is Paul Hudak's original version as Cabal package
 http://hackage.haskell.org/package/haskore-vintage


I just put the directory src/ in this package and replaced it with  
Haskore/ in the Hugs distribution, and then it loaded.



and one that I have messed
 http://hackage.haskell.org/package/haskore


What changes have you made? - perhaps the packages should be unified.

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


Re: [Haskell-cafe] Hugs Haskore loading

2010-08-21 Thread Hans Aberg

On 21 Aug 2010, at 20:57, Henning Thielemann wrote:

Did you install Haskore with Cabal or is it a version of Haskore  
that is shipped with Hugs?


It is the version that comes with Hugs. It is the same as listed on http://haskell.org/haskore/ 
. What other version do you have in mind.


There is Paul Hudak's original version as Cabal package
http://hackage.haskell.org/package/haskore-vintage and one that I  
have messed

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


I see now that the original Haskore page http://haskell.org/haskore/  
has been replaced without linking by http://www.haskell.org/haskellwiki/Haskore 
. So just make a forward link there, I think.


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


Re: [Haskell-cafe] Hugs Haskore loading

2010-08-21 Thread Hans Aberg

On 21 Aug 2010, at 21:51, Henning Thielemann wrote:


and one that I have messed
http://hackage.haskell.org/package/haskore


What changes have you made? - perhaps the packages should be unified.


I changed almost everything: Divided modules, designed a hierarchy  
for module names, generalized many functions and types. In  
retrospective I should have given it a distinct name.


If the basic functionality is the essentially the same, it is probably  
better to have a single, large package, where people can add their own  
stuff modularly, though it is good to have a license that admits  
independent cloning for those that so wish.


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


Re: [Haskell-cafe] ghc in macports

2010-08-12 Thread Hans Aberg


On 12 Aug 2010, at 12:49, Benedict Eastaugh wrote:


On 11 August 2010 15:49, Ozgur Akgun ozgurak...@gmail.com wrote:

Personally, I'd like to use the macports version, if the ghc  
version there
was resonably recent (having 2 versions, a stable and an edge could  
be a

good idea?)


You could use Homebrew instead. That has a fairly up-to-date version
of GHC and the Haskell Platform.

http://mxcl.github.com/homebrew/


On
  http://wiki.github.com/mxcl/homebrew/installation
it says:
  delete /usr/local/include and/usr/local/lib
So its not for those that also installs standard distributions, it  
seems.


But what's wrong with the binaries listed here:
  http://haskell.org/ghc/
Fairly easy to install.

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


Re: [Haskell-cafe] ghc in macports

2010-08-12 Thread Hans Aberg

On 12 Aug 2010, at 14:08, Ozgur Akgun wrote:


On
 http://wiki.github.com/mxcl/homebrew/installation
it says:
 delete /usr/local/include and/usr/local/lib
So its not for those that also installs standard distributions, it  
seems.


I thought this was just a recommendation.


It also says:
  We’ve had a *lot* of bug reports that are first inexplicable and  
later it turns out that it’s because the user has some of their own  
libs and headers in/usr/local.



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


Re: [Haskell-cafe] ghc in macports

2010-08-12 Thread Hans Aberg

On 12 Aug 2010, at 20:46, Gaius Hammond wrote:

its not for those that also installs standard distributions, it  
seems.


But what's wrong with the binaries listed here:
http://haskell.org/ghc/
Fairly easy to install.


Yes and no; on OSX 10.5.8 it works better to install GHC from the  
binary then build Platform yourself. On 10.6 it seems to be OK.


OK. I was only thinking on the compiler (as in the first post). When  
adding packages, it is trickier; I've only by hand. Then in some case  
MacPorts might be better if wanting to do a lot of package chasing -  
perhaps it was Gtk.


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


Re: [Haskell-cafe] lambdacats

2010-08-06 Thread Hans Aberg

On 6 Aug 2010, at 09:48, Andrew Coppin wrote:

Hello, does anyone happen to have the lambdacats page cached? The  
domain (arcanux.org http://arcanux.org) and server have  
disappeared and the wayback machine doesn't have the images.


Somebody else noticed, eh?

Good thing I grabbed most of the actually amusing images before it  
vanished. Still, that site was hardly ever updated anyway. And it's  
not like you need a special website just to stick broken English on  
pictures of cats...


Search by an actual image can be done at http://www.tineye.com/.  
This is useful if one wants to find an original, or see its original  
context.


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


Re: [Haskell-cafe] Suggestions For An Intro To Monads Talk.

2010-08-04 Thread Hans Aberg

On 3 Aug 2010, at 23:51, aditya siram wrote:

I am doing an Intro To Monads talk in September [1]. The audience  
consists of experienced non-Haskell developers but they will be  
familiar with basic functional concepts (closures, first-class  
functions etc.).


I am looking for suggestions on how to introduce the concept and its  
implications. I'd also like to include a section on why monads exist  
and why we don't really see them outside of Haskell.


Probably because one does not bother writing them out in the type  
system. I wrote on a C++ wrap for Guile, and they showed up when  
typing expressions, though C++ templates are too limited to make this  
efficiently.


The monad has a code lifting property. If one has code which has both  
non-monadic and monadic components, it can be lifted up to the monadic  
level without having iterates (can be taken away with the monad  
projection).


So if one has code which has both non-IO and IO components, it can be  
lifted to the becoming all IO. Since IO and other imperative  
structures are incompatible with the lazy evaluation default, the type  
system can be used to describe them using monads.


Then one can use syntactic sugar like do and = to make the code  
look like ordinary imperative code.


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


Re: [Haskell-cafe] Category Theory woes

2010-02-19 Thread Hans Aberg

On 19 Feb 2010, at 00:52, Richard O'Keefe wrote:


Turning to the Wikipedia article, we find
The word kangaroo derives from the Guugu Yimidhirr word gangurru,
referring to a grey kangaroo


Thanks, particularly for giving the name of the native language. Hope  
the Wikipedia article can be trusted. :-)



It's time this urban legend was forgotten.


Not at all, there are sites specializing in such
  http://www.snopes.com/
  http://www.snopes.com/inboxer/hoaxes/computer.asp

  Hans


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


Re: [Haskell-cafe] Category Theory woes

2010-02-19 Thread Hans Aberg

On 19 Feb 2010, at 00:05, Nick Rudnick wrote:
Mathematicians though stick to their own concepts and definitions  
individually. For example, I had conversations with one who calls  
monads triads, and then one has to cope with that.



Yes. But isn't it also an enrichment by some way?


Yes, one must be able to choose notation that fits with the notions.

A similar situation exists in the case of computer languages, having  
their own syntax.


  Hans


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


Re: [Haskell-cafe] Category Theory woes

2010-02-19 Thread Hans Aberg

On 19 Feb 2010, at 00:55, Daniel Fischer wrote:


I'd always assumed ring was generalised from Z[n].


As in cyclic group, arrange the numbers in a ring like on a  
clockface?
Maybe. As far as I know, the term ring (in the mathematical sense)  
first

appears in chapter 9 - Die Zahlringe des Körpers - of Hilbert's Die
Theorie der algebraischen Zahlkörper. Unfortunately, Hilbert gives  
no hint

why he chose that name (Dedekind, who coined the term Körper, called
these structures Ordnung [order]).


The Wikipedia article Ring says he used it for a specific one where  
the elements somehow cycled back.


  Hans


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


Re: [Haskell-cafe] Category Theory woes

2010-02-19 Thread Hans Aberg

On 19 Feb 2010, at 12:12, Daniel Fischer wrote:


...As far as I know, the term ring (in the mathematical sense)
first
appears in chapter 9 - Die Zahlringe des Körpers - of Hilbert's Die
Theorie der algebraischen Zahlkörper. Unfortunately, Hilbert gives
no hint
why he chose that name (Dedekind, who coined the term Körper,  
called

these structures Ordnung [order]).


The Wikipedia article Ring says he used it for a specific one where
the elements somehow cycled back.


Yes. And I deem a) the english wikipedia a more reliable source of
information [concerning things mathematical] than the german, b)  
Harvey
Cohn more trustworthy than either wikipedia. But a quick look at  
Hilbert's
paper didn't reveal the property Cohn mentioned (according to wp)  
and no

explanation of Hilbert why he chose the term. So I remain in doubt.


The term group was introduced Évariste Galois, though he meant what  
we call a cancellative monoid, but since they are finite, have inverses.


So perhaps Hilbert made play on that word: a group is a small number  
of people, a ring larger, like a gang.


  Hans


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


Re: [Haskell-cafe] Category Theory woes

2010-02-18 Thread Hans Aberg

On 18 Feb 2010, at 14:48, Nick Rudnick wrote:

* the definition of open/closed sets in topology with the boundary  
elements of a closed set to considerable extent regardable as facing  
to an «outside» (so that reversing these terms could even appear  
more intuitive, or «bordered» instead of closed and «unbordered»  
instead of open),


I take closed as coming from being closed under limit operations -  
the origin from analysis. A closure operation c is defined by the  
property c(c(x)) = c(x). If one takes c(X) = the set of limit points  
of X, then it is the smallest closed set under this operation. The  
closed sets X are those that satisfy c(X) = X. Naming the complements  
of the closed sets open might have been introduced as an opposite of  
closed.


  Hans


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


Re: [Haskell-cafe] Category Theory woes

2010-02-18 Thread Hans Aberg

On 18 Feb 2010, at 20:20, Daniel Fischer wrote:


+ definition backtracking: «A closure operation c is defined by the
property c(c(x)) = c(x).


Actually, that's incomplete, ...


That's right, it is just the idempotency relation.


...missing are
- c(x) contains x
- c(x) is minimal among the sets containing x with y = c(y).


It suffices*) with a lattice L with relation = (inclusion in the case  
of sets) satifying

  i. x = y implies c(x) = c(y)
 ii. x = c(x) for all x in L.
iii. c(c(x)) = x.

  Hans

*) The definition in a book on lattice theory by Balbes  Dwinger.


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


Re: [Haskell-cafe] Category Theory woes

2010-02-18 Thread Hans Aberg

On 18 Feb 2010, at 19:19, Nick Rudnick wrote:


agreed, but, in my eyes, you directly point to the problem:

* doesn't this just delegate the problem to the topic of limit  
operations, i.e., in how far is the term «closed» here more  
perspicuous?


* that's (for a very simple concept) the way that maths prescribes:
+ historical background: «I take closed as coming from being  
closed under limit operations - the origin from analysis.»
+ definition backtracking: «A closure operation c is defined by the  
property c(c(x)) = c(x). If one takes c(X) = the set of limit points  
of X, then it is the smallest closed set under this operation. The  
closed sets X are those that satisfy c(X) = X. Naming the  
complements of the closed sets open might have been introduced as an  
opposite of closed.»


418 bytes in my file system... how many in my brain...? Is it  
efficient, inevitable?


Yes, it is efficient conceptually. The idea of closed sets let to  
topology, and in combination with abstractions of differential  
geometry led to cohomology theory which needed category theory solving  
problems in number theory, used in a computer language called Haskell  
using a feature called Currying, named after a logician and  
mathematician, though only one person.


  Hans


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


Re: [Haskell-cafe] Category Theory woes

2010-02-18 Thread Hans Aberg

On 18 Feb 2010, at 22:06, Daniel Fischer wrote:


...missing are
- c(x) contains x
- c(x) is minimal among the sets containing x with y = c(y).


It suffices*) with a lattice L with relation = (inclusion in the  
case

of sets) satifying
  i. x = y implies c(x) = c(y)
 ii. x = c(x) for all x in L.
iii. c(c(x)) = x.


Typo, iii. c(c(x)) = c(x), of course.


Sure.


If we replace set by lattice element and contains by =, the
definitions are equivalent.


Right.


The one you quoted is better, though.


It is a powerful concept. I think of a function closure as what one  
gets when adding all an expression binds to, though I'm not sure that  
is why it is called a closure.


  Hans


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


Re: [Haskell-cafe] Category Theory woes

2010-02-18 Thread Hans Aberg

On 18 Feb 2010, at 23:02, Nick Rudnick wrote:

418 bytes in my file system... how many in my brain...? Is it  
efficient, inevitable?


Yes, it is efficient conceptually. The idea of closed sets let to  
topology, and in combination with abstractions of differential  
geometry led to cohomology theory which needed category theory  
solving problems in number theory, used in a computer language  
called Haskell using a feature called Currying, named after a  
logician and mathematician, though only one person.

It is SUCCESSFUL, NO MATTER... :-)

But I spoke about efficiency, in the Pareto sense (http://en.wikipedia.org/wiki/Pareto_efficiency 
)... Can we say that the way in which things are done now cannot be  
improved??


Hans, you were the most specific response to my actual intention --  
could I clear up the reference thing for you?


That seems to be an economic theory version of utilitarianism - the  
problem is that when dealing with concepts there may be no optimizing  
function to agree upon. There is an Occam's razor one may try to apply  
in the case of axiomatic systems, but one then finds it may be more  
practical with one that is not minimal.


As for the naming problem, it is more of a linguistic problem: the  
names were somehow handed by tradition, and it may be difficult to  
change them. For example, there is a rumor that kangaroo means I do  
not understand in a native language; assuming this to be true, it  
might be difficult to change it.


Mathematicians though stick to their own concepts and definitions  
individually. For example, I had conversations with one who calls  
monads triads, and then one has to cope with that.


  Hans


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


Re: [Haskell-cafe] multMM :: Matrix - Matrix - Matrix --multiplies two matrices question (Homework)

2010-02-03 Thread Hans Aberg


On 3 Feb 2010, at 07:38, 조광래 wrote:


hi i was trying to solve it but

All i got is
type Matrix=[[Double]]

multMM :: Matrix - Matrix - Matrix --multiplies two matrices
multMM m t =[[sum (zipWith (*) (head m)(a)) ] ]where  a = [head  
a | a-  t]



Main multMM [[2,1,-6],[1,-3,2]] [[1,0,-3],[0,4,20],[-2,1,1]]
[[14.0]]

from this i could get only the first multiplication 14that is  
by  2*1 + 1*0 + -6*-2 = 14


how can i make this go throw all rows and colums to get multiple of  
matrixs?


Perhaps you might try the beginners mailing list:
  http://haskell.org/haskellwiki/Mailing_lists
  http://haskell.org/mailman/listinfo/beginners
because here, people will just assume one wants effective solutions. :-)

Anyway, the page I mentioned before has a matrix multiplication:
  http://haskell.org/haskellwiki/Prelude_extensions
It uses the function transpose(), which is in the module Data.List.

I find looking into the modules of Hugs useful, on my computer they  
are in

  /usr/local/lib/hugs/packages
but those for GHC are also available online:
  http://www.haskell.org/ghc/docs/latest/html/libraries/

  Hans


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


Re: [Haskell-cafe] Very imperfect hash function

2010-02-02 Thread Hans Aberg

On 2 Feb 2010, at 03:05, Richard O'Keefe wrote:

A simple hash-function for strings is to simply exclusive-or the  
bytes and then reduce modulo a prime number,


Simply exclusive-oring the bytes will give you at most 256 distinct
results.  (For an ASCII source, 128 distinct results.)  After that,
there hardly seems to be any point in reduction modulo a prime.


Right - I just gave an example of how simple hash functions may be  
created. The original question deals with Int32s, not strings.


As already mentioned before, there are more advance libraries here
  http://en.wikipedia.org/wiki/Perfect_hash_function
but they are not written in Haskell. So you have to rewrite them or  
use the FFI.



This approach can't tell a CAT from an ACT or a DOG from a GOD, which
is another strike against it.  (It also can't tell a TITTLE from a  
TILE,

or a BOTTLE from a BOLE, for obvious reasons.)


The hash function just tries to produce random lookup values, which  
are used to flatten the average depth of the lookup table at the  
entries of the array. So there is a tradeoff between a fast hash  
function, and one that does a good job.


  Hans


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


Re: [Haskell-cafe] matrix question

2010-02-02 Thread Hans Aberg

On 2 Feb 2010, at 13:15, 조광래 wrote:


define functions

type Matrix=[[Double]]

multMM :: Matrix - Matrix - Matrix --multiplies two matrices
det :: Matrix - Double --computes the determinant of a matrix
inv :: Matrix - Matrix --inverts a matrix

i stuck on those problems

can any one help me out?


Plug in the word matrix on http://haskell.org/; then there comes  
up matches Prelude extensions which has that type. There is also a  
Numeric Prelude.


  Hans


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


Re: [Haskell-cafe] OT: Literature on translation of lambda calculus to combinators

2010-02-01 Thread Hans Aberg

On 28 Jan 2010, at 10:54, Dušan Kolář wrote:

 Could anyone provide a link to some paper/book (electronic version  
of both preferred, even if not free) that describes an algorithm of  
translation of untyped lambda calculus expression to a set of  
combinators? Preferably SKI or BCKW. I'm either feeding google with  
wrong question or there is no link available now...


Here is a paper that uses that standard arithmetic operators that  
Church defined:

  http://www.dcs.ed.ac.uk/home/pgh/amen.ps

  Hans


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


Re: [Haskell-cafe] Very imperfect hash function

2010-01-31 Thread Hans Aberg

On 31 Jan 2010, at 20:07, John Lato wrote:


Or are you suggesting an actual hash table?


The hash function folds the keys onto an interval. Since you have  
Int values

k, you might just use a mod k n function for that.


If it's the
latter, I'm not certain where the array fits into the picture.  I'm
pretty sure I'm missing something here.


There is a module Data.HashTable. The array is just to make lookup  
fast.

Like in:
 ST s (STArray s HashKey (Map Key Value))


I was misunderstanding your intention here.  This is an interesting
approach, but I would still try an IntMap first.


A simple hash-function for strings is to simply exclusive-or the bytes  
and then reduce modulo a prime number, which will be the table size.  
The average lookup time complexity is the one of the hash table. You  
can then compare with the IntMap, which may have time complexity O(4),  
the number of bytes in an Int32.


There might be a big difference in the constant factor, though: an  
array seems to be much faster. I first made multivariate polynomial  
division using lists, because it is easy to work with, and an example  
of some stuff built on top took tens of seconds to run in Hugs. When  
reworking it using STArray (mutable) and Array (immutable), it has no  
noticeable delay.


Though I am using Map and Set, too, the choice of container seems  
otherwise be dictated by what is most convenient to program.


  Hans


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


Re: [Haskell-cafe] Strange random choice algorithm

2010-01-30 Thread Hans Aberg

On 30 Jan 2010, at 20:59, michael rice wrote:

I'm not sure where I got this PICK function from, and don't  
understand why it's written as it is, so I wanted to test it for  
randomness. It seems random enough. But if I understand the  
algorithm correctly, instead of selecting one of the elements from  
the list, it eliminates all the elements but one and that's the  
value it returns. Seems like a roundabout way of doing it. Comments?


Below is a function draw() that shuffles an interval, and prints it out.

  Hans


import Random

getRandomIndex :: [a] - IO(Int)
getRandomIndex ls = getStdRandom(randomR(0, (length ls) - 1))

remove:: Int - [a] - [a]
remove 0 (x:xs)   = xs
remove n (x:xs) | n0 = x: remove (n-1) xs
remove _ (_:_)= error remove: negative argument
remove _ []   = error remove: too large argument

shuffle :: [a] - IO [a]
shuffle [] = return []
shuffle ls = do i - getRandomIndex ls
do l - shuffle (remove i ls)
   return ((ls !! i) : l)

draw ls = do k - shuffle ls
 putStr (show k)


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


Re: [Haskell-cafe] Very imperfect hash function

2010-01-29 Thread Hans Aberg

On 29 Jan 2010, at 12:52, John Lato wrote:


There are minimal perfect hash functions; there are some libraries
mentioned here, though they are not in Haskell code:
  http://en.wikipedia.org/wiki/Perfect_hash_function

This is suitable when you do a lot of lookups with few key updates.  
An

alternative might be Data.Map, where lookups have time complexity
O(log n), n = size of map.


The minimal perfect hash function looks like the real algorithmic
solution, but I would just use Data.IntMap for this.


That looks interesting too. Yet another idea: use arrays
  http://haskell.org/haskellwiki/Arrays
Then build a hash table, say just taking mod k n, and have values in  
some lookup map. If n  set of keys, average time complexity is O(1),  
and arrays should be very fast.


  Hans


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


Re: [Haskell-cafe] Very imperfect hash function

2010-01-29 Thread Hans Aberg

On 29 Jan 2010, at 15:57, John Lato wrote:


That looks interesting too. Yet another idea: use arrays
 http://haskell.org/haskellwiki/Arrays
Then build a hash table, say just taking mod k n, and have values  
in some
lookup map. If n  set of keys, average time complexity is O(1),  
and arrays

should be very fast.


I just want to be sure I understand this.  For this plan, you aren't
intending to use a perfect hash function at all, correct?


Yes, this is another idea. In a hash table, it is not important to  
have different indices, only that that table entries are as flat as  
possible.



Are you
basically just suggesting to stick everything in an array with the key
as an index?


You still need to fold the key values onto some interval.


Or are you suggesting an actual hash table?


The hash function folds the keys onto an interval. Since you have Int  
values k, you might just use a mod k n function for that.



If it's the
latter, I'm not certain where the array fits into the picture.  I'm
pretty sure I'm missing something here.


There is a module Data.HashTable. The array is just to make lookup  
fast. Like in:

  ST s (STArray s HashKey (Map Key Value))


In either case, I don't think this would be as good as what I thought
was your original suggestion, i.e. using a minimal perfect hash
function mphf that hashes keys to a value 0..v-1.  With v=number of
values, valArr = array of all values, then

lookup k = valArr ! mphf k


Right, but you may have to avoid implementing the perfect hash  
function by yourself, if it is only available in C. :-) There is a  
FFI, though.


  Hans


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


Re: [Haskell-cafe] Map unionWith generalization

2010-01-28 Thread Hans Aberg

On 28 Jan 2010, at 03:09, Twan van Laarhoven wrote:

For example, in Map String Integer (sparse representation of  
monomials) compute the minimum value of all associative pairs with  
the same key (the gcd); if only one key is present, the absent  
should be treated as having value 0. So

 unionWith min xs ys
will not work, because unionWith will always apply the identity to  
the remaining value when one key is missing, whereas it should be  
sent to 0.


If missing keys represent 0, then wouldn't this work?

   intersectionWith min xs ys


Yes, that works for the gcd function using min. Thank you - this  
function is used a lot, so it is good to have it simple.


For the general problem, one still needs a better interface. For (-),  
though missing keys represent 0, if the first is missing, the second  
should be negated. And if both are present, one should filter out keys  
with 0 value. Right now, this is a combination of negate, (+), and  
filter (/= 0).


  Hans


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


Re: [Haskell-cafe] Very imperfect hash function

2010-01-28 Thread Hans Aberg

On 28 Jan 2010, at 20:07, Steve Schafer wrote:

The data are currently in a large lookup table. To save space, I'd  
like

to convert that into a sort of hash function:

hash :: key - value

My question is this: Is there any kind of generic approach that can  
make

use of the knowledge about the internal redundancy of the keys to come
up with an efficient function?


There are minimal perfect hash functions; there are some libraries  
mentioned here, though they are not in Haskell code:

  http://en.wikipedia.org/wiki/Perfect_hash_function

This is suitable when you do a lot of lookups with few key updates. An  
alternative might be Data.Map, where lookups have time complexity  
O(log n), n = size of map.


  Hans


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


[Haskell-cafe] Map unionWith generalization

2010-01-27 Thread Hans Aberg
I need ideally some generalizations of unionWith and unionWithKey, for  
efficiency matters (i.e. avoiding conversions and traversing the maps  
more than once). I could use a modification of the code in Map.hs, but  
then the problem is that the module Map interface does not export the  
constructors of data Map. So suggestions are welcome.


For example, in Map String Integer (sparse representation of  
monomials) compute the minimum value of all associative pairs with the  
same key (the gcd); if only one key is present, the absent should be  
treated as having value 0. So

  unionWith min xs ys
will not work, because unionWith will always apply the identity to the  
remaining value when one key is missing, whereas it should be sent to 0.


So here, one would want:
  (a - c) - (b - c) - (a - b - c) - Map k a - Map k b - Map  
k c
where the two first functions are applied when the first or second key  
is missing.


  Hans


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


Re: [Haskell-cafe] Map unionWith generalization

2010-01-27 Thread Hans Aberg

On 27 Jan 2010, at 14:56, Jan-Willem Maessen wrote:


So here, one would want:
(a - c) - (b - c) - (a - b - c) - Map k a - Map k b - Map  
k c
where the two first functions are applied when the first or second  
key is missing.


Ah, the swiss army knife function on maps.  This particular  
formulation works well for the application you describe above, where  
you're completely traversing both maps.  The following really grubby  
variant can be used to implement asymptotically efficient variations  
of union, intersection, difference, etc., etc:


swissArmy ::
 (Map k a - Map k c) --- Used to process submaps unique to the  
left map
 (Map k b - Map k c) --- Used to process submaps unique to the  
right map

 (a - b - Maybe c) - -- Used to process a single common entry
 Map k a - Map k b - Map k c


I'm not sure why you want to throw in functions between maps in the  
two first arguments. Then there is no requirement that single keys are  
preserved.


But it is a good idea to have a Maybe so that one can remove keys on  
the fly.



Then your function appears to be:

-- helper
just2 :: (a - b - c) - a - b - Maybe c
just2 f a b = Just (f a b)

swissArmy (fmap (const 0)) (fmap (const 0)) (just2 gcd)

Here are unionWith and intersectionWith:

unionWith f = swissArmy id id (just2 f)
intersectionWith = swissArmy (const empty) (const empty) (just2 f)
differenceWith = swissArmy id (const empty) (\a b - Nothing)

When throwing together tree-like data structures, I often start by  
writing this function; it handles most of the bulk operations I  
might want to do as one-liners.  It's got a messy, ugly type  
signature, but it does everything you want as efficiently as you  
want.*


My guess is that is when you write things from scratch.

I wanted to add these function on top of the module Data.Map, but then  
that seems not to be possible, as the constructors are not exported. I  
could make a copy of this file, and then make my own variation.


  Hans


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


Re: [Haskell-cafe] Map unionWith generalization

2010-01-27 Thread Hans Aberg

On 27 Jan 2010, at 16:33, Jan-Willem Maessen wrote:

I'm not sure why you want to throw in functions between maps in the  
two first arguments. Then there is no requirement that single keys  
are preserved.


But it is a good idea to have a Maybe so that one can remove keys  
on the fly.


A good point.  Technically, one should delimit the scope of the  
first two arguments:


data KeyPreservingMapOperation k a b = AlwaysEmpty | Identity |  
MapMaybeWithKey (k - a - Maybe b)


perform :: KeyPreservingMapOperation a b - Map k a - Map k b
perform AlwaysEmpty = const empty
perform Identity = id
perform (MapMaybeWithKey f) = mapMaybeWithKey f


I'm thinking about
  (k - Maybe a - Maybe b - Maybe c) - Map k a - Map k b - Map k c
The first two Maybe's tell if the keys are present, the last if one  
wants it in the resulting map.


When throwing together tree-like data structures, I often start by  
writing this function; it handles most of the bulk operations I  
might want to do as one-liners.  It's got a messy, ugly type  
signature, but it does everything you want as efficiently as you  
want.*


My guess is that is when you write things from scratch.


Yes.  On the other hand, I've repeatedly run into the same problem  
you're describing: a api that doesn't give me an efficient way to  
perform an operation I know to be very simple.  If every map  
provided an operation like this one, then I can avoid writing my own  
library from scratch when I need it --- especially when from  
scratch means fork the code and add what I need.


So, library implementors: think hard about your swiss army knife  
combinators.  You end up with messy functions with gigantic  
signatures.  On the other hand, you can often add a couple of  
judicious INLINE annotations and remove tons of code from the rest  
of your library.  Then expose them, and mark them as the functions  
of last resort that they truly are.


One can transverse the product of keys. Then I'm thinking about
  (k1 - k2 - a - b - Maybe c - Maybe(k, c)) - Map k1 a - Map  
k2 b - Map k c
The first Maybe tells if the key is already present; the second if one  
wants it inserted.


The idea in both cases is to combine the modifying functions into one.  
This simplifies the interface.


  Hans


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


Re: [Haskell-cafe] Map unionWith generalization

2010-01-27 Thread Hans Aberg

On 27 Jan 2010, at 21:29, Jan-Willem Maessen wrote:


I'm thinking about
(k - Maybe a - Maybe b - Maybe c) - Map k a - Map k b - Map k c
The first two Maybe's tell if the keys are present, the last if one  
wants it in the resulting map.


That has the same behavior semantically, but it's no more efficient  
than performing a unionWith followed by a filter.


It would not be the complexity, but the constant factor, by not having  
to transverse it twice. I'm not sure how it works in a functional  
language, and the trees must be rebalanced, too.



For example, consider implementing:

xs `intersection` singleton k v

in this way.  With the function given, the complexity is necessarily  
O(size xs): we must traverse every key/value pair in xs.  By  
contrast, by aggregating the operations on keys that exist only in a  
single map, we can write functions like intersection with the  
desired complexity (which is O(log (size xs)) in this case).


That is a good point.


One can transverse the product of keys. Then I'm thinking about
(k1 - k2 - a - b - Maybe c - Maybe(k, c)) - Map k1 a - Map  
k2 b - Map k c
The first Maybe tells if the key is already present; the second if  
one wants it inserted.


Traversing cross products is a very different operation from zipping  
in the key space.  Again I wouldn't want to mistakenly substitute  
one for the other!


For the first one, think of sums of sparse matrices or polynomials,  
and the second, products.


But in this case I think you'll find that you're already well served  
by the functions that already exist---adding this function doesn't  
enable you to do anything more efficiently (at least in a big-O  
sense).


Yes, I can't implements (-) directly; it must be a combination of (+)  
and negate, and the 0 must be filtered out in an extra pass. And for  
gcd of monomials, it is now a combination of lcm, (*) and (/), instead  
of a single pass. Unfortunately, these operations are used a lot, so  
getting a smaller constant factor is important.


The idea in both cases is to combine the modifying functions into  
one. This simplifies the interface.


Understood, and with a sufficiently smart compiler we might analyze  
the behavior of the function and do the right thing with the single- 
function interface in both cases.  I have yet to encounter a  
compiler that is both smart and reliable on this count.  That is why  
I've found it necessary to expose these kinds of functions.


By your example above, there may be a conflict between a general,  
simple interface, and implementing things like intersections.


  Hans


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


Re: [Haskell-cafe] Parse error

2010-01-17 Thread Hans Aberg

On 17 Jan 2010, at 11:44, Andrew Coppin wrote:


Urg, but that's *ugly*. Is there no way I can reduce the amount of
indentation to something more reasonable?


main = do
 putStrLn Line 1
 putStrLn Line 2

 let xs = do
   x - [1..10]
   y - [1..10]
   return (x+y)

 print xs

That better?


It's an improvement. It's still not pretty, but I guess that's as  
good as it's going to get...


Maybe this is an instance of Haskell trying to tell me if you need  
to write a 20-line do-block in the middle of your function, you're  
doing it wrong.


Haskell starts the new indentation level where the following lexeme is  
(Haskell-98 Report, sec. 2.7). So to reduce indentation, one must  
start a new line (already mentioned in this thread). This works in Hugs:

main =
  do
  putStrLn Line 1
  putStrLn Line 2

  let
xs =
  do
  x - [1..10]
  y - [1..10]
  return (x+y)

  print xs

The xs on a new line looks a bit unusual, and it takes a bit more  
vertical space, but one gets nice indentation levels.


  Hans


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


Re: [Haskell-cafe] help with musical data structures

2009-11-15 Thread Hans Aberg

On 15 Nov 2009, at 12:55, Stephen Tetley wrote:


http://hackage.haskell.org/packages/archive/haskore/0.1/doc/html/Haskore-Basic-Pitch.html
 but maybe it is not what you need, since it distinguishes between  
C sharp

and D flat and so on.



The enharmonic doublings and existing Ord instance make Haskore's
PitchClass a tricky proposition for representing the Serialist's view
of pitch classes. An integer (or Z12) represent would be simpler.


A Z12 representation is really only suitable for serial music, which  
in effect uses 12 scale degrees per octave.



To get pitch names I would recover them with a post-processing step,
spelling pitches with respect to a scale (here a SpellingMap):


spell :: SpellingMap - Pitch - Pitch


The spell function returns the note in the scale (SpellingMap) if
present, otherwise it returns the original to be printed with an
accidental.

I have my own pitch representation, but a SpellingMap for Haskore  
would be



type SpellingMap = Data.Map PitchClass PitchClass


Scales here are functions that generate SpellingMaps rather than
objects themselves.
The modes and major and minor scales have easy generation as they are
someways rotational over the circle of fifths (I've have implemented a
useful algorithm for this but can't readily describe it[1]). Hijaz and
klezmer fans need to construct their spelling maps by hand.


The pitch and notation systems that Western music uses can be  
described as generated by a minor second m and major second M. Sharps  
and flats alter with the interval M - m. If departing from two  
independent intervals, like a perfect fifth and the octave, then m and  
M can be computed. - I have written some code for ChucK which does  
that and makes them playable on the (typing) keyboard in a two- 
dimensional layout.


The pitch system, which I call a diatonic pitch system, is then the  
set of combinations p m + q M, where p, q are integers (relative a  
tuning frequency). The sum d = p + q acts a scale degree of the pitch  
system. Sharps and flats do not alter this scale degree. Typical  
common 7 note scales have adjacent scale degrees. This is also true  
for scales like hijaz.


The note name can then be computed as follows:

First one needs (p, q) values representing the note names a b c d e f  
g having scale degrees 0, ..., 6, plus a value for the octave. If  
given an arbitrary combination (p, q), first reduce its octave, and  
then compute its scale degree; subtract the (p, q) value of the note  
name with the same scale degree. There results a note with p + q = 0,  
i.e., p = - q. If q  0, it is is the number of sharps, if p  0 it is  
the number of flats.


This method can be generalized. It is not necessary to have 7 notes  
per diapason, and the diapason need not
be the octave. By adding neutral seconds, one can describe more  
general pitch systems (one is enough for Arab, Persian and Turkish  
scales).


  Hans


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


Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Hans Aberg

On 15 Jul 2009, at 12:25, Eugene Kirpichov wrote:


If ++ could be pattern matched, what should have been the result of
let (x++y)=[1,2,3] in (x,y)?


It will branch. In terms of unification, you get a list of  
substitutions.


  Hans


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


Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Hans Aberg

On 15 Jul 2009, at 13:22, Luke Palmer wrote:


If ++ could be pattern matched, what should have been the result of
let (x++y)=[1,2,3] in (x,y)?

It will branch. In terms of unification, you get a list of  
substitutions.


f :: [a] - ([a],[a])
f (x ++ y) = (x,y)


For an argument s, any pair (x, y) satisfying s = x ++ y will match.  
That is, if s = [s_1, ..., s_k], the solutions j = 0, ..., k, x =  
[s_1, ..., s_j], y = [s_(j+1), ..., s_k]. And for each one, a  
potentially different value could given. That is, s could produce  
multiple values.


If this pattern branches, it could hardly be considered a function  
which takes lists and returns pairs.  It would have to return  
something else.



So this would be a multi-valued function, which sometime is useful as  
a concept. But if the choices are indexed, they can be reduced to a  
single valued function. Like g(x,y) with the requirement that if x ++  
y = x' ++ y', then g(x, y) = g(x', y').


This branching is what would happen if one tries to make a type theory  
based on sets. (It is possible to implement Horn clauses as  
unification branching.) The selection of branches correspond to a  
choice in the proof tree.


  Hans


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


Re: [Haskell-cafe] gcd

2009-05-03 Thread Hans Aberg

On 2 May 2009, at 04:05, Steve wrote:


Why is gcd 0 0 undefined?


In math, one may define gcd(x, y) as a generator of the ideal  
generated by x and y in the ring of integers Z. The gcd(x, y) then  
always exists as the ring Z is a PID (principal ideal domain), i.e.,  
all ideals can be generated by a single element, which can be proven  
using Euclid's algorithm, also useful for computing the gcd in Z.


Anyway, the ideal generated by 0 and 0 is the zero ideal 0, which also  
is generated by the single generator 0. So gcd(0, 0) = 0 by this  
definition.


In Z, one may take the gcd = 0, but that may not work in every PID.  
If k is a field, then the polynomial ring k[x] is a PID, but not the  
ring k[x_1, ..., x_n]. So that leads to Buchberger's Groebner Basis  
Algorithm.


  Hans


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


Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?

2009-03-22 Thread Hans Aberg

On 22 Mar 2009, at 10:28, Colin Adams wrote:


OK, I got it installed, but build warned me of duplicate dylibs, and
running my program gave a bus error.

So I port uninstalled gtk2, so now it compiled without warnings, but
the program won't run because I had been forced to uninstall pangoft
to uninstall gtk2.

So now I need to uninstall the gtk framework - how do I do that?

Then i can re-install the macports version and have a working system  
again.


You might move it out of the way:
  sudo mv /opt /opt1
and then move it back. To get rid of ports altogether,
  sudo rm -rf /opt
(But be careful so you type right when removing as root, as errors can  
screw up the whole installation.)


I looked up my records - I compiled gtk2hs, and as was remarked, the  
one in MacPorts (but not gtk2 alone) insists on installing its own  
GHC. When taking down the sources (external to MacPorts) of gtk2hs,  
the .tgz ones worked, but the sources from the archive caused some  
problems with autoconf - despite intense discussions also on the  
gtk2hs list, this problem was left unresolved.


The libraries might cause problems when compiling, because even if a  
libpath is included in the compile, if there are system ones  
available, then may be used - a GCC quirk. So in such cases, one might  
have to edit the libpath so that the system libraries are not at all  
there, moving selected one out of the way, using libtools or  
something. This is very technical, though.


  Hans Aberg


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


Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?

2009-03-22 Thread Hans Aberg

On 22 Mar 2009, at 11:32, Colin Adams wrote:


creating build/temp.macosx-10.3-i386-2.5
-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include
-I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ 
include/python2.5

-c _hashopenssl.c -o build/temp.macosx-10.3-i386-2.5/_hashopenssl.o
unable to execute -DNDEBUG: No such file or directory
error: command '-DNDEBUG' failed with exit status 1


A search on the Apple site says it is a compile option used to remove  
assert():

http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/assert.3.html

The first line mentions macosx-10.3 - do you have a compiler for an  
old system, or something?


And I have a fairly recent python:
$ python --version
Python 2.5.1
$ which python
/usr/bin/python

Make sure to sign up (for free) as a developer at developer.apple.com  
and take down latest Xcode (mine is Version 3.1.2, though I do not  
know if it is the absolutely latest).


  Hans Aberg


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


Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?

2009-03-22 Thread Hans Aberg

On 22 Mar 2009, at 12:45, Colin Adams wrote:


No. It's all recent.


And MacPorts installs its own gcc. Achim Scheider pointed out that the  
compiler name is missing, so the shell tries to execute '-DNDEBUG' as  
a program. When I try it, I get:

$ sudo port install python_select
Password:
---  Fetching python_select
---  Attempting to fetch select-0.2.1.tar.gz from 
http://arn.se.distfiles.macports.org/python_select
---  Verifying checksum(s) for python_select
---  Extracting python_select
---  Configuring python_select
---  Building python_select
---  Staging python_select into destroot
---  Installing python_select @0.2.1_0+darwin_9
---  Activating python_select @0.2.1_0+darwin_9
---  Cleaning python_select

$ sudo python_select python25
Selecting version python25 for python

Which perhaps only means that I already have it installed.

But I also get this:
$ which python
/opt/local/bin/python

$ python --version
Python 2.5.1

$ /usr/bin/python --version
Python 2.5.1

The version you tried to install is 2.5.2 - perhaps there is a script  
problem, then.


  Hans


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


Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?

2009-03-22 Thread Hans Aberg

On 22 Mar 2009, at 11:32, Colin Adams wrote:


I tried issuing the sudo port install command on the wiki page.


What did you try to install? ...


After some time running it failed with:

To fully complete your installation and make python 2.5 the default,  
please run


   sudo port install python_select
   sudo python_select python25


...The thing is that when I removed python_select and python, there  
remains a

  $ /opt/local/bin/python --version
  Python 2.5.1
So your package somehow needs 2.5.2, which may be the culprit.

  Hans


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


Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?

2009-03-22 Thread Hans Aberg

On 22 Mar 2009, at 13:42, Colin Adams wrote:


After some time running it failed with:

To fully complete your installation and make python 2.5 the default,
please run

  sudo port install python_select
  sudo python_select python25


...The thing is that when I removed python_select and python, there  
remains

a
 $ /opt/local/bin/python --version
 Python 2.5.1
So your package somehow needs 2.5.2, which may be the culprit.


Which package? None of them are mine.


One of the packages you tried to install asked for this, in this list:


Just what it says on the wiki page:

sudo port install glade3 libglade2 gstreamer gst-plugins-base
gtksourceview cairo librsvg gtkglext firefox


Looking into your post:

---  Cleaning python25
---  Fetching py25-hashlib
---  Attempting to fetch Python-2.5.2.tar.bz2 from
http://www.python.org/ftp/python/2.5.2/
---  Verifying checksum(s) for py25-hashlib
---  Extracting py25-hashlib
---  Configuring py25-hashlib
---  Building py25-hashlib with target build
Error: Target org.macports.build returned: shell command  cd

it is py25-hashlib that is the culprit.

I was able to install it. Then I got a later Python:

---  Attempting to fetch Python-2.5.4.tar.bz2 from 
http://arn.se.distfiles.macports.org/python25


The procedure followed was (do a 'sudo -s' so save writing:

First uninstall python25 and dependencies:
# port uninstall python25
---  Unable to uninstall python25 2.5.2_5+darwin_8, the following  
ports depend on it:

--- py25-gobject
--- py25-numeric
--- gstreamer

# port uninstall gstrea...@0.10.19_0
---  Deactivating gstreamer @0.10.19_0
---  Uninstalling gstreamer @0.10.19_0

# port uninstall gstrea...@0.10.8_0
---  Uninstalling gstreamer @0.10.8_0

# port uninstall py25-gobject
---  Deactivating py25-gobject @2.14.2_0
---  Uninstalling py25-gobject @2.14.2_0

# port uninstall py25-numeric
---  Deactivating py25-numeric @24.2_1+macosx
---  Uninstalling py25-numeric @24.2_1+macosx

# sudo port uninstall python25

Then I noticed there was an unregistered python - those seems to  
confuse MacPorts. OS move it:

# cd /opt/local/bin/
# mv python python1

Then I installed python_select and python25:

# port install python_select
---  Fetching python_select
---  Verifying checksum(s) for python_select
---  Extracting python_select
---  Configuring python_select
---  Building python_select
---  Staging python_select into destroot
---  Installing python_select @0.2.1_0+darwin_9
---  Activating python_select @0.2.1_0+darwin_9
---  Cleaning python_select
bash-3.2# port install python25
---  Fetching python25
---  Attempting to fetch Python-2.5.4.tar.bz2 from 
http://arn.se.distfiles.macports.org/python25
---  Verifying checksum(s) for python25
---  Extracting python25
---  Applying patches to python25
---  Configuring python25
---  Building python25
---  Staging python25 into destroot
---  Installing python25 @2.5.4_0+darwin_9+macosx
---  Activating python25 @2.5.4_0+darwin_9+macosx

To fully complete your installation and make python 2.5 the default,  
please run


sudo port install python_select
sudo python_select python25

---  Cleaning python25

After that follow the instructions:

# sudo port install python_select
Skipping org.macports.activate (python_select +darwin_9) since this  
port is already active

---  Cleaning python_select

# sudo python_select python25
Selecting version python25 for python

And finally to py25-hashlib:

# port install py25-hashlib
Portfile changed since last build; discarding previous state.
---  Fetching openssl
---  Attempting to fetch openssl-0.9.8j.tar.gz from 
http://arn.se.distfiles.macports.org/openssl
---  Verifying checksum(s) for openssl
---  Extracting openssl
---  Applying patches to openssl
---  Configuring openssl
---  Building openssl
---  Staging openssl into destroot
---  Installing openssl @0.9.8j_0
---  Activating openssl @0.9.8j_0
Error: Target org.macports.activate returned: Image error: /opt/local/ 
share/man/man3/bn_print.3.gz already exists and does not belong to a  
registered port.  Unable to activate port openssl.

Error: The following dependencies failed to build: openssl
Error: Status 1 encountered during processing.

So here I just remove the unregistered file:
# rm /opt/local/share/man/man3/bn_print.3.gz
# port activate openssl @0.9.8j_0
---  Activating openssl @0.9.8j_0

So now it worked. Try py25-hashlib again:
# port install py25-hashlib
---  Fetching py25-hashlib
---  Verifying checksum(s) for py25-hashlib
---  Extracting py25-hashlib
---  Configuring py25-hashlib
---  Building py25-hashlib
---  Staging py25-hashlib into destroot
---  Installing py25-hashlib @2.5.4_0
---  Activating py25-hashlib @2.5.4_0
---  Cleaning py25-hashlib

So now I git t installed. - I got beyond the point where you got stuck.

  Hans


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Ease of Haskell development on OS X?

2009-03-21 Thread Hans Aberg

On 21 Mar 2009, at 01:10, Brandon S. Allbery KF8NH wrote:


On 2009 Mar 20, at 17:02, Hans Aberg wrote:
Therefore, as mentioned before, it might be best to install the GHC  
binaries and install libraries like Gtk+ from MacPorts. There is  
also Intel Gtk+ that binds directly to Aqua, the


This won;t work as you expect:  since there's a dependency on ghc,  
the ports version of ghc will be installed.  (No, it doesn't behave  
like BSD ports, and can't:  breaking base, which is outside of  
their control, could have severe consequences, so it doesn't simply  
accept installed versions of programs.)



I'm not sure what you are saying here: installing MacPorts Gtk does  
not cause its GHC to be installed, nor does it bind to it.


The way it works with Gnat, is that there is a GtkAda package which  
binds to Gtk, and the paths of this package must be set to whatever  
Gtk one is using. Using an external Gnat binding to MacPorts Gtk works  
just fine. As for the Intel Gtk package that binds to to Aqua, it is  
integrated with the Xcode GCC. So one must do some extra tweaking there.


  Hans Aberg


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


Re: [Haskell-cafe] Ease of Haskell development on OS X?

2009-03-20 Thread Hans Aberg

On 20 Mar 2009, at 21:05, David Leimbach wrote:


 Since GHC is written in Haskell, do you need to have another Haskell
 compiler installed before GHC 6.10.1 can be installed through  
MacPorts?


It bootstraps itself.

???  GHC does or MacPorts does.  My experience was that you needed  
GHC to build GHC :-)


MacPort developers tweak sources into packages which can install by  
themselves. So one just types

  sudo port install ghc
and it does the rest. Here is info about ghc:

$ port info ghc
ghc 6.8.3, Revision 1, lang/ghc (Variants: universal, darwin_6,  
darwin_7, darwin_8_powerpc, darwin_8_i386, darwin_9_powerpc,  
darwin_9_i386, no_opengl)

http://haskell.org/

The Glasgow Haskell Compiler is a robust, fully-featured, optimising  
compiler and interactive environment for Haskell 98, GHC compiles  
Haskell to either native code or C. It implements numerous  
experimental language extensions to Haskell 98, for example:  
concurrency, a foreign language interface, multi-parameter type  
classes, scoped type variables, existential and universal  
quantification, unboxed types, exceptions, weak pointers, and so on.  
GHC comes with a generational garbage collector, and a space and  
time profiler.


Library Dependencies: readline, gmp
Runtime Dependencies: perl5.8
Platforms: darwin
Maintainers: gwri...@macports.org


However, as someone needs to do the packaging, the versions tend to be  
older than from direct sources. So the latter is to be preferred, but  
the package manager does the package chasing for you (which is a  
problem with Gtk+ installed directly).


Therefore, as mentioned before, it might be best to install the GHC  
binaries and install libraries like Gtk+ from MacPorts. There is also  
Intel Gtk+ that binds directly to Aqua, the Mac OS X native GUI (for  
making native Mac OS X Applications):

  http://www.gtk-osx.org/

You need to set of environmental variables UNIX style, but there is a  
Mac OS X way, too (see below). In the traditional way, one must be  
aware of that the shell 'bash' (see 'man bash') reads different  
startup files when called as a login shell (as from the Terminal) and  
non-login-shell (as from X11 and xterm). For the former, one can put  
the stuff in .profile, and the latter .bashrc. To make things simple,  
one can put in .bashrc:

  source ~/.profile
thus reading .profile. In .profile, one might put something like the  
stuff at the bottom of this letter (which also adds support for the  
other package manager, as well admitting user binaries to be installed).


There is another, Mac OS X specific way (also see below): go to  
Terminal, and make a directory:

  cd
  mkdir .MacOSX
  cd .MacOSX
  touch environment.plist
  open -a Xcode environment.plist
The last command opens the file into the Xcode editor, which has a  
facility to create the special format for these files. Pne drawback of  
this method is the one has to log out and login again to set them.


This assumes you have installed Xcode, wither from the installation  
disk, or by signing up as a developer at http://developer.apple.com/


When working with files, it is convenient to set them so that they  
open in your favorite program. For that, I have found it convenient to  
install a System Preferences panel 'Default Apps' found at

  http://www.rubicode.com/Software/
I see now they have one for editing the environment.plist file.

If you come from a non-UNIX (POSIX) platform, then note that in order  
to work as root, it is most of the time sufficient to use (from an  
administrator account)

  sudo -s
The 'root' account is by default disabled (can be started from the  
Directory Utility). Also never edit in /usr/ outside /usr/local/, the  
other system directories, or /System/ as they belong to the system  
installation (Mac OS X user modified system files are out into / 
Library/, but often via some other program which does safety checks.)


  Hans Aberg



# Add to end of searchpath:
append_path()
{
  if ! eval test -z \\${$1##*:$2:*}\ -o -z \\${$1%%*:$2}\ -o - 
z \\${$1##$2:*}\ -o -z \\${$1##$2}\ ; then

eval $1=\$$1:$2
  fi
}

# Add to beginning of searchpath:
prepend_path()
{
  if ! eval test -z \\${$1##*:$2:*}\ -o -z \\${$1%%*:$2}\ -o - 
z \\${$1##$2:*}\ -o -z \\${$1##$2}\ ; then

eval $1=$2:\$$1
  fi
}

# Set system searchpaths:

# In the case a directory may exist (depending on the program) both  
with and without
# parent directory 'share/' (like in the cae of MANPATH and INFOPATH),  
the 'share/'
# version is put first, as it is what is used in /usr on Mac OS X  
FreeSD UNIX.
# The idea is that if a program is somehow adapted to this platform,  
the the stuff will
# be moved to the 'share/' variation, and should thus be ovverride the  
unadapted versions.


PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin
MANPATH=/usr/share/man:/usr/X11R6/man
INFOPATH=/usr/share/info
LIBPATH=/usr/lib:/usr/X11R6/lib

# Prepend Fink searchpaths:
test -r /sw/bin/init.sh  . /sw/bin/init.sh

Re: [Haskell-cafe] Ease of Haskell development on OS X?

2009-03-20 Thread Hans Aberg

On 20 Mar 2009, at 22:44, Miguel Mitrofanov wrote:


Here is info about ghc:

$ port info ghc
ghc 6.8.3, Revision 1, lang/ghc (Variants: universal, darwin_6,  
darwin_7, darwin_8_powerpc, darwin_8_i386, darwin_9_powerpc,  
darwin_9_i386, no_opengl)

http://haskell.org/


A bit out of date:

MigMit:~ MigMit$ port info ghc
ghc @6.10.1, Revision 8 (lang, haskell)
...blah-blah...

Maybe, your $(port version)


You mean 'port version' (or 'echo $(port version)') :-).


is still 1.600?


That is right. One should from time-to-time run
  sudo port -d selfupdate
I do not have the ports version of GHC installed. So the version of  
'port' itself may affect the info about packages, too, it seems.


In addition, one may have to download a new copy from the site. This  
happened when I made a new system installation (though restore from  
the Time Machine backup worked fine).


Also, updating may break some code - libraries are dynamically linked.  
I used this for a compile of Scala (in Ada) which links to the  
MacPorts Gtk+ libraries. And now you tricked me to update - let's see  
if it breaks.


  Hans


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


Re: [Haskell-cafe] Ease of Haskell development on OS X?

2009-03-20 Thread Hans Aberg

On 20 Mar 2009, at 22:44, Miguel Mitrofanov wrote:


A bit out of date:

MigMit:~ MigMit$ port info ghc
ghc @6.10.1, Revision 8 (lang, haskell)
...blah-blah...

Maybe, your $(port version) is still 1.600?


Yes, now it worked:
$ port version
Version: 1.700

$ port info ghc
ghc @6.10.1, Revision 9 (lang, haskell)
Variants:darwin_6, darwin_7, darwin_8_i386, darwin_8_powerpc,  
darwin_9_i386, darwin_9_powerpc

...

One more thing to keep in is this line Variants:...:

Packages can have variants, and when installing, one can choose  
between them, and even have several different installed  
simultaneously, switching between them. This may make a difference on  
a package like Gtk+. I get:

  gtk2 @2.14.7, Revision 1 (x11)
  Variants:darwin_7, darwin_8, no_x11, quartz, universal, x11
  ...
So when installing it, one should type
  sudo install gtk2

Also, MacPorts is very careful using full paths to its own components.  
This makes a very safe build. But it is a problem for libraries if one  
wants to redistribute them: They are hardcoded to the MacPorts  
location in /opt/ (calling each other). If one wants to make programs  
that can be distributed either in /usr/local/ or as Mac OS X native / 
Applications/, then the only way seems to be to do all the package  
chasing.


Therefore, it might be best trying to use
  http://www.gtk-osx.org/
But it will then only work on Intel Macs (or at least when I checked  
it out).


  Hans


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


Re: [Haskell-cafe] Re: Theory about uncurried functions

2009-03-05 Thread Hans Aberg

On 5 Mar 2009, at 13:29, Daniel Fischer wrote:

In standard NBG set theory, it is easy to prove that card(P(N)) ==  
card(R).


No, it is an axiom: Cohen showed in 1963 (mentioned in Mendelson,  
Introduction to Mathematical Logic) that the continuum hypothesis  
(CH) is independent of NBG+(AC)+(Axiom of Restriction), where AC is  
the axiom of choice. Thus you can assume CH or its negation (which is  
intuitively somewhat strange). AC is independent of NGB, so you can  
assume it or its negation (also intuitively strange), though GHC  
(generalized CH, for any cardinality) + NBG implies AC (result by  
Sierpinski 1947 and Specker 1954). GHC says that for any set x, there  
are no cardinalities between card x and card 2^x (the power-set  
cardinality). Since card ω  card R by Cantors diagonal method, and  
card R = card 2^ω since R can be constructed out of binary sequences  
(and since the interval [0, 1] and R can be shown having the same  
cardinalities), GHC implies card R = card 2^ω. (Here, ω is a lower  
case omega, denoting the first infinite ordinal.)


  Hans Aberg


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


Re: [Haskell-cafe] Re: Theory about uncurried functions

2009-03-05 Thread Hans Aberg

On 5 Mar 2009, at 15:12, Daniel Fischer wrote:


No, it is an axiom: Cohen showed in 1963 (mentioned in Mendelson,
Introduction to Mathematical Logic) that the continuum hypothesis
(CH) is independent of NBG+(AC)+(Axiom of Restriction), where AC is
the axiom of choice.


Yes, but the continuum hypothesis is 2^Aleph_0 == Aleph_1, which is  
quite

something different from 2^Aleph_0 == card(R).


Yes, right, card R = 2^Aleph_0, as you said, and Aleph_1 is defined as  
the smallest cardinal greater than Aleph_0.


  Hans Aberg


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


Re: [Haskell-cafe] Re: Theory about uncurried functions

2009-03-05 Thread Hans Aberg

On 5 Mar 2009, at 15:23, Daniel Fischer wrote:


Just to flesh this up a bit:

let f : P(N) - R be given by f(M) = sum [2*3^(-k) | k - M ]
f is easily seen to be injective.

define g : (0,1) - P(N) by
let x = sum [a_k*2^(-k) | k in N (\{0}), a_k in {0,1}, infinitely  
many a_k =

1]
and then g(x) = {k | a_k = 1}

again clearly g is an injection.
Now the Cantor-Bernstein theorem asserts there is a bijection  
between the two

sets.


I think one just defines an equivalence relation of elements mapped to  
each other by a finite number of iterations of f o g and g o f. The  
equivalence classes are then at most countable. So one can set up a  
bijection on each equivalence class: easy for at most countable sets.  
Then paste it together. The axiom of choice probably implicit here.


  Hans Aberg


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


Re: [Haskell-cafe] Re: Theory about uncurried functions

2009-03-05 Thread Hans Aberg

On 5 Mar 2009, at 17:06, Daniel Fischer wrote:

Cantor-Bernstein doesn't require choice (may be different for  
intuitionists).

http://en.wikipedia.org/wiki/Cantor-Bernstein_theorem


Yes, that is right, Mendelson says that. - I find it hard to figure  
out when it is used, as it is so intuitive.


Mendelson says AC is in fact equivalent proving
  all x, y: card x = card y or card y = card x

  Hans Aberg


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


Re: [Haskell-cafe] Theory about uncurried functions

2009-03-03 Thread Hans Aberg

On 3 Mar 2009, at 10:43, Peter Verswyvelen wrote:


Lambda calculus is a nice theory in which every function always has
one input and one output. Functions with multiple arguments can be
simulated because functions are first class and hence a function can
return a function. Multiple outputs cannot be done, one must embed
these outputs in some data type, e.g. using a tuple, or one must use
continuation passing style.

Now, does a similar theory exist of functions that always have one
input and one output, but these inputs and outputs are *always*
tuples? Or maybe this does not make any sense?


I think most of the replies have already described it, but the  
Church's lambda-calculus is just a minimal theory describing a way to  
construct functions, which turns out to be quite general, including  
all algorithms. The first lambda-calculus he describes in his book  
does not even include the constant functions - for some reason it is  
convenient.


So if you want to have more, just add it. That is why functional  
computer languages like Haskell can exist.


As for currying, it builds on the fact that in the category of sets  
(but others may not have it) one has a natural equivalence (arguments  
can also be functions)

  psi: Hom(A x B, C) -- Hom(A, Hom(B, C))
 f   |- (a |- (b |- f(a, b)))
((a, b) |- g(a)(b)) -|  g
So it simply means that set-theoretic products can be rewritten into  
iterated functions. (Strictly speaking, currying involves a choice of  
natural equivalence psi.)


In axiomatic set theory, it is common to construct tuplets (i.e., set- 
theoretic products) so that (x) = x, (x_1, ..., x_n) = ((x_1, ...,  
x_(n-1), x_n), and one might set () to the empty set (so that, for  
example, the real R^0 has only one point). The recursive formula has  
slipped into functional languages. Pure math, unless there are special  
requirements, uses naive set theory in which that recursion formula  
would not be used: in computer lingo, it corresponds to the  
implementation (axiomatic set theory), and is not part of the  
interface (naive set theory).


By contrast, in lists, [x] is not the same as x. (If S is a set, the  
set of lists with elements from S is the free monoid on S.)


But you might view f() as passing the object () to f, f(x) passes x to  
f, and f(x_1, ..., x_n) passes (x_1, ..., x_n) to f.


So the only addition needed is to add the objects (x_1, ..., x_n), n =  
0, 1, 2, ..., to your language. You can still curry the functions if  
you like to - a convention, just as already noted.


  Hans Aberg


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


Re: [Haskell-cafe] Origins of '$'

2008-12-09 Thread Hans Aberg

On 8 Dec 2008, at 23:15, Joachim Breitner wrote:


Am Montag, den 08.12.2008, 15:59 -0600 schrieb Nathan Bloomfield:


Slightly off topic, but the A^B notation for hom-sets also makes the
natural isomorphism we call currying expressable as A^(BxC) = (A^B) 
^C.


So A^(B+C) = A^B × A^C ?

Oh, right, I guess that’s actually true:...


I posted some of those relations for lambda-calculus two days ago  
(this thread).


It is so very off-topic, because one can reverse the process, take  
those operators and some relations, and show it contains the lambda- 
calculus (or so I remember, don't recall details). Then one problem  
is that these operators are not so intuitive for all practical purposes.


  Hans


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


Re: [Haskell-cafe] Origins of '$'

2008-12-07 Thread Hans Aberg

On 7 Dec 2008, at 11:34, Luke Palmer wrote:


On Sun, Dec 7, 2008 at 3:05 AM, Hans Aberg [EMAIL PROTECTED] wrote:
One can define operators
 a ^ b := b(a)  -- Application in inverse.
 (a * b)(x) := b(a(x))  -- Function composition in inverse.
 (a + b)(x) := a(x) * b(x)
 O(x) := I  -- Constant function returning identity.
 I(x) := x  -- Identity.
and use them to define lambda calculus (suffices with the first  
four; Church reverses the order of *).


The simple elegance of writing this encoding just increased my  
already infinite love of Haskell by another cardinality.


a .^ b = b a
(a .* b) x = b (a x)
(a .+ b) x = a x .* b x
o x = i
i x = x

toNat x = x (+1) 0
fromNat n = foldr (.) id . replicate n


I have some more notes on this that you might translate, if possible  
(see below).


If one implements integers this way, time complexity of the operators  
will be of high order, but it is in fact due to representing n in  
effect as 1+...+1. If one represents them, using these operators, in  
a positional notation system, that should be fixed, though there is a  
lot of other overhead.


  Hans


Associativity: a*(b*c) = (a*b)*c, a+(b+c) = (a+b)+c

RHS Relations:
  a^O = I, a^I = a
  a^(b * c) = (a^b)^c
  a^(b + c) = a^b * a^c
  a*(b + c) = a*b + a*c

LHS Relations:
  I * a = a, O + a = a, O * a = I ^ a
  c functor (i.e., c(a*b) = c(a)*c(b), c(I) = I) =
(a*b)^c = a^c * b^c
(a+b)*c = a*c + b*c
I^c = I

If n in Natural, f: A - A an endo-function, define
  f^n := I,  if n = 0
 f * ... * f,if n  1
 |-n times-|
The natural number functionals, corresponding to Church's number
functionals, are then defined by
  \bar n(f) := f^k
If S(x) := x + 1 (regular integer addition), then
  \bar n(S)(0) = n

Also write (following Hancock)
  log_x b := \lambda x b
Then
  log_x I = O
  log_x x = I
  log_x(a * b) = log_x a + log_x b
  log_x(a ^ b) = (log_x a) * b,x not free in b.


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


Re: [Haskell-cafe] Origins of '$'

2008-12-07 Thread Hans Aberg

On 7 Dec 2008, at 04:30, George Pollard wrote:


This is a little bit random, but I was just wondering if anyone knew
where the $ low-precedence parenthesis-eliminating application  
operator

originated. The Haskell Report doesn't mention anything, and I can't
search for $ on Google. So... who thought it up? Does it  
originate in

an earlier language, or is it uniquely Haskellish? :)


As for the operator itself, it appears in Alonzo Church, The Calculi  
of Lambda-Conversion, where it is written as exponentiation, like  
x^f, or typographically as

 f
x

One can define operators
  a ^ b := b(a)  -- Application in inverse.
  (a * b)(x) := b(a(x))  -- Function composition in inverse.
  (a + b)(x) := a(x) * b(x)
  O(x) := I  -- Constant function returning identity.
  I(x) := x  -- Identity.
and use them to define lambda calculus (suffices with the first four;  
Church reverses the order of *).


Then on Church's natural number functionals, these are just the  
expected natural number operations.


  Hans


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


Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-25 Thread Hans Aberg

On 18 Apr 2008, at 20:04, Martin Sulzmann wrote:


Let's consider our running example

class D a b | a - b
instance D a b = D [a] [b]

which we can write in CHR notation

D a b, D a c == b=c(FD)

D [a] [b] = D a b   (Inst)

These rules overlap.


I experimented with translations into GNU Prolog (gprolog). Since =  
is hard to get working in Prolog unless integrated into unification,  
I tried (using the idea of rewriting unique existence as functions,  
possible if one assumes the axiom of choice):

  class(d, A, b(A)).
  instance(d, l(A), l(B)) :- class(d, A, B).
Then:
  ?- instance(d, l(A), l(B)).
  B = b(A)

  ?- instance(d, l(A), C).
  C = l(b(A))

  ?- instance(d, l(A), l(B)), instance(d, l(A), C).
  B = b(A)
  C = l(b(A))
Though I am not sure about the intended semantics, it does produce  
unique solutions.


  Hans


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


Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-25 Thread Hans Aberg

On 25 Apr 2008, at 14:20, Tom Schrijvers wrote:

Prolog works under the assumption of a closed world. That's  
contrary to the open world view of regular type classes. So these  
aren't the intended semantics.


By which I gather you mean the interpretation of :- as logical  
connective = rather than provability |-?


My point, though, was to interpret
  class a b | a - b
as a functional dependency b = b(a) rather than as
  D a b, D a c == b=c
Thus trying to eliminate the use of =.

Might that be exploited in the type theory context?

  Hans


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


Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-25 Thread Hans Aberg

On 25 Apr 2008, at 15:38, Tom Schrijvers wrote:

Prolog works under the assumption of a closed world. That's  
contrary to the open world view of regular type classes. So these  
aren't the intended semantics.


By which I gather you mean the interpretation of :- as logical  
connective = rather than provability |-?


What I meant was that when Prolog says there are no more  
solutions, it doesn't know of any more. In realtiy it means there  
no more solutions under the closed world assumption. That means  
there could be more solutions if you haven't told Prolog  
everything. In this context, there may be more class instances (you  
simply haven't told the system yet).


I had no intention to deal with that problem. Just forget what Prolog  
says, and when it says there are no more solutions think of it as  
no more solutions determined.


(If one interprets :- as provability |-, there needs to be  
additional axioms for the object theory, and if the theory is  
consistent,  it becomes possible to prove that there are no more  
solutions.)



My point, though, was to interpret
class a b | a - b
as a functional dependency b = b(a) rather than as
D a b, D a c == b=c
Thus trying to eliminate the use of =.


I don't follow you here.


I got
  ?- instance(d, l(A), l(B)).
  B = b(A)
  ?- instance(d, l(A), C).
  C = l(b(A))
so pattern-wise C and l(B) are the same. But I do not bother  
introduce an explicit operator =. So at least in this case, if say  
D [a] Int will be reject as Int is not of the feom l(_). If one has D  
[Int] [Char] and tries to define D [Int] [Float], the leads to trying  
to associate the implicit b(Int) with both Char and Float, which  
would be rejected.


  Hans


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


[Haskell-cafe] Funny State monad dependency

2008-04-16 Thread Hans Aberg
When I load the State module in Hugs, then I can define the function  
f below, but I do not immediately see exactly what function return  
returns. Explanation welcome.


For example:
   f [2..4] [6..9]
  [6,7,8,9,6,7,8,9,6,7,8,9]
That is, it just repeats the second argument as many times as the  
length of the second argument.


  Hans Aberg


import Control.Monad.State

f :: Monad a = a b - a c - a c
f x y = x = (return y)


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


Re: [Haskell-cafe] Funny State monad dependency

2008-04-16 Thread Hans Aberg

On 16 Apr 2008, at 15:22, Daniel Fischer wrote:

The point is the

instance Monad ((-) a) where
return x = const x
f = g = \x - g (f x) x

which is defined in Control.Monad.Instances...


Thank you. I suspected there was an instance somewhere, and I wanted  
to know where it is defined.



  (try in GHCI:
Prelude let f x y = x = (return y)
Prelude :t f
f :: (Monad ((-) a), Monad m) = m a - m b - m b
).


It works in Hugs too. If I don't import Control.Monad.State, then
  f :: (Monad a, Monad ((-) b)) = a b - a c - a c


This is imported into Control.Monad.State and hence the instance is
visible.

By the type of (=), (return y) must have type (a - m b), on the  
other hand,
if y has type c, then (return y) has type (m' c) for some monad m'.  
Unifying

m' c and a - m b gives then m' === ((-) a) and c === m b.
Now according to the instance, return y === const y, so f is the  
same as

g x y = x = (const y).


Good to know the details. Thanks.

  Hans


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


Re: [Haskell-cafe] Funny State monad dependency

2008-04-16 Thread Hans Aberg

On 16 Apr 2008, at 15:14, Miguel Mitrofanov wrote:

Before somebody noticed: I'm wrong.

It's not List monad, but also a (-) x monad, also defined in  
Control.Monad.


Therefore, return y is just const y. Therefore,

x = (return y) = x = (const y) = x  y


Right. It is an interesting monad, but it may cause unexpected  
effect, in view of its implicit name.


  Hans


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


Re: [Haskell-cafe] instance Monad m = Functor m

2008-04-10 Thread Hans Aberg

On 9 Apr 2008, at 17:49, Henning Thielemann wrote:
Additionally I see the problem, that we put more interpretation  
into standard symbols by convention. Programming is not only about  
the most general formulation of an algorithm but also about error  
detection. E.g. you cannot compare complex numbers in a natural  
way, that is

  x  (y :: Complex Rational)
 is probably a programming error. However, some people might be  
happy if () is defined by lexicgraphic ordering. This way complex  
numbers can be used as keys in a Data.Map. But then accidental uses  
of () could no longer be detected. (Thus I voted for a different  
class for keys to be used in Data.Map, Data.Set et.al.)


If one just needs to compare equal and unequal elements, then a hash- 
map is faster than a balanced tree map, and a total order is not  
needed. So those that want to use complex numbers as keys perhaps  
have not considered that possibility.


And if one considers a total order () for all data types, then if  
that includes functions, then it may happen that two equal functions  
f, g satisfy f  g. So it would not have the expected semantic  
properties.


  Hans


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


Re: [Haskell-cafe] instance Monad m = Functor m

2008-04-09 Thread Hans Aberg

On 9 Apr 2008, at 11:26, Jules Bean wrote:

Using 'hugs -98', I noticed it accepts:
  instance Monad m = Functor m where
fmap f x = x = return.f
Has this been considered (say) as a part of the upcoming Haskell  
Prime?


This forbids any Functors which are not monads. Unless you allow  
overlapping instances...


I see it as a Haskell limitation of not being able to indicate the  
function names in the class definition head:


If one could write say
  class Monoid (a; unit, mult) where
unit :: a
mult :: a - a - a
then it is possible to say
  instance Monoid ([]; [], (++)) where
-- 'unit' already defined
-- definition of (++)

Similarly:
  class Functor (m; fmap) where
fmap :: (a - b) - (m a - m b)

  instance Monad m = Functor (m, mmap) where
mmap f x = x = return.f

- For backwards compatibility, if the function names are not  
indicated, one gets the declaration names as default.


I don't know if it is possible to extend the syntax this way, but it  
would be closer to math usage. And one would avoid duplicate  
definitions just to indicate different operator names, like:

  class AdditiveMonoid a where
o :: a
(+) :: a - a - a
as it could be create using
  class Monoid (a; o, (+))


...(which of course would not be h98 any more!).


It does not work in 'hugs +98' mode; if I avoid the Prelude names by:
  class Munctor m where
mmap :: (a - b) - (m a - m b)

  instance Monad m = Munctor m where
mmap f x = x = return.f
I get
  ERROR - Syntax error in instance head (constructor expected)

Other solutions, such as class Functor m = Monad m are frequently  
discussed.


The point is that Monads have a code lifting property, so the functor  
is already conatained in the current definition.


One might want to have away to override, so even if
  instance Monad m = Functor (m, mmap)
functor specialization can take place if one has a more efficeint  
definition. For example

  instance Functor ([], mmap) where
mmap = map

  Hans


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


Re: [Haskell-cafe] instance Monad m = Functor m

2008-04-09 Thread Hans Aberg

On 9 Apr 2008, at 15:23, Henning Thielemann wrote:
I don't know if it is possible to extend the syntax this way, but  
it would be closer to math usage. And one would avoid duplicate  
definitions just to indicate different operator names, like:

class AdditiveMonoid a where
  o :: a
  (+) :: a - a - a
as it could be create using
class Monoid (a; o, (+))


I also recognized that problem in the past, but didn't know how to  
solve it. In Haskell 98, methods are resolved using the types of  
the operands. How would the compiler find out which implementation  
of (+) to choose for an expression like x+y using your approach?


Different names result in different operator hierarchies. So a class  
like

  class Monoid (a; unit, mult) where
unit :: a
mult :: a - a - a
must have an instantiation that specifies the names of the operators.  
In particular, one will need a

  class (Monoid (a; 0; (+)), ...) = Num a ...
if (+) should be used as Monoid.(+) together with Num.(+).

Or give an example you think may cause problems, and I will give it a  
try.


  Hans


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


Re: [Haskell-cafe] instance Monad m = Functor m

2008-04-09 Thread Hans Aberg

On 9 Apr 2008, at 15:23, Henning Thielemann wrote:
I also recognized that problem in the past, but didn't know how to  
solve it. In Haskell 98, methods are resolved using the types of  
the operands. How would the compiler find out which implementation  
of (+) to choose for an expression like x+y using your approach?


I might describe the idea via mangling. So if one has
  class Magma (a; unit, mult) where
unit :: a
mult :: a - a - a
then instances
  Monoid (a; 0; (+))
  Monoid (a; 1; (*))
should logically equivalent to
  Monoid_0_+ (a)
0 :: a
(+) :: a - a - a

  Monoid_1_* (a)
1 :: a
(*) :: a - a - a
or whatever internal mangling that ensures that the names Monoid_0_+  
and Monoid_1_* are different.


Would this not work? - They code should be essentially a shortcut for  
defining new classes.


  Hans


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


Re: [Haskell-cafe] instance Monad m = Functor m

2008-04-09 Thread Hans Aberg

On 9 Apr 2008, at 16:26, Henning Thielemann wrote:
I think a classical example are number sequences which can be  
considered as rings in two ways:

 1. elementwise multiplication
 2. convolution

and you have some function which invokes the ring multiplication

f :: Ring a = a - a

and a concrete sequence

x :: Sequence Integer

what multiplication (elementwise or convolution) shall be used for  
computing (f x) ?


For that problem to arise, one must have, when defining Sequence
  class Ring (a; o, e, add, mult)
  ...
  class (Ring(a; o, e, add, (*)), Ring(a; o, e, add, (**)) =  
Sequence a


It is a good question, but can be avoided by not admitting such  
constructs. - I will think a bit more on it.


  Hans


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


Re: [Haskell-cafe] instance Monad m = Functor m

2008-04-09 Thread Hans Aberg

On 9 Apr 2008, at 16:26, Henning Thielemann wrote:

 1. elementwise multiplication
 2. convolution

and you have some function which invokes the ring multiplication

f :: Ring a = a - a

and a concrete sequence

x :: Sequence Integer

what multiplication (elementwise or convolution) shall be used for  
computing (f x) ?


In math, if there is a theorem about a ring, and one wants to apply  
it to an object which more than one ring structure, one needs to  
indicate which ring to use. So if I translate, then one might get  
something like

  class Ring (a; o, e, add, mult) ...
  ...
  class Ring(a; o, e, add, (*)) = Sequence.mult a
Ring(a; o, e, add, (**) = Sequence.conv a
  where ...
Then Sequence.mult and Sequence.conv will be treated as different  
types whenever there is a clash using Sequence only. - I am not sure  
how this fits into Haskell syntax though.


This might be useful, if it can be worked out.

  Hans


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


Re: [Haskell-cafe] instance Monad m = Functor m

2008-04-09 Thread Hans Aberg

On 9 Apr 2008, at 17:49, Henning Thielemann wrote:
Additionally I see the problem, that we put more interpretation  
into standard symbols by convention. Programming is not only about  
the most general formulation of an algorithm but also about error  
detection. E.g. you cannot compare complex numbers in a natural  
way, that is

  x  (y :: Complex Rational)
 is probably a programming error. However, some people might be  
happy if () is defined by lexicgraphic ordering. This way complex  
numbers can be used as keys in a Data.Map. But then accidental uses  
of () could no longer be detected. (Thus I voted for a different  
class for keys to be used in Data.Map, Data.Set et.al.)


I think there it might be convenient with a total order defined on  
all types, for that data-map sorting purpose you indicate. But it  
would then be different from the semantic order that some types have.  
So the former should have a different name.


Also, one might have
  Ordering(LT, EQ, GT, Unrelated)
so t can be used on all relations.

 Also (2*5 == 7) would surprise people, if (*) is the symbol for a  
general group operation, and we want to use it for the additive  
group of integers.


This is in fact as it should be; the idea is to admit such things:
  class Group(a; unit, inverse, mult) ...

  class (Group(a; 0, (-), (+)), Monoid(a; 1, (*)) = Ring(a; 0, 1,  
(-), (+), (*)) ...

  -- (or better variable names).

  instance Ring(a; 0, 1, (-), (+), (*)) = Integer

A group can be written additively or multiplicatively, (+) is often  
reserved for commutative operations. But there is not way to express  
that, unless one can write

  class AbelianGroup(a; unit, inverse, mult) where
...
  satisfying
mult a b = mult b a
One would need pattern matching to Haskell in order to make this useful.

  Hans



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


Re: [Haskell-cafe] instance Monad m = Functor m

2008-04-09 Thread Hans Aberg

On 9 Apr 2008, at 17:49, Henning Thielemann wrote:
 Also (2*5 == 7) would surprise people, if (*) is the symbol for a  
general group operation, and we want to use it for the additive  
group of integers.


One might resolve the Num binding of (+) problem by putting all  
operators into an implicit superclass:


Roughly, let T be the set of of most general types, and for each t in  
T define a mangling string s(t). Then if the operator

  op :: t
is defined somewhere, it is internally defined as
  class Operator_s(t)_op t where
op :: t
Then usages of it get implicit
  class (Operator_s(t)_op t, ...) = Class where ...
and
  instance Operator_s(t)_op t where ...

If I now have another class using (+), it need not be derived from  
Num, as both usages are derivable from an internal

  class Operator_(+)

The mangling of the type via s(t) might be used to generate C++ style  
name overloading. It will then depend on how much ambiguity one wants  
to accept in the context.


I do not see exactly how this works with Haskell current syntax; just  
an input.


  Hans





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


Re: Re[2]: [Haskell-cafe] deriving

2008-04-08 Thread Hans Aberg

On 8 Apr 2008, at 00:30, Bulat Ziganshin wrote:

At least Hugs complains if one does not indent deriving ..., but I
do not know what the standard says. If is required, then it can be
changed.


deriving is a part of data clause and indentation just allows us to
continue clause from prev. line. if not indented, deriving will be
parsed as separate clause (and btw such clause, standalone deriving
was added to ghc 6.8)


So it seems that if one uses the word instance instead of  
deriving, then the compiler can immediately tell when this word  
appears whether it is a part if the data clause, or the start of a  
new instance clause. So it can probably be changed, getting rid of  
deriving which I think is not used elsewhere. It will break a lot  
of code, but it is easy to change, and also easy to make a  
compatibility mode.


  Hans


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


[Haskell-cafe] instance Monad m = Functor m

2008-04-08 Thread Hans Aberg

Using 'hugs -98', I noticed it accepts:
  instance Monad m = Functor m where
fmap f x = x = return.f

Has this been considered (say) as a part of the upcoming Haskell Prime?

  Hans Aberg


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


Re: Re[4]: [Haskell-cafe] deriving

2008-04-08 Thread Hans Aberg

On 8 Apr 2008, at 10:47, Bulat Ziganshin wrote:

deriving which I think is not used elsewhere. It will break a lot
of code, but it is easy to change, and also easy to make a
compatibility mode.


it's also easy to replace all the books, update all code repositories
and reteach all the programmers if you ready to pay for it all :D


I guess it is only the code breaking part that is any concern of  
standard. It is really up to the companies to pay for courses  
retraining programmers for the word change. As for the books, it is a  
good selling opportunity.


  Hans


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


Re: Re[4]: [Haskell-cafe] deriving

2008-04-08 Thread Hans Aberg

On 8 Apr 2008, at 15:26, PR Stanley wrote:

I'm sure you could introduce change gradually without too much pain.


So then you only have to get the compilers to gradually understand  
it :-).


I personally think deriving is a descriptive term, now that I  
understand its role better.


There are two processes here: deriving, i.e., inheriting an  
interface; and instantiating, i.e., producing running code. Haskell  
denotes derivation by =. And data a deriving (b_1, ..., b_k)  
is really a short for

  data a
  instance b_1 where compiler implementation
  ...
  instance b_k where compiler implementation

So instance seems the word that should have been used.

But discussions of a change seems is likely just a café thing - I  
must go finishing mine :-).


I suppose you could consider specialize or instanciate but both  
those terms are very closely associated with OO and deriving an  
instance of a class with a type isn't quite like instantiation or  
even specialisation.


So then you introduce a new keyword and screwing up all existing code.

We want a single word which is equivalent  to derives from.  
Deriving by itself can seem a bit ambiguous at first.


What about the already used =?

  Hans


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


Re: [Haskell-cafe] deriving

2008-04-08 Thread Hans Aberg

On 8 Apr 2008, at 16:32, Anton van Straaten wrote:
There are two processes here: deriving, i.e., inheriting an  
interface; and instantiating, i.e., producing running code.  
Haskell denotes derivation by =. And data a deriving  
(b_1, ..., b_k) is really a short for

  data a
  instance b_1 where compiler implementation
  ...
  instance b_k where compiler implementation
So instance seems the word that should have been used.


How about making deriving x an expression which means:

  instance x where compiler implementation

This innovative solution will minimize changes to the Haskell  
compiler, documentation, and programmer's brains.


So what is the difference from the current state? They way you have  
written it, one can say

  data A ...

  deriving Eq A
Is that what you want?

Seriously, there's only so much connotational meaning you can pack  
into  or extract from a keyword.  Ultimately, programming language  
keywords follow the rule given by Humpty Dumpty:


When _I_ use a word, it means just what I choose it to mean --  
neither more nor less.


That is why computer languages are what they are. Think of C static.

  Hans



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


Re: [Haskell-cafe] deriving

2008-04-08 Thread Hans Aberg

On 8 Apr 2008, at 16:57, Anton van Straaten wrote:

So what is the difference from the current state?


None.  See how efficient a solution it is?  ;)


So for a change, you propose it should be the same. So you are one of  
those A-programmers :-).


Seriously, there's only so much connotational meaning you can pack  
into  or extract from a keyword.  Ultimately, programming language  
keywords follow the rule given by Humpty Dumpty:


When _I_ use a word, it means just what I choose it to mean --  
neither more nor less.


So your favorite language must be Humpty?! :-)

  Hans


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


Re: [Haskell-cafe] Re: deriving

2008-04-08 Thread Hans Aberg

On 8 Apr 2008, at 17:03, Christian Maeder wrote:
deriving Eq i.e. following data List a = List a creates an  
instance

like:

 instance Eq a = Eq (List a) where compiler implementation

The problem was discussed for Stand-alone deriving declarations:

http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html


There is a difference between
  data Foo a = Bar a | Baz String
  deriving instance Eq a = Eq (Foo a)
and
  data Eq a = Foo a = Bar a | Baz String deriving (Eq)

The second is more restrictive, as it requires Eq for the  
construction of Foo a, whereas the first could be construed to mean  
that Eq a is only required for the construction of Eq(Foo a). So the  
first could be used without Eq a if Eq(Foo a) is not needed. This is  
good when constructing libraries for general types.


  Hans



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


Re: [Haskell-cafe] Function Precedence

2008-04-08 Thread Hans Aberg

On 2 Apr 2008, at 16:20, Loup Vaillant wrote:

class AdditiveSemiMonoid a where
  (+) :: a - a - a


Err, why *semi* monoid? Plain monoid would not be accurate?


I found an example where it is crucial that the monoid has a unit:

When given a monoid m, then one can also define an m-algebra, by  
giving a structure map (works in 'hugs -98'):

  class Monad m = MAlgebra m a where
smap :: m a - a

Now, the set of lists on a set A is just the free monoid with base A;  
the list monad identifies the free monoids, i.e., the lists. So this  
then gives Haskell interpretation

  class Monoid a where
  unit  :: a
  (***) :: a - a - a

instance Monoid a = MAlgebra [] a where
  smap [] = unit
  smap (x:xs) = x *** smap xs
Here, I use (***) to not clash with the Prelude (*).

But the function product here shows up as the structure map of a  
multiplicative monoid. Similarly, sum is the structure map of the  
additive monoids. And (++) is just the monoid multiplication of the  
free monoids.


  Hans


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


Re: [Haskell-cafe] deriving

2008-04-07 Thread Hans Aberg

On 7 Apr 2008, at 21:15, Dan Weston wrote:

To answer your second question (which everyone else ignored):

Yes. A different keyword might have been more descriptive, such as  
automatically_deriving_instances_for.


They are called instantiations, which Haskell can supply  
automatically in some cases. And there is already a keyword  
instance for that - in general, it is good to keep down the number  
of keywords. So

  data Bool = False | True
instance (Eq, Ord, Enum, Read, Show, Bounded)
might have been better.

But here, one would have to think about how the compiler should be  
able to distinguish

  data Bool = False | True
instance (Eq)
from
  data Bool = False | True

  instance Eq Bool where
x == y = ...
One wants to be able to do that with as little lookahead as possible.

  Hans Aberg


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


Re: [Haskell-cafe] deriving

2008-04-07 Thread Hans Aberg

On 7 Apr 2008, at 21:48, Brandon S. Allbery KF8NH wrote:
But here, one would have to think about how the compiler should be  
able to distinguish

  data Bool = False | True
instance (Eq)
from
  data Bool = False | True

  instance Eq Bool where
x == y = ...


Layout already does that, doesn't it?  The former, being indented,  
is a continuation line.


At least Hugs complains if one does not indent deriving ..., but I  
do not know what the standard says. If is required, then it can be  
changed.


  Hans


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


  1   2   3   >