[Haskell-cafe] first the platform, the cabal

2009-09-20 Thread Peter J. Veger
I just installed the Haskell Platform 2009.2.0.2 on Windows.

There is no cabal.exe, only Cabal-1.6.0.3

How to continue: build cabal?

Then what to download from where and what to execute?

 

greetings,

Peter J. Veger, Best Netherlands

 

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


[Haskell-cafe] TFM09: Call for Participation (FMWeek, Eindhoven, November 2009)

2009-09-20 Thread J.N. Oliveira



 TFM2009
2nd Int. FME Conference on Teaching Formal Methods

Friday, November 6th 2009, co-located with
  FM2009 : 16th Int. Symposium on Formal Methods
 Eindhoven, the Netherlands, November 2 - November 6, 2009

   CALL FOR PARTICIPATION

  (URL: http://www.di.uminho.pt/tfm09)


1. About the conference
---
Ten years after the First World Formal Methods Congress (FM'99) in  
Toulouse,
formal methods communities from all over the world will once again  
have an

opportunity to come together.  As part of the First Formal Methods Week
event surrounding the FM2009 conference in Eindhoven, Formal Methods  
Europe

will be organizing TFM2009, the Second International Conference on
Teaching Formal Methods.

The conference will serve as a forum to explore the successes and  
failures

of Formal Methods (FM) education, and to promote cooperative projects to
further education and training in FMs.

TFM2009 will include a panel discussion on the idea of building a 'Guide
to the Formal Methods Body of Knowledge' (FMBoK), inspired by similar
efforts for software engineering (SWEBoK) and for project management
(PMBoK); such a resource would provide guidance to teachers, managers,
and developers on what should be expected from a comprehensive,
balanced programme of education in FMs.


2. Invited speaker
--

Jeff Kramer(Imperial College London, UK)


3. Accepted papers
--

   * Teaching Concurrency: Theory in Practice (Luca Aceto, Anna
 Ingolfsdottir, Kim Guldstrand Larsen, Jiri Srba)

   * Integrated and Tool-Supported Teaching of Testing, Debugging, and
 Verification (Wolfgang Ahrendt, Richard Bubel, Reiner Haehnle)

   * What Top-Level Software Engineers Tackle after Learning Formal  
Methods
 - Experiences from the Top SE Project (Fuyuki Ishikawa, Kenji  
Taguchi,

 Nobukazu Yoshioka, Shinichi Honiden)

   * Teaching program specification and verification using JML and
 ESC/Java2 (Erik Poll)

   * Chief Chefs of Z to Alloy: Using A Kitchen Example to Teach  
Alloy with

 Z (Sureyya Tarkan, Vibha Sazawal)

   * Teaching Formal Methods based on Rewriting Logic and Maude
 (Peter Olveczky)

   * Which Mathematics for the Information Society? (Joao Ferreira,
 Alexandra Mendes, Roland Backhouse, Luis Barbosa)

   * How to explain mistakes (Stefan Hallerstede, Michael Leuschel)
   * On Teaching Formal Methods: Behavior Models and Code Analysis (Jan
 Kofron, Ondrej Sery, Pavel Parizek)

   * Teaching Formal Methods for the Unconquered Territory (Nestor  
Catano,

 Camilo Rueda)


4. Sponsors
--

   * Formal Methods Europe Association (FME)
   * Software Improvement Group (SIG) , Amsterdam, Netherlands


5. Programme Committee
--
Izzat Alsmadi(North Dakota State University, USA)
Dines Bjorner(IIMM Institute, Denmark)
Eerke Boiten(University of Kent, UK)
Raymond Boute(Universiteit Gent, Belgium)
Andrew Butterfield(Trinity College, Dublin)
Jim Davies(University of Oxford, UK)
David Duce(Oxford Brookes University, UK)
John Fitzgerald(University of Newcastle upon Tyne, UK)
Jeremy Gibbons(University of Oxford, UK)
Randolph Johnson(National Security Agency, USA)
Michael Mac an Airchinnigh(Trinity College, Dublin)
Dino Mandrioli(Politecnico di Milano, Italy)
Jose Oliveira(Universidade do Minho, Portugal)
Kees Pronk(Technische Universiteit Delft, NL)
Bernhard Schaetz(Tecnical University of Munique, Germany)
Wolfgang Schreiner(Johannes Kepler University Linz, Austria)
Simao Melo de Sousa(Universidade da Beira Interior, Portugal)
Kenji Taguchi(National Institute of Informatics, Japan)
Jeannette Wing(Carnegie-Mellon University, USA)



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


Re: [Haskell-cafe] Re: Is it safe to use unsafePerformIO here?

2009-09-20 Thread Cristiano Paris
On Sat, Sep 19, 2009 at 6:53 PM, Ben Franksen ben.frank...@online.de wrote:
 Cristiano Paris wrote:
 Daniel Fischer wrote:
 I would separate the reading of headers and bodies, reopening the files
 whose body is needed, for some (maybe compelling) reason he wants to do
 it differently.

 Yes, that's the way Haskell forces you to do that as it's the only way
 for you to go safe.

 I don't think it has anything to do with Haskell.

My sentence was to be understood in a positive way. I think this has a
lot to do with Haskell, as it forbids you to write certain kinds of
programs: this is a distinguished feature of all the static typed
languages and more specifically in Haskell, which has a very
expressive type system. In particular, you can't have a program that
runs IO out-of-order: if you really want to do that, you must use
unsafe(Perform|Interleave)IO which is like cheating, in a way.

Indeed, the only way to do that not using unsafePerformIO is to have a
two stage reading, either making the body an IO action or having an
intermediate data structure which represents a file whose body has not
been read yet: in general this is safer, unless you know something
about your program and can assure the compiler it won't behave badly
with respect to side effects.

 How would you do this in
 C? You'd pass a flag indicating whether to read the whole file or just the
 header. You can do the same in Haskell, of course, no lazy IO needed. The
 body remains undefined if the flag indicates header only. Even better wrap
 the body in a Maybe.

The difference is in the expressivity of the type system.

In C I may use a NULL pointer indicating the body has not been read
yet, but then the compiler won't enforce good uses of that pointer and
can't assure you that in no way a NULL pointer would be ever
dereferenced, leaving room for untested, uncaught bugs.

In Haskell this is simply not possible.

...
 I have a hard time believing this is possible, if you demand that the files
 should not stay opened indefinitely. How is the runtime supposed to know
 whether to close the file or not? What you /can/ do is use unsafePerformIO
 to lazily re-open, read the body, and close the file, as soon as the body
 gets demanded. However, this is ugly and not advised.

Here in Cafè once I had a discussion about when is safe and advisable
to use unsafePerformIO. I don't think this function is evil per-se and
indeed THERE ARE situations where it's more elegant and clear
implementing things using unsafePerformIO. I see it as way to tell the
compiler don't mind: I know what I'm doing. This is certainly true
when using FFI to implement in C pure functions, but it's true in
other situations, like mine, in which using unsafeInterleaveIO allows
me to write my code cleanly and easily, separating IO from processing,
and avoid having to read the files in a two-stage way.

Of course, I can be wrong and I can't look forward to hearing from the
wise people and argument againts my point.

 Cheers
 Ben

Thanks.

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


Re: [Haskell-cafe] first the platform, the cabal

2009-09-20 Thread Martin Huschenbett

Hello Peter,

cabal.exe is locatated in extralibs\bin. On my machine the installer 
added this directory to the PATH, too.


Regards,

Martin.

Peter J. Veger schrieb:

I just installed the Haskell Platform 2009.2.0.2 on Windows.

There is no cabal.exe, only Cabal-1.6.0.3

How to continue: build cabal?

Then what to download from where and what to execute?

 


greetings,

Peter J. Veger, Best Netherlands

 





___
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] How to generate random string?

2009-09-20 Thread mf-hcafe-15c311f0c

does this compile at all?  i don't think i understand the first line.
anyway, a few hints:

  - if you want to have all numbers between 0..n in your output for
some n, just in random order, google for permutation.

  - perhaps you can generate the output in an ordered fashion first,
eg. into an array, and then shuffle the list by plucking elements
from it at random into a new list.

  - do not use unsafePerformIO.  it may reduce the entropy
(randomness) of the results, but even if it doesn't, the code is
prettier without.

good luck!  if you get stuck again, just post more code.
matthias


On Fri, Sep 18, 2009 at 10:14:53AM -0700, Snouser wrote:
 To: haskell-cafe@haskell.org
 From: Snouser linusolean...@gmail.com
 Date: Fri, 18 Sep 2009 10:14:53 -0700 (PDT)
 Subject: Re: [Haskell-cafe] How to generate random string?
 
 
 
 
 Snouser wrote:
  
  I need to generate a random string from 1 to 30.
  
  This is the parts I've done so far.
  
  unikString xs | let x = unsafePerformIO (randomRIO (1,30)) elem x xs = x :
  unikString xs
| otherwise = unikString xs
  
  How do I proceed?
  
  I need the string/list to look like this:
  
  [1,9,3,6,2] et.c with only unik numbers.
  
  Thanks!
  
 
 I wasnt added to the mailinglist, but now I'm.
 
 
 -- 
 View this message in context: 
 http://www.nabble.com/How-to-generate-random-string--tp25512293p25512298.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
  
  ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** 
 CLASSIFY succeeds; success probability: 1.  pR: 6.3668
 Best match to file #0 (nonspam.css) prob: 1.  pR: 6.3668  
 Total features in input file: 2688
 #0 (nonspam.css): features: 758386, hits: 2881904, prob: 1.00e+00, pR:   6.37 
 #1 (spam.css): features: 1686754, hits: 3078784, prob: 4.30e-07, pR:  -6.37 
  
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Building com-1.2.3

2009-09-20 Thread Andrew Coppin

C:\com-1.2.3runhaskell Setup configure
Configuring com-1.2.3...
Setup: Missing dependencies on foreign libraries:
* Missing header file: include/WideStringSrc.h
* Missing C libraries: kernel32, user32, ole32, oleaut32, advapi32
This problem can usually be solved by installing the system packages that
provide these libraries (you may need the -dev versions). If the libraries
are already installed but in a non-standard location then you can use the
flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.

Any hints?

(It is conspicuous that the hissing header file is actually present at 
the exact path indicated... WTH?)


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


[Haskell-cafe] [ANN] histogram-fill, library for creating hitograms

2009-09-20 Thread Khudyakov Alexey
Hello.

I'm glad to announce library for filling histograms. Its purpose to provide 
generic and convenient API and be fast. 


Features list:

* Allows to fill many histograms at once. I used it to fill about hundred.

* It provide support for arbitrary binning algorithm. Currently there are 
integer bins, equal sized floating point bins and generic 2D bins. One however 
could implement more exotic variants. Bins with variable width for example.

* Immutable histograms. It's relatively recent addition so it could have few 
rough edges.

* Histogram serialization to/from human readable text. So data could be used 
with other tools.



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


Re: [Haskell-cafe] [ANN] histogram-fill, library for creating hitograms

2009-09-20 Thread Don Stewart
alexey.skladnoy:
 Hello.
 
 I'm glad to announce library for filling histograms. Its purpose to provide 
 generic and convenient API and be fast. 
 
 
 Features list:
 
 * Allows to fill many histograms at once. I used it to fill about hundred.
 
 * It provide support for arbitrary binning algorithm. Currently there are 
 integer bins, equal sized floating point bins and generic 2D bins. One 
 however 
 could implement more exotic variants. Bins with variable width for example.
 
 * Immutable histograms. It's relatively recent addition so it could have few 
 rough edges.
 
 * Histogram serialization to/from human readable text. So data could be used 
 with other tools.
 
 

Where can we get the code? :)

