[Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Francesco Mazzoli
Hi,

I have been using ghc-mod for a long time and I can’t give it up now, but I have
an annoying problem.

When I have a cabal file with a library and an executable depending on the
library (for example here
https://github.com/bitonic/kant/blob/master/kant.cabal), ghc-mod is not happy,
complaining in every file that

Error:command line: cannot satisfy -package kant

Where ‘kant’ is the package that the cabal file defines with the library that
the executable needs.  Note that if I issue ‘cabal configure; cabal build’,
everything goes smoothly.

Did anybody stumble on the same problem?

Thanks,
Francesco

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread CJ van den Berg
Hi Francesco,

To keep ghc-mod happy, you also have to keep ghci happy. What you
probably need is a .ghci file in the directory with a :set -isrc line
in it. You may also need to add other stuff to .ghci such as language
extensions and whatever else is needed to load your project with ghci.

Regards,
CJ  

On 08/02/13 11:00, Francesco Mazzoli wrote:
 Hi,
 
 I have been using ghc-mod for a long time and I can’t give it up now, but I 
 have
 an annoying problem.
 
 When I have a cabal file with a library and an executable depending on the
 library (for example here
 https://github.com/bitonic/kant/blob/master/kant.cabal), ghc-mod is not 
 happy,
 complaining in every file that
 
 Error:command line: cannot satisfy -package kant
 
 Where ‘kant’ is the package that the cabal file defines with the library that
 the executable needs.  Note that if I issue ‘cabal configure; cabal build’,
 everything goes smoothly.
 
 Did anybody stumble on the same problem?
 
 Thanks,
 Francesco
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 


-- 
CJ van den Berg

mailto:c...@vdbonline.com
xmpp:neuroc...@gmail.com

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Francesco Mazzoli
At Fri, 08 Feb 2013 11:11:06 +0100,
CJ van den Berg wrote:
 Hi Francesco,
 
 To keep ghc-mod happy, you also have to keep ghci happy. What you
 probably need is a .ghci file in the directory with a :set -isrc line
 in it. You may also need to add other stuff to .ghci such as language
 extensions and whatever else is needed to load your project with ghci.

Hi CJ,

Thanks for your answer.

I had tried to do that (actually I had modified ‘ghc-ghc-options’, but the
result should be the same), but it doesn’t fix the issue - and I don’t see why
it should, since the problem here is about not satisfying a package dependency.

Francesco

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread CJ van den Berg


On 08/02/13 11:20, Francesco Mazzoli wrote:
 At Fri, 08 Feb 2013 11:11:06 +0100,
 CJ van den Berg wrote:
 To keep ghc-mod happy, you also have to keep ghci happy. What you
 probably need is a .ghci file in the directory with a :set -isrc line
 in it. You may also need to add other stuff to .ghci such as language
 extensions and whatever else is needed to load your project with ghci.
 
 I had tried to do that (actually I had modified ‘ghc-ghc-options’, but the
 result should be the same), but it doesn’t fix the issue - and I don’t see why
 it should, since the problem here is about not satisfying a package 
 dependency.

I downloaded your package and tried it. It does work.

Kant.REPL, which it is trying to load, is in the kant package. So it is
looking for either the installed kant package, or the source files for
the kant package modules.

How is that not a package dependency? Telling it where to find the
source files will remove the need to find an installed kant package.

-- 
CJ van den Berg

mailto:c...@vdbonline.com
xmpp:neuroc...@gmail.com

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


Re: [Haskell-cafe] Extensible Type Unification

2013-02-08 Thread Leon Smith
It finally occurred to me how to get most of what I want,  at least from a
functional perspective.Here's a sample GADT,  with four categories of
constructor:

data Foo :: Bool - Bool - Bool - Bool - * where
A :: Foo True b c d
B :: Foo True b c d
C :: Foo a True c d
D :: Foo a b True d
E :: Foo a b c True

Given an Eq instance,  we can easily compare two constructors for equality;
  we can put some constructors in a list and tell which categories appear
in the list,   and it plays reasonably nicely with the case coverage
analyzer,  which I think is important from a software engineering
standpoint.For example,  this function will compile without warning:

fooVal :: Foo a b False False - Int
fooVal  x =
   case x of
  A - 0
  B - 1
  C - 2

The only thing this doesn't do that I wish it did is infer the type of
fooVal above.Rather,  GHC  infers the type  :: Foo a b c d - Int,
and then warns me that I'm missing cases.   But this is admittedly a
strange form of type inference,   completely alien to the Haskell
landscape,   which I realized only shortly after sending my original email.
  My original description of ranges of sets of types wasn't sufficient to
fully capture my intention.

That said,  this solution falls rather flat in several software engineering
respects.  It doesn't scale with complexity;   types quickly become
overbearing even with modest numbers of categories.If you want to add
additional categories,   you have to modify every type constructor instance
you've ever written down.You could mitigate some of this via the
existing type-level machinery,  but it seems a band-aid,  not a solution.

For comparison,  here is the best I had when I wrote my original email:

data Category = W | X | Y | Z

data Foo :: [Category] - * where
A :: (Member W ub) = Foo ub
B :: (Member W ub) = Foo ub
C :: (Member X ub) = Foo ub
D :: (Member Y ub) = Foo ub
E :: (Member Z ub) = Foo ub

class Member (a :: x) (bs :: [x])
instance Member a (a ': bs)
instance Member a bs = Member a (b ': bs)

The code is closer to what I want,  in terms of expression,  though it
mostly fails on the functional requirements.Case analysis doesn't work,
  I can't compare two constructors without additional type annotations,
and while I can find out which categories of constructors appear in a list,
  it doesn't seem I can actually turn those contexts into many useful
things,  automatically.

So while I didn't have any trouble computing set operations over unordered
lists at the type level,   I couldn't figure out out to put it to use in
the way I wanted.Perhaps there is a clever way to emulate unification,
 but I really like the new features that reduce the need to be clever when
it comes to type-level computation.

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Francesco Mazzoli
At Fri, 08 Feb 2013 11:39:19 +0100,
CJ van den Berg wrote:
 I downloaded your package and tried it. It does work.

So, what I have is

   bitonic@clay ~/src/kant (git)-[master] % cat .ghci
   :set -isrc

And I still get the mentioned error.  Did you take any other measures to make
things work?  I’m using ghc-mod version 1.11.3.
 
 Kant.REPL, which it is trying to load, is in the kant package. So it is
 looking for either the installed kant package, or the source files for
 the kant package modules.
 
 How is that not a package dependency? Telling it where to find the
 source files will remove the need to find an installed kant package.

OK, now I understand what you are doing: instead of making ghc-mod rely on
cabal, you simply make it load the files directly.  Which is a bit annoying in
my case because I have some files that need to be preprocessed (alex/happy), but
it would still be better than nothing.  I can achieve the same result by simply
moving the ‘cabal’ file, or by deleting the target.  I guess that the ‘.ghci’
has (or should have) the same effect.

Francesco

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Ivan Lazar Miljenovic
On 8 February 2013 22:25, Francesco Mazzoli f...@mazzo.li wrote:
 At Fri, 08 Feb 2013 11:39:19 +0100,
 CJ van den Berg wrote:
 I downloaded your package and tried it. It does work.

 So, what I have is

bitonic@clay ~/src/kant (git)-[master] % cat .ghci
:set -isrc

Try also having :set -isrc/dist and possibly :set
-isrc/dist/package name (not on a machine with Haskell so I can't
test this); I think I've had to do something like that before.


 And I still get the mentioned error.  Did you take any other measures to make
 things work?  I’m using ghc-mod version 1.11.3.

 Kant.REPL, which it is trying to load, is in the kant package. So it is
 looking for either the installed kant package, or the source files for
 the kant package modules.

 How is that not a package dependency? Telling it where to find the
 source files will remove the need to find an installed kant package.

 OK, now I understand what you are doing: instead of making ghc-mod rely on
 cabal, you simply make it load the files directly.  Which is a bit annoying in
 my case because I have some files that need to be preprocessed (alex/happy), 
 but
 it would still be better than nothing.  I can achieve the same result by 
 simply
 moving the ‘cabal’ file, or by deleting the target.  I guess that the ‘.ghci’
 has (or should have) the same effect.

 Francesco

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



-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
http://IvanMiljenovic.wordpress.com

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread CJ van den Berg
On 08/02/13 12:25, Francesco Mazzoli wrote:
 At Fri, 08 Feb 2013 11:39:19 +0100,
 CJ van den Berg wrote:
 I downloaded your package and tried it. It does work.
 
 So, what I have is
 
bitonic@clay ~/src/kant (git)-[master] % cat .ghci
:set -isrc
 
 And I still get the mentioned error.  Did you take any other measures to make
 things work?  I’m using ghc-mod version 1.11.3.

Ah, I only just realised that you’re talking about the flymake error,
not the inferior-mode error. The problem is pretty much the same though.
flymake uses ghc --make, which can’t import the Kant module because it
doesn’t know how to build Parser.y.
ghc-ghc-options is the right place for flymake options to ghc.

 Kant.REPL, which it is trying to load, is in the kant package. So it is
 looking for either the installed kant package, or the source files for
 the kant package modules.

 How is that not a package dependency? Telling it where to find the
 source files will remove the need to find an installed kant package.
 
 OK, now I understand what you are doing: instead of making ghc-mod rely on
 cabal, you simply make it load the files directly.  Which is a bit annoying in
 my case because I have some files that need to be preprocessed (alex/happy), 
 but
 it would still be better than nothing.  I can achieve the same result by 
 simply
 moving the ‘cabal’ file, or by deleting the target.  I guess that the ‘.ghci’
 has (or should have) the same effect.

Options in .ghci won’t fix flymake, only inferior-mode. ghc-ghc-options
is the place to fix flymake, although it won’t help if the import fails
anyway.

Can’t you manually preprocess Parser.y so that ghc --make has a .hs file
it can use?

-- 
CJ van den Berg

mailto:c...@vdbonline.com
xmpp:neuroc...@gmail.com


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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread 山本和彦
Hi,

 When I have a cabal file with a library and an executable depending on the
 library (for example here
 https://github.com/bitonic/kant/blob/master/kant.cabal), ghc-mod is not 
 happy,
 complaining in every file that
 
 Error:command line: cannot satisfy -package kant

 Where ‘kant’ is the package that the cabal file defines with the library that
 the executable needs.  Note that if I issue ‘cabal configure; cabal build’,
 everything goes smoothly.

I guess you don't install the kant library, right?

If so, I will think how to treat this kind problem.

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Francesco Mazzoli
At Fri, 08 Feb 2013 21:22:23 +0900 (JST),
Kazu Yamamoto (山本和彦) wrote:
 I guess you don't install the kant library, right?
 
 If so, I will think how to treat this kind problem.

The ‘kant’ package is the package I’m developing and using ghc-mod on.  It
includes both a library and an executable.  The executable target has ‘kant’ as
a dependency.

Francesco

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Francesco Mazzoli
At Fri, 08 Feb 2013 12:50:47 +0100,
CJ van den Berg wrote:
 
 On 08/02/13 12:25, Francesco Mazzoli wrote:
  At Fri, 08 Feb 2013 11:39:19 +0100,
  CJ van den Berg wrote:
  I downloaded your package and tried it. It does work.
  
  So, what I have is
  
 bitonic@clay ~/src/kant (git)-[master] % cat .ghci
 :set -isrc
  
  And I still get the mentioned error.  Did you take any other measures to 
  make
  things work?  I’m using ghc-mod version 1.11.3.
 
 Ah, I only just realised that you’re talking about the flymake error,
 not the inferior-mode error. The problem is pretty much the same though.
 flymake uses ghc --make, which can’t import the Kant module because it
 doesn’t know how to build Parser.y.

No, that is not the problem, I have a manually preprocessed Parser.hs in place.

 ghc-ghc-options is the right place for flymake options to ghc.

Tried setting ‘ghc-ghc-options’, still no luck.  And by the way, running
‘ghc-mod’ manually doesn’t help either:

bitonic@clay ~/src/kant (git)-[master] % cat .ghci
:set -isrc
bitonic@clay ~/src/kant (git)-[master] % ghc-mod check src/Kant/REPL.hs
src/Kant/REPL.hs:0:0:Error:command line: cannot satisfy -package kant
(use -v for more information)

 Options in .ghci won’t fix flymake, only inferior-mode. ghc-ghc-options
 is the place to fix flymake, although it won’t help if the import fails
 anyway.
 
 Can’t you manually preprocess Parser.y so that ghc --make has a .hs file
 it can use?

Well yes I can, but it’s a bit annoying.  I think things would be easier if
‘ghc-mod’ just used cabal commands (e.g. ‘cabal build’) to check things.

Francesco

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread 山本和彦
 The ‘kant’ package is the package I’m developing and using ghc-mod on. 

Yes. I understand it.

 It includes both a library and an executable.  The executable target
 has ‘kant’ as a dependency.

What I asked is whether or not the kant library is installed by
cabal.

To edit a Haskell file for the kant executable, the current ghc-mod
needs to find the kant library in global or user.

I guess this bug does not exist in ghc-mod v1.11.1.

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Francesco Mazzoli
At Fri, 08 Feb 2013 22:18:20 +0900 (JST),
Kazu Yamamoto (山本和彦) wrote:
 
  The ‘kant’ package is the package I’m developing and using ghc-mod on. 
 
 Yes. I understand it.
 
  It includes both a library and an executable.  The executable target
  has ‘kant’ as a dependency.
 
 What I asked is whether or not the kant library is installed by
 cabal.

Well installing it has the big problem that each time I make a change to the
interface I have to manually re-install, and this happens often since I’m in an
early stage...

 To edit a Haskell file for the kant executable, the current ghc-mod
 needs to find the kant library in global or user.

Right, but this is surely doable since cabal handles the situation fine.  In
general it seems that ghc-mod should work with cabal when it can.

 I guess this bug does not exist in ghc-mod v1.11.1.

I’ll try with that.

Francesco

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread 山本和彦
 Well installing it has the big problem that each time I make a
 change to the interface I have to manually re-install, and this
 happens often since I’m in an early stage...

I'm not saying that you should install it. But I just want to know
your situation.

 Right, but this is surely doable since cabal handles the situation fine.  In
 general it seems that ghc-mod should work with cabal when it can.

Yes. This is a bug of the current ghc-mod. This behavior change was
introduced by another guy, I guess. I need to look into his code.

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Francesco Mazzoli
At Fri, 08 Feb 2013 22:39:07 +0900 (JST),
Kazu Yamamoto (山本和彦) wrote:
 
  Well installing it has the big problem that each time I make a
  change to the interface I have to manually re-install, and this
  happens often since I’m in an early stage...
 
 I'm not saying that you should install it. But I just want to know
 your situation.

Oh OK, I took it as an advice.  Yes, it works if I install it.

  Right, but this is surely doable since cabal handles the situation fine.  In
  general it seems that ghc-mod should work with cabal when it can.
 
 Yes. This is a bug of the current ghc-mod. This behavior change was
 introduced by another guy, I guess. I need to look into his code.

Thanks a lot, I’ll downgrade and wait for a fix.

Francesco

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


Re: [Haskell-cafe] ghc-mod and cabal targets

2013-02-08 Thread Francesco Mazzoli
At Fri, 08 Feb 2013 13:43:12 +,
Francesco Mazzoli wrote:
 
 At Fri, 08 Feb 2013 22:39:07 +0900 (JST),
 Kazu Yamamoto (山本和彦) wrote:
  
   Well installing it has the big problem that each time I make a
   change to the interface I have to manually re-install, and this
   happens often since I’m in an early stage...
  
  I'm not saying that you should install it. But I just want to know
  your situation.
 
 Oh OK, I took it as an advice.  Yes, it works if I install it.
 
   Right, but this is surely doable since cabal handles the situation fine.  
   In
   general it seems that ghc-mod should work with cabal when it can.
  
  Yes. This is a bug of the current ghc-mod. This behavior change was
  introduced by another guy, I guess. I need to look into his code.
 
 Thanks a lot, I’ll downgrade and wait for a fix.
 
 Francesco

I can confirm that 1.11.1 works.

Francesco

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


[Haskell-cafe] cabal-dev add-source

2013-02-08 Thread JP Moresmau
Hello, I'm trying to understand cabal-dev, and I seem to be missing some
basic point, because I can't get dependencies between projects working
properly.
I have two projects, let's call them P1 and P2. P2 depends on P1, as
indicated by its cabal file build-depends field.
I run cabal-dev add-source ..\P1 inside P2
then cabal-dev install
Everything works fine, and my project compiles, with modules in P2 calling
functions from P1.
Then I add a new function if an exposed module of P1. I rerun the cabal-dev
add-source and cabal-dev install commands to tell P2 of the change, as per
the cabal-dev documentation. I change a file in P2 to use the new function,
the compilation fails.
If I check into the cabal-dev folder, I see the .hi file for my changed
module has not been updated (old date).
What am I missing?

Thanks

-- 
JP Moresmau
http://jpmoresmau.blogspot.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] arrow notation

2013-02-08 Thread Ross Paterson
The proposed changes are described here:

http://hackage.haskell.org/trac/ghc/wiki/ArrowNotation

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


Re: [Haskell-cafe] cabal-dev add-source

2013-02-08 Thread Blake Rain
You need to call cabal-dev add-source on P1 again to copy over the sdist,
then do a cabal-dev install.

See notes under Using a sandbox-local Hackage on
https://github.com/creswick/cabal-dev


On Feb 8, 2013 2:22 PM, JP Moresmau jpmores...@gmail.com wrote:

 Hello, I'm trying to understand cabal-dev, and I seem to be missing some
basic point, because I can't get dependencies between projects working
properly.
 I have two projects, let's call them P1 and P2. P2 depends on P1, as
indicated by its cabal file build-depends field.
 I run cabal-dev add-source ..\P1 inside P2
 then cabal-dev install
 Everything works fine, and my project compiles, with modules in P2
calling functions from P1.
 Then I add a new function if an exposed module of P1. I rerun the
cabal-dev add-source and cabal-dev install commands to tell P2 of the
change, as per the cabal-dev documentation. I change a file in P2 to use
the new function, the compilation fails.
 If I check into the cabal-dev folder, I see the .hi file for my changed
module has not been updated (old date).
 What am I missing?

 Thanks

 --
 JP Moresmau
 http://jpmoresmau.blogspot.com/

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

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


Re: [Haskell-cafe] cabal-dev add-source

2013-02-08 Thread Johan Tibell
On Fri, Feb 8, 2013 at 9:53 AM, Blake Rain blake.r...@gmail.com wrote:

 You need to call cabal-dev add-source on P1 again to copy over the sdist,
 then do a cabal-dev install.

 See notes under Using a sandbox-local Hackage on
 https://github.com/creswick/cabal-dehttps://github.com/creswick/cabal-dev


With the new cabal sandboxing (due in 1.18) this won't be necessary as we
create a link to the repo, instead of installing a copy. We will rebuild
the linked repo as needed.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-dev add-source

2013-02-08 Thread JP Moresmau
That's exactly what I'm doing, and I was exactly following these notes, but
it doesn't work. This google+ post and the answers to it (
https://plus.google.com/102016502921512042165/posts/TGaENqWfubP) lead me to
at least one solution that seems to work: you need to unregister the
changed package first.
So
cabal-dev ghc-pkg unregister --force P1
cabal-dev add-source ../P1
cabal-dev install

Does the trick. There seems to be a way to pass a --reinstall flag to
cabal-dev install but I haven't gotten it to work yet.

Thanks

JP


On Fri, Feb 8, 2013 at 6:53 PM, Blake Rain blake.r...@gmail.com wrote:

 You need to call cabal-dev add-source on P1 again to copy over the sdist,
 then do a cabal-dev install.

 See notes under Using a sandbox-local Hackage on
 https://github.com/creswick/cabal-dev


 On Feb 8, 2013 2:22 PM, JP Moresmau jpmores...@gmail.com wrote:
 
  Hello, I'm trying to understand cabal-dev, and I seem to be missing some
 basic point, because I can't get dependencies between projects working
 properly.
  I have two projects, let's call them P1 and P2. P2 depends on P1, as
 indicated by its cabal file build-depends field.
  I run cabal-dev add-source ..\P1 inside P2
  then cabal-dev install
  Everything works fine, and my project compiles, with modules in P2
 calling functions from P1.
  Then I add a new function if an exposed module of P1. I rerun the
 cabal-dev add-source and cabal-dev install commands to tell P2 of the
 change, as per the cabal-dev documentation. I change a file in P2 to use
 the new function, the compilation fails.
  If I check into the cabal-dev folder, I see the .hi file for my changed
 module has not been updated (old date).
  What am I missing?
 
  Thanks
 
  --
  JP Moresmau
  http://jpmoresmau.blogspot.com/
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 




-- 
JP Moresmau
http://jpmoresmau.blogspot.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-dev add-source

2013-02-08 Thread JP Moresmau
Johan, thanks, that brings me to a point that I wanted to raise. I'm
playing with cabal-dev because users have asked me to add support for it in
EclipseFP (so projects could have their own sandbox and have dependencies
between projects without polluting the main package databases). It is worth
it, or should I just wait for cabal 1.18 and use the sandboxing facility?
Or will the two work similarly enough that supporting both will be easy?
Does the sandboxing in cabal means that tools like cabal-dev are going to
get deprecated?

Thanks

JP


On Fri, Feb 8, 2013 at 7:02 PM, Johan Tibell johan.tib...@gmail.com wrote:

 On Fri, Feb 8, 2013 at 9:53 AM, Blake Rain blake.r...@gmail.com wrote:

 You need to call cabal-dev add-source on P1 again to copy over the sdist,
 then do a cabal-dev install.

 See notes under Using a sandbox-local Hackage on
 https://github.com/creswick/cabal-dehttps://github.com/creswick/cabal-dev


 With the new cabal sandboxing (due in 1.18) this won't be necessary as we
 create a link to the repo, instead of installing a copy. We will rebuild
 the linked repo as needed.




-- 
JP Moresmau
http://jpmoresmau.blogspot.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-dev add-source

2013-02-08 Thread Johan Tibell
On Fri, Feb 8, 2013 at 10:07 AM, JP Moresmau jpmores...@gmail.com wrote:

 Johan, thanks, that brings me to a point that I wanted to raise. I'm
 playing with cabal-dev because users have asked me to add support for it in
 EclipseFP (so projects could have their own sandbox and have dependencies
 between projects without polluting the main package databases). It is worth
 it, or should I just wait for cabal 1.18 and use the sandboxing facility?
 Or will the two work similarly enough that supporting both will be easy?
 Does the sandboxing in cabal means that tools like cabal-dev are going to
 get deprecated?


I think they will be similar enough that you could easily port the code.
The new cabal sandboxing will work as follows:

cabal sandbox --init
cabal add-source dir

and then you use cabal commands like normal (e.g. configure, build, test).
No installing necessary.

I cannot speak for the cabal-dev developers. We do intend to support a
superset of the cabal-dev functionality eventually. What we're missing now
is ghci support.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal-dev add-source

2013-02-08 Thread Ozgun Ataman


On Friday, February 8, 2013 at 1:19 PM, Johan Tibell wrote:

 On Fri, Feb 8, 2013 at 10:07 AM, JP Moresmau jpmores...@gmail.com 
 (mailto:jpmores...@gmail.com) wrote:
  Johan, thanks, that brings me to a point that I wanted to raise. I'm 
  playing with cabal-dev because users have asked me to add support for it in 
  EclipseFP (so projects could have their own sandbox and have dependencies 
  between projects without polluting the main package databases). It is worth 
  it, or should I just wait for cabal 1.18 and use the sandboxing facility? 
  Or will the two work similarly enough that supporting both will be easy? 
  Does the sandboxing in cabal means that tools like cabal-dev are going to 
  get deprecated? 
 
 I think they will be similar enough that you could easily port the code. The 
 new cabal sandboxing will work as follows:
 
 cabal sandbox --init
 cabal add-source dir
 
 and then you use cabal commands like normal (e.g. configure, build, test). No 
 installing necessary.
 
 I cannot speak for the cabal-dev developers. We do intend to support a 
 superset of the cabal-dev functionality eventually. What we're missing now is 
 ghci support.
Which, thanks to Johan's help yesterday, can still be worked around (for now) 
by starting ghci with:

ghci -package-conf ./cabal-sandbox/your-package-conf-folder-here/ 

I'm trying to get Emacs haskell-mode and inferior-haskell to play nice with 
this, but it's not working so far for some reason.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org (mailto: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] ICFP 2013: Call for papers

2013-02-08 Thread David Van Horn
=

 18th ACM SIGPLAN International Conference on Functional Programming

 ICFP 2013

 Boston, MA, USA, 25-27 September 2013

 http://www.icfpconference.org/icfp2013

=

Important Dates
~~~

   Submissions due:  Thursday, 28 March 2013 23:59 UTC-11
(Pago Pago, American Samoa, time)
   Author response:  Wednesday, 22 May 0:00 UTC-11
   Friday, 24 May 2013 23:59 UTC-11
  Notification:  Friday, 7 June 2013
Final copy due:  Friday, 5 July 2013

Scope
~

ICFP 2013 seeks original papers on the art and science of functional
programming.  Submissions are invited on all topics from principles to
practice, from foundations to features, and from abstraction to
application.  The scope includes all languages that encourage
functional programming, including both purely applicative and
imperative languages, as well as languages with objects, concurrency,
or parallelism.  Topics of interest include (but are not limited to):

* Language Design: concurrency and distribution; modules; components
  and composition; metaprogramming; interoperability; type systems;
  relations to imperative, object-oriented, or logic programming

* Implementation: abstract machines; virtual machines; interpretation;
  compilation; compile-time and run-time optimization; memory
  management; multi-threading; exploiting parallel hardware; interfaces
  to foreign functions, services, components, or low-level machine
  resources

* Software-Development Techniques: algorithms and data structures;
  design patterns; specification; verification; validation; proof
  assistants; debugging; testing; tracing; profiling

* Foundations: formal semantics; lambda calculus; rewriting; type
  theory; monads; continuations; control; state; effects; program
  verification; dependent types

* Analysis and Transformation: control-flow; data-flow; abstract
  interpretation; partial evaluation; program calculation

* Applications and Domain-Specific Languages: symbolic computing;
  formal-methods tools; artificial intelligence; systems programming;
  distributed-systems and web programming; hardware design; databases;
  XML processing; scientific and numerical computing; graphical user
  interfaces; multimedia programming; scripting; system
  administration; security

* Education: teaching introductory programming; parallel programming;
  mathematical proof; algebra

* Functional Pearls: elegant, instructive, and fun essays on
  functional programming

* Experience Reports: short papers that provide evidence that
  functional programming really works or describe obstacles that have
  kept it from working

If you are concerned about the appropriateness of some topic, do not
hesitate to contact the program chair.

Abbreviated instructions for authors


* By Thursday, 28 March 2013, 23:59 UTC-11 (American Samoa time),
  submit a full paper of at most 12 pages (6 pages for an Experience
  Report), including bibliography and figures.

The deadlines will be strictly enforced and papers exceeding the page
limits will be summarily rejected.

* Authors have the option to attach supplementary material to a submission,
  on the understanding that reviewers may choose not to look at it.

* Each submission must adhere to SIGPLAN's republication policy, as
  explained on the web at
  http://www.acm.org/sigplan/republicationpolicy.htm

* Authors of resubmitted (but previously rejected) papers have the
  option to attach an annotated copy of the reviews of their previous
  submission(s), explaining how they have addressed these previous
  reviews in the present submission.  If a reviewer identifies
  him/herself as a reviewer of this previous submission and wishes to
  see how his/her comments have been addressed, the program chair will
  communicate to this reviewer the annotated copy of his/her previous
  review.  Otherwise, no reviewer will read the annotated copies of
  the previous reviews.

Overall, a submission will be evaluated according to its relevance,
correctness, significance, originality, and clarity.  It should
explain its contributions in both general and technical terms, clearly
identifying what has been accomplished, explaining why it is
significant, and comparing it with previous work.  The technical
content should be accessible to a broad audience.  Functional Pearls
and Experience Reports are separate categories of papers that need not
report original research results and must be marked as such at the
time of submission.  Detailed guidelines on both categories are on the
conference web site.

Proceedings will be published by ACM Press.  Authors of accepted
submissions are expected to transfer the copyright to the
ACM.  Presentations will be videotaped and released online if the
presenter consents.

Formatting: 

Re: [Haskell-cafe] cabal-dev add-source

2013-02-08 Thread Johan Tibell
On Fri, Feb 8, 2013 at 10:24 AM, Ozgun Ataman ozata...@gmail.com wrote:

  Which, thanks to Johan's help yesterday, can still be worked around (for
 now) by starting ghci with:

 ghci -package-conf ./cabal-sandbox/your-package-conf-folder-here/


You can indeed do this. For real ghci support in cabal we need to also pass
-package flags, C libraries, etc to ghci. That's why it's not done yet.

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


[Haskell-cafe] performance question

2013-02-08 Thread Nicolas Bock
Hi list,

I wrote a script that reads matrix elements from standard input, parses the
input using a regular expression, and then bins the matrix elements by
magnitude. I wrote the same script in python (just to be sure :) ) and find
that the python version vastly outperforms the Haskell script.

To be concrete:

$ time ./createMatrixDump.py -N 128 | ./printMatrixDecay
real0m2.655s
user0m2.677s
sys 0m0.095s

$ time ./createMatrixDump.py -N 128 | ./printMatrixDecay.py -
real0m0.445s
user0m0.615s
sys 0m0.032s

The Haskell script was compiled with ghc --make printMatrixDecay.hs.

Could you have a look at the script and give me some pointers as to where I
could improve it, both in terms of performance and also generally, as I am
very new to Haskell.

Thanks already,

nick


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


Re: [Haskell-cafe] performance question

2013-02-08 Thread Aleksey Khudyakov

On 08.02.2013 23:26, Nicolas Bock wrote:

Hi list,

I wrote a script that reads matrix elements from standard input, parses
the input using a regular expression, and then bins the matrix elements
by magnitude. I wrote the same script in python (just to be sure :) )
and find that the python version vastly outperforms the Haskell script.


General performance hints

1) Strings are slow. Fast alternatives are text[1] for textual data and 
bytestrings[2] for binary data. I can't say anything about performance 
of Text.Regex.Posix.


2) Appending list wrong operation to do in performance sensitive code.
(++) traverses its first argument so it's O(n) in its length.


What exactly are you tryeing to do? Create a histogram?



The Haskell script was compiled with ghc --make printMatrixDecay.hs.


If you want performance you absolutely should use -O2.


[1] http://hackage.haskell.org/package/text
[2] http://hackage.haskell.org/package/bytestring

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


Re: [Haskell-cafe] performance question

2013-02-08 Thread Bob Ippolito
Do you mind posting createMatrixDump.py and printMatrixDecay.py? That would
certainly make it easier to help you.


On Fri, Feb 8, 2013 at 11:26 AM, Nicolas Bock nicolasb...@gmail.com wrote:

 Hi list,

 I wrote a script that reads matrix elements from standard input, parses
 the input using a regular expression, and then bins the matrix elements by
 magnitude. I wrote the same script in python (just to be sure :) ) and find
 that the python version vastly outperforms the Haskell script.

 To be concrete:

 $ time ./createMatrixDump.py -N 128 | ./printMatrixDecay
 real0m2.655s
 user0m2.677s
 sys 0m0.095s

 $ time ./createMatrixDump.py -N 128 | ./printMatrixDecay.py -
 real0m0.445s
 user0m0.615s
 sys 0m0.032s

 The Haskell script was compiled with ghc --make printMatrixDecay.hs.

 Could you have a look at the script and give me some pointers as to where
 I could improve it, both in terms of performance and also generally, as I
 am very new to Haskell.

 Thanks already,

 nick


 ___
 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] performance question

