Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Stephen Tetley
On 27 December 2010 07:35, Jonathan Geddes geddes.jonat...@gmail.com wrote:

 #1 Parse a string at compile-time so that a custom syntax for
 representing data can be used. At the extreme, this data might even
 be an EDSL.


Hello Jonathan

By this are you meaning to add quasiquoting to the language Haskell
or the Glasgow Haskell, taking it out of the domain of Template
Haskell?

How would the first example look like with Template Haskell and is
current quasiquoting syntax? I'm suspecting the differences are pretty
small.

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


Re: [Haskell-cafe] global, modifiable variable for debugging

2010-12-27 Thread Gregory Collins
We have some code to do exactly this:

https://github.com/snapframework/snap-core/blob/master/src/Snap/Internal/Debug.hs

You set a DEBUG environment variable to turn debugging output on. We
should probably split this code out into its own package.

G

On Sun, Dec 26, 2010 at 8:53 PM,  bri...@aracnet.com wrote:
 Hi,

 I have a program with a debug flag in it (Strangely I've yet to be
 able to write bug-free code).  I'd like to change the state of the
 debug flag based on command line args.

 I looked at IOVar but that would cause all the pure procedures to get
 swallowed by the IO Monad.

 Is a better way to get this behavior ?

 Thanks,

 Brian


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




-- 
Gregory Collins g...@gregorycollins.net

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


Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Jonas Almström Duregård
Hi,

 But TH gives me the same feeling as other language features that have
 been described as bolted on. Also, TH is both library and built-in
 syntax (via an extension) which feels strange to me.

I don't understand why the library/extension duality is a problem. I would
say that the best approach is to have language support (through extensions)
for primitive operations like splicing, and to have libraries that combine
these operations into more complex systems (like automatic derivation of
type classes).

 Again, TH is very powerful, and fills in a number of holes in
 Haskell's feature set. But it leaves me wondering if these holes
 should not be filled in by other, more specialized features, leaving
 TH to continue to find other holes to fill.

Shouldn't specialized features be defined in terms of general features?

 json :: String - JsonObject
 json = ...

 data = [ json |
{ name : Jonathan
, favorite language: Haskell
}
|]

How does this differ from the current QuasiQuotes extension? From what I can
tell, all you need to achieve this with TH is to automatically derive a
Language.Haskell.TH.Lift instance for JsonObject, i.e. a  function lift ::
JsonObject - Q Exp such that the expression will evaluate to the original
JsonObject. A QuasiQuoter like the one you describe can then be created by
QuasiQuoter { parseExp = lift . json }. Should both approaches be supported
directly, or should we sacrifice the generality of the current quoters for
the simplicity of the ones you suggest?


The second part (deriving instances for general type classes) is a lot more
complicated. I would say that the most general way of showing that a class
can be derived is to provide a function that produces a set of declarations
given the name of the datatype. Here's a very simple suggestion for
incorporating this into the Haskell deriving syntax. Suppose we have these
two classes and TH functions for deriving them:

class Class1 ...
class Class2 ...

class1 :: Name - Q [Dec]
class2 :: Name - Q [Dec]

data D = D deriving (Show,class1,class2)

The last declaration could expand to:

data D = D deriving Show
class1 'D
class2 'D

If you don't want to write class1 and class2 by operating directly on
Haskell declarations, but rather use some DSL for specifying instances, then
all you need is a function deriv :: DerivationDSL - (Name - Q [Dec]).

/J

On 27 December 2010 08:35, Jonathan Geddes geddes.jonat...@gmail.com
wrote:
 Cafe,

 First let me say that Template Haskell is very powerful and a lot of
 great work has been done in this area. It fills in a number of holes
 in Haskell's feature set.

 But TH gives me the same feeling as other language features that have
 been described as bolted on. Also, TH is both library and built-in
 syntax (via an extension) which feels strange to me. Finally, It's
 very complicated to do some simple things.

 I see TH used most for the following tasks:

 #1 Parse a string at compile-time so that a custom syntax for
 representing data can be used. At the extreme, this data might even
 be an EDSL.
 #2 Provide instances automatically.

 I would propose that more specialized features be implemented to
 accomplish these tasks. To start, I'll throw out some ideas that
 provide these capabilities.

 For TH use #1, compile-time parsing of arbitrary strings, I think it
 would be nice for quasiquote semantics to be modified so that code
 like

 json :: String - JsonObject
 json = ...

 data = [ json |
{ name : Jonathan
, favorite language: Haskell
}
|]

 causes the function json to be called at compile time with a string
 argument of{\name\ : \Jonathan\\n   , \favorite language\:
 \Haskell\\n   }. The whole expression being then replaced with the
 result of the function application. What I like about this is that
 defining quasiquoters is trivial. They're just functions of the form
 String - a. Many such quasiquoters already exist and would be ready
 for use! I imagine certain rules would apply, ie a quasiquoter must be
 defined prior to use and in a separate module, etc.

 For TH use #2, automatic instances, I would propose a way of declaring
 that a class can be automatically derived, and therefore added to the
 set [Eq, Ord, Show, Read, ... , etc]. This is the set of classes that
 can be put in the deriving clause of a type declaration. I don't
 know exactly what the syntax for this would look like, but I imagine
 it would look a bit like the various current implementations of
 automatic instances in TH.

 Again, TH is very powerful, and fills in a number of holes in
 Haskell's feature set. But it leaves me wondering if these holes
 should not be filled in by other, more specialized features, leaving
 TH to continue to find other holes to fill.

 I'm wondering if others see TH as a permanent solution, or if you
 agree with me that some of TH's most common usages should have more
 specialized features dedicated to them. It may very well be that I am
 simply not experienced 

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Jonas Almström Duregård
Hi Henning,

 I also think that Template Haskell is used too much. Several
 things that are done in existing libraries could be done in plain
 Haskell in a better way.