http://hackage.haskell.org/package/histogram-fill-0.1.0

-- Don (who thinks it is interesting that hackage is now implied)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] first the platform, the cabal

2009-09-20 Thread Don Stewart
veger:
 I just installed the Haskell Platform 2009.2.0.2 on Windows.
 
 There is no cabal.exe, only Cabal-1.6.0.3
 
 How to continue: build cabal?
 
 Then what to download from where and what to execute?
 
  

It does come with the cabal executable. Maybe it isn't in your path?

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


Re: [Haskell-cafe] Haskell Weekly News: Issue 131 - September 19, 2009

2009-09-20 Thread Andrew Coppin

Joe Fredette wrote:

Haskell Weekly News
http://sequence.complete.org/hwn/20090918
Issue 131 - September 18, 2009


Does anybody else get page not found for this URL?

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


Re: [Haskell-cafe] Haskell Weekly News: Issue 131 - September 19, 2009

2009-09-20 Thread Joe Fredette
Ahh, I found the issue. I generated this on the 18th, the software  
makes files of the form yearmonthdate.ext, so when Brent  
uploaded the hwn for me, the link it generates is to the date it was  
generated on, not the date it was published on.


The appropriate link is

http://sequence.complete.org/hwn/20090919

In the future, I'll have to make sure to do the `make` on the date of  
publication, but ATM I don't have access to the sequence.complete.org  
to post the hwns myself. So I try to get the issue to Brent a day early.