2013-02-08 Thread Nicolas Bock
Sorry, should have done this right away. Here are the other two scripts.


On Fri, Feb 8, 2013 at 1:45 PM, Bob Ippolito b...@redivi.com wrote:

 Do you mind posting createMatrixDump.py and printMatrixDecay.py? That
 would certainly make it easier to help you.


 On Fri, Feb 8, 2013 at 11:26 AM, Nicolas Bock nicolasb...@gmail.comwrote:

 Hi list,

 I wrote a script that reads matrix elements from standard input, parses
 the input using a regular expression, and then bins the matrix elements by
 magnitude. I wrote the same script in python (just to be sure :) ) and find
 that the python version vastly outperforms the Haskell script.

 To be concrete:

 $ time ./createMatrixDump.py -N 128 | ./printMatrixDecay
 real0m2.655s
 user0m2.677s
 sys 0m0.095s

 $ time ./createMatrixDump.py -N 128 | ./printMatrixDecay.py -
 real0m0.445s
 user0m0.615s
 sys 0m0.032s

 The Haskell script was compiled with ghc --make printMatrixDecay.hs.

 Could you have a look at the script and give me some pointers as to where
 I could improve it, both in terms of performance and also generally, as I
 am very new to Haskell.

 Thanks already,

 nick


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





