Re: Module that causes GHC-7.8 to exhaust memory when -O2 is on

2014-03-30 Thread David Fox
On Sat, Mar 29, 2014 at 12:23 PM, Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk
 wrote:

 On 29/03/14 17:31, David Fox wrote:
  The repository at http://src.seereason.com/o2bug contains a package that
  causes GHC-7.8.1 (rc2?) to exhaust 16GB of RAM and die when the -O2 flag
 is
  turned on.  I haven't been able to simplify it very much, almost any
 change
  to JSON.Render causes it to start working properly.  I did get it to fail
  using only packages available in hackage.  Just thought I should let
 folks
  know about this issue.  Let me know if it fails to fail.
 
  Maybe someone who can log in could put this in trac.
 
 
 
  ___
  Glasgow-haskell-users mailing list
  Glasgow-haskell-users@haskell.org
  http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
 

 You can log in to Trac with username 'guest' and password 'guest' I
 believe.


Thanks, I've created https://ghc.haskell.org/trac/ghc/ticket/8941.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Module that causes GHC-7.8 to exhaust memory when -O2 is on

2014-03-29 Thread David Fox
The repository at http://src.seereason.com/o2bug contains a package that
causes GHC-7.8.1 (rc2?) to exhaust 16GB of RAM and die when the -O2 flag is
turned on.  I haven't been able to simplify it very much, almost any change
to JSON.Render causes it to start working properly.  I did get it to fail
using only packages available in hackage.  Just thought I should let folks
know about this issue.  Let me know if it fails to fail.

Maybe someone who can log in could put this in trac.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC error message on type mismatch

2013-11-07 Thread David Fox
It *is* sometimes difficult to remember that my expectations and I are not
part of this equation - it might be a better prompt to say something like

   type mismatch between function parameter and supplied value:
  function parameter type: A
  supplied value type: B


On Thu, Nov 7, 2013 at 6:02 AM, Simon Peyton-Jones simo...@microsoft.comwrote:

 The motivation is this. Consider

 f True

 where f :: Int - Char

 Then
   f *expects* an argument of type Int
   but the *actual* argument has type Bool

 Does that help?

 Simon

 | -Original Message-
 | From: Glasgow-haskell-users [mailto:glasgow-haskell-users-
 | boun...@haskell.org] On Behalf Of David Luposchainsky
 | Sent: 07 November 2013 12:23
 | To: Daniel Trstenjak; glasgow-haskell-users@haskell.org
 | Subject: Re: GHC error message on type mismatch
 |
 | On 2013-11-07 12:52, Daniel Trstenjak wrote:
 |  My problem is with 'Expected' and 'Actual', that I'm often unsure if
 |  the compiler is expecting something or if I'm the expecting one
 |  and the same goes for actual.
 |
 | Funny you mention it; I think I just got too used to the fact that every
 | time I see this error I have to take a step back to remember what it
 | means exactly. Renaming it to given or provided would really help.
 |
 | +1
 |
 | David
 |
 | ___
 | Glasgow-haskell-users mailing list
 | Glasgow-haskell-users@haskell.org
 | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Interfacing real-time stocks data API

2013-10-09 Thread David Fox
I would love to see Haskell bindings for this:
https://us.etrade.com/active-trading/api


On Tue, Oct 8, 2013 at 1:26 PM, Miro Karpis miroslav.kar...@gmail.comwrote:

 Please, did/does anybody tried to interface with Haskell some real-time
 stocks data API? If yes, please which one? So far I came down to
 ActveTick,...

 thanks,
 m.

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


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


[Haskell-cafe] What am I missing? Cycle in type synonym declarations

2013-08-20 Thread David Fox
This file gives me the error Cycle in type synonym declarations  Can
anyone tell me why?  I'm just trying to write a function to create a
type that is a FooT with the type parameter fixed.

{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH (Q, Dec, TypeQ)

data FooT a = FooT a

foo :: TypeQ - Q [Dec]
foo t = [d| type Bar = FooT $t |]

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


Re: [Haskell-cafe] What am I missing? Cycle in type synonym declarations

2013-08-20 Thread David Fox
On Tue, Aug 20, 2013 at 2:35 PM, adam vogt vogt.a...@gmail.com wrote:
 On Tue, Aug 20, 2013 at 5:00 PM, David Fox d...@seereason.com wrote:
 This file gives me the error Cycle in type synonym declarations  Can
 anyone tell me why?  I'm just trying to write a function to create a
 type that is a FooT with the type parameter fixed.

 {-# LANGUAGE TemplateHaskell #-}
 import Language.Haskell.TH (Q, Dec, TypeQ)

 data FooT a = FooT a

 foo :: TypeQ - Q [Dec]
 foo t = [d| type Bar = FooT $t |]

 Hi David,

 That's strange considering you can accomplish  the same thing with:

 foo t = fmap (:[]) $ tySynD (mkName Bar) [] [t| FooT $t |]

 Bugs like http://ghc.haskell.org/trac/ghc/ticket/4230 are a similar
 problem. In your case it seems that GHC is too eager to prevent the
 cycle you could make with  foo (conT (mkName Bar)))

 Regards,
 Adam

Thanks Adam, this must be the answer.  And thanks for the equivalent expression.

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


Re: [Haskell-cafe] Proposal: Non-recursive let

2013-07-25 Thread David Fox
On Wed, Jul 24, 2013 at 1:11 AM, Andreas Abel andreas.a...@ifi.lmu.de wrote:
 On 23.07.13 4:34 AM, Richard A. O'Keefe wrote:


 On 22/07/2013, at 8:14 PM, Andreas Abel wrote:

 Just today, my student asked me why the following program does nothing:


 Did you ask your student why their code should not be torn into pieces,
 burned to ashes, and incorporated into a pot for radioactive waste?

 All those occurrences of unsafePerformIO!


 No, here they are intended, to simulate something like uniqueness types in
 Clean, which incidentially has been mentioned on this thread before.

 The loop has nothing to do with unsafePerformIO, but stems from Haskell's
 idiosyncratic recursive let, which is a trap for all that come from another
 functional language.

Have your students turn on -fwarn-name-shadowing -Werror:

[1 of 1] Compiling Main ( foo.hs, interpreted )

foo.hs:53:16: Warning:
This binding for `arr' shadows the existing binding
  bound at foo.hs:50:28

foo.hs:62:18: Warning:
This binding for `arr' shadows the existing binding
  bound at foo.hs:56:24

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-07-16 Thread David Fox
I am pleased to announce that, after a terrible struggle, version 0.13
of the module-management package is now available on hackage.  The
performance has been upped from dismal to adequate (about a 30-fold
improvement) and many bugs have been fixed.  The most important for
import cleaning is that it no longer gets confused by tabs.  The split
and merge operations are vastly more reliable, though it is likely
that bugs still lurk.  Also, the API has been simplified a little. and
the examples in Language.Haskell.Modules have been updated.  The
documentation should appear soon at
http://hackage.haskell.org/package/module-management.

On Tue, Jul 2, 2013 at 1:36 PM, David Fox d...@seereason.com wrote:
 Ok, version 0.11.1 is probably my last upload for a while unless I get
 some specific requests, as I need to get back to real work.  It adds
 the new splitModule function that lets you specify a function defining
 which symbols go to which modules, with the old function replaced by a
 call to splitModules defaultSymbolToModule.

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-07-02 Thread David Fox
Ok, version 0.11.1 is probably my last upload for a while unless I get
some specific requests, as I need to get back to real work.  It adds
the new splitModule function that lets you specify a function defining
which symbols go to which modules, with the old function replaced by a
call to splitModules defaultSymbolToModule.

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-07-01 Thread David Fox
On Sat, Jun 29, 2013 at 12:09 PM, David Fox d...@seereason.com wrote:
 I've just uploaded version 0.10, which corrects some formatting bugs
 and incorporates most of the changes suggested in this thread.  Please
 give it a try!

Version 0.10.1 is now available - it should build with GHC 7.4.1,
fixes more formatting bugs, includes the unit test input data and
debian/changelog.  The next release will address people's concerns
about the signature of the splitModule function.  It will take a
function defining how to map symbols to module names, so people can
define their own splits.  It will also return a set of values
describing what it did.

Should I keep posting updates in this thread?

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-06-29 Thread David Fox
I've just uploaded version 0.10, which corrects some formatting bugs
and incorporates most of the changes suggested in this thread.  Please
give it a try!

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


[Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-06-27 Thread David Fox
I am pleased to announce the first release of module-management, a
package for cleaning import lists, and splitting and merging modules.
You can see a description at the top of the documentation for
Language.Haskell.Modules (once it appears) here:

http://hackage.haskell.org/package/module-management

It is worth noting that the split and merge operations cause global
changes to the module tree, all the modules that import the split or
merged modules get their import lists adjusted.  For this reason,
before these operations can run the caller needs to specify the
moduVerse, the set of modules to scan for import changes.

A number of bugs in GHC's -ddump-minimal-imports feature cropped up
while I was writing this, and when the fixes for these issues make it
into the compiler things will work a bit more smoothly, particularly
if you are using NoImplicitPrelude or type families.

http://hackage.haskell.org/trac/ghc/ticket/7963
http://hackage.haskell.org/trac/ghc/ticket/7969
http://hackage.haskell.org/trac/ghc/ticket/8000
http://hackage.haskell.org/trac/ghc/ticket/8011

There are workarounds for 7963 and 7969.  Not surprisingly, template
haskell can cause problems, but frequently it does not.  CPP
directives do not work.  I hope you find this useful - all feedback is
welcome!

-david

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-06-27 Thread David Fox
I put an intro into the top module - hackage will generate it in a
little while, but until then you can look here:

http://doc.seereason.com/libghc-module-management-doc/html/Language-Haskell-Modules.html

I commented out the test section because the test cases use the debian
module, and I didn't want people to have to mess with that - I will
use cabal flags to control that, or better still replace those cases
with something more self contained.

On Thu, Jun 27, 2013 at 5:26 PM, Marc Weber marco-owe...@gmx.de wrote:
 Dear David,

 would you mind adding a short intro about how to use your library?

 I mean editor plugin authors may want to know whether or how to
 integrate the features of your library ?

 From looking at the cabal file I see there is a library and a commented
 tests (by the way you can make tests optional by using cabal flags).

 (before library/ executables):

 flag build_test
   description: build the test executable
   default: Fales


 To the executable add:

   if !flag(build_test)
 buildable: False

 Marc Weber

 ___
 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] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-06-27 Thread David Fox
Thanks, great feedback, clearly I've been too close to this to see
what people need to know.  Let me give some answers, and they I will
integrate them into the documentation.

On Thu, Jun 27, 2013 at 6:06 PM, Marc Weber marco-owe...@gmx.de wrote:
 let me give you an example:

   splitModule :: MonadClean m = ModuleName - m ()

   Split each of a module's declarations into a new module. Update the
   imports of all the modules in the moduVerse to reflect the split.

 Why do I want that? What does it mean?

Split and merge were the simplest set of operations that would allow
you build more complex operations like move a symbol from one module
to another.  Directly implementing more complex for reasons that I
could discuss later.  It may be desirable to provide compound
operations like move symbol implemented in terms of split and merge.


 === start file ==
   module Start where

   a = 1
   b = 2
   c = 3

 will calling that function yield

   module foobar where
   a = 1

   module baz.something.idont.know where
   b =2

   module 3rd where
   c =3

 I want to say: I have no idea
   - how the new modules will be named
   - which paths the new modules will have

Yes, you will get three modules each containing the declarations of a
single symbol.  The modules are placed in a sub-directory of the
original module, and the names are constructed from the symbol names.
So you will get modules Start.A, Start.B and Start.C.  If there are
non-alphanumeric characters in the symbol they are removed, and the
first character is capitalized.  If more than one symbol maps to the
same module name a single module is created containing both.  If no
module name can be constructed the symbol goes into
Start.OtherSymbols.

Instances go into a module named Start.Instances.  Symbols that were
just imported and re-exported from Start go into Start.ReExported.
Symbols that were not exported from Start go into the subdirectory
Internal, so if 'a' was not exported it would go into
Start.Internal.A.


 Function's return type is m (), so doesn't help much.

 Consider improving that documentation.

 More questions: input/output.

   findPaths Language = runMonadClean . mapM cleanImports . toList

 Whose task is it to write the new cleaned up module to disk again?
 does runMonadClean do it for me? Docs don't tell yet.

 Marc Weber

The cleanImports function is the one that computes the new file
contents and does the IO.  The runMonadClean function sets up the
environment for cleanImports to run, if you wanted to chain a series
of clean/split/merge operations together you would do it in a single
runMonadClean operation so that the set of modules that need to be
checked and updated can be tracked.

runCleanT would probably be a better name.

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-06-27 Thread David Fox
There are several modes of operations that are controlled by settings
in Language.Haskell.Modules.Params:

modifyModuVerse - controls the initial set of modules whose imports
will be updated as modules are split and merged.  This set is updated
as splits and merges are performed.

modifyRemoveEmptyImports - If this flag is set, imports that become
empty are removed.  Sometimes this will lead to errors, as the
instances in the removed import will no longer be available.  In that
case this flag should be set.  Note that an import that is already
empty will never be removed, on the assumption that was placed there
to import instances.

modifyExtensions - This controls the language extensions that are used
by module parser, and by GHC when it runs -ddump-minimal-imports.
This is usually not necessary, because the module usually contains
pragmas saying what extensions it needs.

modifyHsFlags - lets you pass additional flags to GHC

modifySourceDirs - lets you specify a list of directories to search
for modules.  This is similar to the Hs-Source-Dirs cabal field.


On Thu, Jun 27, 2013 at 7:04 PM, David Fox d...@seereason.com wrote:
 Thanks, great feedback, clearly I've been too close to this to see
 what people need to know.  Let me give some answers, and they I will
 integrate them into the documentation.

 On Thu, Jun 27, 2013 at 6:06 PM, Marc Weber marco-owe...@gmx.de wrote:
 let me give you an example:

   splitModule :: MonadClean m = ModuleName - m ()

   Split each of a module's declarations into a new module. Update the
   imports of all the modules in the moduVerse to reflect the split.

 Why do I want that? What does it mean?

 Split and merge were the simplest set of operations that would allow
 you build more complex operations like move a symbol from one module
 to another.  Directly implementing more complex for reasons that I
 could discuss later.  It may be desirable to provide compound
 operations like move symbol implemented in terms of split and merge.


 === start file ==
   module Start where

   a = 1
   b = 2
   c = 3

 will calling that function yield

   module foobar where
   a = 1

   module baz.something.idont.know where
   b =2

   module 3rd where
   c =3

 I want to say: I have no idea
   - how the new modules will be named
   - which paths the new modules will have

 Yes, you will get three modules each containing the declarations of a
 single symbol.  The modules are placed in a sub-directory of the
 original module, and the names are constructed from the symbol names.
 So you will get modules Start.A, Start.B and Start.C.  If there are
 non-alphanumeric characters in the symbol they are removed, and the
 first character is capitalized.  If more than one symbol maps to the
 same module name a single module is created containing both.  If no
 module name can be constructed the symbol goes into
 Start.OtherSymbols.

 Instances go into a module named Start.Instances.  Symbols that were
 just imported and re-exported from Start go into Start.ReExported.
 Symbols that were not exported from Start go into the subdirectory
 Internal, so if 'a' was not exported it would go into
 Start.Internal.A.


 Function's return type is m (), so doesn't help much.

 Consider improving that documentation.

 More questions: input/output.

   findPaths Language = runMonadClean . mapM cleanImports . toList

 Whose task is it to write the new cleaned up module to disk again?
 does runMonadClean do it for me? Docs don't tell yet.

 Marc Weber

 The cleanImports function is the one that computes the new file
 contents and does the IO.  The runMonadClean function sets up the
 environment for cleanImports to run, if you wanted to chain a series
 of clean/split/merge operations together you would do it in a single
 runMonadClean operation so that the set of modules that need to be
 checked and updated can be tracked.

 runCleanT would probably be a better name.

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-06-27 Thread David Fox
Since you pass a list of modules to merge, you can (must) specify the
order that the symbols will appear in the new module.  So it is almost
an identity operation, unless the symbols went into the OtherSymbols
module.

On Thu, Jun 27, 2013 at 7:24 PM, Felipe Almeida Lessa
felipe.le...@gmail.com wrote:
 On Thu, Jun 27, 2013 at 11:18 PM, Marc Weber marco-owe...@gmx.de wrote:
 Excerpts from David Fox's message of Fri Jun 28 04:04:59 +0200 2013:
 So you will get modules Start.A, Start.B and Start.C.  If there are

 But that's very unlikly what the programmer wants. I mean I might want
 Types and Funs as module names, move A,B to Types, C to Funs.

 I agree that I could reach my goal using a merge afterwards ?

 From what I'm reading, I don't actually agree that the goal may be
 reached by using a merge afterwards.  I assume that split-then-merge
 isn't the same as identity since at very least the order of the
 symbols is lost.

 --
 Felipe.

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-06-27 Thread David Fox
On Thu, Jun 27, 2013 at 7:18 PM, Marc Weber marco-owe...@gmx.de wrote:
 Excerpts from David Fox's message of Fri Jun 28 04:04:59 +0200 2013:
 So you will get modules Start.A, Start.B and Start.C.  If there are

 But that's very unlikly what the programmer wants. I mean I might want
 Types and Funs as module names, move A,B to Types, C to Funs.

 I agree that I could reach my goal using a merge afterwards ?

 Because some modules may have many symbols having that many files
 created feels strange.

 Useful for the programmer (me?) would be:

 up to line 200 move to A, from 200 till end move to module B

 Even if you think the way to go is creating 50 files (because you happen
 to have 50 symbols) you may want to consider telling the user that he
 knows what to expect - and that you welcome patches to make this even
 nicer and more useful.

 Marc Weber

Yes, these are issues that should be addressed by layers on top of
what I have so far.  I could even see this being integrated into an
IDE.  The split-in-two operation sounds very useful.  As does
mega-split warning.  Moving a single symbol, or a list of symbols,
sounds like another great option.  I realized that split was not going
to be the final solution, but it had a very simple signature and led
to the implementation of all the mechanisms these nicer operations
will require.

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


Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules

2013-06-27 Thread David Fox
On Thu, Jun 27, 2013 at 8:46 PM, John Wiegley jo...@fpcomplete.com wrote:
 David Fox d...@seereason.com writes:

 I am pleased to announce the first release of module-management, a package
 for cleaning import lists, and splitting and merging modules.  You can see a
 description at the top of the documentation for Language.Haskell.Modules
 (once it appears) here:

 How about building an executable along with the library called cleanImports,
 so that I can use it from the command-line.  Otherwise, every who wants to use
 your library in this way will be writing pretty much the exact same code.

 cleanImports is something I've been wanting, just hadn't gotten around to
 writing it yet.  Thanks!

Cliff Beshers wrote a CLI for this, I will add it as a cabal
executable in the next version.

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


Re: [Haskell-cafe] Hackage down, again?

2012-12-15 Thread David Fox
new-hackage is down too.

On Sat, Dec 15, 2012 at 11:05 AM, Magnus Therning mag...@therning.orgwrote:

 It looks like hackage is down again.  Is it planned or unplanned
 downtime this time?

 There doesn't happen to be some mirror of the packages that is a bit
 more reliable than the original?

 /M

 --
 Magnus Therning  OpenPGP: 0xAB4DFBA4
 email: mag...@therning.org   jabber: mag...@therning.org
 twitter: magthe   http://therning.org/magnus

 Most software today is very much like an Egyptian pyramid with
 millions of bricks piled on top of each other, with no structural
 integrity, but just done by brute force and thousands of slaves.
  -- Alan Kay

 ___
 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] ANNOUNCE: uuid-1.2.6