Can you give any examples of this? I'm not saying it's not true, I'm just
curious as to why you would venture into the realm of TH without a reason.

/J

On 27 December 2010 08:44, Henning Thielemann lemm...@henning-thielemann.de
 wrote:


 On Mon, 27 Dec 2010, Jonathan Geddes wrote:

  #1 Parse a string at compile-time so that a custom syntax for
 representing data can be used. At the extreme, this data might even
 be an EDSL.


 I think it would be enough, if the compiler could be told to unfold an
 expression like
  parse text in a domain specific language
  at compile time.

  #2 Provide instances automatically.



 http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/generic-classes.html


 I also think that Template Haskell is used too much. Several things that
 are done in existing libraries could be done in plain Haskell in a better
 way. For the cases where Template Haskell is really needed, I'd prefer a
 solution that allows to generate the code before compilation, such that
 packages with automatically generated code can be run also on compilers that
 do not support Template Haskell.


 ___
 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] parsec2 vs. parsec3... again

2010-12-27 Thread Evan Laforge
On Thu, Dec 23, 2010 at 12:01 PM, Evan Laforge qdun...@gmail.com wrote:
 Yeah, I know this has been discussed a number of times, but I have
 some concrete questions I haven't seen asked before.  And the parsec
 3 is now as fast as parsec 2 thing I've seen around doesn't seem to
 be true for me.

[ snip responses ]

So it sounds like the consensus is to bite the bullet and try
converting to ByteString + attoparsec and see if that helps.  Or write
attoparsec-text myself, or wait for someone else to do it :)

I might not get around to this real soon, but I'll post my results
when (if) I do.

Thanks for the responses!

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


Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Henning Thielemann


On Mon, 27 Dec 2010, Jonas Almström Duregård wrote:


Hi Henning,

 I also think that Template Haskell is used too much. Several
 things that are done in existing libraries could be done in plain
 Haskell in a better way.

Can you give any examples of this? I'm not saying it's not true, I'm just 
curious as to why you
would venture into the realm of TH without a reason.


E.g. refer to the recent discussion of storable-endian.

http://www.haskell.org/pipermail/haskell-cafe/2010-December/087551.html

Or look into package 'encoding'. It uses TemplateHaskell in order to 
convert Text descriptions of character sets into Haskell tables. I think 
the character tables could be simply rewritten to Haskell syntax, or they 
could be parsed by a function, where the parsed content is unfolded at 
compile time. It could even be computed at runtime, since it is only 
computed once because of laziness.


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


Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Ivan Lazar Miljenovic
2010/12/27 Henning Thielemann lemm...@henning-thielemann.de:
 Or look into package 'encoding'. It uses TemplateHaskell in order to convert
 Text descriptions of character sets into Haskell tables. I think the
 character tables could be simply rewritten to Haskell syntax, or they could
 be parsed by a function, where the parsed content is unfolded at compile
 time. It could even be computed at runtime, since it is only computed once
 because of laziness.

http://hackage.haskell.org/package/zeroth ?

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

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


[Haskell-cafe] ANNOUNCE: greg-client - a scalable distributed logger with a high-precision global time axis

2010-12-27 Thread Eugene Kirpichov
Hi cafe,

Let me bring to your attention this package developed by me and Dmitry Astapov:

http://hackage.haskell.org/package/greg-client

It is a Haskell binding to the greg logger (
http://code.google.com/p/greg , http://github.com/jkff/greg - global
registrator ).

You can read the project's description and motivation at the homepage
http://code.google.com/p/greg , but here are some highlights:

 * It's designed for debugging lattency bottlenecks or synchronization
issues in distributed systems. I've been using it on small and large
clusters, Dmitry has been using it for debugging haskell-mpi if I'm
correct (Dmitry, can you elaborate a bit?).

 * It's a client/server logger - you launch a server and clients log
messages to it
 * It provides a high-precision global time axis by computing clock
offset between server and each client (this allows to register events
with their occurence timestamps, not arrival-to-server timestamps)
 * It's very fast (I squeezed 400,000 messages/sec = 20Mb/s out of the
Java binding)
 * It can handle a huge number of clients (a much less scalable
implementation was tested on a 2000-core cluster)
 * It's robust to intermittent deaths of clients, server or the link
between them
 * It's very lightweight - no persistence infrastructure, piles of
config files or whatever - just send him the messages, it will align
them on the global axis and log them to console