It shouldn't happen again, thanks for catching it.

/Joe

On Sep 20, 2009, at 3:06 PM, Andrew Coppin wrote:


http://sequence.complete.org/hwn/20090918


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


Re: [Haskell-cafe] [ANN] histogram-fill, library for creating hitograms

2009-09-20 Thread Khudyakov Alexey
В сообщении от Воскресенье 20 сентября 2009 22:03:42 вы написали:
 alexey.skladnoy:
  Hello.
 
  ... skipped ...
 
 Where can we get the code? :)
 
 http://hackage.haskell.org/package/histogram-fill-0.1.0
 
 -- Don (who thinks it is interesting that hackage is now implied)
 
It's so easy something important (-:

That's how things become de-facto standard. You wake up one day and find that 
it's standard. Or someone tell you. 

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


RE: [Haskell-cafe] first the platform, the cabal

2009-09-20 Thread Peter J. Veger
Martin Huschenbett told me:
cabal.exe is locatated in extralibs\bin. On my machine the installer added this 
directory to the PATH, too.
Thanks you both for your answers

greetings,
Peter J. Veger, Best Netherlands


-Original Message-
From: Don Stewart [mailto:d...@galois.com] 
Sent: zondag 20 september 2009 20:43
To: Peter J. Veger
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] first the platform, the cabal