2012-09-20 Thread David Fox
I was wondering about this:

  -- My goal with this instance was to make it work just enough to do what
  -- I want when used with the HStringTemplate library.
  instance Data UUID where
  toConstr uu  = mkConstr uuidType (show uu) [] (error fixity)
  gunfold _ _  = error gunfold
  dataTypeOf _ = uuidType

Is there any reason not to just say deriving Data in the type declaration?

On Wed, Jun 13, 2012 at 8:59 PM, Antoine Latter aslat...@gmail.com wrote:

 Hi folks,

 I'm happy to announce a new point release of the uuid library, 1.2.6:

 http://hackage.haskell.org/package/uuid-1.2.6

 The 'uuid' package implements most of RFC 4122[1] including random
 generation and generation based on hardware MAC addresses.

 I haven't announced a point-release in a while. The changes since 1.2.1
 include:

 * When generating UUIDs from the hardware MAC address, if the MAC
 address is not available we now use a random seed for our (hidden,
 global) state machine

 * The 'Read' instance now drops leading spaces

 * Added the functions 'toWords' and 'fromWords', primary to support
 the package uuid-quasi[2].

 Take care,
 Antoine

 1: http://tools.ietf.org/html/rfc4122
 2: http://hackage.haskell.org/package/uuid-quasi

 ___
 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] hGetContents Illegal byte sequence / ghc-pkg

2012-08-12 Thread David Fox
On Sat, Aug 11, 2012 at 4:13 AM, Benjamin Edwards edwards.b...@gmail.comwrote:

 Hello café,

 I have a program that is crashing, and I have no idea why:

 module Main
   where

 import System.Process (readProcessWithExitCode)


 main :: IO ()
 main = do _ - readProcessWithExitCode ghc-pkg [describe, hoopl] 
   putStrLn Should never get here

 this is using the process package from hackage. The program crashes with

 minimal-test: fd:5: hGetContents: invalid argument (invalid byte sequence)
 minimal-test: thread blocked indefinitely in an MVar operation

 inspecting the source of readProcessWithExitCode yields an obvious
 explanation to the MVar problem, but I don't understand why hGetContents is
 so offended.

 For the lazy it is defined as follows:

 readProcessWithExitCode
 :: FilePath -- ^ command to run
 - [String] -- ^ any arguments
 - String   -- ^ standard input
 - IO (ExitCode,String,String) -- ^ exitcode, stdout, stderr
 readProcessWithExitCode cmd args input = do
 (Just inh, Just outh, Just errh, pid) -
 createProcess (proc cmd args){ std_in  = CreatePipe,
std_out = CreatePipe,
std_err = CreatePipe }

 outMVar - newEmptyMVar

 -- fork off a thread to start consuming stdout
 out  - hGetContents outh
 _ - forkIO $ C.evaluate (length out)  putMVar outMVar ()

 -- fork off a thread to start consuming stderr
 err  - hGetContents errh
 _ - forkIO $ C.evaluate (length err)  putMVar outMVar ()

 -- now write and flush any input
 when (not (null input)) $ do hPutStr inh input; hFlush inh
 hClose inh -- done with stdin

 -- wait on the output
 takeMVar outMVar
 takeMVar outMVar
 hClose outh
 hClose errh

 -- wait on the process
 ex - waitForProcess pid

 return (ex, out, err)

 Now having looked at the source of ghc-pkg it is dumping it's output using
 putStr and friends, so that should be using my local encoding on the
 system, right? and so should hGetContents in my program..?

 Now, for the curious: the reason I care is that this problem has
 effectively prevented me from using virthualenv. Sadness and woe.


I would recommend using ByteStrings.  There is a link to a version of
readProcessWithExitCode that uses ByteString instead of String here:
http://www.haskell.org/pipermail/libraries/2012-August/018263.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Typed TemplateHaskell?

2012-05-25 Thread David Fox
Its a much simpler thing, but I would like to see a template haskell
library and quasi-quoter that used a monad transformer instead of just Q.

On Thu, May 24, 2012 at 1:47 AM, Simon Peyton-Jones
simo...@microsoft.comwrote:

 Maybe take a look at
   http://hackage.haskell.org/trac/ghc/blog/Template%20Haskell%20Proposal

 | -Original Message-
 | From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-
 | boun...@haskell.org] On Behalf Of Tillmann Rendel
 | Sent: 23 May 2012 18:20
 | To: Haskell Café
 | Subject: Re: [Haskell-cafe] Typed TemplateHaskell?
 |
 | Hi Ilya,
 |
 | Ilya Portnov wrote:
 |  As far as can I see, using features of last GHC one could write typed
 |  TH library relatively easily, and saving backwards compatibility.
 | 
 |  For example, now we have Q monad and Exp type in template-haskell
 |  package. Let's imagine some new package, say typed-template-haskell,
 |  with new TQ monad and new polymorphic type Exp :: * - *. Using last
 |  GHC's features, one will easily write something like expr :: Exp
 |  String, which will mean that expr represents a string expression.
 |  And we will need a new function, say runTQ :: TQ a - Q a (or some
 |  more complicated type), which will turn TypedTemplateHaskell's
 |  constructs into plain TH.
 |
 | That would be a good thing to have. But it might be quite hard to
 | implement. For example, I guess you might want to have functions like
 | this one:
 |
 |apply :: Exp (a - b) - Exp a - Exp b
 |
 | This function takes two typed expressions and produces an application.
 | The types ensure that the generated application will typecheck. Cool.
 |
 | But can you do the same thing for lambdas? Lambdas create functions, so
 | the type would be something like the following:
 |
 |lambda :: ... - Exp (a - b)
 |
 | But what would you put instead of the ...?
 |
 | I fear that overall, you would have to reimplement Haskell's type system
 | in Haskell's type system. Which sounds like a cool thing to do, but
 | maybe not so easily.
 |
 |Tillmann
 |
 | ___
 | 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] adding the elements of two lists

2012-03-29 Thread David Fox
On Sun, Mar 25, 2012 at 5:06 AM, Michael Snoyman mich...@snoyman.com wrote:
 On Sun, Mar 25, 2012 at 2:01 PM, TP paratribulati...@free.fr wrote:
 Hello,

 My primary problem may be reduced to adding elements of two lists:
 [1,2,3] + [4,5,6] = [5,7,9]

 My first idea was to declare a list of Int as an instance of Num, and define 
 (+)
 in the correct way.
 However, it seems it is not possible to do that:

 ---
 instance Num [Int] where
        l1 + l2 = 
 ---

 Why?
 It seems it is necessary to do:

 --
 newtype ListOfInt = ListOfInt { getList :: [Int] }
    deriving (Show, Eq)

 instance Num ListOfInt where
     l1 + l2 = ...
 ---

 Am I correct? Is it the best way to do that?

 Now, what is the most usual way to implement l1+l2?
 I have just read about applicative functors, with which I can do:

 ---
 import Control.Applicative
 let l1 = [1,2,3]
 let l2 = [4,5,6]
 print $ getZipList $ (+) $ ZipList l1 * ZipList l2
 [5,7,9]
 ---

 Is it the correct way to do that?
 I have tried:

 ---
 instance Num ListOfInt where
     l1 + l2 = ListOfInt $ getZipList $ (+) $ ZipList (getList l1) *
                                     ZipList (getList l2)
 ---

 Isn't it too much complicated?

 Thanks

 TP

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

 A simple solution is to use the zipWith[1] function:

    zipWith (+) [1,2,3] [4,5,6] == [5,7,9]

 It takes a bit of time to get acquainted with all of the incredibly
 convenient functions in base, but once you know them, it can greatly
 simplify your code.

 Michael

Not knowing zipWith, I usually write

   map (uncurry (+)) (zip [1,2,3] [4,5,6])

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


Re: [Haskell-cafe] where to put general-purpose utility functions

2012-01-24 Thread David Fox
On Mon, Jan 23, 2012 at 1:01 PM, Joey Hess j...@kitenet.net wrote:

    Other stuff:
 
    separate :: (a - Bool) - [a] - ([a], [a])

 Is this partition from Data.List?

 No; it's like break but does not include the separating character in the
 snd list.

I like  let (hd, _ : tl) = break prd lst in...

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


Re: [Haskell-cafe] where to put general-purpose utility functions

2012-01-24 Thread David Fox
On Tue, Jan 24, 2012 at 1:00 PM, David Fox dds...@gmail.com wrote:
 On Mon, Jan 23, 2012 at 1:01 PM, Joey Hess j...@kitenet.net wrote:

    Other stuff:
 
    separate :: (a - Bool) - [a] - ([a], [a])

 Is this partition from Data.List?

 No; it's like break but does not include the separating character in the
 snd list.

 I like  let (hd, _ : tl) = break prd lst in...

Oh, wait.  That won't always work. :(

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


Re: [Haskell-cafe] where to put general-purpose utility functions

2012-01-22 Thread David Fox
I try to create a workflow for this sort of thing.  I create a package
with a name like set-extra, with one module Data.Set.Extra and an
alternative Data.Set module that exports both the old Data.Set and the
symbols in Data.Set.Extra.  Then I email the maintainers of the
Containers package with a suggestion.  After a while I upload
set-extra to hackage if I need to use set-extra in another hackage
package.