I found it especially useful in conjunction with the log visualization
tools described here
http://slideshare.net/jkff/two-visualization-tools .

P.S. How to use it (while hackage hasn't yet rebuilt the docs):

import System.Log.Greg

main = withGregDo defaultConfiguration $ do 
...logMessage Something happened...

-- 
Eugene Kirpichov
Senior Software Engineer,
Grid Dynamics http://www.griddynamics.com/

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


Re: [Haskell-cafe] parsec2 vs. parsec3... again

2010-12-27 Thread Felipe Almeida Lessa
Hello!

On Mon, Dec 27, 2010 at 9:41 AM, Evan Laforge qdun...@gmail.com wrote:
 So it sounds like the consensus is to bite the bullet and try
 converting to ByteString + attoparsec and see if that helps.  Or write
 attoparsec-text myself, or wait for someone else to do it :)

 I might not get around to this real soon, but I'll post my results
 when (if) I do.

I've uploaded attoparsec-text and attoparsec-text-enumerator to
Hackage.  I've written those packages late last week and asked for
comments from attoparsec and attoparsec-enumerator's maintainers.
Although both packages weren't stress tested (actually they were very
lightly tested), I'm releasing them so that we don't waste efforts
duplicating work =).

I'll make an announcement later today if no critical bugs are found.
Please test it and try to break it =).  Bonus points if we give us
some numbers about how it compares to your Parsec 2/3 approach.

Links:
http://hackage.haskell.org/package/attoparsec-text
http://hackage.haskell.org/package/attoparsec-text-enumerator

Cheers! =D

-- 
Felipe.

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


Re: [Haskell-cafe] parsec2 vs. parsec3... again

2010-12-27 Thread Evan Laforge
 I've uploaded attoparsec-text and attoparsec-text-enumerator to
 Hackage.  I've written those packages late last week and asked for

Very nice!  I'll download this and try it out.  Attoparsec has a bit
different combinators than parsec so it'll take some rewriting, but
it's work I'd have to do anyway to try the bytestring+attoparsec
approach.

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


[Haskell-cafe] ANNOUNCE: yackage 0.0.0

2010-12-27 Thread Michael Snoyman
Hi all,

I was speaking with my coworker Yitz[1] about a project he's working
on. Basically, he's going to end up with about 16 cabal packages that
are not going to be deployed to Hackage, and wanted us to set up a
Hackage server for our company to deploy these kinds of things.
However, getting all the pieces of Hackage aligned properly for such a
simple use case seemed a bit overkill.

I then realized that I had the exact same problem during Yesod
development: before I make a major release, I usually end up with
about 10-15 packages that are not yet live on Hackage. It gets to be a
real pain when suddenly wai-extra is depending on network 2.3 and
authenticate requires network 2.2, and suddenly I need to manually
recompile 10 packages.

So I decided to write up a simple web service to act as a local
Hackage server. It has no security (anyone with access can upload a
package), doesn't build haddocks, doesn't show package descriptions,
etc. All it does is:

Show a list of uploaded packages/versions
Links to the tarballs
Allows you to upload new versions, which will automatically overwrite
existing packages
Provides the 00-index.tar.gz file needed by cabal-install, as well as
the tarballs for all the packages

In order to use this, just do the following:

cabal install yackage
run yackage
Upload your packages
Add remote-repo: yackage:http://localhost:3500/ to your ~/.cabal/config file
cabal update
Install your packages are usual

You'll need to leave yackage running whenever you want to run an
update or download new packages. A few other usage notes:

If you overwrite a package, your cache folder will still have the old
version. You might want to just wipe our your cache folder on each
usage.
Running cabal update will download the update for both yackage and the
main hackage server; the latter can be a long process depending on
your internet connection.

Here's a little shell script that will disable the Hackage repo, wipe
our the Yackage cache, update and re-enable the Hackage repo:

#!/bin/sh

CABAL_DIR=~/.cabal

cp $CABAL_DIR/config $CABAL_DIR/config.sav
sed 's/^remote-repo: hackage/--remote-repo: hackage/' 
$CABAL_DIR/config.sav  $CABAL_DIR/config
rm -rf $CABAL_DIR/packages/yackage
cabal update
cp $CABAL_DIR/config.sav $CABAL_DIR/config

I hope others find this tool useful.

Michael

[1] http://www.haskellers.com/user/Yitz_Gale/

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


Re: [Haskell-cafe] ANNOUNCE: yackage 0.0.0

2010-12-27 Thread David Leimbach
This is very interesting.  I was thinking if this could work like an
overlayed namespace on top of Hackage, rather than a complete override,
that it would be a very interesting way to fork Hackage so it does what
you want, transparently, and as a proxy.  Is that actually how it works
though?  (It might be that I've not had my coffee yet, but I'm a little
fuzzy on that point).

While the Haskell-platform is a great stabilizing technology for the Haskell
community and gives a nice warm fuzzy feeling to those who want to try it in
commercial settings, it's not always true that it provides enough
functionality for everyone's needs, and being able to somewhat modify what's
available on Hackage could be very valuable.