veger:
 I just installed the Haskell Platform 2009.2.0.2 on Windows.
 
 There is no cabal.exe, only Cabal-1.6.0.3
 
 How to continue: build cabal?
 
 Then what to download from where and what to execute?
 
  

It does come with the cabal executable. Maybe it isn't in your path?

-- Don

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


[Haskell-cafe] GHC will not let me install

2009-09-20 Thread James Michael Stephens
I am trying to install Xmonad on my Mac. I download GHC installer for  
mac the .dmg from Haskell.org and when I install it gets stuck here


[img]http://www.jmstephens.99k.org/picture.png[/img]

As you can see the install button is grey and will not let me click it.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC will not let me install

2009-09-20 Thread Don Stewart
jmstephens:
 I am trying to install Xmonad on my Mac. I download GHC installer for mac the
 .dmg from Haskell.org and when I install it gets stuck here
 [img]http://www.jmstephens.99k.org/picture.png[/img] As you can see the 
 install
 button is grey and will not let me click it.


Are you running Snow Leopard? If so, you need to build GHC manually
first.


http://www.reddit.com/r/haskell/comments/9krbo/whats_the_status_of_ghc_on_the_64_bit_mac_osx/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Cabal packages - cabbages

2009-09-20 Thread Jason Dusek
  Some day, we're going to need a short, catchy name for Cabal
  packages. Let's call them cabbages.

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


Re: [Haskell-cafe] Cabal packages - cabbages

2009-09-20 Thread Jeff Wheeler
On Sun, Sep 20, 2009 at 5:11 PM, Jason Dusek jason.du...@gmail.com wrote:

  Some day, we're going to need a short, catchy name for Cabal
  packages. Let's call them cabbages.

+1

Yes, let's.

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


Re: [Haskell-cafe] Cabal packages - cabbages

2009-09-20 Thread Joe Fredette

I also agree. Hackage should also be renamed to something appropriate.

The Cabbage Patch?


On Sep 20, 2009, at 6:12 PM, Jeff Wheeler wrote:

On Sun, Sep 20, 2009 at 5:11 PM, Jason Dusek jason.du...@gmail.com  
wrote:



 Some day, we're going to need a short, catchy name for Cabal
 packages. Let's call them cabbages.


+1

Yes, let's.

Jeff Wheeler
___
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] Cabal packages - cabbages