On Sat, Jan 21, 2012 at 12:20 PM, Joey Hess j...@kitenet.net wrote:
 I'm finding a rather unusual problem as I write haskell..

 Unlike every other language I've used, large portions of my haskell code
 are turning out to be general-purpose, reusable code. Fully 20% of the
 haskell code I've written for git-annex is general purpose. Now, I came out
 of a decade of perl with maybe 1% reusable code. So I'm sure this is a
 credit to haskell, and not to me.

 My problem now is that as I start new projects, I want to have my haskell
 utility functions available, and copying them around is not ideal. So, put
 them on hackage. But where, exactly? It already has several grab bag utility
 libraries. The only one with much traction is MissingH. Using the others
 makes a program have an unusual dependency, which while only a cabal
 install away, would make work for distributions that want to package the
 program. I've ruled out using a couple on that basis. Doesn't encourage me
 to add another one.

 My 2000+ lines of reusable code are a grab-bag of generic utility
 functions. Looking them over (see Appendix), I could try to get portions
 into existing libraries on hackage, but it's unlikely I'd find a home
 for most of them, so I'm still left with this problem of what to do.

 I wonder if the model used for xmonad-contrib, of a big library package,
 that is very open to additions from contributors, would be helpful here?

 John, any interest in moving MissingH in this direction? I get the
 impression it's not otherwise changing much lately, and parts of it are
 becoming naturally obsolete, maybe this could inject some life into it.
 Any other thoughts you have on grab-bag utility libraries on hackage
 also appreciated.

 

 Appendix: A sample of a a few of the better functions from my utility library.

  Some quite generic monadic control functions, few of them truely unique:

  whenM :: Monad m = m Bool - m () - m ()   -- also ?
  unlessM :: Monad m = m Bool - m () - m () -- also !
  firstM :: Monad m = (a - m Bool) - [a] - m (Maybe a)

  A module that exports functions conflicting with partial
  functions in the Prelude, to avoid them being accidentially
  used. And provides some alternatives (which overlap somewhat with Safe):

  headMaybe :: [a] - Maybe a
  readMaybe :: Read a = String - Maybe a
  beginning :: [a] - [a]

  Various path manipulation functions such as:

  dirContains :: FilePath - FilePath - Bool
  dotfile :: FilePath - Bool
  absPath :: FilePath - IO FilePath

  Other stuff:

  separate :: (a - Bool) - [a] - ([a], [a])
  catchMaybeIO :: IO a - IO (Maybe a)
  readSize :: [Unit] - String - Maybe ByteSize -- parses 100 kb etc
  format :: Format - Variables - String
  findPubKeys :: String - IO GpgKeyIds
  boolSystem :: FilePath - [CommandParam] - IO Bool
  withTempFile :: Template - (FilePath - Handle - IO a) - IO a

 --
 see shy jo

 ___
 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: GeneralizedNewtypeDeriving

2011-12-27 Thread David Fox
My guess is that Americans were involved.

On Mon, Dec 26, 2011 at 7:24 AM, Matthew Farkas-Dyck strake...@gmail.comwrote:

 Just of curiosity, why is it spelt with a z? Is it spelt thus in
 Scottish English? I thought that generalised is written throughout
 Great Britain.

 Cheers,
 MFD

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


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

2011-12-20 Thread David Fox
On Mon, Dec 19, 2011 at 11:20 AM, Robert Clausecker fuz...@gmail.comwrote:

 Image you would create your own language with a paradigm similar to
 Haskell or have to chance to change Haskell without the need to keep any
 compatibility. What stuff would you add to your language, what stuff
 would you remove and what problems would you solve completely different?

 Thanks in advance for all answers, yours


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 ℝ.
___
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-19 Thread David Fox
After eight years I'm still discovering why various decisions made in
Haskell are right.

On Mon, Dec 19, 2011 at 11:20 AM, Robert Clausecker fuz...@gmail.comwrote:

 Image you would create your own language with a paradigm similar to
 Haskell or have to chance to change Haskell without the need to keep any
 compatibility. What stuff would you add to your language, what stuff
 would you remove and what problems would you solve completely different?

 Thanks in advance for all answers, yours

Robert Clausecker


 ___
 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] Decision procedure for foldr/foldl/foldl'?

2011-11-22 Thread David Fox
On Tue, Nov 22, 2011 at 5:04 AM, Jerzy Karczmarczuk
jerzy.karczmarc...@unicaen.fr wrote:
 David Fox reacts to my criticism of his attitude towards the meaning of
 folds:

 I'm not trying to avoid learning the differences between the different
 folds, but I am looking for a mnemonic device that will allow me to
 proceed more quickly towards my goal.  My ultimate goal is to write
 software, not to understand folds.   Just as it is inappropriate for a
 young officer to even contemplate an overall strategy for winning the
 war, it would be inappropriate for a general to spend more time than
 necessary on the minute details of military tactics, as vital as they
 are.

 David, cynism or not, you might have found in my post some concrete remarks,
 about incrementality, about tail-recursion... Not a single comment of your
 part. No comment addressed to other people who tried also to help you
 (whether we really help you in such a way is subject to discussion...)

 I am sorry, but saying that your goal is to write software is not even
 funny. The relatively modern science of programming evolves for the last 60
 years, and the progress in writing software NEVER came out of kitchen
 recipes, on the contrary ! The laziness is not a trick to avoid
 computation, but a methodology of ordering the operations, and if you are
 unable to order them in your head, you won't be able to exploit this or that
 design pattern.
 OK, you gather some patterns, and you apply them. Once. And then, you will
 be helpless, when the need for refactoring arrives. You will never be able
 to teach those patterns to your younger colleagues. And finally, your last
 remarks might be less relevant than you wish. A general gets his stars
 usually after several years of demonstrating that he UNDERSTANDS the minute
 details of military tactics, so he can consciously choose those who will
 implement them.

I think the other replies in this thread speak for themselves - i
found them very helpful.

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


Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-21 Thread David Fox
On Mon, Nov 21, 2011 at 4:44 AM, Jerzy Karczmarczuk
jerzy.karczmarc...@unicaen.fr wrote:

 In general, sorry for the cynism, but when I read:

 There are times when I would like to find out which to use in the quickest
 way possible, rather than reading a long explanation of why each one behaves
 the way it does of David Fox, I compare it with a question of a young army
 officer, addressed to his elders:

 Tell me how to win the war in the quickest way possible, rather than boring
 me with the explanations behind all those complicated strategies.

I'm not trying to avoid learning the differences between the different
folds, but I am looking for a mnemonic device that will allow me to
proceed more quickly towards my goal.  My ultimate goal is to write
software, not to understand folds.   Just as it is inappropriate for a
young officer to even contemplate an overall strategy for winning the
war, it would be inappropriate for a general to spend more time than
necessary on the minute details of military tactics, as vital as they
are.

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


Re: [Haskell-cafe] Superset of Haddock and Markdown

2011-11-21 Thread David Fox
On Sun, Nov 20, 2011 at 2:20 PM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 On 21 November 2011 03:19, David Fox dds...@gmail.com wrote:
 On Fri, Nov 18, 2011 at 1:10 AM, Ertugrul Soeylemez e...@ertes.de wrote:
 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote:

 Wasn't there talk at one stage of integrating pandoc into haddock?

 I wouldn't mind Haddock depending on Pandoc, at least optionally
 (-fmarkdown-comments).  Taking this to its conclusion you could easily
 have syntax-highlighted code examples in Haddock documentations and
 allow alternative output formats.

 I'm not sure the pandoc license (GPL) is compatible with the GHC license.

 Do you mean because GHC ships with a Haddock binary?


Haddock carries the same license as GHC.

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


Re: [Haskell-cafe] Superset of Haddock and Markdown

2011-11-20 Thread David Fox
On Fri, Nov 18, 2011 at 1:10 AM, Ertugrul Soeylemez e...@ertes.de wrote:
 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote:

 Wasn't there talk at one stage of integrating pandoc into haddock?

 I wouldn't mind Haddock depending on Pandoc, at least optionally
 (-fmarkdown-comments).  Taking this to its conclusion you could easily
 have syntax-highlighted code examples in Haddock documentations and
 allow alternative output formats.

I'm not sure the pandoc license (GPL) is compatible with the GHC license.

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


[Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-20 Thread David Fox
Does anyone have a quick way to decide which of the fold functions to
use in a given situation?  There are times when I would like to find
out which to use in the quickest way possible, rather than reading a
long explanation of why each one behaves the way it does.

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


Re: Should GHC default to -O1 ?

2011-11-08 Thread David Fox
On Tue, Nov 8, 2011 at 6:31 AM, Daniel Fischer
daniel.is.fisc...@googlemail.com wrote:
 On the haskell-cafe as well as the beginners mailing lists, there
 frequently (for some value of frequent) are posts where the author inquires
 about a badly performing programme, in the form of stack overflows, space
 leaks or slowness.

 Often this is because they compiled their programme without optimisations,
 simply recompiling with -O or -O2 yields a decently performing programme.

 So I wonder, should ghc compile with -O1 by default?
 What would be the downsides?

I think this is an excellent idea.  Even better -O2.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Should GHC default to -O1 ?

2011-11-08 Thread David Fox
On Tue, Nov 8, 2011 at 8:16 AM, Simon Marlow marlo...@gmail.com wrote:
 On 08/11/2011 14:31, Daniel Fischer wrote:

 On the haskell-cafe as well as the beginners mailing lists, there
 frequently (for some value of frequent) are posts where the author
 inquires
 about a badly performing programme, in the form of stack overflows, space
 leaks or slowness.

 Often this is because they compiled their programme without optimisations,
 simply recompiling with -O or -O2 yields a decently performing programme.

 So I wonder, should ghc compile with -O1 by default?
 What would be the downsides?

 I understand the problem.  However, -O has a couple of serious downsides:

  1. it costs about 2x compile time and memory usage

  2. it forces a lot more recompilation to happen after changes,
     due to inter-module optimisations.

 most people know about 1, but I think 2 is probably less well-known. When in
 the edit-compile-debug cycle it really helps to have -O off, because your
 compiles will be so much quicker due to both factors 1  2.

 So the default -O setting is a careful compromise, trying to hit a good
 compile-time/runtime tradeoff.  Perhaps we're more sensitive in Haskell
 because -O can easily give you an order of magnitude or more speedup,
 whereas in C you're likely to get a pretty consistent 30% or so.  The
 difference between -O and -O2 is another careful tradeoff.

 Also bear in mind that using GHCi gives you another 2x speedup in
 compilation (approx), but 30x slowdown in runtime (varies wildly from
 program to program though).  And subsequent recompiles are much faster
 because GHCi has cached a lot of interfaces.

 I suppose we should really run an up to date set of benchmarks on some real
 Haskell programs (i.e. not nofib) and reconsider how we set these defaults.
  I really doubt that we'll want to turn on -O by default, though.

We should remember that we are only talking about which default leads
to the best outcome when, due to inexperience, someone fails to set
the option the way they want it.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling using gmake

2011-11-07 Thread David Fox
On Sat, Nov 5, 2011 at 4:41 PM, Christian Brolin cbro...@gmail.com wrote:
 Hello

 I try to set-up a gnu makefile for compiling Haskell programs with GHC. I
 want to generate dependencies automatically and I want to put my object (.o)
 files in a binary specifc directories to be able to compile for different
 architechtures. The problem is when GHC derives the dependencies it names
 the object file for the Main module to Main.o and not filename.o as it does
 if I don't specifiy an odir. This gives me two problems, first I cannot have
 more than one Main module in the same directory as I often need, e.g. for
 different test programs. The second problem is that it doesn't match my
 compile command which always names the object files after the the source
 files by just changing extensions from .hs to .o. So gmake does not
 recognize dependencies from my Main modules to other modules.

 I am stuck here. Any ideas?

I found early on that trying to use gmake with haskell is a losing
battle.  Maybe you could change your approach to use cabal?   That way
you can specify the build directory using something like runhaskell
Setup --builddir dist-whatever build

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Question on `runState'

2011-10-17 Thread David Fox
On Mon, Oct 17, 2011 at 5:32 PM, Conrad Parker con...@metadecks.org wrote:
 On 17 October 2011 23:59, Captain Freako capn.fre...@gmail.com wrote:
 In this excerpt from the `StateArrow' page:

 runState :: Arrow a = StateArrow s a e b - a (e, s) (b, s)Source

 what's the significance of having written StateArrow s a e b, instead of
 StateArrow s a b c?

 In the context of that page, do you think e might stand for something?

 btw. what's the URL?

http://hackage.haskell.org/packages/archive/arrows/0.4.1.2/doc/html/Control-Arrow-Transformer-State.html

I think maybe b is for beginning and e is for end?

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


Re: Use -V0 causes space to leak?

2011-09-16 Thread David Fox
On Thu, Sep 15, 2011 at 8:11 AM, Neil Davies
semanticphilosop...@gmail.com wrote:
 Hi

 I have some long running (multi-gigabit, multi-cpu hour) programs and as
 part of trying to speed up I thought I would set the -V0 flag - when I did
 this there was a slow space leak that caused it to blow the heap.

 Anyone out there have an explanation? Is there some garbage collection thing
 associated with something that -V0 suppresses?

If you mean -v0, maybe this is not a leak but rather an indefinite
postponement of garbage collection because no results have been
forced?

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell-cafe] Is it written down somewhere what sort of things belong in Data.*?

2011-08-22 Thread David Fox
I'm never quite sure what the distinction is that defines the modules
under Data.*.  Can anyone explain?

-david

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


Re: [Haskell-cafe] Diffs for hackage

2011-08-13 Thread David Fox
On Sat, Aug 13, 2011 at 5:18 AM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 On 13 August 2011 20:57, Joachim Breitner m...@joachim-breitner.de wrote:
 Maybe it would already help to add a changelog-file field to .cabal,
 just as with license-file, and reject packages on hackage that do not
 have this field and file, and later decide if we need a more
 standardized format for changelogs.

 I agree, but it would be nice to also have optional readme-file,
 todo-file and doc-files fields (the latter to let us avoid banging
 documentation in with extra-source-files).

 As for a standardised format... I'm not sure if we need to enforce a
 particular format, as long as it's understandable.

Debian's packaging has a very strict changelog format where each entry
combines a log entry with the package name, the version number, the
author's name and email, and the date.  This creates a very nice,
centralized, authoritative source for these pieces of information that
can't be accidentally omitted or allowed to become stale.

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


Re: [Haskell-cafe] Diffs for hackage

2011-08-13 Thread David Fox
On Sat, Aug 13, 2011 at 8:13 AM, Joachim Breitner
m...@joachim-breitner.de wrote:
 Hi,

 Am Sonntag, den 14.08.2011, 00:29 +1000 schrieb Ivan Lazar Miljenovic:
 On 14 August 2011 00:25, David Fox dds...@gmail.com wrote:
  Debian's packaging has a very strict changelog format where each entry
  combines a log entry with the package name, the version number, the
  author's name and email, and the date.  This creates a very nice,
  centralized, authoritative source for these pieces of information that
  can't be accidentally omitted or allowed to become stale.

 Is this for the actual Debian packages, or even for source tarballs
 that they get from upstream?

 it’s for the packaging work, here is an example:
 http://packages.debian.org/changelogs/pool/main/g/ghc/ghc_7.0.4-4/changelog

 But I think David is suggesting to adapt a similarly formatted changelog
 file for Cabal packages, e.g. to display them on hackage. I am all for
 that, as long as it does not prevent the introduction of changelogs
 (e.g. by excessive bikeshedding or by having people lose interest
 again).

If anyone wants to take a look, there is a parser for Debian's
changelog format in the debian package, module Debian.Changes:
http://hackage.haskell.org/package/debian

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


Re: [Haskell-cafe] Hackage internal server error

2011-05-24 Thread David Fox
On Tue, May 24, 2011 at 2:52 AM, Niklas Broberg
niklas.brob...@gmail.com wrote:

 nibro@nibro-laptop:~/src/haskell-src-exts$ cabal sdist
 Building source dist for haskell-src-exts-1.11.1...
 Preprocessing library haskell-src-exts-1.11.1...
 Source tarball created: dist/haskell-src-exts-1.11.1.tar.gz
 nibro@nibro-laptop:~/src/haskell-src-exts$ cabal upload
 dist/haskell-src-exts-1.11.1.tar.gz
 Hackage username: NiklasBroberg
 Hackage password:
 Uploading dist/haskell-src-exts-1.11.1.tar.gz...
 Error: dist/haskell-src-exts-1.11.1.tar.gz: 500 Internal Server Error
 500 Internal Server Error
 stdin: hWaitForInput: invalid argument (Invalid or incomplete multibyte or
 wide character)
 nibro@nibro-laptop:~/src/haskell-src-exts$


 Hackage's fault, cabal's fault, or (*gasp*) mine?

Here's my guess - there is a character in some non-unicode encoding in
one of the names in the cabal file.

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


Can't pull http://darcs.haskell.org/ghc

2010-11-15 Thread David Fox
I can neither darcs pull nor darcs get the repository at
http://darcs.haskell.org/ghc - it just hangs indefinitely.   Anyone
else having this problem?

-david
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Opportunity for Haskell porting to java at RD labs in Bay Area, CA

2010-11-11 Thread David Fox
I would hesitate to call it a terrible decision unless I had a good
idea of what the ratio of Java programmers to Haskell programmers was
out in the world.  Just sayin...

On Thu, Nov 11, 2010 at 7:14 AM, namekuseijin namekusei...@gmail.com wrote:
 given all Oracle woes in the last few months, I'd say this is a
 terrible timing and terrible decision.  How about instead an
 experienced Haskell programmer to best leverage it rather than a
 junior who's learned java at university and has just read Learn
 Haskell in 2 weeks?

 On Wed, Nov 10, 2010 at 6:42 PM, Padma pa...@sraoss.com wrote:
 We are looking for a entry level Haskell programmer who has experience in
 porting from Haskell to java. Please contact me by Email or you can call me
 at 408-207-9367.



 LOCATION: SUNNYVALE, CA

 DURATION: 6 MONTHS



 Degree: Bs or Ms or Ph.D

 Start immediately

 Good experience in porting particularly from Haskell to java environment.

 Check and validate smooth functioning of the system.(After porting is done)

 This is a RD project. (prior experience is desired)

 Good experience in testing and compiling.







 Regards,

 Padma

 SRAOSS INC.

 5300 Stevens Creek Blvd  Suite 460

 San Jose,CA 95129

 Direct:(408) 207-9367
 Tel: (408) 855-8200 x 321
 Fax: (408) 855-8206
 pa...@sraoss.com
 www.sraoss.com
 www.sra.co.jp



 ___
 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: new-www

2010-11-08 Thread David Fox
On Mon, Nov 1, 2010 at 4:10 AM, Brent Yorgey byor...@seas.upenn.edu wrote:
 On Sat, Oct 30, 2010 at 01:08:50PM +0400, Serge D. Mechveliani wrote:
 People,
 what is, in short, the relation between  www.haskell.org   and
 new-www.haskell.org ?
 Which one do I need to use for looking for the Haskell materials,
 for GHC materials?

 As far as I can tell, new-www is just a sample mock-up of a potential
 new design for www.haskell.org.  If you look carefully you will note
 that all the events listed at new-www are old.  www.haskell.org is
 and will continue to be the place to go.

new-www has the release directories for the ghc7 release candidates,
such as http://new-www.haskell.org/ghc/dist/7.0.1-rc2/.  These are not
present on www.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


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

2010-11-04 Thread David Fox
On Thu, Nov 4, 2010 at 2:41 PM, Albert Y. C. Lai tre...@vex.net wrote:
 On 10-11-03 10:00 PM, Jonathan Geddes wrote:

 It's called The *Ultimate* Computer Language Guide, and it's on the
 internets, so it must be correct, right?

 The correct conclusion: it's on the internets, so it must be LOL.

The stuff that is *not* on the internets must be really awesome - can
anyone give me a link to that?

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


Re: [Haskell-cafe] change in overlapping instance behavior between GHC 6.12 and GHC 7 causes compilation failure

2010-11-03 Thread David Fox
I would love to know the answer to this.

On Tue, Nov 2, 2010 at 3:36 PM, Jeremy Shaw jer...@n-heptane.com wrote:
 Hello,

 I have a module, XMLGenerator, which has some overlapping instances.
 I have a second module, Test, which imports that module and also adds
 some more overlapping instances.

 Both modules contain {-# LANGUAGE OverlappingInstances #-} at the top.

 Under some old version of 6.13 (and probably 6.12), if I put both
 modules in the same directory and try to load Test.hs, it gets the
 error:

 Test.hs:16:15:
    Overlapping instances for EmbedAsChild (M IO) (XMLGenT m (XML m))
      arising from a use of `asChild' at Test.hs:16:15-21
    Matching instances:
      instance (m1 ~ m, EmbedAsChild m c) =
               EmbedAsChild m (XMLGenT m1 c)
        -- Defined at XMLGenerator.hs:16:10-68
      instance (XML m ~ x, XMLGen m) = EmbedAsChild m x
        -- Defined at XMLGenerator.hs:19:10-51
    In the first argument of `($)', namely `asChild'
    In the expression: asChild $ (genElement foo)
    In the definition of `asChild':
        asChild b = asChild $ (genElement foo)

 If I put the XMLGenerator module in a separate package, dummy-hsx, and
 the Test modules links against it, I still get the error.

 *but* if I add:

  Extensions:      OverlappingInstances

 to the dummy-hsx.cabal file, then Test.hs compiles just fine! So, for
 starters, I do not understand why that happens.

 Under GHC 7.0rc1, modifying the .cabal file has no effect. Instead I
 always get the error:

 Test.hs:16:15:
    Overlapping instances for EmbedAsChild (M IO) (XMLGenT m (XML m))
      arising from a use of `asChild'
    Matching instances:
      instance [overlap ok] (m1 ~ m, EmbedAsChild m c) =
                            EmbedAsChild m (XMLGenT m1 c)
        -- Defined in XMLGenerator
    (The choice depends on the instantiation of `m'
     To pick the first instance above, use -XIncoherentInstances
     when compiling the other instance declarations)

 Adding the IncoherentInstances flag does make it compile -- but I have
 never enabled that flag and not regretted it.

 What changed between GHC 6.12 and GHC 7.0? Is there a some solution
 besides using IncoherentInstances in every module that imports
 XMLGenerator?

 I have attached XMLGenerator.hs, Test.hs, and dummy-hsx.cabal.

 thanks!
 - jeremy

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


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] change in overlapping instance behavior between GHC 6.12 and GHC 7 causes compilation failure

2010-11-03 Thread David Fox
I would love to know the answer to this.

On Tue, Nov 2, 2010 at 3:36 PM, Jeremy Shaw jer...@n-heptane.com wrote:
 Hello,

 I have a module, XMLGenerator, which has some overlapping instances.
 I have a second module, Test, which imports that module and also adds
 some more overlapping instances.

 Both modules contain {-# LANGUAGE OverlappingInstances #-} at the top.

 Under some old version of 6.13 (and probably 6.12), if I put both
 modules in the same directory and try to load Test.hs, it gets the
 error:

 Test.hs:16:15:
    Overlapping instances for EmbedAsChild (M IO) (XMLGenT m (XML m))
      arising from a use of `asChild' at Test.hs:16:15-21
    Matching instances:
      instance (m1 ~ m, EmbedAsChild m c) =
               EmbedAsChild m (XMLGenT m1 c)
        -- Defined at XMLGenerator.hs:16:10-68
      instance (XML m ~ x, XMLGen m) = EmbedAsChild m x
        -- Defined at XMLGenerator.hs:19:10-51
    In the first argument of `($)', namely `asChild'
    In the expression: asChild $ (genElement foo)
    In the definition of `asChild':
        asChild b = asChild $ (genElement foo)

 If I put the XMLGenerator module in a separate package, dummy-hsx, and
 the Test modules links against it, I still get the error.

 *but* if I add:

  Extensions:      OverlappingInstances

 to the dummy-hsx.cabal file, then Test.hs compiles just fine! So, for
 starters, I do not understand why that happens.

 Under GHC 7.0rc1, modifying the .cabal file has no effect. Instead I
 always get the error:

 Test.hs:16:15:
    Overlapping instances for EmbedAsChild (M IO) (XMLGenT m (XML m))
      arising from a use of `asChild'
    Matching instances:
      instance [overlap ok] (m1 ~ m, EmbedAsChild m c) =
                            EmbedAsChild m (XMLGenT m1 c)
        -- Defined in XMLGenerator
    (The choice depends on the instantiation of `m'
     To pick the first instance above, use -XIncoherentInstances
     when compiling the other instance declarations)

 Adding the IncoherentInstances flag does make it compile -- but I have
 never enabled that flag and not regretted it.

 What changed between GHC 6.12 and GHC 7.0? Is there a some solution
 besides using IncoherentInstances in every module that imports
 XMLGenerator?

 I have attached XMLGenerator.hs, Test.hs, and dummy-hsx.cabal.

 thanks!
 - jeremy

 ___
 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: making 7.01-pre

2010-10-30 Thread David Fox
On Sat, Oct 30, 2010 at 4:43 AM, Serge D. Mechveliani mech...@botik.ru wrote:
 Dear GHC developers,

 I am testing this fresh  ghc-7.0.0.20101028
 on  Debian Linux, i386-family.
 Making it from source by  ghc-6.12.3  is all right.
 Then, making it from source by itself reports
 (here I abbreviate the messages by inserting `...')

 -
 + test -f mk/config.mk.old
 + cp -p mk/config.mk mk/config.mk.old
 ...
 ...
 inplace/bin/mkdirhier utils/ghc-cabal/dist/build/tmp//.
 inplace/bin/mkdirhier bootstrapping/.
 /home/mechvel/ghc/7.01pre/inst1/bin/ghc -H32m -O --make
  utils/ghc-cabal/ghc-cabal.hs -o utils/ghc-cabal/dist/build/tmp/ghc-cabal
 ...
 ...
 rm -f compiler/stage1/ghc_boot_platform.h
 Creating compiler/stage1/ghc_boot_platform.h...
 Done.
 /usr/bin/gcc  -fno-stack-protector  -DTABLES_NEXT_TO_CODE -Iincludes
  -Irts  -DGEN_HASKELL  -c includes/mkDerivedConstants.c -o
 includes/dist-ghcconstants/build/mkDerivedConstants.o
 ...
 ...
 ...
 utils/genprimopcode/dist/build/Lexer.o: In function `s2yT_info':
 (.text+0x1e1d): undefined reference to
  `__stginit_arrayzm0zi3zi0zi2_DataziArray_'
 ...
 ...
 utils/genprimopcode/dist/build/Parser.o: In function `s4pK_info':
 (.text+0x5691): undefined reference to
 `__stginit_arrayzm0zi3zi0zi2_DataziArray_'
 collect2: ld returned 1 exit status
 make[1]: *** [utils/genprimopcode/dist/build/tmp/genprimopcode] Error 1
 make: *** [all] Error 2
 -

 Why cannot it make itself?

 Regards,

 -
 Serge Mechveliani
 mech...@botik.ru
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


I am also seeing this.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: making 7.01-pre

2010-10-30 Thread David Fox
On Sat, Oct 30, 2010 at 8:52 AM, David Fox dds...@gmail.com wrote:
 On Sat, Oct 30, 2010 at 4:43 AM, Serge D. Mechveliani mech...@botik.ru 
 wrote:
 Dear GHC developers,

 I am testing this fresh  ghc-7.0.0.20101028
 on  Debian Linux, i386-family.
 Making it from source by  ghc-6.12.3  is all right.
 Then, making it from source by itself reports
 (here I abbreviate the messages by inserting `...')

 -
 + test -f mk/config.mk.old
 + cp -p mk/config.mk mk/config.mk.old
 ...
 ...
 inplace/bin/mkdirhier utils/ghc-cabal/dist/build/tmp//.
 inplace/bin/mkdirhier bootstrapping/.
 /home/mechvel/ghc/7.01pre/inst1/bin/ghc -H32m -O --make
  utils/ghc-cabal/ghc-cabal.hs -o utils/ghc-cabal/dist/build/tmp/ghc-cabal
 ...
 ...
 rm -f compiler/stage1/ghc_boot_platform.h
 Creating compiler/stage1/ghc_boot_platform.h...
 Done.
 /usr/bin/gcc  -fno-stack-protector  -DTABLES_NEXT_TO_CODE -Iincludes
  -Irts  -DGEN_HASKELL  -c includes/mkDerivedConstants.c -o
 includes/dist-ghcconstants/build/mkDerivedConstants.o
 ...
 ...
 ...
 utils/genprimopcode/dist/build/Lexer.o: In function `s2yT_info':
 (.text+0x1e1d): undefined reference to
  `__stginit_arrayzm0zi3zi0zi2_DataziArray_'
 ...
 ...
 utils/genprimopcode/dist/build/Parser.o: In function `s4pK_info':
 (.text+0x5691): undefined reference to
 `__stginit_arrayzm0zi3zi0zi2_DataziArray_'
 collect2: ld returned 1 exit status
 make[1]: *** [utils/genprimopcode/dist/build/tmp/genprimopcode] Error 1
 make: *** [all] Error 2
 -

 Why cannot it make itself?

 Regards,

 -
 Serge Mechveliani
 mech...@botik.ru
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


 I am also seeing this.


Actually, I'm seeing these undefined symbols immediately rather than
on stage 2, I suppose because I'm bootstrapping with the 20100615
snapshot.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ANNOUNCE: GHC 7.0.1 Release Candidate 1

2010-09-28 Thread David Fox
I'm seeing errors like this in various places, which I guess are
coming from the new type checker:

Data/Array/Vector/Prim/BUArr.hs:663:3:
    Couldn't match type `s' with `s3'
  because this skolem type variable would escape: `s3'
    This skolem is bound by the polymorphic type `forall s. ST s a'
    The following variables have types that mention s
  fill0 :: MBUArr s e - ST s Int
    (bound at Data/Array/Vector/Prim/BUArr.hs:669:5)
    In the first argument of `runST', namely
  `(do { marr - newMBU n;
 n' - fill0 marr;
 unsafeFreezeMBU marr n' })'

I would love to hear an explanation about what they mean and what to
do about them.  (This one is from uvector.)
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ANNOUNCE: GHC 7.0.1 Release Candidate 1

2010-09-28 Thread David Fox
On Tue, Sep 28, 2010 at 8:36 PM, Antoine Latter aslat...@gmail.com wrote:
 On Tue, Sep 28, 2010 at 10:10 PM, David Fox dds...@gmail.com wrote:
 I'm seeing errors like this in various places, which I guess are
 coming from the new type checker:

 Data/Array/Vector/Prim/BUArr.hs:663:3:
     Couldn't match type `s' with `s3'
   because this skolem type variable would escape: `s3'
     This skolem is bound by the polymorphic type `forall s. ST s a'
     The following variables have types that mention s
   fill0 :: MBUArr s e - ST s Int
     (bound at Data/Array/Vector/Prim/BUArr.hs:669:5)
     In the first argument of `runST', namely
   `(do { marr - newMBU n;
  n' - fill0 marr;
  unsafeFreezeMBU marr n' })'


 GHC no longer generalizes local bindings - which means that while
 previously the 'where' defined function would have had a type:

 fill0 :: forall s .  ... - ST s Int

 Where the elipsis indicates an unspecified portion of the local type 
 signature.

 I would recommend writing a type signature, but that requires writing
 a type signature for it's helper function:

 fill s i = ...

 Except I don't know how to write a type signature for this.

 The value 's' passed in is bound by pattern matching on this guy's 
 constructor:

 data Stream a = forall s. Stream (s - Step s a) !s Int

 in the top-level function, so I don't even know if it has a type I can name.

 I'll try to boil this down to something I can put on hpaste.

 Antoine


I have to say, as an everyday joe programmer, that the obscurity of
this message disturbs me.  I hope I don't see it very often.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Version 7.0.1-rc1 bootstrapping

2010-09-27 Thread David Fox
On Mon, Sep 27, 2010 at 3:46 AM, Simon Marlow marlo...@gmail.com wrote:

 On 26/09/10 17:52, David Fox wrote:

 In order to bootstrap with the compiler we are using, I had to rename
 the function at line 13 of compiler/utils/Exception.hs from mask_ to
 mask.  Sorry I didn't reply to the announcement, I just found out I
 wasn't subscribed to this list.  (I also had to change 613 to 614, but
 this won't affect many people.)


 I presume you're bootstrapping using a 6.13 snapshot, and you had to
 configure with --enable-bootstrap-with-devel-snapshot?

 Cheers,
Simon


Yes, I forgot about that because its all inside a deb.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Version 7.0.1-rc1 bootstrapping

2010-09-26 Thread David Fox
In order to bootstrap with the compiler we are using, I had to rename the
function at line 13 of compiler/utils/Exception.hs from mask_ to mask.
Sorry I didn't reply to the announcement, I just found out I wasn't
subscribed to this list.  (I also had to change 613 to 614, but this won't
affect many people.)
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell-cafe] ghc 6.12.1 and regex

2009-12-29 Thread David Fox
Is anyone else seeing this problem:

 :m +Text.Regex.Posix
 \250 =~ \250 :: Bool
True
 \250 =~ [\250] :: Bool
False
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: ghc 6.12.1 and regex

2009-12-29 Thread David Fox
On Tue, Dec 29, 2009 at 7:28 AM, David Fox dds...@gmail.com wrote:
 Is anyone else seeing this problem:

 :m +Text.Regex.Posix
 \250 =~ \250 :: Bool
 True
 \250 =~ [\250] :: Bool
 False


Paul Tanimoto suggested TDFA, which gets me most of the way there.
However, it can't seem to handle match anything except a dash:

 xyz =~ ^[^-]*$ :: Bool
*** Exception: Explict error in module Text.Regex.TDFA.String :
Text.Regex.TDFA.String died: parseRegex for Text.Regex.TDFA.String
failed:^[^-]*$ (line 1, column 5):
unexpected ]
expecting Failed to parse bracketed string
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: ghc 6.12.1 and regex

2009-12-29 Thread David Fox
On Tue, Dec 29, 2009 at 10:23 AM, David Fox dds...@gmail.com wrote:
 On Tue, Dec 29, 2009 at 7:28 AM, David Fox dds...@gmail.com wrote:
 Is anyone else seeing this problem:

 :m +Text.Regex.Posix
 \250 =~ \250 :: Bool
 True
 \250 =~ [\250] :: Bool
 False


 Paul Tanimoto suggested TDFA, which gets me most of the way there.
 However, it can't seem to handle match anything except a dash:

 xyz =~ ^[^-]*$ :: Bool
 *** Exception: Explict error in module Text.Regex.TDFA.String :
 Text.Regex.TDFA.String died: parseRegex for Text.Regex.TDFA.String
 failed:^[^-]*$ (line 1, column 5):
 unexpected ]
 expecting Failed to parse bracketed string


Hmm this seems to work: ^[^--]$
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] SYB looping very, very mysteriously

2009-12-07 Thread David Fox
On Sat, Dec 5, 2009 at 2:38 AM, Andrea Vezzosi sanzhi...@gmail.com wrote:
 On Fri, Dec 4, 2009 at 8:51 PM, Jeremy Shaw jer...@n-heptane.com wrote:
 I have stripped things down to the bare minimum, and test under GHC 6.10,
 GHC 6.12, Linux, and Mac OS X. Results are consistent.

 In the following code,

  1. if you load the code into ghci and evaluate e it will hang, but
 (defaultValueD dict) :: Expression returns fine
  2. if you change the gunfold instance for Proposition to, error gunfold
 it stops hanging -- even though this code is never called.
  3. if you change, ( Data ctx [Expression], Sat (ctx Expression) = Data ctx
 Expression, to (Data ctx Expression, ) = ... it stops hanging.

 If someone could explain why each of these cases perform as they do, that
 would be awesome! Right now it is a big mystery to me.. e calls dict .. and
 there is only one instance of dict available, which should call error right
 away. I can't see how something could get in the way there...


 It's less of a mystery if you think about the actual dictionaries ghc
 uses to implement typeclasses.
 The instance for Data ctx [a] depends on Data ctx a, so by requiring
 Data ctx [Expression] in the Data ctx Expression instance you're
 indeed making a loop there, though typeclasses do allow this, and the
 implementation has to be lazy enough to permit it.
 Strange that with a direct Data ctx Expression = Data ctx Expression
 loop we don't get the same problem.
 The reason the implementation of Proposition's gunfold matters is
 probably that k gets passed the dictionary for Data DefaultD
 Expression at the site of its call and some optimization is making it
 stricter than necessary.

 Looks like we need a ghc dev here to fully unravel the mystery, in the
 meantime i'll try to reduce the test case even further.

I have posted a ghc bug for this:
http://hackage.haskell.org/trac/ghc/ticket/3731
and an syb-with-class bug, in case it is not a ghc bug (perhaps due to
undecidable 
instances?):http://code.google.com/p/syb-with-class/issues/detail?id=3
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] SYB looping very, very mysteriously

2009-12-04 Thread David Fox
I have created an entry in the syb-with-class issue database
here:http://code.google.com/p/syb-with-class/issues/detail?id=3

I attached a version of the code with the necessary bits of
Happstack.Data.Default included in-line.

On Thu, Dec 3, 2009 at 2:50 PM, Jeremy Shaw jer...@n-heptane.com wrote:
 I have the following program which loops under GHC 6.10.4:

 http://www.hpaste.org/fastcgi/hpaste.fcgi/view?id=13561#a13561

 {-# LANGUAGE DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses,
 UndecidableInstances #-}
 module Main where

 import qualified Data.Data as Data
 import Data.Typeable (Typeable)
 import Happstack.Data.Default
 import Data.Generics.SYB.WithClass.Basics
 import Data.Generics.SYB.WithClass.Instances ()

 data Proposition = Proposition Expression  deriving (Show, Data.Data,
 Typeable)
 data Expression = Conjunction (Maybe Expression) deriving (Show, Data.Data,
 Typeable)

 -- instance (Sat (ctx [Expression]), Sat (ctx Expression), Sat (ctx
 Proposition)) = Data ctx Proposition where
 instance Data DefaultD Proposition where
    gunfold _ k z c =
        case constrIndex c of
          1 - k (z Proposition)
 instance Default Proposition

 constrExpr :: Constr
 constrExpr = mkConstr dataTypeExpr Conjuction [] Prefix

 dataTypeExpr :: DataType
 dataTypeExpr = mkDataType Expression [constrExpr]

 instance ( Data ctx [Expression]
         , Sat  (ctx Expression)
         , Sat  (ctx (Maybe Expression))) = Data ctx Expression where
 {-
 instance Data DefaultD Expression where
 -}
    gunfold _ k z c =
        case constrIndex c of
          1 - k (z Conjunction)
    dataTypeOf _ _ = dataTypeExpr

 instance Default Expression

 e :: Expression
 e =  defaultValueD dict

 main = print e

 I wish to explain the *many* ways in which it is mysterious. If you load the
 program into GHCi and evaluate 'e' it will hang. If you compile the program
 and run it, it will output loop. This behavior seems annoying, but not
 very weird. But, here is where it gets fun:

 1. if you load the program into GHCi and eval 'e' it will hang. But, if you
 load the program and type, '(defaultValueD dict) :: Expression' at the
 prompt, it works fine!

 2. if you remove the (Data DefaultD Proposition) instance, it  works fine.
 (Even though Expression does not refer to Proposition in any way)

 3. if you simply change the definition of 'gunfold' in the 'Data ctx
 Proposition' instance to, error foo. The application works fine. That's
 right, if you change the body of a function that isn't even being called,
 evaluating 'e' starts working. (Even though Expression does not refer to
 Proposition in any way. And even though that gunfold instance is never
 actually called).

 4. if you change the constraint on, Data ctx Expression,  from (Data ctx
 [Expression]) to (Data ctx Expression) it works fine. (Or remove it all
 together).

 5. if you change 'instance (Data DefaultD Proposition) where' to the line
 above it which is commented out, it works fine.

 6. if you change the type of Proposition to, data Proposition = Proposition
 (Expression, Expression), then it works fine.

 So far I have only tested this in GHC 6.10.4.

 Any idea what is going on here? I can't imagine how changing the body of
 functions that aren't being called would fix things...

 - jeremy
 ___
 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] Community.haskell.org is down

2009-09-13 Thread David Fox
I assume this is the same as code.haskell.org, which is also down?

On Sun, Sep 13, 2009 at 10:31 AM, Joe Fredette jfred...@gmail.com wrote:

 Confirmed for me, I actually have no idea who owns C.H.O, but a WHOIS gives
 the Yale University Comp. Sci. Dept. Haskell Group as the registrant, maybe
 someone over there needs to take a look?

 /Joe


 On Sep 13, 2009, at 1:17 PM, Neil Mitchell wrote:

  Hi,

 http://community.haskell.org/ seems to be down for me. In general, who
 should this be reported to?

 Thanks

 Neil
 ___
 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] Data.Generics.gzip3 anyone?

2009-08-08 Thread David Fox
Ok, here is another piece of the three way merging puzzle.  The gzip3
function can do three
way merging when there are no conflicts that need to be resolved manually.
When there are
such conflicts we need a user interface which displays the common ancestor,
the two alternative
edits, and provides a place to input the merged result.  For this we are
using a generic
programming interface to formlets .  Formlets are members of class
Applicative, so we can write
a function to turn a value into a formlet using a gmapA function (this is
syb-with-class generics):

  type GenericA f ctx = forall a. (Applicative f, Data ctx a) = a - f a

  gmapA :: (Applicative f) = Proxy ctx - GenericA f ctx - GenericA f ctx
  gmapA ctx f =
gfoldl ctx k pure
where k c x = c * (f x)

Then the formlet for a value is created using something like this:

  gmapA formletOfProxy (formletOfD dict) x

For three way merging, though, we need to turn three values of the same type
into a formlet,
something like a gmap3A function:

  gmap3A formletOfProxy (formletOfD dict) ancestor variant1 variant2

Its this gmap3A function that I'm unable to create.  I'm hoping someone out
there will find this
a piece of cake...

On Mon, Jun 1, 2009 at 3:40 PM, Ralf Laemmel rlaem...@gmail.com wrote:

  Thank you!  What I have in mind is three way merging - you have two
  revisions based on the same original value, and you need to decide
 whether
  they can be merged automatically or they need to be merged by a user.
 You
  only have a real conflict when both revisions differ from the original
 and
  from each other.

 Here is the completed exercise.
 For comparison, the two args versions are shown up-front.
 There is gzipWithM3 needed for gzip3, and gzip3 itself.
 I also made it so that the top-level gzip functions have the
 appropriate polymorphism.
 Say same type for the args rather than independent polymorphism.

 {-# LANGUAGE RankNTypes #-}

 import Prelude hiding (GT)
 import Data.Generics

 -- As originally defined: Twin map for transformation

 gzipWithT2 :: GenericQ (GenericT) - GenericQ (GenericT)
 gzipWithT2 f x y = case gmapAccumT perkid funs y of
([], c) - c
_   - error gzipWithT2
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = gmapQ (\k - GT (f k)) x


 -- As originally defined: Twin map for transformation

 gzipWithM2 :: Monad m = GenericQ (GenericM m) - GenericQ (GenericM m)
 gzipWithM2 f x y = case gmapAccumM perkid funs y of
([], c) - c
_   - error gzipWithM
  where
  perkid a d = (tail a, unGM (head a) d)
  funs = gmapQ (\k - GM (f k)) x


 -- As originally defined: generic zip

 gzip2 ::
(forall x. Data x = x - x - Maybe x)
  - (forall x. Data x = x - x - Maybe x)

 gzip2 f = gzip2' f'
  where
  f' :: GenericQ (GenericM Maybe)
  f' x y = cast x = \x' - f x' y
  gzip2' :: GenericQ (GenericM Maybe) - GenericQ (GenericM Maybe)
  gzip2' f x y =
f x y
`orElse`
if toConstr x == toConstr y
  then gzipWithM2 (gzip2' f) x y
  else Nothing


 -- For three args now

 gzipWithT3 ::
GenericQ (GenericQ (GenericT))
  - GenericQ (GenericQ (GenericT))
 gzipWithT3 f x y z =
case gmapAccumT perkid funs z of
  ([], c) - c
  _   - error gzipWithT3
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
   _   - error gzipWithT3
   where
perkid' a d = (tail a, unGQ (head a) d)
funs' = gmapQ (\k - (GQ (\k' - GT (f k k' x

 gzipWithM3 :: Monad m
  = GenericQ (GenericQ (GenericM m))
  - GenericQ (GenericQ (GenericM m))
 gzipWithM3 f x y z =
case gmapAccumM perkid funs z of
  ([], c) - c
  _   - error gzipWithM3
  where
  perkid a d = (tail a, unGM (head a) d)
   funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
_   - error gzipWithM3
where
perkid' a d = (tail a, unGQ (head a) d)
 funs' = gmapQ (\k - (GQ (\k' - GM (f k k' x

 gzip3 ::
(forall x. Data x = x - x - x - Maybe x)
  - (forall x. Data x = x - x - x - Maybe x)

 gzip3 f = gzip3' f'
  where
  f' :: GenericQ (GenericQ (GenericM Maybe))
  f' x y z = cast x = \x' - cast y = \y' - f x' y' z
  gzip3' ::
   GenericQ (GenericQ (GenericM Maybe))
- GenericQ (GenericQ (GenericM Maybe))
  gzip3' f x y z =
f x y z
`orElse`
if and [toConstr x == toConstr y, toConstr y == toConstr z]
  then gzipWithM3 (gzip3' f) x y z
  else Nothing

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


Re: [Haskell] Data.Generics.gzip3 anyone?

2009-08-08 Thread David Fox
On Sat, Aug 8, 2009 at 4:05 PM, David Fox dds...@gmail.com wrote:

 Ok, here is another piece of the three way merging puzzle.  The gzip3
 function can do three
 way merging when there are no conflicts that need to be resolved manually.
 When there are
 such conflicts we need a user interface which displays the common ancestor,
 the two alternative
 edits, and provides a place to input the merged result.  For this we are
 using a generic
 programming interface to formlets .  Formlets are members of class
 Applicative, so we can write
 a function to turn a value into a formlet using a gmapA function (this is
 syb-with-class generics):

   type GenericA f ctx = forall a. (Applicative f, Data ctx a) = a - f a

   gmapA :: (Applicative f) = Proxy ctx - GenericA f ctx - GenericA f ctx
   gmapA ctx f =
 gfoldl ctx k pure
 where k c x = c * (f x)

 Then the formlet for a value is created using something like this:

   gmapA formletOfProxy (formletOfD dict) x

 For three way merging, though, we need to turn three values of the same
 type into a formlet,
 something like a gmap3A function:

   gmap3A formletOfProxy (formletOfD dict) ancestor variant1 variant2


I guess this should be a more like this:

gmap3A formletOfProxy (formletOf3WayMergeD dict) ancestor variant1
variant2

when converting a value of an arbitrary algebraic type, and
formletOf3WayMerge would have
custom implementations for various primitive and more specialized types.



 Its this gmap3A function that I'm unable to create.  I'm hoping someone out
 there will find this
 a piece of cake...


 On Mon, Jun 1, 2009 at 3:40 PM, Ralf Laemmel rlaem...@gmail.com wrote:

  Thank you!  What I have in mind is three way merging - you have two
  revisions based on the same original value, and you need to decide
 whether
  they can be merged automatically or they need to be merged by a user.
 You
  only have a real conflict when both revisions differ from the original
 and
  from each other.

 Here is the completed exercise.
 For comparison, the two args versions are shown up-front.
 There is gzipWithM3 needed for gzip3, and gzip3 itself.
 I also made it so that the top-level gzip functions have the
 appropriate polymorphism.
 Say same type for the args rather than independent polymorphism.

 {-# LANGUAGE RankNTypes #-}

 import Prelude hiding (GT)
 import Data.Generics

 -- As originally defined: Twin map for transformation

 gzipWithT2 :: GenericQ (GenericT) - GenericQ (GenericT)
 gzipWithT2 f x y = case gmapAccumT perkid funs y of
([], c) - c
_   - error gzipWithT2
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = gmapQ (\k - GT (f k)) x


 -- As originally defined: Twin map for transformation

 gzipWithM2 :: Monad m = GenericQ (GenericM m) - GenericQ (GenericM m)
 gzipWithM2 f x y = case gmapAccumM perkid funs y of
([], c) - c
_   - error gzipWithM
  where
  perkid a d = (tail a, unGM (head a) d)
  funs = gmapQ (\k - GM (f k)) x


 -- As originally defined: generic zip

 gzip2 ::
(forall x. Data x = x - x - Maybe x)
  - (forall x. Data x = x - x - Maybe x)

 gzip2 f = gzip2' f'
  where
  f' :: GenericQ (GenericM Maybe)
  f' x y = cast x = \x' - f x' y
  gzip2' :: GenericQ (GenericM Maybe) - GenericQ (GenericM Maybe)
  gzip2' f x y =
f x y
`orElse`
if toConstr x == toConstr y
  then gzipWithM2 (gzip2' f) x y
  else Nothing


 -- For three args now

 gzipWithT3 ::
GenericQ (GenericQ (GenericT))
  - GenericQ (GenericQ (GenericT))
 gzipWithT3 f x y z =
case gmapAccumT perkid funs z of
  ([], c) - c
  _   - error gzipWithT3
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
   _   - error gzipWithT3
   where
perkid' a d = (tail a, unGQ (head a) d)
funs' = gmapQ (\k - (GQ (\k' - GT (f k k' x

 gzipWithM3 :: Monad m
  = GenericQ (GenericQ (GenericM m))
  - GenericQ (GenericQ (GenericM m))
 gzipWithM3 f x y z =
case gmapAccumM perkid funs z of
  ([], c) - c
  _   - error gzipWithM3
  where
  perkid a d = (tail a, unGM (head a) d)
   funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
_   - error gzipWithM3
where
perkid' a d = (tail a, unGQ (head a) d)
 funs' = gmapQ (\k - (GQ (\k' - GM (f k k' x

 gzip3 ::
(forall x. Data x = x - x - x - Maybe x)
  - (forall x. Data x = x - x - x - Maybe x)

 gzip3 f = gzip3' f'
  where
  f' :: GenericQ (GenericQ (GenericM Maybe))
  f' x y z = cast x = \x' - cast y = \y' - f x' y' z
  gzip3' ::
   GenericQ (GenericQ (GenericM Maybe))
- GenericQ (GenericQ (GenericM Maybe))
  gzip3' f x y z =
f x y z
`orElse`
if and [toConstr x == toConstr y, toConstr y == toConstr z]
  then gzipWithM3 (gzip3' f) x y z
  else Nothing



___
Haskell mailing list
Haskell

[Haskell-cafe] Can you determine a constructor's arity using Data.Typeable and Data.Data?

2009-06-25 Thread David Fox
Is it possible to determine the arity of a value's constructor?
Suppose I have a value x of type

  data A = B Int | C

They typeOf function returns its TypeRep, which contains its type
constructor, but I don't see how to decide whether that
constructor's arity is 0 or 1.  If the type has field names
I can look at those using Data.Data.conFields and count them,
but if it doesn't I don't see how to do it.

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


Re: [Haskell-cafe] Can you determine a constructor's arity using Data.Typeable and Data.Data?

2009-06-25 Thread David Fox
Oh, that make sense!

2009/6/25 José Pedro Magalhães j...@cs.uu.nl

 Hey David,

 For instance:

 arity :: (Data a) = a - Int
 arity = length . gmapQ (const ())



 Cheers,
 Pedro

 On Thu, Jun 25, 2009 at 17:31, David Fox dds...@gmail.com wrote:

 Is it possible to determine the arity of a value's constructor?
 Suppose I have a value x of type

   data A = B Int | C

 They typeOf function returns its TypeRep, which contains its type
 constructor, but I don't see how to decide whether that
 constructor's arity is 0 or 1.  If the type has field names
 I can look at those using Data.Data.conFields and count them,
 but if it doesn't I don't see how to do it.

 -david


 ___
 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] Data.Generics.gzip3 anyone?

2009-06-05 Thread David Fox
I definitely think these functions should be added to syb.  I certainly
could not have written them myself without hours, perhaps days, of study.

2009/6/2 José Pedro Magalhães j...@cs.uu.nl

 Hello,

 Would there be interest in having this function added to the SYB library?


 Thanks,
 Pedro

 On Tue, Jun 2, 2009 at 00:40, Ralf Laemmel rlaem...@gmail.com wrote:

  Thank you!  What I have in mind is three way merging - you have two
  revisions based on the same original value, and you need to decide
 whether
  they can be merged automatically or they need to be merged by a user.
 You
  only have a real conflict when both revisions differ from the original
 and
  from each other.

 Here is the completed exercise.
 For comparison, the two args versions are shown up-front.
 There is gzipWithM3 needed for gzip3, and gzip3 itself.
 I also made it so that the top-level gzip functions have the
 appropriate polymorphism.
 Say same type for the args rather than independent polymorphism.

 {-# LANGUAGE RankNTypes #-}

 import Prelude hiding (GT)
 import Data.Generics

 -- As originally defined: Twin map for transformation

 gzipWithT2 :: GenericQ (GenericT) - GenericQ (GenericT)
 gzipWithT2 f x y = case gmapAccumT perkid funs y of
([], c) - c
_   - error gzipWithT2
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = gmapQ (\k - GT (f k)) x


 -- As originally defined: Twin map for transformation

 gzipWithM2 :: Monad m = GenericQ (GenericM m) - GenericQ (GenericM m)
 gzipWithM2 f x y = case gmapAccumM perkid funs y of
([], c) - c
_   - error gzipWithM
  where
  perkid a d = (tail a, unGM (head a) d)
  funs = gmapQ (\k - GM (f k)) x


 -- As originally defined: generic zip

 gzip2 ::
(forall x. Data x = x - x - Maybe x)
  - (forall x. Data x = x - x - Maybe x)

 gzip2 f = gzip2' f'
  where
  f' :: GenericQ (GenericM Maybe)
  f' x y = cast x = \x' - f x' y
  gzip2' :: GenericQ (GenericM Maybe) - GenericQ (GenericM Maybe)
  gzip2' f x y =
f x y
`orElse`
if toConstr x == toConstr y
  then gzipWithM2 (gzip2' f) x y
  else Nothing


 -- For three args now

 gzipWithT3 ::
GenericQ (GenericQ (GenericT))
  - GenericQ (GenericQ (GenericT))
 gzipWithT3 f x y z =
case gmapAccumT perkid funs z of
  ([], c) - c
  _   - error gzipWithT3
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
   _   - error gzipWithT3
   where
perkid' a d = (tail a, unGQ (head a) d)
funs' = gmapQ (\k - (GQ (\k' - GT (f k k' x

 gzipWithM3 :: Monad m
  = GenericQ (GenericQ (GenericM m))
  - GenericQ (GenericQ (GenericM m))
 gzipWithM3 f x y z =
case gmapAccumM perkid funs z of
  ([], c) - c
  _   - error gzipWithM3
  where
  perkid a d = (tail a, unGM (head a) d)
   funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
_   - error gzipWithM3
where
perkid' a d = (tail a, unGQ (head a) d)
 funs' = gmapQ (\k - (GQ (\k' - GM (f k k' x

 gzip3 ::
(forall x. Data x = x - x - x - Maybe x)
  - (forall x. Data x = x - x - x - Maybe x)

 gzip3 f = gzip3' f'
  where
  f' :: GenericQ (GenericQ (GenericM Maybe))
  f' x y z = cast x = \x' - cast y = \y' - f x' y' z
  gzip3' ::
   GenericQ (GenericQ (GenericM Maybe))
- GenericQ (GenericQ (GenericM Maybe))
  gzip3' f x y z =
f x y z
`orElse`
if and [toConstr x == toConstr y, toConstr y == toConstr z]
  then gzipWithM3 (gzip3' f) x y z
  else Nothing
 ___
 Haskell mailing list
 Haskell@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell



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


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


Re: [Haskell] Data.Generics.gzip3 anyone?

2009-06-03 Thread David Fox
Wait, its much funnier than that.  It wouldn't merge the three revisions
because they always differed in one field - the revision number!

On Tue, Jun 2, 2009 at 4:57 PM, David Fox dds...@gmail.com wrote:



 On Tue, Jun 2, 2009 at 1:13 PM, David Fox dds...@gmail.com wrote:

 On Mon, Jun 1, 2009 at 3:40 PM, Ralf Laemmel rlaem...@gmail.com wrote:

  Thank you!  What I have in mind is three way merging - you have two
  revisions based on the same original value, and you need to decide
 whether
  they can be merged automatically or they need to be merged by a user.
 You
  only have a real conflict when both revisions differ from the original
 and
  from each other.

 Here is the completed exercise.
 For comparison, the two args versions are shown up-front.
 There is gzipWithM3 needed for gzip3, and gzip3 itself.
 I also made it so that the top-level gzip functions have the
 appropriate polymorphism.
 Say same type for the args rather than independent polymorphism.

 {-# LANGUAGE RankNTypes #-}

 import Prelude hiding (GT)
 import Data.Generics

 -- As originally defined: Twin map for transformation

 gzipWithT2 :: GenericQ (GenericT) - GenericQ (GenericT)
 gzipWithT2 f x y = case gmapAccumT perkid funs y of
([], c) - c
_   - error gzipWithT2
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = gmapQ (\k - GT (f k)) x


 -- As originally defined: Twin map for transformation

 gzipWithM2 :: Monad m = GenericQ (GenericM m) - GenericQ (GenericM m)
 gzipWithM2 f x y = case gmapAccumM perkid funs y of
([], c) - c
_   - error gzipWithM
  where
  perkid a d = (tail a, unGM (head a) d)
  funs = gmapQ (\k - GM (f k)) x


 -- As originally defined: generic zip

 gzip2 ::
(forall x. Data x = x - x - Maybe x)
  - (forall x. Data x = x - x - Maybe x)

 gzip2 f = gzip2' f'
  where
  f' :: GenericQ (GenericM Maybe)
  f' x y = cast x = \x' - f x' y
  gzip2' :: GenericQ (GenericM Maybe) - GenericQ (GenericM Maybe)
  gzip2' f x y =
f x y
`orElse`
if toConstr x == toConstr y
  then gzipWithM2 (gzip2' f) x y
  else Nothing


 -- For three args now

 gzipWithT3 ::
GenericQ (GenericQ (GenericT))
  - GenericQ (GenericQ (GenericT))
 gzipWithT3 f x y z =
case gmapAccumT perkid funs z of
  ([], c) - c
  _   - error gzipWithT3
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
   _   - error gzipWithT3
   where
perkid' a d = (tail a, unGQ (head a) d)
funs' = gmapQ (\k - (GQ (\k' - GT (f k k' x

 gzipWithM3 :: Monad m
  = GenericQ (GenericQ (GenericM m))
  - GenericQ (GenericQ (GenericM m))
 gzipWithM3 f x y z =
case gmapAccumM perkid funs z of
  ([], c) - c
  _   - error gzipWithM3
  where
  perkid a d = (tail a, unGM (head a) d)
   funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
_   - error gzipWithM3
where
perkid' a d = (tail a, unGQ (head a) d)
 funs' = gmapQ (\k - (GQ (\k' - GM (f k k' x

 gzip3 ::
(forall x. Data x = x - x - x - Maybe x)
  - (forall x. Data x = x - x - x - Maybe x)

 gzip3 f = gzip3' f'
  where
  f' :: GenericQ (GenericQ (GenericM Maybe))
  f' x y z = cast x = \x' - cast y = \y' - f x' y' z
  gzip3' ::
   GenericQ (GenericQ (GenericM Maybe))
- GenericQ (GenericQ (GenericM Maybe))
  gzip3' f x y z =
f x y z
`orElse`
if and [toConstr x == toConstr y, toConstr y == toConstr z]
  then gzipWithM3 (gzip3' f) x y z
  else Nothing


 Ok, what I initially thought would work is not.  I tried to do the three
 way merge as follows:

 combine3 :: (Data a) = a - a - a - Maybe a
 combine3 original left right =
 gzip3 f original left right
 where
   f :: forall a. (Data a) = a - a - a - Maybe a
   f original left right
   | geq original left = Just right
   | geq original right = Just left
   | geq left right = Just left
   | otherwise = Nothing

 However, what happens is that we usually reach the otherwise clause when
 processing the top level of the data structure, so you get nothing.  What
 really needs to happen is that it traverses down into the data structure and
 finds out that f is able to merge all the more primitive pieces of the data
 structure, in which case it combines those merged parts to yield a merged
 whole.  I'm not quite sure how to fit this operation into the generic
 framework.


 Oh, I got it.  I have to remove the f x y z `orElse` from the definition
 of gzip3.


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


Re: [Haskell] Data.Generics.gzip3 anyone?

2009-06-02 Thread David Fox
On Mon, Jun 1, 2009 at 3:40 PM, Ralf Laemmel rlaem...@gmail.com wrote:

  Thank you!  What I have in mind is three way merging - you have two
  revisions based on the same original value, and you need to decide
 whether
  they can be merged automatically or they need to be merged by a user.
 You
  only have a real conflict when both revisions differ from the original
 and
  from each other.

 Here is the completed exercise.
 For comparison, the two args versions are shown up-front.
 There is gzipWithM3 needed for gzip3, and gzip3 itself.
 I also made it so that the top-level gzip functions have the
 appropriate polymorphism.
 Say same type for the args rather than independent polymorphism.

 {-# LANGUAGE RankNTypes #-}

 import Prelude hiding (GT)
 import Data.Generics

 -- As originally defined: Twin map for transformation

 gzipWithT2 :: GenericQ (GenericT) - GenericQ (GenericT)
 gzipWithT2 f x y = case gmapAccumT perkid funs y of
([], c) - c
_   - error gzipWithT2
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = gmapQ (\k - GT (f k)) x


 -- As originally defined: Twin map for transformation

 gzipWithM2 :: Monad m = GenericQ (GenericM m) - GenericQ (GenericM m)
 gzipWithM2 f x y = case gmapAccumM perkid funs y of
([], c) - c
_   - error gzipWithM
  where
  perkid a d = (tail a, unGM (head a) d)
  funs = gmapQ (\k - GM (f k)) x


 -- As originally defined: generic zip

 gzip2 ::
(forall x. Data x = x - x - Maybe x)
  - (forall x. Data x = x - x - Maybe x)

 gzip2 f = gzip2' f'
  where
  f' :: GenericQ (GenericM Maybe)
  f' x y = cast x = \x' - f x' y
  gzip2' :: GenericQ (GenericM Maybe) - GenericQ (GenericM Maybe)
  gzip2' f x y =
f x y
`orElse`
if toConstr x == toConstr y
  then gzipWithM2 (gzip2' f) x y
  else Nothing


 -- For three args now

 gzipWithT3 ::
GenericQ (GenericQ (GenericT))
  - GenericQ (GenericQ (GenericT))
 gzipWithT3 f x y z =
case gmapAccumT perkid funs z of
  ([], c) - c
  _   - error gzipWithT3
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
   _   - error gzipWithT3
   where
perkid' a d = (tail a, unGQ (head a) d)
funs' = gmapQ (\k - (GQ (\k' - GT (f k k' x

 gzipWithM3 :: Monad m
  = GenericQ (GenericQ (GenericM m))
  - GenericQ (GenericQ (GenericM m))
 gzipWithM3 f x y z =
case gmapAccumM perkid funs z of
  ([], c) - c
  _   - error gzipWithM3
  where
  perkid a d = (tail a, unGM (head a) d)
   funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
_   - error gzipWithM3
where
perkid' a d = (tail a, unGQ (head a) d)
 funs' = gmapQ (\k - (GQ (\k' - GM (f k k' x

 gzip3 ::
(forall x. Data x = x - x - x - Maybe x)
  - (forall x. Data x = x - x - x - Maybe x)

 gzip3 f = gzip3' f'
  where
  f' :: GenericQ (GenericQ (GenericM Maybe))
  f' x y z = cast x = \x' - cast y = \y' - f x' y' z
  gzip3' ::
   GenericQ (GenericQ (GenericM Maybe))
- GenericQ (GenericQ (GenericM Maybe))
  gzip3' f x y z =
f x y z
`orElse`
if and [toConstr x == toConstr y, toConstr y == toConstr z]
  then gzipWithM3 (gzip3' f) x y z
  else Nothing


Ok, what I initially thought would work is not.  I tried to do the three way
merge as follows:

combine3 :: (Data a) = a - a - a - Maybe a
combine3 original left right =
gzip3 f original left right
where
  f :: forall a. (Data a) = a - a - a - Maybe a
  f original left right
  | geq original left = Just right
  | geq original right = Just left
  | geq left right = Just left
  | otherwise = Nothing

However, what happens is that we usually reach the otherwise clause when
processing the top level of the data structure, so you get nothing.  What
really needs to happen is that it traverses down into the data structure and
finds out that f is able to merge all the more primitive pieces of the data
structure, in which case it combines those merged parts to yield a merged
whole.  I'm not quite sure how to fit this operation into the generic
framework.
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Data.Generics.gzip3 anyone?

2009-06-02 Thread David Fox
On Tue, Jun 2, 2009 at 1:13 PM, David Fox dds...@gmail.com wrote:

 On Mon, Jun 1, 2009 at 3:40 PM, Ralf Laemmel rlaem...@gmail.com wrote:

  Thank you!  What I have in mind is three way merging - you have two
  revisions based on the same original value, and you need to decide
 whether
  they can be merged automatically or they need to be merged by a user.
 You
  only have a real conflict when both revisions differ from the original
 and
  from each other.

 Here is the completed exercise.
 For comparison, the two args versions are shown up-front.
 There is gzipWithM3 needed for gzip3, and gzip3 itself.
 I also made it so that the top-level gzip functions have the
 appropriate polymorphism.
 Say same type for the args rather than independent polymorphism.

 {-# LANGUAGE RankNTypes #-}

 import Prelude hiding (GT)
 import Data.Generics

 -- As originally defined: Twin map for transformation

 gzipWithT2 :: GenericQ (GenericT) - GenericQ (GenericT)
 gzipWithT2 f x y = case gmapAccumT perkid funs y of
([], c) - c
_   - error gzipWithT2
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = gmapQ (\k - GT (f k)) x


 -- As originally defined: Twin map for transformation

 gzipWithM2 :: Monad m = GenericQ (GenericM m) - GenericQ (GenericM m)
 gzipWithM2 f x y = case gmapAccumM perkid funs y of
([], c) - c
_   - error gzipWithM
  where
  perkid a d = (tail a, unGM (head a) d)
  funs = gmapQ (\k - GM (f k)) x


 -- As originally defined: generic zip

 gzip2 ::
(forall x. Data x = x - x - Maybe x)
  - (forall x. Data x = x - x - Maybe x)

 gzip2 f = gzip2' f'
  where
  f' :: GenericQ (GenericM Maybe)
  f' x y = cast x = \x' - f x' y
  gzip2' :: GenericQ (GenericM Maybe) - GenericQ (GenericM Maybe)
  gzip2' f x y =
f x y
`orElse`
if toConstr x == toConstr y
  then gzipWithM2 (gzip2' f) x y
  else Nothing


 -- For three args now

 gzipWithT3 ::
GenericQ (GenericQ (GenericT))
  - GenericQ (GenericQ (GenericT))
 gzipWithT3 f x y z =
case gmapAccumT perkid funs z of
  ([], c) - c
  _   - error gzipWithT3
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
   _   - error gzipWithT3
   where
perkid' a d = (tail a, unGQ (head a) d)
funs' = gmapQ (\k - (GQ (\k' - GT (f k k' x

 gzipWithM3 :: Monad m
  = GenericQ (GenericQ (GenericM m))
  - GenericQ (GenericQ (GenericM m))
 gzipWithM3 f x y z =
case gmapAccumM perkid funs z of
  ([], c) - c
  _   - error gzipWithM3
  where
  perkid a d = (tail a, unGM (head a) d)
   funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
_   - error gzipWithM3
where
perkid' a d = (tail a, unGQ (head a) d)
 funs' = gmapQ (\k - (GQ (\k' - GM (f k k' x

 gzip3 ::
(forall x. Data x = x - x - x - Maybe x)
  - (forall x. Data x = x - x - x - Maybe x)

 gzip3 f = gzip3' f'
  where
  f' :: GenericQ (GenericQ (GenericM Maybe))
  f' x y z = cast x = \x' - cast y = \y' - f x' y' z
  gzip3' ::
   GenericQ (GenericQ (GenericM Maybe))
- GenericQ (GenericQ (GenericM Maybe))
  gzip3' f x y z =
f x y z
`orElse`
if and [toConstr x == toConstr y, toConstr y == toConstr z]
  then gzipWithM3 (gzip3' f) x y z
  else Nothing


 Ok, what I initially thought would work is not.  I tried to do the three
 way merge as follows:

 combine3 :: (Data a) = a - a - a - Maybe a
 combine3 original left right =
 gzip3 f original left right
 where
   f :: forall a. (Data a) = a - a - a - Maybe a
   f original left right
   | geq original left = Just right
   | geq original right = Just left
   | geq left right = Just left
   | otherwise = Nothing

 However, what happens is that we usually reach the otherwise clause when
 processing the top level of the data structure, so you get nothing.  What
 really needs to happen is that it traverses down into the data structure and
 finds out that f is able to merge all the more primitive pieces of the data
 structure, in which case it combines those merged parts to yield a merged
 whole.  I'm not quite sure how to fit this operation into the generic
 framework.


Oh, I got it.  I have to remove the f x y z `orElse` from the definition
of gzip3.
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Data.Generics.gzip3 anyone?

2009-06-01 Thread David Fox
Is there a Scrap Your Boilerplate guru out there who could whip up a three
argument version of gzip for me?
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Data.Generics.gzip3 anyone?

2009-06-01 Thread David Fox
On Mon, Jun 1, 2009 at 3:40 PM, Ralf Laemmel rlaem...@gmail.com wrote:

  Thank you!  What I have in mind is three way merging - you have two
  revisions based on the same original value, and you need to decide
 whether
  they can be merged automatically or they need to be merged by a user.
 You
  only have a real conflict when both revisions differ from the original
 and
  from each other.

 Here is the completed exercise.
 For comparison, the two args versions are shown up-front.
 There is gzipWithM3 needed for gzip3, and gzip3 itself.
 I also made it so that the top-level gzip functions have the
 appropriate polymorphism.
 Say same type for the args rather than independent polymorphism.

 {-# LANGUAGE RankNTypes #-}

 import Prelude hiding (GT)
 import Data.Generics

 -- As originally defined: Twin map for transformation

 gzipWithT2 :: GenericQ (GenericT) - GenericQ (GenericT)
 gzipWithT2 f x y = case gmapAccumT perkid funs y of
([], c) - c
_   - error gzipWithT2
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = gmapQ (\k - GT (f k)) x


 -- As originally defined: Twin map for transformation

 gzipWithM2 :: Monad m = GenericQ (GenericM m) - GenericQ (GenericM m)
 gzipWithM2 f x y = case gmapAccumM perkid funs y of
([], c) - c
_   - error gzipWithM
  where
  perkid a d = (tail a, unGM (head a) d)
  funs = gmapQ (\k - GM (f k)) x


 -- As originally defined: generic zip

 gzip2 ::
(forall x. Data x = x - x - Maybe x)
  - (forall x. Data x = x - x - Maybe x)

 gzip2 f = gzip2' f'
  where
  f' :: GenericQ (GenericM Maybe)
  f' x y = cast x = \x' - f x' y
  gzip2' :: GenericQ (GenericM Maybe) - GenericQ (GenericM Maybe)
  gzip2' f x y =
f x y
`orElse`
if toConstr x == toConstr y
  then gzipWithM2 (gzip2' f) x y
  else Nothing


 -- For three args now

 gzipWithT3 ::
GenericQ (GenericQ (GenericT))
  - GenericQ (GenericQ (GenericT))
 gzipWithT3 f x y z =
case gmapAccumT perkid funs z of
  ([], c) - c
  _   - error gzipWithT3
  where
  perkid a d = (tail a, unGT (head a) d)
  funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
   _   - error gzipWithT3
   where
perkid' a d = (tail a, unGQ (head a) d)
funs' = gmapQ (\k - (GQ (\k' - GT (f k k' x

 gzipWithM3 :: Monad m
  = GenericQ (GenericQ (GenericM m))
  - GenericQ (GenericQ (GenericM m))
 gzipWithM3 f x y z =
case gmapAccumM perkid funs z of
  ([], c) - c
  _   - error gzipWithM3
  where
  perkid a d = (tail a, unGM (head a) d)
   funs = case gmapAccumQ perkid' funs' y of
   ([], q) - q
_   - error gzipWithM3
where
perkid' a d = (tail a, unGQ (head a) d)
 funs' = gmapQ (\k - (GQ (\k' - GM (f k k' x

 gzip3 ::
(forall x. Data x = x - x - x - Maybe x)
  - (forall x. Data x = x - x - x - Maybe x)

 gzip3 f = gzip3' f'
  where
  f' :: GenericQ (GenericQ (GenericM Maybe))
  f' x y z = cast x = \x' - cast y = \y' - f x' y' z
  gzip3' ::
   GenericQ (GenericQ (GenericM Maybe))
- GenericQ (GenericQ (GenericM Maybe))
  gzip3' f x y z =
f x y z
`orElse`
if and [toConstr x == toConstr y, toConstr y == toConstr z]
  then gzipWithM3 (gzip3' f) x y z
  else Nothing


Oh, thank goodness!

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


Re: [Haskell-cafe] the problem of design by negation

2009-05-27 Thread David Fox
What I do like about this so-called negative approach is that it
represents a part of a program's documentation that is usually omitted.  You
can look at the code and see exactly how and (to a certain extent) why the
program does what it does, but what you can't see is all the things it
doesn't do, and the reasons it doesn't do them.  This can be extremely
important to know when you are thinking about modifying a program.  The
change you are considering may have already been tried and rejected, but
unless these sorts of negative decisions are documented in the software you
may end up spinning your wheels.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Does readFile /proc/mounts hang for you?

2009-01-22 Thread David Fox
On Wed, Jan 21, 2009 at 9:20 AM, David Fox dds...@gmail.com wrote:

 I posted a bug about this (http://hackage.haskell.org/trac/ghc/ticket/2971)
 but its so odd I had to ask here.  Using ghc 6.10.1, both readFile
 /proc/mounts and Data.ByteString.Lazy.Char8.readFile /proc/mounts hang
 on an amd64 machine running Linux.  Also, Data.ByteString.readFile
 /proc/mounts returns the empty string.  Is this behavior present for
 others?  On i386?


I can now confirm that this bug also affects the i386 architecture.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Does readFile /proc/mounts hang for you?

2009-01-21 Thread David Fox
I posted a bug about this (http://hackage.haskell.org/trac/ghc/ticket/2971)
but its so odd I had to ask here.  Using ghc 6.10.1, both readFile
/proc/mounts and Data.ByteString.Lazy.Char8.readFile /proc/mounts hang
on an amd64 machine running Linux.  Also, Data.ByteString.readFile
/proc/mounts returns the empty string.  Is this behavior present for
others?  On i386?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-15 Thread David Fox
On Thu, Jan 15, 2009 at 9:04 AM, m...@justinbogner.com wrote:

 John Goerzen jgoer...@complete.org writes:
  Wikipedia's first sentence about monoids is:
 
In abstract algebra, a branch of mathematics, a monoid is an algebraic
structure with a single, associative binary operation and an identity
element.
 
  Which is *not* intuitive to someone that comes from a background in
   any other programming language.
 

 Instead of Wikipedia, why not try a dictionary? Looking up monoid using
 dictionary.com:

  An operator * and a value x form a monoid if * is
  associative and x is its left and right identity.

 On the other hand, appendable doesn't seem to be a word, and while you
 can infer that it means something that can be appended to, that's only
 half of the story...


 Monoid isn't something I came across and didn't understand, its something
I should have been using for a long time before I discovered it.  But it
never jumped out at me when I was browsing the library documentation tree.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Turning all the Nothings into Just defaultValue using Data.Generics

2008-11-12 Thread David Fox
I want to use Data.Generics to write a function to turn all the Nothings in
a data structure into Just defaultValue, as shown below.  I get the
following error because the compiler doesn't know enough about Maybe a for
mkT to create the generic function that everywhere requires, I guess.

Test.hs:26:16:
Ambiguous type variable `a' in the constraints:
  `Typeable a'
arising from a use of `mkT' at Senior/Test2.hs:26:16-30
  `Default a'
arising from a use of `justDefault' at Senior/Test2.hs:26:20-30
Probable fix: add a type signature that fixes these type variable(s)

Here is the example.  It all works except for test.  Any suggestions how
to do this?

{-# LANGUAGE  DeriveDataTypeable, FlexibleContexts, FlexibleInstances,
MultiParamTypeClasses, RankNTypes, TemplateHaskell, TypeSynonymInstances #-}
{-# OPTIONS_GHC -fallow-undecidable-instances #-}
module Test where

import Data.Generics

class Default a where
defaultValue :: a

instance Default Int where
defaultValue = 0

instance Default String where
defaultValue = 

instance Default (Maybe a) where
defaultValue = Nothing

data A = A {b :: Int, c :: Maybe String} deriving (Show, Data, Typeable)

instance Default A where
defaultValue = A {b = defaultValue, c = defaultValue}

test =
everywhere (mkT justDefault) (defaultValue :: A)
where
  justDefault Nothing = Just defaultValue
  justDefault (Just x) = Just x
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug in System.Environment - EOT inserted into argument string

2008-02-04 Thread David Fox
I think it is a bug in the emacs shell mode.

On Feb 4, 2008 9:30 AM, Clifford Beshers [EMAIL PROTECTED] wrote:

 No, I cannot reproduce this.

 2008/2/4 David Fox [EMAIL PROTECTED]:

  I'm seeing the character ^D inserted into argument strings that are
  about 256 characters long with GHC 6.8.2.  Anyone else?
 
  Test.hs:
 
  module Main where
 
  import System.Environment
  import System.IO
 
  main =
  do args - getArgs
 hPutStrLn stderr (args:  ++ show args)
 
 
  Output:
 
  $ ghc6 --make Test.hs -o test
  [1 of 1] Compiling Main ( Test.hs, Test.o )
  Linking test ...
  $ ./test
  012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
  args:
  [01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234\EOT5678901234567890123456789]
 
 
  ___
  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] Bug in System.Environment - EOT inserted into argument string

2008-02-04 Thread David Fox
I'm seeing the character ^D inserted into argument strings that are about
256 characters long with GHC 6.8.2.  Anyone else?

Test.hs:

module Main where

import System.Environment
import System.IO

main =
do args - getArgs
   hPutStrLn stderr (args:  ++ show args)


Output:

$ ghc6 --make Test.hs -o test
[1 of 1] Compiling Main ( Test.hs, Test.o )
Linking test ...
$ ./test
012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
args:
[01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234\EOT5678901234567890123456789]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the role of $!?

2007-12-09 Thread David Fox
Argh, that last sentence should read the file is left alone..

On Dec 9, 2007 10:15 PM, David Fox [EMAIL PROTECTED] wrote:

 Here is a practical example I ran into a few days ago.  With this
 expression:

writeFile path (compute text)

 the file at path would be overwritten with an empty file if an error
 occurs while evaluating (compute text).  With this one:

   writeFile path $! (compute text)

 the file alone when an error occurs.


 On Nov 17, 2007 8:04 PM, PR Stanley [EMAIL PROTECTED] wrote:

  Hi
  okay, so $! is a bit like $ i.e. the equivalent of putting
  parentheses around the righthand expression. I'm still not sure of
  the difference between $ and $!. Maybe it's because I don't
  understand the meaning of strict application. While we're on the
  subject, what's meant by Haskell being a non-strict language?
  Cheers
  Paul
  At 01:50 15/11/2007, you wrote:
  On 14 Nov 2007, at 4:32 PM, Shachaf Ben-Kiki wrote:
  
  On Nov 14, 2007 4:27 PM, Justin Bailey  [EMAIL PROTECTED] wrote:
  It's:
  
 f $! x = x `seq` f x
  
  That is, the argument to the right of $! is forced to evaluate, and
  then that value is passed to the function on the left. The function
  itself is not strictly evaluated (i.e., f x) I don't believe.
  
  Unless you mean f -- which I still don't think would do much -- it
  wouldn't make sense to evaluate (f x) strictly.
  
  Right.  (f x) evaluates f and then applies it to x.  (f $! x)
  evaluates x, evaluates f, and then applies f to x.
  
  jcc
  
  ___
  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] New slogan for haskell.org

2007-11-27 Thread David Fox
On Nov 27, 2007 8:14 AM, Henning Thielemann [EMAIL PROTECTED]
wrote:


 On Tue, 27 Nov 2007, Thomas Davie wrote:

  On 27 Nov 2007, at 14:44, David Menendez wrote:
 
   On Nov 26, 2007 1:44 PM, Thomas Davie [EMAIL PROTECTED] wrote:
  
   But the point is that this section of the site is the bit that's meant
   to be an advertisement -- we're trying to encourage people to read
   more,
  
   Are we? I thought Haskell.org was intended to describe what Haskell
   *is*. There are plenty of articles and blog posts and wiki pages out
   there that advocate Haskell. I don't see why the main web page needs
   to be polluted with marketing.
 
  Because someone's first contact with Haskell is likely to be someone
  saying I use this really cool language called Haskell, or a lecturer
  teaching it to them.  In either case, if a tiny amount of interest is
  sparked, their likely second contact is likely to be haskell.org
  (through guessing or googling).

 I think this is true, but for me it means, that we do not need another
 advertisement at Haskell.org, but facts. I also expect that people
 visiting the site already know about static typing and have categorized
 themselves into static typing lovers or haters. They will also have heard
 about polymorphism (just like object-orientation :-). So they only need to
 find out about the words, they do not know.

   Quite frankly, there's nothing going to put me off a language more than
  a paragraph full of unknown buzz words that I have to look up on the
  front page.
 
  There's plenty of places on Haskell.org where we can describe what
  haskell *is*, but the front page should be used for grabbing peoples
  attention and telling them why it's useful.

 Haskell.org is not only for new users. I like it as front page, because of
 the news and the entry points to the Wiki.
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



In that case we need to identify all the groups that the front page is
serving and create separate areas for each, all above the fold as it were:

1. A sales pitch for new users.  I see how much this disturbs some people,
but maybe it is better to think of it as a quick introduction with a focus
on benefits and comparisons to things which are already familiar.  This is
what one needs when one is in the stage of deciding whether to pursue
something.

2. After you have decided whether to pursue Haskell, you probably want to
decide *how* to pursue it.  In this section would be much of what is there
now - links to the definition, documentation, and important tutorials,
mailing lists, and so on.

3. Finally, you want a section for people who are already deeply involved.
This would be a news section, probably an RSS feed, links to newsletters,
and so on.

This thread should focus on part 1 above.  I think it would be a huge
mistake to deliberately omit this material because we do not need another
advertisement at Haskell.org http://haskell.org/, but facts.  Its all
facts!  Haskell.org needs to serve everyone who arrives there.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: New slogan for haskell.org

2007-11-27 Thread David Fox
On Nov 27, 2007 1:33 PM, apfelmus [EMAIL PROTECTED] wrote:

 David Menendez wrote:
  Thomas Davie wrote:
 
  But the point is that this section of the site is the bit that's meant
  to be an advertisement -- we're trying to encourage people to read
  more,
 
 
  Are we? I thought Haskell.org was intended to describe what Haskell
 *is*.
  There are plenty of articles and blog posts and wiki pages out there
 that
  advocate Haskell. I don't see why the main web page needs to be polluted
  with marketing.

 Agreed! I hate marketing! The facts can speak for themselves, if you
 need somebody to explain them, then something's wrong.

 More specifically, fact means something that you can easily check
 yourself. Robust/maintainable/testable code are things you _can't_
 easily check yourself without already learning the language.

 But shorter code is a fact you can easily check, for instance with
 quicksort as example. In fact, short code is the reason why I picked
 up Haskell. Back then, I was given the task to calculate some sequence
 of numbers which I did in one page of C code. So far so good, but when I
 asked the task assigner about his solution, he responded: Ah, this
 problem, that's 1 line in Haskell. Well, 2 lines if the terminal is too
 small. Such power! Hearing just this was more than enough reason for me
 to learn Haskell and to never look back.


 Regards,
 apfelmus


This is not a reasonable definition of fact.  There are many facts which
are not practical for a person to verify quickly, and many of them are quite
important.  It is perfectly reasonable to seek a consensus of experts on a
subject, and it is perfectly reasonable to present information such as
claims of robustness / maintainability / testability on the assumption that
the person reading it will then take steps to verify the claims, generally
by asking trusted experts.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-11-26 Thread David Fox
On Nov 26, 2007 11:38 AM, Thomas Schilling [EMAIL PROTECTED] wrote:


 Haskell is a general-purpose, pure functional programming languages
 that puts many interesting results from research into a practical
 programming language.  It's features include:


 I think it is stronger to say many powerful results rather than many
interesting results.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Best Linux for Haskell?

2007-11-06 Thread David Fox
On 11/6/07, Peter Verswyvelen [EMAIL PROTECTED] wrote:

 So which kind Linux works best for running GHC (6.8.1) and related tools? (I
 want to give Yi a go, I can't get it to work on Windows). Debian? Fedora?
 Ubuntu?

I took an informal poll at this year's Haskell Hackathon, and well
over half were using some type of Debian based distribution, with a
majority of those using Ubuntu.  GHC 6.8.1 is not yet available in the
form of Debian packages, but I believe it will be shortly.

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