Dave

On Mon, Dec 27, 2010 at 8:41 AM, Michael Snoyman mich...@snoyman.comwrote:

 Hi all,

 I was speaking with my coworker Yitz[1] about a project he's working
 on. Basically, he's going to end up with about 16 cabal packages that
 are not going to be deployed to Hackage, and wanted us to set up a
 Hackage server for our company to deploy these kinds of things.
 However, getting all the pieces of Hackage aligned properly for such a
 simple use case seemed a bit overkill.

 I then realized that I had the exact same problem during Yesod
 development: before I make a major release, I usually end up with
 about 10-15 packages that are not yet live on Hackage. It gets to be a
 real pain when suddenly wai-extra is depending on network 2.3 and
 authenticate requires network 2.2, and suddenly I need to manually
 recompile 10 packages.

 So I decided to write up a simple web service to act as a local
 Hackage server. It has no security (anyone with access can upload a
 package), doesn't build haddocks, doesn't show package descriptions,
 etc. All it does is:

 Show a list of uploaded packages/versions
 Links to the tarballs
 Allows you to upload new versions, which will automatically overwrite
 existing packages
 Provides the 00-index.tar.gz file needed by cabal-install, as well as
 the tarballs for all the packages

 In order to use this, just do the following:

 cabal install yackage
 run yackage
 Upload your packages
 Add remote-repo: yackage:http://localhost:3500/ to your ~/.cabal/config
 file
 cabal update
 Install your packages are usual

 You'll need to leave yackage running whenever you want to run an
 update or download new packages. A few other usage notes:

 If you overwrite a package, your cache folder will still have the old
 version. You might want to just wipe our your cache folder on each
 usage.
 Running cabal update will download the update for both yackage and the
 main hackage server; the latter can be a long process depending on
 your internet connection.

 Here's a little shell script that will disable the Hackage repo, wipe
 our the Yackage cache, update and re-enable the Hackage repo:

 #!/bin/sh

 CABAL_DIR=~/.cabal

 cp $CABAL_DIR/config $CABAL_DIR/config.sav
 sed 's/^remote-repo: hackage/--remote-repo: hackage/' 
 $CABAL_DIR/config.sav  $CABAL_DIR/config
 rm -rf $CABAL_DIR/packages/yackage
 cabal update
 cp $CABAL_DIR/config.sav $CABAL_DIR/config

 I hope others find this tool useful.

 Michael

 [1] http://www.haskellers.com/user/Yitz_Gale/

 ___
 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] Template Haskell a Permanent solution?

2010-12-27 Thread Jonathan Geddes
On Mon, Dec 27, 2010 at 12:44 AM, Henning Thielemann
lemm...@henning-thielemann.de wrote:
 I think it would be enough, if the compiler could be told to unfold an
 expression like
  parse text in a domain specific language
  at compile time.

I'm afraid I have to disagree with you here. Being able to specify
that the string should be parsed at compile time is only half of the
equation in my mind. The other half is the clean syntax for multi-line
strings.

Haskell already has great syntax for specifying data in a declarative
manner. Especially in contrast with ie Java/C++. Even as good as the
dynamic languages ie JavaScript/Python/Ruby. When you add the ability
to specify data in ANY syntax you can parse, Haskell is clearly the
best. But the complexity of TH detracts from the elegance of this
greatly in my opinion. And wrapping your data in string syntax,
multi-line or otherwise, detracts from the elegance as well. A syntax
has to be less painful or more convenient or more
readable/maintainable than literal list/record syntax before it is
useful.

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


Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Jonathan Geddes
On Mon, Dec 27, 2010 at 1:14 AM, Stephen Tetley
stephen.tet...@gmail.com wrote:

 By this are you meaning to add quasiquoting to the language Haskell
 or the Glasgow Haskell, taking it out of the domain of Template
 Haskell?

I believe that all new features should start as extensions and as an
extension, these things could coexist with TH. I just can't see TH
becoming standard. I think something much simpler that accomplishes
the common uses of TH is more likely to make it into Haskell'
20[1-2]x.

--Jonathan

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


Re: [Haskell-cafe] ANNOUNCE: yackage 0.0.0

2010-12-27 Thread Erik Hesselink
There is also the hackage 2.0 code [1]. This can be easily
cabal-installed, and added as an extra remote-repo to your
.cabal/config file. We've set this up at typLAB [2], and it's working
great. Cabal upload doesn't support multiple remote repo's, but we've
created a small deployment utility to quickly deploy to our own
hackage. By careful version number management, you can also create
local forks of hackage packages.

Erik

[1] http://hackage.haskell.org/trac/hackage/wiki/HackageDB
[2] http://www.typlab.com

On Mon, Dec 27, 2010 at 17:53, David Leimbach leim...@gmail.com wrote:
 This is very interesting.  I was thinking if this could work like an
 overlayed namespace on top of Hackage, rather than a complete override,
 that it would be a very interesting way to fork Hackage so it does what
 you want, transparently, and as a proxy.  Is that actually how it works
 though?  (It might be that I've not had my coffee yet, but I'm a little
 fuzzy on that point).
 While the Haskell-platform is a great stabilizing technology for the Haskell
 community and gives a nice warm fuzzy feeling to those who want to try it in
 commercial settings, it's not always true that it provides enough
 functionality for everyone's needs, and being able to somewhat modify what's
 available on Hackage could be very valuable.
 Dave

 On Mon, Dec 27, 2010 at 8:41 AM, Michael Snoyman mich...@snoyman.com
 wrote:

 Hi all,

 I was speaking with my coworker Yitz[1] about a project he's working
 on. Basically, he's going to end up with about 16 cabal packages that
 are not going to be deployed to Hackage, and wanted us to set up a
 Hackage server for our company to deploy these kinds of things.
 However, getting all the pieces of Hackage aligned properly for such a
 simple use case seemed a bit overkill.

 I then realized that I had the exact same problem during Yesod
 development: before I make a major release, I usually end up with
 about 10-15 packages that are not yet live on Hackage. It gets to be a
 real pain when suddenly wai-extra is depending on network 2.3 and
 authenticate requires network 2.2, and suddenly I need to manually
 recompile 10 packages.

 So I decided to write up a simple web service to act as a local
 Hackage server. It has no security (anyone with access can upload a
 package), doesn't build haddocks, doesn't show package descriptions,
 etc. All it does is:

 Show a list of uploaded packages/versions
 Links to the tarballs
 Allows you to upload new versions, which will automatically overwrite
 existing packages
 Provides the 00-index.tar.gz file needed by cabal-install, as well as
 the tarballs for all the packages

 In order to use this, just do the following:

 cabal install yackage
 run yackage
 Upload your packages
 Add remote-repo: yackage:http://localhost:3500/ to your ~/.cabal/config
 file
 cabal update
 Install your packages are usual

 You'll need to leave yackage running whenever you want to run an
 update or download new packages. A few other usage notes:

 If you overwrite a package, your cache folder will still have the old
 version. You might want to just wipe our your cache folder on each
 usage.
 Running cabal update will download the update for both yackage and the
 main hackage server; the latter can be a long process depending on
 your internet connection.

 Here's a little shell script that will disable the Hackage repo, wipe
 our the Yackage cache, update and re-enable the Hackage repo:

 #!/bin/sh

 CABAL_DIR=~/.cabal

 cp $CABAL_DIR/config $CABAL_DIR/config.sav
 sed 's/^remote-repo: hackage/--remote-repo: hackage/' 
 $CABAL_DIR/config.sav  $CABAL_DIR/config
 rm -rf $CABAL_DIR/packages/yackage
 cabal update
 cp $CABAL_DIR/config.sav $CABAL_DIR/config

 I hope others find this tool useful.

 Michael

 [1] http://www.haskellers.com/user/Yitz_Gale/

 ___
 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] ANNOUNCE: yackage 0.0.0

2010-12-27 Thread Michael Snoyman
This was brought up on reddit[1]. Anyone who is interested in the
differences should feel free to look there.

Michael

[1] 
http://www.reddit.com/r/haskell/comments/es3of/announcing_yackage_your_personal_hackage_server/c1ah7gi

On Mon, Dec 27, 2010 at 9:24 PM, Erik Hesselink hessel...@gmail.com wrote:
 There is also the hackage 2.0 code [1]. This can be easily
 cabal-installed, and added as an extra remote-repo to your
 .cabal/config file. We've set this up at typLAB [2], and it's working
 great. Cabal upload doesn't support multiple remote repo's, but we've
 created a small deployment utility to quickly deploy to our own
 hackage. By careful version number management, you can also create
 local forks of hackage packages.

 Erik

 [1] http://hackage.haskell.org/trac/hackage/wiki/HackageDB
 [2] http://www.typlab.com

 On Mon, Dec 27, 2010 at 17:53, David Leimbach leim...@gmail.com wrote:
 This is very interesting.  I was thinking if this could work like an
 overlayed namespace on top of Hackage, rather than a complete override,
 that it would be a very interesting way to fork Hackage so it does what
 you want, transparently, and as a proxy.  Is that actually how it works
 though?  (It might be that I've not had my coffee yet, but I'm a little
 fuzzy on that point).
 While the Haskell-platform is a great stabilizing technology for the Haskell
 community and gives a nice warm fuzzy feeling to those who want to try it in
 commercial settings, it's not always true that it provides enough
 functionality for everyone's needs, and being able to somewhat modify what's
 available on Hackage could be very valuable.
 Dave

 On Mon, Dec 27, 2010 at 8:41 AM, Michael Snoyman mich...@snoyman.com
 wrote:

 Hi all,

 I was speaking with my coworker Yitz[1] about a project he's working
 on. Basically, he's going to end up with about 16 cabal packages that
 are not going to be deployed to Hackage, and wanted us to set up a
 Hackage server for our company to deploy these kinds of things.
 However, getting all the pieces of Hackage aligned properly for such a
 simple use case seemed a bit overkill.

 I then realized that I had the exact same problem during Yesod
 development: before I make a major release, I usually end up with
 about 10-15 packages that are not yet live on Hackage. It gets to be a
 real pain when suddenly wai-extra is depending on network 2.3 and
 authenticate requires network 2.2, and suddenly I need to manually
 recompile 10 packages.

 So I decided to write up a simple web service to act as a local
 Hackage server. It has no security (anyone with access can upload a
 package), doesn't build haddocks, doesn't show package descriptions,
 etc. All it does is:

 Show a list of uploaded packages/versions
 Links to the tarballs
 Allows you to upload new versions, which will automatically overwrite
 existing packages
 Provides the 00-index.tar.gz file needed by cabal-install, as well as
 the tarballs for all the packages

 In order to use this, just do the following:

 cabal install yackage
 run yackage
 Upload your packages
 Add remote-repo: yackage:http://localhost:3500/ to your ~/.cabal/config
 file
 cabal update
 Install your packages are usual

 You'll need to leave yackage running whenever you want to run an
 update or download new packages. A few other usage notes:

 If you overwrite a package, your cache folder will still have the old
 version. You might want to just wipe our your cache folder on each
 usage.
 Running cabal update will download the update for both yackage and the
 main hackage server; the latter can be a long process depending on
 your internet connection.

 Here's a little shell script that will disable the Hackage repo, wipe
 our the Yackage cache, update and re-enable the Hackage repo:

 #!/bin/sh

 CABAL_DIR=~/.cabal

 cp $CABAL_DIR/config $CABAL_DIR/config.sav
 sed 's/^remote-repo: hackage/--remote-repo: hackage/' 
 $CABAL_DIR/config.sav  $CABAL_DIR/config
 rm -rf $CABAL_DIR/packages/yackage
 cabal update
 cp $CABAL_DIR/config.sav $CABAL_DIR/config

 I hope others find this tool useful.

 Michael

 [1] http://www.haskellers.com/user/Yitz_Gale/

 ___
 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] Unknown symbol `__dso_handle' with Template Haskell and wxHaskell

2010-12-27 Thread Erik Hesselink
We had this problem with a binding to a C++ library (through a C
wrapper). GHCi and cabal didn't work, but ghc --make did. How are you
compiling exactly when you get this error? This is somehow related to
TH, without it, at least cabal also works. I'm not sure about GHCi.
There's also a relevant bug in the GHC trac, but I can't seem to find
it now.

Erik

On Sat, Dec 25, 2010 at 18:41, Alexander Bau a...@imn.htwk-leipzig.de wrote:
 Hi,

 I am using Template Haskell and wxHaskell [1]. When Graphics.UI.WX is
 loaded during THs code generation, I get the following error:

 ...
 Loading package wxdirect-0.12.1.3 ... linking ... done.
 ghc: /usr/local/lib/wxcore-0.12.1.6/ghc-6.12.3/HSwxcore-0.12.1.6.o:
 unknown symbol `__dso_handle'
 Loading package wxcore-0.12.1.6 ...
 linking ... ghc: unable to load package `wxcore-0.12.1.6'

 System stats:
 ghc-6.12.3
 template-haskell-2.4.0.1
 wx-0.12.1.6

 Regards,

 Alex

 [1] Example:

 -- Test.hs --

 {-# LANGUAGE TemplateHaskell #-}
 module Test2 where

 import Language.Haskell.TH
 import qualified Graphics.UI.WX as WX

 foo :: Q [Dec]
 foo = do
  info - reify ''WX.Color
  runIO $ print info
  return []

 -- Main.hs --

 {-# LANGUAGE TemplateHaskell #-}
 module Main where

 import Test

 $(foo)


 ___
 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] instance for (Show ([(String, Int)] - Int))

2010-12-27 Thread Aaron Gray
On 24 December 2010 23:58, Daniel Fischer
daniel.is.fisc...@googlemail.comwrote:

 On Saturday 25 December 2010 00:32:38, Aaron Gray wrote:
  Okay great, works this end too, but what does the 'flip' do ???

 It flips the order of arguments to calc. You could also write

 main = getContents = print . (`calc` []) . lexer

 Generally,

 flip f = \x y - f y x

 or

 flip f x = \y - f y x

 flip f x y = f y x


Thanks Daniel,

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


Re: [Haskell-cafe] instance for (Show ([(String, Int)] - Int))

2010-12-27 Thread Aaron Gray
On 24 December 2010 23:58, Daniel Fischer
daniel.is.fisc...@googlemail.comwrote:

 On Saturday 25 December 2010 00:32:38, Aaron Gray wrote:
  Okay great, works this end too, but what does the 'flip' do ???

 It flips the order of arguments to calc. You could also write

 main = getContents = print . (`calc` []) . lexer

 Generally,

 flip f = \x y - f y x

 or

 flip f x = \y - f y x

 flip f x y = f y x


Or :-

calcExpr :: [Token] - Int
calcExpr tokens = calc tokens []

process = print . calcExpr . lexer

makes things clearer.

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


Re: [Haskell-cafe] Unknown symbol `__dso_handle' with Template Haskell and wxHaskell

2010-12-27 Thread Alexander Bau
 GHCi and cabal didn't work, but ghc --make did.

Neither GHCi, cabal nor ghc --make works.

I refactored my code, so that all TH related stuff does not depend on 
wxHaskell, i.e. wxHaskell doesn't need to be loaded during THs code 
generation. Then ghc --make works fine. But when using cabal, the same 
error occurs. 

It seems to me that TH (when used with cabal) loads all packages 
specified at Build-Depends in your cabal file (whether they are needed 
or not). ghc --make instead just loads all packages, that are really 
needed for THs code generation.

But this is just a workaround and does not explain why TH does not work 
with wxHaskell. I think this is somehow related to the inability to use 
wxHaskell inside of GHCi [1], because then the same error occurs.

[1] http://comments.gmane.org/
gmane.comp.lang.haskell.wxhaskell.general/923


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


[Haskell-cafe] How to instance MonadIO Identity?

2010-12-27 Thread Magicloud Magiclouds
Hi,
  From another thread in this list, I got code as:
 instance MonadIO Identity where
 liftIO = id
  Well, it does not work for me as:
Message.hs:22:12:
Couldn't match expected type `Identity a' with actual type `IO a'
Expected type: IO a - Identity a
  Actual type: IO a - IO a
In the expression: id
In an equation for `liftIO': liftIO = id
-- 
竹密岂妨流水过
山高哪阻野云飞

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


Re: [Haskell-cafe] How to instance MonadIO Identity?

2010-12-27 Thread Michael Snoyman
The only way to create such an instance would be with unsafePerformIO,
which in this case would be a Very Bad Idea (tm).

Michael

On Tue, Dec 28, 2010 at 7:29 AM, Magicloud Magiclouds
magicloud.magiclo...@gmail.com wrote:
 Hi,
  From another thread in this list, I got code as:
 instance MonadIO Identity where
 liftIO = id
  Well, it does not work for me as:
 Message.hs:22:12:
Couldn't match expected type `Identity a' with actual type `IO a'
Expected type: IO a - Identity a
  Actual type: IO a - IO a
In the expression: id
In an equation for `liftIO': liftIO = id
 --
 竹密岂妨流水过
 山高哪阻野云飞

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


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


Re: [Haskell-cafe] How to instance MonadIO Identity?

2010-12-27 Thread Magicloud Magiclouds
  Ah, that is a bad news.
  I am using Control.Monad.Writer and Data.Encoding. Code like (not compilable)
43|instance WithMessage String where
44|  append s = (liftIO $ getSystemEncoding) = (\e - tell $
encodeLazyByteString e s)
  May I know how to make this work?

2010/12/28 Michael Snoyman mich...@snoyman.com:
 The only way to create such an instance would be with unsafePerformIO,
 which in this case would be a Very Bad Idea (tm).

 Michael

 On Tue, Dec 28, 2010 at 7:29 AM, Magicloud Magiclouds
 magicloud.magiclo...@gmail.com wrote:
 Hi,
  From another thread in this list, I got code as:
 instance MonadIO Identity where
     liftIO = id
  Well, it does not work for me as:
 Message.hs:22:12:
    Couldn't match expected type `Identity a' with actual type `IO a'
    Expected type: IO a - Identity a
      Actual type: IO a - IO a
    In the expression: id
    In an equation for `liftIO': liftIO = id
 --
 竹密岂妨流水过
 山高哪阻野云飞

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





-- 
竹密岂妨流水过
山高哪阻野云飞

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


Re: [Haskell-cafe] How to instance MonadIO Identity?

2010-12-27 Thread Michael Snoyman
Well, you *could* use unsafePerformIO on getSystemEncoding, though I'm
not familiar with getSystemEncoding, so I can't tell you whether this
is an acceptable usage of unsafePerformIO.

On Tue, Dec 28, 2010 at 7:47 AM, Magicloud Magiclouds
magicloud.magiclo...@gmail.com wrote:
  Ah, that is a bad news.
  I am using Control.Monad.Writer and Data.Encoding. Code like (not compilable)
 43|instance WithMessage String where
 44|  append s = (liftIO $ getSystemEncoding) = (\e - tell $
 encodeLazyByteString e s)
  May I know how to make this work?

 2010/12/28 Michael Snoyman mich...@snoyman.com:
 The only way to create such an instance would be with unsafePerformIO,
 which in this case would be a Very Bad Idea (tm).

 Michael

 On Tue, Dec 28, 2010 at 7:29 AM, Magicloud Magiclouds
 magicloud.magiclo...@gmail.com wrote:
 Hi,
  From another thread in this list, I got code as:
 instance MonadIO Identity where
 liftIO = id
  Well, it does not work for me as:
 Message.hs:22:12:
Couldn't match expected type `Identity a' with actual type `IO a'
Expected type: IO a - Identity a
  Actual type: IO a - IO a
In the expression: id
In an equation for `liftIO': liftIO = id
 --
 竹密岂妨流水过
 山高哪阻野云飞

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





 --
 竹密岂妨流水过
 山高哪阻野云飞


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


Re: [Haskell-cafe] How to instance MonadIO Identity?

2010-12-27 Thread Antoine Latter
There are a couple of ways to handle this - either call
getSystemEncoding on the outside, before calling 'runWriter', and then
pass it in to your writer computation, or use 'WriterT IO' instead of
'Writer'.

That would be something like:

main = do
  result - runWriterT ( computation involving 'tell' and 'liftIO')
  ( computation using result)

The error message in your case can be difficult to understand - the
'Writer' type is a synonym for the type 'WriterT Identity'. Since none
of these types involve IO, then liftIO can't be used.

Antoine


On Tue, Dec 28, 2010 at 12:47 AM, Magicloud Magiclouds
magicloud.magiclo...@gmail.com wrote:
  Ah, that is a bad news.
  I am using Control.Monad.Writer and Data.Encoding. Code like (not compilable)
 43|instance WithMessage String where
 44|  append s = (liftIO $ getSystemEncoding) = (\e - tell $
 encodeLazyByteString e s)
  May I know how to make this work?

 2010/12/28 Michael Snoyman mich...@snoyman.com:
 The only way to create such an instance would be with unsafePerformIO,
 which in this case would be a Very Bad Idea (tm).

 Michael

 On Tue, Dec 28, 2010 at 7:29 AM, Magicloud Magiclouds
 magicloud.magiclo...@gmail.com wrote:
 Hi,
  From another thread in this list, I got code as:
 instance MonadIO Identity where
     liftIO = id
  Well, it does not work for me as:
 Message.hs:22:12:
    Couldn't match expected type `Identity a' with actual type `IO a'
    Expected type: IO a - Identity a
      Actual type: IO a - IO a
    In the expression: id
    In an equation for `liftIO': liftIO = id
 --
 竹密岂妨流水过
 山高哪阻野云飞

 ___
 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] How to instance MonadIO Identity?

2010-12-27 Thread Magicloud Magiclouds
Wow, this explains a lot. Thanks.

On Tue, Dec 28, 2010 at 2:05 PM, Antoine Latter aslat...@gmail.com wrote:
 There are a couple of ways to handle this - either call
 getSystemEncoding on the outside, before calling 'runWriter', and then
 pass it in to your writer computation, or use 'WriterT IO' instead of
 'Writer'.

 That would be something like:

 main = do
  result - runWriterT ( computation involving 'tell' and 'liftIO')
  ( computation using result)

 The error message in your case can be difficult to understand - the
 'Writer' type is a synonym for the type 'WriterT Identity'. Since none
 of these types involve IO, then liftIO can't be used.

 Antoine


 On Tue, Dec 28, 2010 at 12:47 AM, Magicloud Magiclouds
 magicloud.magiclo...@gmail.com wrote:
  Ah, that is a bad news.
  I am using Control.Monad.Writer and Data.Encoding. Code like (not 
 compilable)
 43|instance WithMessage String where
 44|  append s = (liftIO $ getSystemEncoding) = (\e - tell $
 encodeLazyByteString e s)
  May I know how to make this work?

 2010/12/28 Michael Snoyman mich...@snoyman.com:
 The only way to create such an instance would be with unsafePerformIO,
 which in this case would be a Very Bad Idea (tm).

 Michael

 On Tue, Dec 28, 2010 at 7:29 AM, Magicloud Magiclouds
 magicloud.magiclo...@gmail.com wrote:
 Hi,
  From another thread in this list, I got code as:
 instance MonadIO Identity where
     liftIO = id
  Well, it does not work for me as:
 Message.hs:22:12:
    Couldn't match expected type `Identity a' with actual type `IO a'
    Expected type: IO a - Identity a
      Actual type: IO a - IO a
    In the expression: id
    In an equation for `liftIO': liftIO = id
 --
 竹密岂妨流水过
 山高哪阻野云飞

 ___
 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] Template Haskell a Permanent solution?

2010-12-27 Thread Jonathan Geddes
Thanks, everyone, for the responses.

 I don't understand why the library/extension duality is a problem.

I don't think it is a _problem_ it just feels strange to me. Maybe I'm
misunderstanding, is it possible to use TH without using the library
components?

 Shouldn't specialized features be defined in terms of general features?

Absolutely, but usually don't you use the specialized features over
general ones where you can? For example, I don't often (if ever) use
the general feature of the goto statement in C. Instead I use
conditionals, loops, and functions. I don't often write explicitly
recursive functions in Haskell, rather I use map, filter, fold, etc.
whenever the structure of the recursion allows.

 How does this differ from the current QuasiQuotes extension? From what I can
 tell, all you need to achieve this with TH is to automatically derive a
 Language.Haskell.TH.Lift instance for JsonObject, i.e. a  function lift ::
 JsonObject - Q Exp such that the expression will evaluate to the original
 JsonObject. A QuasiQuoter like the one you describe can then be created by
 QuasiQuoter { parseExp = lift . json }.

Right, it's not a lot of extra work. But it's enough that in most
cases, I stick with constructing records or using other built-in
syntax.

 Should both approaches be supported
 directly, or should we sacrifice the generality of the current quoters for
 the simplicity of the ones you suggest?

No, I don't think TH should be sacrificed. I just think more specific
(and more simple) features might be nice in place of some of TH's
specific uses.

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