2009-09-20 Thread Jason Dusek
  File extension ideas:

.choux  --  My favorite.

.kohl   --  Less characters.

.cbz--  More conventional.

.cbg.gz, .cbg.bz2   --  Allows one to be specific about
--  compression.

  The last one can be extended to the other ones, at the cost of
  a few characters.

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


Re: [Haskell-cafe] Cabal packages - cabbages

2009-09-20 Thread Jason Dusek
2009/09/20 Joe Fredette jfred...@gmail.com:
 I also agree. Hackage should also be renamed to something appropriate.

 The Cabbage Patch?

  +1

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


Re: [Haskell-cafe] Cabal packages - cabbages

2009-09-20 Thread Jeff Wheeler
On Sun, Sep 20, 2009 at 5:20 PM, Joe Fredette jfred...@gmail.com wrote:

 The Cabbage Patch?

'Patch' is pretty well defined, so using it here seems somewhat
awkward and confused to me.

Plus, I don't think we really want to sound childish, and the first
thing I think of is the cabbage patch kid dolls. The original idea,
cabbage, doesn't seem silly to me.

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


Re: [Haskell-cafe] Cabal packages - cabbages

2009-09-20 Thread Don Stewart
jeff:
 On Sun, Sep 20, 2009 at 5:20 PM, Joe Fredette jfred...@gmail.com wrote:
 
  The Cabbage Patch?
 
 'Patch' is pretty well defined, so using it here seems somewhat
 awkward and confused to me.
 
 Plus, I don't think we really want to sound childish, and the first
 thing I think of is the cabbage patch kid dolls. The original idea,
 cabbage, doesn't seem silly to me.

Cabbage patches would be tweaks and fixes you upload to Hackage.

Hackage is more of a cabbage farm.

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


[Haskell-cafe] Type Families

2009-09-20 Thread Alexander Solla
(I'm using a fixed width font, so if you don't see nice formatting,  
you need to use a fixed width font.  This is literate Haskell, but I  
copied and pasted the code.  YMMV)


Hi Everybody! (Hi Dr. Nick)

I've been looking for a good way to use some richer notions of  
polymorphism than Haskell98 allows.


First, I tried to define a monad of the things I want to quantify  
over (so each type of view or type of evaluable thing would be a  
constructor in a monadic type.)  But that didn't seem to offer the  
kind of extensibility I wanted, since I basically want to join several  
types together.  I tried FunDeps next, and that worked okay, but it  
was a bit difficult to keep track of what was meant to do what.  I  
guess I could have plowed through the work, but it wasn't any fun.


I finally heard about TypeFamilies, and they seem to give me the kind  
of extensibility I want, while keeping the theoretical foundations  
relatively clean.


But I am not so sure I understand them.  Let us consider the code:

 type AbstractValue = Int
 class Evaluate asset where
data Value asset :: *
value :: (Value asset) - AbstractValue

That's easy enough.  Value asset is an indexed type.  That is  
reflected in the instance declaration:


 instance Evaluate Abstract where
data Value Abstract = AbstractValue Abstract
value (AbstractValue int) = int

Okay, easy enough.  But what happens when we want to add Evaluate  
instances?


 data Add a b = Add a b
 instance ( Evaluate a
  , Evaluate b
  ) = Evaluate (Add a b) where
  data Value (Sum a b) = SumValue (Sum a b)

Even this much is straightforward.  We require a and b to be  
Evaluate'able before we can find the sum of a and b as values.  Now  
I want to write my definition for the value function.  But... how is  
that supposed to work?  My first guess is


value (SumValue (Sum a b)) = (value a) + (value b)

But I more-or-less expected that to fail.  I realize I need some more  
typing information.  What am I supposed to fill in?  My next guess was


 	   value (SumValue (Sum a b)) = (value $ Value a) + (value $ Value  
b)


But Value doesn't exist as a type constructor.  So now that I am  
starting to get what's going on, I wonder why I don't get what's  
going on.  Since I need to use a type constructor for the (Value a)  
and (Value b) things, it kind of defeats the point.  (I hesitate to  
say value, since I have been using value to mean the result/blah  
of an Evaluate instance)


Speaking of which, I am still not sure what the difference between  
associate data type families and associated type constructor families  
are.  The former use the data keyword in class declarations, and the  
latter use type keywords.  What can I do with one and not the other?