createMatrixDump.py
Description: Binary data


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


Re: [Haskell-cafe] performance question

2013-02-08 Thread Nicolas Bock
On Fri, Feb 8, 2013 at 1:23 PM, Aleksey Khudyakov alexey.sklad...@gmail.com
 wrote:

 On 08.02.2013 23:26, Nicolas Bock wrote:

 Hi list,

 I wrote a script that reads matrix elements from standard input, parses
 the input using a regular expression, and then bins the matrix elements
 by magnitude. I wrote the same script in python (just to be sure :) )
 and find that the python version vastly outperforms the Haskell script.

  General performance hints

 1) Strings are slow. Fast alternatives are text[1] for textual data and
 bytestrings[2] for binary data. I can't say anything about performance of
 Text.Regex.Posix.

 Thanks for the suggestion, I will try that.



 2) Appending list wrong operation to do in performance sensitive code.
 (++) traverses its first argument so it's O(n) in its length.


 What exactly are you tryeing to do? Create a histogram?

 Yes, a histogram. The binning code is really a little awkward. I haven't
gotten used to thinking in terms of inmutable objects yet and this list
appending is really a pretty bad hack to kind of allow me to increment the
bin counts. How would one do this more haskellishish?





  The Haskell script was compiled with ghc --make printMatrixDecay.hs.

  If you want performance you absolutely should use -O2.

 I'll try that.




 [1] 
 http://hackage.haskell.org/**package/texthttp://hackage.haskell.org/package/text
 [2] 
 http://hackage.haskell.org/**package/bytestringhttp://hackage.haskell.org/package/bytestring

 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://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] performance question

2013-02-08 Thread Aleksey Khudyakov

On 09.02.2013 01:02, Nicolas Bock wrote:

Yes, a histogram. The binning code is really a little awkward. I haven't
gotten used to thinking in terms of inmutable objects yet and this list
appending is really a pretty bad hack to kind of allow me to increment
the bin counts. How would one do this more haskellishish?

Histogramming is a bit awkward in haskell. If we want to stick to 
immutable data types best choice is to have map bin → number of entries. 
For every new entry select bin and add 1 to its content.


But if we want to store data in array we have to deal with mutable 
state. It's not realistic to copy array on every update. For that case I 
wrote I library histogram-fill[1]. Below is program which does 
approximately same thing.


 import Data.Histogram.Fill
 import Data.Histogram  (Histogram)

 hb :: HBuilder String (Histogram LogBinD Int)
 hb = forceInt - mkSimple (logBinDN 1e-8 10 10) - read

 main :: IO ()
 main = do
   l - getContents
   print $ fillBuilder hb $ lines l

I cheated and used sed to strip unused data. It uses String so it's 
still slower than python.



$ time (python gen.py -N 300 | sed 's/.*=//' | ./printMatrixDecay )
real0m0.958s
user0m2.096s
sys 0m0.052s

$ time (python gen.py -N 300 | python printMatrixDecay.py -)
real0m0.590s
user0m0.952s
sys 0m0.016s


[1] http://hackage.haskell.org/package/histogram-fill

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


[Haskell-cafe] xml conduit

2013-02-08 Thread grant
Hi,

Is there a nice way to update xml. I want to be able to use xml-conduit
to find a location in the xml and then add/update that node. 

eg xpath from //d/e/f and then change the content at 'f' or add a new node

a
...
  d
e
  fsome data to change
  /f
/e
  /d
...
/a


Thanks for any help,
Grant


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


Re: [Haskell-cafe] performance question

2013-02-08 Thread Branimir Maksimovic

Heh, I have wrote c++ version and that is much faster than python ;) 
bmaxa@maxa:~/haskell$ time ./createMatrixDump.py -N 128  output.txt
real0m0.041suser0m0.040ssys 0m0.000sbmaxa@maxa:~/haskell$ time 
./printMatrixDecay.py -  output.txt(-) read 16384 matrix elements (128x128 = 
16384)[0.00e+00, 1.00e-08) = 0 (0.00%) 0[1.00e-08, 1.00e-07) = 0 (0.00%) 
0[1.00e-07, 1.00e-06) = 0 (0.00%) 0[1.00e-06, 1.00e-05) = 0 (0.00%) 0[1.00e-05, 
1.00e-04) = 1 (0.00%) 1[1.00e-04, 1.00e-03) = 15 (0.00%) 16[1.00e-03, 1.00e-02) 
= 149 (0.00%) 165[1.00e-02, 1.00e-01) = 1425 (0.00%) 1590[1.00e-01, 1.00e+00) = 
14794 (0.00%) 16384[1.00e+00, 2.00e+00) = 0 (0.00%) 16384
real0m0.081suser0m0.072ssys 0m0.008sbmaxa@maxa:~/haskell$ time 
./printMatrixDecay  output.txtread 16384 matrix elements (128x128 = 
16384)[0.00e+00, 1.00e-08) = 0 (0.00%) 0[1.00e-08, 1.00e-07) = 0 (0.00%) 
0[1.00e-07, 1.00e-06) = 0 (0.00%) 0[1.00e-06, 1.00e-05) = 0 (0.00%) 0[1.00e-05, 
1.00e-04) = 1 (0.01%) 1[1.00e-04, 1.00e-03) = 15 (0.09%) 16[1.00e-03, 1.00e-02) 
= 149 (0.91%) 165[1.00e-02, 1.00e-01) = 1425 (8.70%) 1590[1.00e-01, 1.00e+00) = 
14794 (90.30%) 16384[1.00e+00, 2.00e+00) = 0 (0.00%) 16384
real0m0.018suser0m0.012ssys 0m0.004s
unfortunately g++ does not have regex implemented yet so I used libpcre ...
#include pcre.h#include sstream#include cstdio#include cmath#include 
iostream#include stdexcept#include vector
template class Fvoid regex(const std::string in, const std::string 
pattern,int n,F f){int ovec[3*n],position;const char* error;   int 
errorpos;
pcre* pe = pcre_compile(pattern.c_str(),0,error,errorpos,0);
if(!pe)throw std::runtime_error(error);
pcre_extra* extra=pcre_study(pe,0,error);
for(position = 0;
pcre_exec(pe,extra,in.c_str(),in.size(),position,0,ovec,3*n)=0;
position = ovec[1])f(position,ovec);f(position,ovec);pcre_free(extra);  
  pcre_free(pe);   }
int main(){  std::ios::sync_with_stdio(false);  std::ostringstream oss;  oss  
std::cin.rdbuf();  const std::string in = oss.str();  std::vectordouble 
strataBounds = { 0.0, 1.0e-8, 1.0e-7, 1.0e-6, 1.0e-5, 1.0e-4, 1.0e-3, 1.0e-2, 
1.0e-1, 1.0, 2.0 };  std::vectorint strataCounts(strataBounds.size());  
unsigned N = 0;  auto f = [](int position,int* ovec)  {if(int(position)  
ovec[0])return;++N;double aij = 0.0;std::istringstream 
iss(in.substr(ovec[2],ovec[3]-ovec[2]));iss  aij;aij=fabs(aij);
for(unsigned i = 0; i  strataBounds.size() - 1; ++i){  if(aij = 
strataBounds[i]  aij  strataBounds[i+1])  {++strataCounts[i];
break;  }}  };  regex(in,matrix.*= ([0-9.eE+-]+)\n,2,f);  
printf(read %d matrix elements (%dx%d = %d)\n,N,int(sqrt(N)),int(sqrt(N)),N); 
 int total = 0;  for(unsigned i = 0; i strataBounds.size()-1;++i)  {total 
+= strataCounts[i];printf([%1.2e, %1.2e) = %d (%1.2f%%) %d\n, 
strataBounds[i], strataBounds[i+1],strataCounts[i], 
100*(double(strataCounts[i])/N), total);  }}


From: nicolasb...@gmail.com
Date: Fri, 8 Feb 2013 12:26:09 -0700
To: haskell-cafe@haskell.org
Subject: [Haskell-cafe] performance question

Hi list,
I wrote a script that reads matrix elements from standard input, parses the 
input using a regular expression, and then bins the matrix elements by 
magnitude. I wrote the same script in python (just to be sure :) ) and find 
that the python version vastly outperforms the Haskell script.


To be concrete:
$ time ./createMatrixDump.py -N 128 | ./printMatrixDecayreal0m2.655s
user0m2.677ssys 0m0.095s


$ time ./createMatrixDump.py -N 128 | ./printMatrixDecay.py -
real0m0.445suser0m0.615ssys 0m0.032s
The Haskell script was compiled with ghc --make printMatrixDecay.hs.


Could you have a look at the script and give me some pointers as to where I 
could improve it, both in terms of performance and also generally, as I am very 
new to Haskell.


Thanks already,
nick


___
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] xml conduit

2013-02-08 Thread Mateusz Kowalczyk
I don't know about xml-conduit but I know that such thing is possible in
HXT. See the `Modifying a Node' section at [1] for a trivial example.
You probably will have to read the whole page to somewhat understand
what's going on though.

[1] - http://adit.io/posts/2012-04-14-working_with_HTML_in_haskell.html

On 08/02/13 23:31, grant wrote:
 Hi,
 
 Is there a nice way to update xml. I want to be able to use xml-conduit
 to find a location in the xml and then add/update that node. 
 
 eg xpath from //d/e/f and then change the content at 'f' or add a new node
 
 a
 ...
   d
 e
   fsome data to change
   /f
 /e
   /d
 ...
 /a
 
 
 Thanks for any help,
 Grant
 
 
 ___
 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] CoArbitrary

2013-02-08 Thread Tony Morris
Hello,
In the QuickCheck library, there is a type-class called CoArbitrary. It
is defined like so:

class CoArbitrary a where
  coarbitrary :: a - Gen b - Gen b -- Gen is a monad

Its purpose is to allow generation of functions. In other words, for
taking Gen x - Gen (a - x), which could be done rather degenerately
(fmap const) but QuickCheck constrains with (CoArbitrary a) to perturb
the resulting value instead of ignoring (const) it.

It has always puzzled me in the general sense of thinking about the
scenario: f x - f (a - x) and whether the CoArbitrary is a
good/general solution, perhaps for the specific case of f=Gen or maybe
even more generally.

-- approximate
(a - f x - f x) -- e.g. CoArbitrary to perturb the result
- f x -- e.g. Gen x
- f (a - x) -- e.g. Gen (a - x)

So I often wonder about what might be a better (and perhaps more
general) constraint to produce functions f x - f (a - x) for a given
Monad f. I was wondering if there is an existing abstraction (or paper)
that might point me in that direction. It is a problem that I encounter
on occasion in general programming and I am using Arbitrary/CoArbitrary
as an example to help make my point, but I am dissatisfied (for reasons
that I am unsure about) with the solution provided by CoArbitrary.

What about other monads? For example, what is a general constraint to be
placed to permit a function Maybe x - Maybe (a - x) that does not
simply const away the argument.

I hope I have phrased this in a way to make the point. I found it a bit
difficult to articulate and I do wonder (hope!) that others encounter
similar scenarios. Thanks for any tips!

-- 
Tony Morris
http://tmorris.net/


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