I would really appreciate some guidance.

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


Re: [Haskell-cafe] Type Families

2009-09-20 Thread Dan Doel
On Sunday 20 September 2009 9:43:53 pm Alexander Solla wrote:
 But I more-or-less expected that to fail.  I realize I need some more
 typing information.  What am I supposed to fill in?  My next guess was
 
 value (SumValue (Sum a b)) = (value $ Value a) + (value $ Value
 
 b)
 
 But Value doesn't exist as a type constructor.  So now that I am
 starting to get what's going on, I wonder why I don't get what's
 going on.  Since I need to use a type constructor for the (Value a)
 and (Value b) things, it kind of defeats the point.  (I hesitate to
 say value, since I have been using value to mean the result/blah
 of an Evaluate instance)

Well, the obvious answer is that you should instead write

  data Value (Add a b) = SumValue (Sum (Value a) (Value b))

So that they are already Values, and value can be called on them. I don't 
really understand what you're using the data families for, though. Value looks 
like sort of an identity wrapper around its argument.

 Speaking of which, I am still not sure what the difference between
 associate data type families and associated type constructor families
 are.  The former use the data keyword in class declarations, and the
 latter use type keywords.  What can I do with one and not the other?

Type families (as far as their use in classes goes) are for when the 
associated type already exists. For instance, in a collection class:

  class Collection c where
type Elem c :: *
...

You'll have instances:

  instance Collection [a] where
type Elem [a] = a
...

By contrast, data families are for when you want to define new data types 
indexed by the type. For instance, if you're doing generalized tries:

  class Key k where
data Trie k :: * - *
...

Then:

  instance (Key k) = Key [k] where
data Trie [k] a = ListTrie (Maybe a) (Trie k (Trie [k] a))
...

You can, of course, approximate one with the other. If you use a data family, 
you can use newtypes so there's no additional overhead (but you'll have to 
sprinkle constructors in your code). And data families can be simulated like 
(using the Trie example):

  class Key k where
type Trie k :: * - *
...

  data ListTrie k a = ListTrie (Maybe a) (Trie k (ListTrie k a))

  instance Key k = Key [k] where
type Trie [k] = ListTrie k
...

But in cases where you're writing lots of new data/newtype declarations, just 
to refer to them with an associated type, you may was well use associated data 
instead and remove the middle man. Of course, sometimes you may not be clearly 
in either situation, so it may be a judgment call.

Type families are also useful if you want to do computation at the type level. 
In that sense, type families are like (value-level) functions, and data 
families are like (value-level) constructors (I think that's accurate).

Hope that helped a bit,

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


Re: [Haskell-cafe] Type Families

2009-09-20 Thread Felipe Lessa
On Sun, Sep 20, 2009 at 06:43:53PM -0700, Alexander Solla wrote:
  data Add a b = Add a b
  instance ( Evaluate a
   , Evaluate b
   ) = Evaluate (Add a b) where

Okay.

   data Value (Sum a b) = SumValue (Sum a b)

Hmmm, have you tried

 data Value (Add a b) = AddValue (Value a) (Value b)

Now your 'value' function would be

 value (AddValue va vb) = value va + value vb

because you're holding 'Value a' and 'Value b', not 'a' and 'b'.


It may help to think as if this class represented a container.
For value, do you need the whole container or just one of its
elements?  I know other will give a better explanation, but maybe
this is enough to get you in the right track :).

HTH,

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


Re: [Haskell-cafe] GHC will not let me install

2009-09-20 Thread Gregory Collins
Don Stewart d...@galois.com writes:

 jmstephens:
 I am trying to install Xmonad on my Mac. I download GHC installer for mac the
 .dmg from Haskell.org and when I install it gets stuck here
 [img]http://www.jmstephens.99k.org/picture.png[/img] As you can see the 
 install
 button is grey and will not let me click it.


 Are you running Snow Leopard? If so, you need to build GHC manually
 first.

 
 http://www.reddit.com/r/haskell/comments/9krbo/whats_the_status_of_ghc_on_the_64_bit_mac_osx/

Also you need to download and install XCode from Apple before the GHC
installer will run.

G
-- 
Gregory Collins g...@gregorycollins.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe