Re: [Haskell-cafe] Proposal: Australian Hackathon

2010-03-15 Thread Erik de Castro Lopo
Ivan Miljenovic wrote:

> Would other Australians be interested in having our own Hackathon (why
> should all those northerners have all the fun)?

Agreed!

>  I'm thinking about
> organising it to be in the July break between university semesters.

I'm a working programmer who has no idea when the university semesters
start and end. Please don't leave me out :-).

> * LLVM if David Terei comes

I'm definitely interested in that one. I spent some time last night
starting to package LLVM and its dependencies for Debian.

> So, at least as an initial listing, we'd need to have a listing of:
> 1) Who's interested
> 2) What dates are good

As the father of a school age child, I have some rather high demands
on my 4 weeks of annual leave. For me, it would be advantageous if
this could be arranged to overlap a weekend or better yet a long
weekend.

> 3) What projects people want to work on

Ben's DDC compiler is another interesting project people could work on.

Cheers,
Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal: Australian Hackathon

2010-03-15 Thread Ben Lippmeier

On 16/03/2010, at 4:28 PM, Ivan Miljenovic wrote:

> * A plotting library using Ben's newly released Gloss library (for
> people who can't or won't install Gtk2Hs to get Chart working; Alex
> Mason is interested in this)
> * Various graph-related project (graphviz, generic graph class, etc.;
> this assumes someone else apart from me cares about this stuff)
> * Hubris if Mark Wotton comes along
> * LLVM if David Terei comes

I'd suggest focusing on core Haskell infrastructure, like compilers and tools, 
rather than individual libraries -- though it all depends on who wants to come 
along.


> So, at least as an initial listing, we'd need to have a listing of:
> 1) Who's interested
> 2) What dates are good
> 3) What projects people want to work on
> 4) Where we can host this

You'll also want to consider how a proposed OzHaskell might align and/or 
combine with other events such as SAPLING[1] and fp-syd[2]. There is also the 
ICFP programming contest in a few months that many people will be interested 
in...

Hosting is not a problem. If people want to come to Sydney then I'm sure we can 
organise a room at UNSW. 

Ben.


[1] http://plrg.ics.mq.edu.au/projects/show/sapling
[2] http://groups.google.com/group/fp-syd
[3] http://www.icfpconference.org/contest.html

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


Re: [Haskell-cafe] Can't cabal install darcs because hashed-storage needs 'System'

2010-03-15 Thread Daniel McAllansmith
On Sat, 13 Mar 2010 Daniel McAllansmith wrote:
> Hello.
> 
> 
> Short story:
> 
> $ cabal install --global --constraint="old-time>=1.0.0.3.1" --reinstall -v
> darcs
> 
> 
> /tmp/hashed-storage-0.4.71127/hashed-storage-0.4.7/Setup.hs:13:7:
> Could not find module `System':
>   Use -v to see a list of the files searched for.
> 
> 
> This is using GHC 6.12.1, cabal-install 0.8.0 and Cabal 1.8.0.2
> 
> How do I get darcs installed?

I managed to get hashed-storage installed by patching Setup.hs replacing:

import System( system, exitWith )

with:

import System.Process( system )
import System.Exit( exitWith )

and adding process>=1.0.1.1 to the build-depends.


I also needed to replace:

import System( system )
import System.Process ( ProcessHandle,
runInteractiveProcess, waitForProcess,
getProcessExitCode )

with:

import System.Process ( ProcessHandle,
runInteractiveProcess, waitForProcess,
getProcessExitCode, system )

in darcs' Distribution/ShellHarness.hs to get it to compile.


I don't know whether these changes would let these packages continue to build 
against older versions of GHC/base but if anyone wants them I can create 
proper darcs patches if they're useful.


Cheers
Dan

> 
> Longer story:
> 
> I've been trying to install darcs 2.4 built against a patched version of
> old- time, 1.0.0.3.1 is effectively 1.0.0.4 just that it's patched locally
> because 1.0.0.4 hasn't been released to hackage yet.
> 
> I ran into various problems with global vs. user packages, no version of
> base being valid and a few other bits and pieces.  So I am trying a global
> install and have had to reinstall Cabal (and various other packages),
> presumably because it was built against old-time 1.0.0.3.
> 
> Looking at the hashed-storage code it imports System (system, exitWith). 
> Is that old base-3 code?
> 
> The debug messages show:
> 
> selecting base-3.0.3.2 (installed) and 4.2.0.0 (installed)
> 
> and
> 
> /usr/local/bin/ghc --make /tmp/hashed-storage-0.4.71127/hashed-
> storage-0.4.7/Setup.hs -o /tmp/hashed-storage-0.4.71127/hashed-
> storage-0.4.7/dist/setup/setup -odir /tmp/hashed-storage-0.4.71127/hashed-
> storage-0.4.7/dist/setup -hidir /tmp/hashed-storage-0.4.71127/hashed-
> storage-0.4.7/dist/setup -i -i/tmp/hashed-storage-0.4.71127/hashed-
> storage-0.4.7 -package Cabal-1.8.0.2
> 
> so I'm not really sure what version of base it's actually trying to compile
> hashed-storage against.
> 
> Any further information I can provide?
> 
> 
> Thanks
> Dan
> ___
> 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] Proposal: Australian Hackathon

2010-03-15 Thread Ivan Miljenovic
Would other Australians be interested in having our own Hackathon (why
should all those northerners have all the fun)?  I'm thinking about
organising it to be in the July break between university semesters.

There was a previous consideration a few years back to have an
OzHaskell group (http://www.haskell.org/haskellwiki/OzHaskell) but
nothing seems to have eventuated out of it.

In terms of projects, here are some ideas:

* A plotting library using Ben's newly released Gloss library (for
people who can't or won't install Gtk2Hs to get Chart working; Alex
Mason is interested in this)
* Various graph-related project (graphviz, generic graph class, etc.;
this assumes someone else apart from me cares about this stuff)
* Hubris if Mark Wotton comes along
* LLVM if David Terei comes

So, at least as an initial listing, we'd need to have a listing of:
1) Who's interested
2) What dates are good
3) What projects people want to work on
4) Where we can host this

Let's get the ball rolling!

-- 
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: tupleinstances-0.0.1

2010-03-15 Thread Diego Echeverri
Hello.

TupleInstances It's a really small library that provides
instances for Functor, Applicative, Foldable and Traversable for
tuples of the form (a,a...a). It uses newtypes to wrap the tuples
and Template Haskell to generate the code.

Here's an example of these instances in action:

example6 :: (Int, Int) -> [(Int, Int)]
example6 p = map unT $ liftA2 (+) (T2 p) <$> moves
 where moves = tail $ traverse (\x -> [0,x+1,x-1]) (pure 0 :: T2 Int)
-- > Result with (1,1): [(1,2),(1,0),(2,1),(2,2),(2,0),(0,1),(0,2),(0,0)]

More examples here: http://github.com/diegoeche/tupleinstances/raw/master/README

PS: This is also my first package uploaded to Hackage. I would
appreciate any feedback.

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


Re: [Haskell-cafe] Re: If wishes were horses...

2010-03-15 Thread wren ng thornton

Ben Millwood wrote:

In general, laziness behaviour can
get complicated quickly and so I'm not convinced that the type
signature is a good home for that information.


Certainly it can. A lot of the same problems arise in the logic 
programming community under the topic of "modes", i.e. whether a logic 
variable must be ground (or rather, how defined it must be) before it's 
safe to "run the function backwards". Though, at present AFAIK, they've 
contented themselves with rough approximations like lifted/unlifted 
value types or strict/lazy arrows, either of which can catch the simple 
cases.


Personally, I think the only way to capture *all* strictness information 
is if we have full dependent types (or worse, for logic languages, since 
their dependencies lack the directionality of usual dependent types). If 
we had full dependent types, and went with the lifted/unlifted 
distinction instead of the strict/lazy one, then we could give `maybe` 
the type:


maybe :: (_:b) -> (_:a -> b') -> (m:Maybe a)
 -> (case m of Nothing => b ; Just _ => b')

Would such a type be helpful?   I think adding full dependent 
types is a bit much if all we're interested in is strictness behavior. 
But, as you say, it seems very unlikely that we can encode strictness 
behaviors which may depend on particular runtime values without DTs.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] definition of sum

2010-03-15 Thread Keith Sheppard
I asked a similar question a while ago on the cafe

http://www.haskell.org/pipermail/haskell-cafe/2009-June/thread.html#62772

On Wed, Mar 10, 2010 at 5:33 PM, TeXitoi  wrote:
> After programming as an exercice the sum function, my version is
> faster than the Data.List's version. Looking at the source code,
> Data.List uses a foldl and not a foldl'. foldl' seems faster and
> allows to use very big lists. So, why is foldl used by Data.List for
> sum?
>
> --
> Guillaume Pinot               http://www.irccyn.ec-nantes.fr/~pinot/
>
> « Les grandes personnes ne comprennent jamais rien toutes seules, et
> c'est fatigant, pour les enfants, de toujours leur donner des
> explications... » -- Antoine de Saint-Exupéry, Le Petit Prince
>
> ()  ASCII ribbon campaign      -- Against HTML e-mail
> /\  http://www.asciiribbon.org -- Against proprietary attachments
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



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


Re: [Haskell-cafe] a poorly thought out suggestion for cabal and packages that have lots of instances

2010-03-15 Thread Marc Weber
Excerpts from Ivan Miljenovic's message of Tue Mar 16 01:53:13 +0100 2010:
> On 16 March 2010 11:50, Marc Weber  wrote:
> > I may be mistaken - but can't you just put the instance in a module
> > (within syb-with-class) and make syb-with-class not import it by
> > default?
> 
> That would still require syb-with-class to depend upon Text, etc.,
> which is probably not a good thing to do.
Doh. I've missed it.

Sure. I think MissingH has similar trouble: You only want to use
one or two features - but you have to install all dependencies.

Three choices:

a) add dependencies to syb-with-class.
  You could even think about refactoring text and split it into
  text-types and text-implementation.

  This way adding a dependency isn't such a big change.

  But it still is bad because syb-with-class maintainers in general 
  don't want to align their changes with text updates. Neither do they
  want to fix problems arising from changes in all those packages it
  should provide instances for. Usually maintainers ask for splitting
  off such code. (vim backend for Scion is one case ..)

  On the other hand the Firebug people chose to align releases of core
  Firebug plugins to enhance stability and user experience.

  Anyway this is what some packages do. Eg Vim *does* contain many gui
  backends. You can't download a vim-common shared library and install
  vim-gui-gtk vim-gui-... There would be too many combinations.
  Package maintainers have stripped them down to
  vim-tiny
  vim-gui-with-X-huge-features
  ... or similar.
  But it's easy in this case - no (?) application depends on Vim.

b) using conditional compilation
  usually package writers writing package descriptions for distributions
  such as gentoo, Debian just compile all backends. I think Debian
  always enables both: gnome and kde.
  Adding use flags to gentoo for each feature would be overkill.

  So in the end this is equal to a) (IMHO)

  I can not even estimate the amount of work it requires to make
  packaging tools cope with conditional compilation. You have to start
  propagating features to base packages etc.

  I think ivy claims to solve this kind of issue partially. (I don't
  know it that well)

c) add many additional packages
  > The problem is that it seems like this might really clutter up hackage?
  The way to go is improving tools (Hackage, IDEs, cabal-install) to
  cope with this situation.
  
  I'd even propose renaming the extra package to
  syb-with-class-text-instances. Then everybody can see what it
  contains.
  
  tools such as cabal-install will have more trouble to find a solution
  because there are much more possible solutions to take into account.
  
  One way to cope with this is always use latest version and fix broken
  packages..

Last but not least it is also a marketing issue:
Eg OpenERP vs Adempiere: OpenERP is said to have *many* plugins. But
some of them just add some DB fields or make a field have more
characters. Adempiere contributors tend to call this a "localization" of
their software. (You can read this up on their sf forums :) )
But I don't think anybody really cares whether we have 3000 or 5000
packages on hackage. In the end we all care about getting things done.
Installing 20 packages and running cabal 20 times more often does
matter.

So what is correct? I don't know.

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


re: [Haskell-cafe] HTTP package freezes on Windows 7

2010-03-15 Thread Phil

Scrap my original query - the problem isn't as black & white as I thought.

The below works fine - I've changed the response type from json to 
xml strange, but for some reason downloading json doesn't work 
it's fine on Linux.


I'm guessing this is more likely to be a Windows issue rather than a 
Haskell issue - any ideas?



import qualified Network.HTTP as HTTP

main :: IO ()
main
   = do
 x <- getLocation
 print x



getLocation = (HTTP.simpleHTTP $ HTTP.getRequest url) >>= 
HTTP.getResponseBody

where
url = 
"http://maps.google.com/maps/api/geocode/xml?address=London&sensor=false";



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


Re: [Haskell-cafe] a poorly thought out suggestion for cabal and packages that have lots of instances

2010-03-15 Thread Ivan Miljenovic
On 16 March 2010 11:50, Marc Weber  wrote:
> I may be mistaken - but can't you just put the instance in a module
> (within syb-with-class) and make syb-with-class not import it by
> default?

That would still require syb-with-class to depend upon Text, etc.,
which is probably not a good thing to do.

-- 
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


Re: [Haskell-cafe] a poorly thought out suggestion for cabal and packages that have lots of instances

2010-03-15 Thread Marc Weber

Hi Jeremy

> A fourth option is to create a new package which contains just the instance.
> For example:
> 
> syb-with-class-text
I may be mistaken - but can't you just put the instance in a module
(within syb-with-class) and make syb-with-class not import it by
default?

Why do you have to create a new package?

Is there something I've missed?

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


[Haskell-cafe] th-kinds v0.0.0

2010-03-15 Thread Louis Wasserman
I'm going to phrase this as a challenge, because I think that's likely to
get the best response:

I just released a package,
th-kinds,
which attempts to automatically infer the kind of a specified type, type
constructor, type family, type class, or pretty much anything else that has
a kind.

This package was developed in response to a sort-of challenge from Brent
Yorgey on #haskell to create this functionality.  So, uh, I stayed up last
night until 5 am learning unification algorithms and implementing
this...heh.

It rolls its own kind inference, so I don't know if it's adequately powerful
to handle all the wacky types you can construct.  Things I have tested it
on:

   - IO and ST
   - Many primitive types, including unboxed tuples and State#
   - mtl
   - newtype Fix f = Fix (f (Fix f))
   - data Tree a = Leaf a | Bin (Tree a) (Tree a)
   - data Foo a b = a (tests proper defaulting behavior)
   - A type family from my old TrieMap package with kind -- I kid you not
   -- ((* -> *) -> ((* -> *) -> * -> *) -> (* -> *) -> * -> * -> *)

Things that it will not work on, and that I don't think will change:

   - GADT types that cannot be reified by TH.  Essentially, I think this is
   "the set of GADT data types that actually couldn't be implemented without
   GADTs."  Not sure, though.  In any event, at the moment, I don't think
   there's any hope of handling GADTs in TH at this point, so I don't really
   object to this problem.

Anyway, y'all should attempt to break th-kinds.  Tell me if you can
construct a type for which my inference checker breaks, but not because you
get an error message saying "Can't reify a GADT data constructor..."

By the way, I'd like to bump
these
tickets .  They're
certainly related, but I'm not sure if they're genuinely equivalent.  It's
really irritating, though, that kind parsing is so broken in TH, and I think
that a TH backend guru should be able to figure out where there's a foldr
instead of a foldl...  th-kinds includes a workaround to this bug, but if
the bug is fixed, it'll break again.  Yuck, bugs.

Louis Wasserman
wasserman.lo...@gmail.com
http://profiles.google.com/wasserman.louis
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] HTTP package freezes on Windows 7

2010-03-15 Thread Phil

Hi,

I'm using GHC 6.12.1 on Windows 7.  I've built the latest Network 
package using Haskell's MinGW and installed HTTP package on top of this.


The code below builds fine, but on execution it just sits there grabbing 
ever increasing amounts of memory.


It's a simplified call that I've got working fine in Linux.

Is this a known issue?  Anyone else had success using HTTP from Windows?


Thanks,

Phil.


import qualified Network.HTTP as HTTP

main :: IO ()
main
  = do
x <- HTTP.simpleHTTP(HTTP.getRequest 
"http://maps.google.com/maps/api/geocode/json?address=London&sensor=false";)

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


Re: [Haskell-cafe] How to do the "permutation and combination" thing?

2010-03-15 Thread Richard O'Keefe


On Mar 15, 2010, at 8:37 PM, Magicloud Magiclouds wrote:


Sorry, I did not make it clear, since I did not know how to say this
in technical terms.


Technical terms are not necessary, but absent those,
clear examples are.



With comprehension, I could get all the possibilities that "draw one
elem from each list and put them together". But consider this: for
example, there are two types of pet, dog and cat. And there are two
persons, him and her. So "how many kinds of matches are there
(orderless)?" The answer is two: "him with dog and her with cat, him
with cat and her with dog".


Why can't they _both_ have cats, or _both_ have dogs?
I _think_ you mean that there is one man and one woman
and not two _types_ of pets, but one dog and one cat.
So if the man gets the dog, there is no dog left for
the woman to get.

Let me offer you a building block:

   select :: [t] -> [(t,[t])]

   Given a list, select lazily returns a list of (item,rest) pairs,
   where item is an element of the original list, and rest is  
everything

   else in the original list, in the original order.

   select xs = choices xs []
 where choices (x:xs) before =
(x,reverse before++xs) : choices xs (x:before)
   choices [] _ = []

Example:
   select [1,2,3] = [(1,[2,3]),(2,[1,3]),(3,[1,2])]

Now suppose you have any number of people and any number of
pets and want to match up each person with a unique pet (but
don't care if any pets are left over):

matchings :: [a] -> [b] -> [[(a,b)]]

matchings [] _ = [[]]
matchings (h:hs) ps =
[(h,p) : m | (p,ps') <- select ps, m <- matchings hs ps']

Example:

   matchings ["him","her"] ["bug","cat","dog"] = [
 [("him","bug"),("her","cat")],
 [("him","bug"),("her","dog")],
 [("him","cat"),("her","bug")],
 [("him","cat"),("her","dog")],
 [("him","dog"),("her","bug")],
 [("him","dog"),("her","cat")]
  ]

It should now be obvious how to extend this to more than two lists.

It should also be obvious that this can be expensive.
If there are N items in both xs and ys, then matchings xs ys
has N! elements.  More generally, if xs has M elements and
ys has N elements and M <= N, matchings xs ys has
M-to-the-falling-N = M!/(M-N)! elements (if I've got this right).

You want to consider whether there are other constraints
on acceptable solutions that should be applied early to
reduce the number of candidates.


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


[Haskell-cafe] a poorly thought out suggestion for cabal and packages that have lots of instances

2010-03-15 Thread Jeremy Shaw
Hello,

There are a number of libraries like syb-with-class, happstack-data, etc,
which provide a new class that potentially has a lot of new instances.

For example, let's say I want a 'Data ctx Text' instance. Where should that
go?

To avoid orphan instances it would need to go in the 'text' package where
Text is defined. But it seems unlikely that I am going to convince the
authors of text to add additional dependencies on things like
syb-with-class, happstack-data, etc, just to satisfy a small number of
users.

A second place to put the instance would be in the syb-with-class package.
They will be orphan instances, but as long as you can't import the Data
class without also getting those instances, it doesn't seem like much could
go wrong.  But now syb-with-class has to depend on all the libraries that it
is going to provide instances for. So, I have just shifted the problem from
one library to another.

A third option is to just define the instance in the library where I want to
use it. But now I have opened up the possibility of conflicting orphan
instances for the type -- which is no good.

A fourth option is to create a new package which contains just the instance.
For example:

syb-with-class-text

This still opens the possibility of conflicting orphan instances. But at
least there is a version that is supposedly the 'official' one.

The problem is that it seems like this might really clutter up hackage?
Also, it is annoying to have to create and maintain and entire new cabal
package just for one single class instance. And if i want to install all the
instances, it would be annoying to have to do 20 different cabal installs.

What might be nicer is if I could have a single project directory that
somehow generated all those instances. And if cabal new how to work with
them as a family.  Something like:

 cabal upload syb-with-class*
 cabal install syb-with-class*

Obviously, I have not really thought this through all the way. I just know
that I am continually wondering what I should do when I want to do something
like add a Text instance for syb-with-class?

If we were to get really experimental I might suggest that when you install
syb-with-class, you don't automatically get all the extra instances by
default. But the package system and compiler would know they exist. So if
you tried to write code that required the missing instance, it would suggest
that you need to install the extra package. This would help reduce instances
of people accidentally creating a conflicting instance. But I am sure it
makes something else horrible happen instead ;)

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


Re: [Haskell-cafe] Parsec to parse tree structures?

2010-03-15 Thread Ryan Ingram
Here are some questions you have not answered that are quite important
for your design:

1) How important is retaining shared references?  In particular, is
the structure mutable after being read-in to memory?  If it is, and
you mutate an object, do you expect other references to that object to
be mutated as well?

2) If the answer to (1) is "not important", then how important is
parsing performance?  If you parse the same object more than once
(turning the directed graph into a tree), is that a problem?

This is an interesting problem and of course there are a lot of ways
to tackle it, but I think you need to elaborate a bit more on what is
needed.  If you want to maintain the "object graph" structure, you'll
treat the problem quite a bit differently than if you are happy to
convert it to a pure data structure.

  -- ryan

On Sun, Mar 14, 2010 at 9:03 AM, david fries  wrote:
> Hello Café
>
> Some time ago I wrote a parser for a project of one our customers. The
> format was proprietary and binary. The data was structured as a tree
> with tables pointing to sub tables farther in the file. (Well actually
> there was one or two cases where branches joined together, so I guess it
> was a directed graph.) Also it had no defined endianess, some tables
> were bigendian others were little endian and some were in their very own
> in-house-endianess.
> All in all, the typical binary data structure that has been in use and
> continuously extended for the last 15 years. You know the kind.
>
> Oddly enough, our customer never bothered to write a parser of their
> own. I wonder why.
>
> My parser was written in C# and wasn't particularly elegant, but it
> worked reliably. I was wondering how you would parse tree-like
> structures with Parsec (or other functional parsers)? Up to know, all
> examples I've seen were of sequential data. To parse trees, you'd
> essentially need to be able to follow pointers, parse whatever is there
> and then jump back. I guess I'd have to mess around with the internal
> state of the parser to do that, which is something I'd rather avoid.
>
>
> regards,
> dave
>
> ___
> 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 define instance for type synonym with parameter.

2010-03-15 Thread Ryan Ingram
TypeSynonymInstances isn't doing anything you couldn't do yourself.
It's just expanding the type synonym in the instance declaration for
you.

In this case, the error is because type synonyms must be fully
applied.  However, your type synonym can be eta-contracted:
type SomeMonad = ErrorT String (ReaderT String IO)

Now you can use it in an instance declaration.  But this doesn't work
in general; this type synonym cannot be made into a monad:
type St s a = s -> (a,s)

However, I think that adding instances this way is bad style.  I
suggest turning on newtype deriving instead, and doing:

newtype SomeMonad a = SomeMonad (ErrorT String (Reader T String IO) a)
   deriving (Monad, MonadError, MonadReader String, MonadIO, Functor)
instance Applicative SomeMonad where
   pure = return
   (<*>) = ap

  -- ryan


On Mon, Mar 15, 2010 at 2:34 PM, Vasyl Pasternak
 wrote:
> Hello,
>
> I am start with example. Suppose I have the following type synonym:
>
> type SomeMonad a = ErrorT String (ReaderT  String IO) a
>
> this is monad, and I want to make it instance of Applicative, so, the
> obvious way is to write the following:
>
> instance Applicative SomeMonad where
>  pure = return
>  (<*>) = ap
>
> GHCi warns me, that I have to use -XTypeSynonymInstances option to
> allow this construction, but than I have following
> error:
>
>    Type synonym `SomeMonad' should have 1 argument, but has been given 0
>    In the instance declaration for `Applicative SomeMonad'
>
> Neither `instance Applicative (SomeMonad a)` nor `instance Applicative
> SomeMonad a` help. But works the following:
>
> instance Applicative (ErrorT String (ReaderT String IO)) where
>  pure = return
>  (<*>) = ap
>
> Which is the same (from my point of view).
>
> Could anyone tell me what is going on, and how to declare SomeMonad as
> instance of Applicative ?
>
> Thanks,
> Vasyl
> ___
> 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 define instance for type synonym with parameter.

2010-03-15 Thread Ivan Lazar Miljenovic
Vasyl Pasternak  writes:
> Could anyone tell me what is going on, and how to declare SomeMonad as
> instance of Applicative ?

You can't, because you can't define new instances for type aliases.  If
you really want SomeMonad to have a custom instance, define it as a
newtype.



-- 
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] How to define instance for type synonym with parameter.

2010-03-15 Thread Vasyl Pasternak
Hello,

I am start with example. Suppose I have the following type synonym:

type SomeMonad a = ErrorT String (ReaderT  String IO) a

this is monad, and I want to make it instance of Applicative, so, the
obvious way is to write the following:

instance Applicative SomeMonad where
  pure = return
  (<*>) = ap

GHCi warns me, that I have to use -XTypeSynonymInstances option to
allow this construction, but than I have following
error:

Type synonym `SomeMonad' should have 1 argument, but has been given 0
In the instance declaration for `Applicative SomeMonad'

Neither `instance Applicative (SomeMonad a)` nor `instance Applicative
SomeMonad a` help. But works the following:

instance Applicative (ErrorT String (ReaderT String IO)) where
  pure = return
  (<*>) = ap

Which is the same (from my point of view).

Could anyone tell me what is going on, and how to declare SomeMonad as
instance of Applicative ?

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


[Haskell-cafe] Re: Space leak

2010-03-15 Thread Achim Schneider
Ketil Malde  wrote:

> Lazy IO always worked well for me, so althouhg I feel I should look
> more deeply into "real" solutions, like Iteratee, my half-hearted
> attemts to do so have only resulted in the conclusion that it was
> more complicated, and thus postponed for some rainy day... lazy IO
> for lazy programmers, I guess. 
>
If you have a huge data set and a large address space (say, a 64-bit
processor), you may want to use bytestring-mmap.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


Re: [Haskell-cafe] If wishes were horses... (was: Re: definition of sum)

2010-03-15 Thread David Leimbach
On Thu, Mar 11, 2010 at 10:42 PM, wren ng thornton wrote:

> David Leimbach wrote:
>
>> Note that foldl' has a ' to indicate that it's not the same as foldl
>> exactly.  I would propose that sum' exist as well as sum, and that sum be
>> lazy.
>>
>
> I wish Haskell allowed ! to occur (non-initially) in alphanum_' identifiers
> as well as in symbolic ones. Then we could be more consistent about having !
> mean strictness like it does with ($!), bang patterns, strict fields,...
> (too bad about (!) and (!!)). The prime has so many other uses, it's a shame
> it gets used up for strict/lazy variants, as if there were no other
> variations.
>
>
Yes, a lot of conventions don't always make sense in certain contexts, but
at least the convention is there to help keep things consistent (for better
or worse)

Dave


> --
> Live well,
> ~wren
>
> ___
> 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] Happstack basic question

2010-03-15 Thread Jeremy Shaw
Neat! I have been wondering how to do that. It is also useful if you want to
run multiple happstack applications on the same machine, but each on a
different IP address.

It would be awesome if this was wrapped up in a more obvious way. I imagine
we would extend the Conf type so that you could optionally specify a list of
IP addresses to listen on.

Unfortunately it is very tricky to implement in a portable way because our
code can not depend on ipv6 being enabled. I just posted a message to
haskell-cafe asking for suggestions.

http://www.haskell.org/pipermail/haskell-cafe/2010-March/074585.html

- jeremy

On Thu, Mar 11, 2010 at 8:35 AM, Martin Kiefel  wrote:

> On Thu, Mar 11, 2010 at 09:24:05AM -0500, Kyle Murphy wrote:
> > You misunderstand his question. He's trying to setup happstack behind a
> > reverse proxy running on the same system, so he needs to be able to bind
> it
> > only to the loopback interface (127.0.0.1), as opposed to all the
> interfaces
> > on the system (thereby making it inaccessible from the network unless
> > accessed through the proxy). I don't know enough about happstack to
> answer
> > his question, but I can see from the documentation you provided that
> there
> > doesn't seem to be any way to specify address to bind to as Dmitry stated
> in
> > his original e-mail.
>
> But I'm doing exactly that.
>
> Here is some of the code:
>
> main = do
>
>  ...
>
>  s <- socket AF_INET Stream defaultProtocol
>  setSocketOption s ReuseAddr 1
>  h <- getHostByName "localhost"
>  let p = toEnum $ port $ httpConf appConf
>  bindSocket s (SockAddrInet p (hostAddress h))
>  listen s 10
>
>  -- start the state system
>  control <- startSystemState' (store appConf) stateProxy
>
>  -- start the http server
>  httpTid <- forkIO $ simpleHTTPWithSocket s (httpConf appConf)
>
>  ...
>
> And then my happstack server is just listening on 127.0.0.1.
>
> To access it, I'm using Apache Proxy.
>
> - Martin
>
> >
> > -R. Kyle Murphy
> > --
> > Curiosity was framed, Ignorance killed the cat.
> >
> >
> > On Thu, Mar 11, 2010 at 07:39, Martin Kiefel  wrote:
> >
> > > Hi Dmitry,
> > >
> > > On Thu, Mar 11, 2010 at 11:38:44AM +0300, Dmitry V'yal wrote:
> > > > Hello haskellers,
> > > >
> > > > I want to host a simple happstack application behind a reverse proxy.
> So
> > > > ideally would be to bind it to localhost only.
> > > >
> > > > According to
> > > >
> > >
> http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/Happstack-Server-HTTP-Types.html#t%3AConf
> > > > Conf datatyle has only Port field. Does it mean, there is currently
> no
> > > > way to prevent binding happstack to all available interfaces?
> > >
> > > I think you are looking for simpleHTTPWithSocket [1]. You can use
> > > whatever socket you like.
> > >
> > > >
> > > > Regards,
> > > > Dmitry
> > >
> > > Cheers,
> > > Martin
> > >
> > > [1]
> > >
> http://happstack.com/docs/0.4/happstack-server/Happstack-Server-SimpleHTTP.html#v%3AsimpleHTTPWithSocket
> > > ___
> > > 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


[Haskell-cafe] how to listen on a specific IP using the network library

2010-03-15 Thread Jeremy Shaw
Hello,

I would really like to modify happstack so that you can specific what IP
address to listen on.

So I think I want a function like:

listenOnAddr :: SockAddr -> IO Socket

The problem is that the user might want to specify IPv4 or IPv6 address. But
support for IPv6 is only conditionally compiled into the network library.

I can not figure out how to write my code so that it will compile regardless
of whether network was compiled with ipv6 enabled.

I got this far:



import qualified Control.Exception as Exception
import Network.BSD(getProtocolNumber)
import Network.Socket

listenOnAddr :: Family -> SocketType -> SockAddr -> IO Socket
listenOnAddr fam typ sockAddr =
  do proto <- getProtocolNumber "tcp"
 Exception.bracketOnError
  (socket fam typ proto)
  (sClose)
  (\sock -> do
  setSocketOption sock ReuseAddr 1
  bindSocket sock sockAddr
  listen sock maxListenQueue
  return sock
)
---

But I am not sure how to modify it to calculate 'fam' and 'typ' from
'sockAddr' with out making my code depend on IPv6 being enabled.

If I was adding this function directly to the network package, there would
be no problem. I could just use:

#if defined(IPV6_SOCKET_SUPPORT)
#endif

But in a 3rd party library IPV6_SOCKET_SUPPORT is not defined. I could copy
the autoconf code into my library -- but there is no guarantee that my
library and the network library were compiled with the same value for
IPV6_SOCKET_SUPPORT.

In happstack we use a really horrible trick involving template haskell where
we see if the  SockAddrInet6 constructor exists at compile time and
conditionally compile different versions of the code that way. But it is
really ugly. We defined supportsIPv6 here:

http://patch-tag.com/r/mae/happstack/snapshot/current/content/pretty/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs

And then use it in acceptLite here:

http://patch-tag.com/r/mae/happstack/snapshot/current/content/pretty/happstack-server/src/Happstack/Server/HTTP/Socket.hs

It wouldn't be that bad if we could actually use the [| |] mechanism. But we
can't because it won't compile when ipv6 support is not enabled due to
'(S.SockAddrInet6 _ _ ha _) -> showHostAddress6 ha'.

Any suggestions? At this point I am thinking that the best solution is to
add a new function to network, since it is not trivial to do it anywhere
else in a portable way, and it seems like a fairly useful and common
operation?

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


[Haskell-cafe] Re: Happstack basic question

2010-03-15 Thread Gracjan Polak

I'd like to add a warning to this discussion.
You might be affected by this issue:

http://trac.haskell.org/network/ticket/11

TL;DR: It is kind of random if you bind to IPv4 or IPv6 or both. For example
Windows Vista likes to bind to IPv6 only.

Watch your ports and protocols!

-- 
Gracjan


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


[Haskell-cafe] darcs hacking sprint (ZuriHac) info!

2010-03-15 Thread Eric Kow
Hi everybody,

Just some quick information for those of you who are interested in
working on Darcs at ZuriHac

Pre-sprint meeting - Fri 12:00; pizzeria
-
We'll be meeting for lunch at Friday noon at the Pizzeria Santa Lucia
Niederdorf (Marktgasse 21), near the City Backpacker hostel.

Details on http://wiki.darcs.net/Sprints/2010-03

This will be a great chance for introductions (especially for new or
potential Darcs hackers).  On the agenda:

 - prioritising ProbablyEasy bugs for new Darcs hackers
 - plans for the sprint (news, other meetings, discussions, etc)

Get your laptops ready!
---
You'll have more fun if you can hit the ground running, so
please make sure you can do all of these things:

  1. darcs get --lazy http://darcs.net
  2. cabal configure; cabal build
  3. darcs send (your patch should wind up on the tracker)

#3 is especially important.  Here's the quick start

  3a. create a test patch (see http://darcs.net/report.html )
  3b. see http://wiki.darcs.net/Msmtp
  3c. darcs send
  3d. wait 10 minutes
  3e. check the patch tracker http://bugs.darcs.net (Patches > Show Open)

Travel reimbursements possible
--
Thanks to a successful fundraising effort, we will be able to reimburse
travel costs for folks working on Darcs.

Do let me know if you're interested, and please save your receipts!  If
you have electronic tickets, I think that's fine (perhaps even better);
please email them to me.

More information on the wiki
---
Information about the sprint, including meetings and maps will be on
  http://wiki.darcs.net/Sprints/2010-03

It may be a good idea to darcs get --lazy http://wiki.darcs.net before
you leave so that you have an up to date version of the wiki :-)

Thanks to our donors for making this sprint possible and to Johan and
the Zurich/Google crew for setting up this massive hackathon.

Whee!

-- 
Eric Kow 
PGP Key ID: 08AC04F9


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


Re: [Haskell-cafe] How to do the "permutation and combination" thing?

2010-03-15 Thread Magicloud Magiclouds
Oh, that is not a precondition. So the answer of yours are correct. I
am working on permutations. I used it in a wrong way.

On Mon, Mar 15, 2010 at 4:39 PM, Daniel Fischer
 wrote:
> Am Montag 15 März 2010 08:37:20 schrieb Magicloud Magiclouds:
>> Sorry, I did not make it clear, since I did not know how to say this
>> in technical terms.
>> With comprehension, I could get all the possibilities that "draw one
>> elem from each list and put them together". But consider this: for
>> example, there are two types of pet, dog and cat. And there are two
>> persons, him and her. So "how many kinds of matches are there
>> (orderless)?" The answer is two: "him with dog and her with cat, him
>> with cat and her with dog". So
>> f [a, b, c] [d, e, f] [g, h, i] =
>>   [ [ (a, d, g), (b, e, h), (c, f, i) ]
>>   , [ (a, d, g), (b, e, i), (c, f, h) ]
>>   , [ (a, d, h), (b, e, i), (c, f, g) ]
>>   , [ (a, d, h), (b, e, g), (c, f, i) ]
>>   , [ (a, d, i), (b, e, g), (c, f, h) ]
>>   , [ (a, d, i), (b, e, h), (c, f, g) ]
>>   ... ]
>>
>
> In both, your verbal example and the pseudo-code example, all the groups
> have the same number of members (equal to the number of groups, which may
> or may not be coincidental).
> Is that a precondition, that all groups have the same number of members?
> If so, would the desired result for three groups of two members each be
>
> f3 [a,b] [c,d] [e,f] =
>  [ [ (a,c,e), (b,d,f) ]
>  , [ (a,c,f), (b,d,e) ]
>  , [ (a,d,e), (b,c,f) ]
>  , [ (a,d,f), (b,c,e) ]
>  ]
>
> and for two groups of three members each
>
> f2 [a,b,c] [d,e,f] =
>  [ [ (a,d), (b,e), (c,f) ]
>  , [ (a,d), (b,f), (c,e) ]
>  , [ (a,e), (b,d), (c,f) ]
>  , [ (a,e), (b,f) , (c,d) ]
>  , [ (a,f), (b,d), (c,e) ]
>  , [ (a,f), (b,e), (c,d) ]
>  ]
>
> ?
>
> In that case, look at Data.List.permutations and the zipN functions.
>
>



-- 
竹密岂妨流水过
山高哪阻野云飞
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: CPSA - Cryptographic Protocol Shapes Analyzer

2010-03-15 Thread John D. Ramsdell
The Cryptographic Protocol Shapes Analyzer (CPSA) has been released on
Hackage at .  CPSA attempts
to enumerate all essentially different executions possible for a
cryptographic protocol.  We call them the shapes of the protocol.
Naturally occurring protocols have only finitely many, indeed very few
shapes.  Authentication and secrecy properties are easy to determine
from them, as are attacks and anomalies.

For each input problem, the CPSA program is given some initial
behavior, and it descovers what shapes are compatible with it.
Normally, the initial behavior is from the point of view of one
participant.  The analysis reveals what the other participants must
have done, given the participant's view.

We are working towards a version of CPSA with the property that
whenever it successfully terminates, every possible execution is
described by its output.  However, the current implementation
occasionally fails to find some executions.

The package contains a set of programs used to perform and display the
analysis.  Program documentation is in the doc directory in the source
distribution, and installed in the package's data directory.  You can
locate the package's data directory by searching for the file
cpsauser.html.  New users should study the documentation and the
sample inputs in the data directory.

The theory and algorithm used by CPSA was developed with the help of
Joshua D. Guttman, John D. Ramsdell, Jon C. Herzog, Shaddin F. Doghmi,
F. Javier Thayer, and Paul D. Rowe.  John D. Ramsdell implemented the
algorithm in Haskell.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using regexps to filter data

2010-03-15 Thread michael rice
Found this tutorial: 
http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/

Seems to work for what I need to do.

Michael

=

[mich...@localhost ~]$ ghci
GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> :mod +Text.Regex.Posix
Prelude Text.Regex.Posix> "bar" =~ "(foo|bar)" :: Bool
Loading package syb ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package bytestring-0.9.1.4 ... linking ... done.
Loading package regex-base-0.72.0.2 ... linking ... done.
Loading package regex-posix-0.72.0.3 ... linking ... done.
True
Prelude Text.Regex.Posix> "-123" =~ "\-?[0-9]+" :: Bool

:1:13:
    lexical error in string/character literal at character '?'
Prelude Text.Regex.Posix> "-123" =~ "[+-]?[0-9]+" :: Bool
True
Prelude Text.Regex.Posix> "+123" =~ "[+-]?[0-9]+" :: Bool
True
Prelude Text.Regex.Posix> "abc" =~ "[+-]?[0-9]+" :: Bool 
False
Prelude Text.Regex.Posix> 



--- On Mon, 3/15/10, Stephen Tetley  wrote:

From: Stephen Tetley 
Subject: Re: [Haskell-cafe] Using regexps to filter data
To: "michael rice" 
Cc: haskell-cafe@haskell.org
Date: Monday, March 15, 2010, 10:09 AM

On 15 March 2010 14:02, michael rice  wrote:
>
> Thanks. Looks kind of complicated. Are there any examples of how to use this 
> stuff?

Hi Michael

I'm note sure, I haven't used the Regex package since it was moved out
of the libs distributed with GHC. I think the multiple backends were
added after this, and it was extended so matching could work on
ByteStrings as well as Strings.

PCRE-light is a simpler alternative, if you can live with PCRE style
regexs rather than Posix ones:

http://hackage.haskell.org/package/pcre-light


Best wishes

Stephen



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


Re: [Haskell-cafe] Using regexps to filter data

2010-03-15 Thread Stephen Tetley
On 15 March 2010 14:02, michael rice  wrote:
>
> Thanks. Looks kind of complicated. Are there any examples of how to use this 
> stuff?

Hi Michael

I'm note sure, I haven't used the Regex package since it was moved out
of the libs distributed with GHC. I think the multiple backends were
added after this, and it was extended so matching could work on
ByteStrings as well as Strings.

PCRE-light is a simpler alternative, if you can live with PCRE style
regexs rather than Posix ones:

http://hackage.haskell.org/package/pcre-light


Best wishes

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


Re: [Haskell-cafe] Using regexps to filter data

2010-03-15 Thread michael rice
Thanks. Looks kind of complicated. Are there any examples of how to use this 
stuff?

Michael

--- On Mon, 3/15/10, Stephen Tetley  wrote:

From: Stephen Tetley 
Subject: Re: [Haskell-cafe] Using regexps to filter data
To: "michael rice" 
Cc: haskell-cafe@haskell.org
Date: Monday, March 15, 2010, 7:14 AM

Hi Michael

I think you want to be using a one of the 'implementation' packages
directly rather than Text.Regex.Base.RegexLike (from regex-base), for
instance regex-posix. If you are searching a string you would want to
import the Text.Regex.Posix.String module.

Text.Regex.Base.RegexLike provides the interface, specific matchers
(e.g. Posix or PCRE) provide the implementation.

Best wishes

Stephen



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


Re: [Haskell-cafe] Parsec to parse tree structures?

2010-03-15 Thread John Lato
Hi Dave,

> From: david fries 
>
> Hello Café
>
> Some time ago I wrote a parser for a project of one our customers. The
> format was proprietary and binary. The data was structured as a tree
> with tables pointing to sub tables farther in the file. (Well actually
> there was one or two cases where branches joined together, so I guess it
> was a directed graph.) Also it had no defined endianess, some tables
> were bigendian others were little endian and some were in their very own
> in-house-endianess.
> All in all, the typical binary data structure that has been in use and
> continuously extended for the last 15 years. You know the kind.
>
> My parser was written in C# and wasn't particularly elegant, but it
> worked reliably. I was wondering how you would parse tree-like
> structures with Parsec (or other functional parsers)? Up to know, all
> examples I've seen were of sequential data. To parse trees, you'd
> essentially need to be able to follow pointers, parse whatever is there
> and then jump back. I guess I'd have to mess around with the internal
> state of the parser to do that, which is something I'd rather avoid.

Have you seen Edward Kmett's Parsing Trifecta talk/slides, available
at http://comonad.com/reader/2009/iteratees-parsec-and-monoid/ ?  I
think a similar approach would allow you to parse this data structure.
 The trick is to create a data source that can read from arbitrary
locations.

Also see http://okmij.org/ftp/Haskell/Iteratee/Tiff.hs for an
iteratee-based TIFF reader.  TIFF files have a similar structure, so
this code could apply pretty directly.  The parsing is quite
low-level, but you could use iteratee-parsec [1] or
attoparsec-iteratee [2] to use parser combinators with this technique.

[1] http://hackage.haskell.org/package/iteratee-parsec
[2] http://hackage.haskell.org/package/attoparsec-iteratee
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Binaries using shared libraries with cabal-install

2010-03-15 Thread Yuras Shumovich
Hi,
As I know it doesn't work for executables, see
http://hackage.haskell.org/trac/hackage/ticket/600

2010/3/15 Mathijs Kwik :
> Hi all,
>
> I'm using cabal-install 0.8.0 on ghc 6.12.1 on linux
> I switched on shared library support on cabal.
>
> Does this enable -dynamic and -fPIC during compilation and -dynamic
> -shared during linking?
> Or does it work a little differently?
>
> I noticed everything works for libraries. .so files get created, and
> using ldd on them shows they depend on other haskell shared libraries.
> But for binaries, it seems it still compiles them with everything included.
> ldd'ing them shows no haskell-library dependencies and their size is
> quite big as well.
>
> Is it possible to tell cabal-install I want binaries to use shared libs 
> instead?
> And is there a way to specify which RTS to link binaries with? (debug,
> threaded, normal)
> Or a way to defer linking to an RTS so I can do this on execution
> using LD_PRELOAD ?
>
> Thanks for any help
> Mathijs
> ___
> 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] Using regexps to filter data

2010-03-15 Thread Stephen Tetley
Hi Michael

I think you want to be using a one of the 'implementation' packages
directly rather than Text.Regex.Base.RegexLike (from regex-base), for
instance regex-posix. If you are searching a string you would want to
import the Text.Regex.Posix.String module.

Text.Regex.Base.RegexLike provides the interface, specific matchers
(e.g. Posix or PCRE) provide the implementation.

Best wishes

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


[Haskell-cafe] Two Google Summer of Code project proposals

2010-03-15 Thread Johan Tibell
Hi,

I'd like to advertise two Google Summer of Code projects that I recently
added to the list [1] of proposed projects:

  Improve Cabal's test support
  http://hackage.haskell.org/trac/summer-of-code/ticket/1581

  Proper test support is essential for good software quality. By
  improving Cabal's test support we can test all Cabal packages
  on continuous build machines which should help us detect
  breakages earlier. Making it easier to run the tests means that
  more people will run them and those who already do will run the
  more often.

and

  A high-performance HTML combinator library using Data.Text
  http://hackage.haskell.org/trac/summer-of-code/ticket/1580

  Being both fast and safe, Haskell would make a great
  replacement for e.g. Python and Ruby for server
  applications. However, good library support for web
  applications is sorely missing. To write web applications you
  need at least three components: a web application server, a
  data storage layer, and an HTML generation library. The goal of
  this project is to address the last of the three, as the two
  are already getting some attention from other Haskell
  developers.

I encourage any interested students to have a look at the two proposals (and
the other proposals on the list) and sign up for GSoC on Trac (or with
Edward Kmett if Trac is still having issues).

1. http://hackage.haskell.org/trac/summer-of-code/report/1

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


Re: [Haskell-cafe] Space leak

2010-03-15 Thread Ketil Malde
Arnoldo Muller  writes:

> I am trying to use haskell in the analysis of bio data. One of the main
> reasons I wanted to use haskell is because lazy I/O allows you to see a
> large bio-sequence as if it was a string in memory.

Funny you should mention it.  I've written a bioinformatics library¹ that
(naturally) supports reading and writing various file formats for
sequences and alignments and stuff.

Some of these files can be substantial in size (i.e., larger than my
laptop's memory), so most IO of potentially large files (Fasta, BLAST
XMl output, 454 SFF files...) are read lazily, and large Fasta sequences
are read as lazy bytestrings.

This works nicely for a lot of use cases (well, my use cases, at any
rate, wich quite often boils down to streaming through the data).  One
thing to look out for is O(n) indexed access to lazy bytestrings, so
there's a defragment operation that converts a sequence to a single
chunk (which gives O(1) access, but of course must fit into memory). 

I guess the most annoying thing about laziness is that small test cases
always work, you need Real Data to stress test your programs for
excessive memory use.

Lazy IO always worked well for me, so althouhg I feel I should look more
deeply into "real" solutions, like Iteratee, my half-hearted attemts to
do so have only resulted in the conclusion that it was more complicated,
and thus postponed for some rainy day... lazy IO for lazy programmers, I
guess. 

-k

¹ Stuff's on Hackage in the bioinformatics section and also on
http://blog.malde.org and http//malde.org/~ketil/bioinformatics.
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to do the "permutation and combination" thing?

2010-03-15 Thread Daniel Fischer
Am Montag 15 März 2010 08:37:20 schrieb Magicloud Magiclouds:
> Sorry, I did not make it clear, since I did not know how to say this
> in technical terms.
> With comprehension, I could get all the possibilities that "draw one
> elem from each list and put them together". But consider this: for
> example, there are two types of pet, dog and cat. And there are two
> persons, him and her. So "how many kinds of matches are there
> (orderless)?" The answer is two: "him with dog and her with cat, him
> with cat and her with dog". So
> f [a, b, c] [d, e, f] [g, h, i] =
>   [ [ (a, d, g), (b, e, h), (c, f, i) ]
>   , [ (a, d, g), (b, e, i), (c, f, h) ]
>   , [ (a, d, h), (b, e, i), (c, f, g) ]
>   , [ (a, d, h), (b, e, g), (c, f, i) ]
>   , [ (a, d, i), (b, e, g), (c, f, h) ]
>   , [ (a, d, i), (b, e, h), (c, f, g) ]
>   ... ]
>

In both, your verbal example and the pseudo-code example, all the groups 
have the same number of members (equal to the number of groups, which may 
or may not be coincidental).
Is that a precondition, that all groups have the same number of members?
If so, would the desired result for three groups of two members each be

f3 [a,b] [c,d] [e,f] =
  [ [ (a,c,e), (b,d,f) ]
  , [ (a,c,f), (b,d,e) ]
  , [ (a,d,e), (b,c,f) ]
  , [ (a,d,f), (b,c,e) ]
  ]

and for two groups of three members each

f2 [a,b,c] [d,e,f] =
  [ [ (a,d), (b,e), (c,f) ]
  , [ (a,d), (b,f), (c,e) ]
  , [ (a,e), (b,d), (c,f) ]
  , [ (a,e), (b,f) , (c,d) ]
  , [ (a,f), (b,d), (c,e) ]
  , [ (a,f), (b,e), (c,d) ]
  ]

?

In that case, look at Data.List.permutations and the zipN functions.

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


Re: [Haskell-cafe] How to do the "permutation and combination" thing?

2010-03-15 Thread Magicloud Magiclouds
I realized I fell into the trap of wrong way. Thank you.

On Fri, Mar 12, 2010 at 4:16 PM, Ketil Malde  wrote:
> Casey Hawthorne  writes:
>
>>>  For example, I have this:
>>>list1 = [a, b, c]
>>>list2 = [d, e, f]
>>>list3 = [g, h, i]
>
>> Think in abstract terms what you want to accomplish.
>
> A bit more specifically, let's say the input is a list of lists, and you
> want to produce all combinations of drawing one element from each of the
> input lists¹:
>
>  perms :: [[a]] -> [[a]]
>
> You need to consider two cases, when the input is empty, and when the
> input contains at least one list of elements:
>
>  perms (l:ls) = ...
>  perms [] = ...
>
> The second case shouldn't be so hard.
>
> Now, if you pretend that 'perms' is already implemented, then you can
> use it to generate all permutations for the tail of the input list.  The
> first case boils down to combining the first input list with all
> permutations of the rest of the lists:
>
>  perms (l:ls) = ... l ... perms ls
>
> Does this help?
>
> -k
>
> ¹ Using tuples is harder to generalize for length, but nicer typewise,
> since you'd get something like 'perms :: ([a],[b],..[x]) -> [(a,b,..,x)]
> --
> If I haven't seen further, it is by standing in the footprints of giants
> ___
> 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 do the "permutation and combination" thing?

2010-03-15 Thread Magicloud Magiclouds
Sorry, I did not make it clear, since I did not know how to say this
in technical terms.
With comprehension, I could get all the possibilities that "draw one
elem from each list and put them together". But consider this: for
example, there are two types of pet, dog and cat. And there are two
persons, him and her. So "how many kinds of matches are there
(orderless)?" The answer is two: "him with dog and her with cat, him
with cat and her with dog". So
f [a, b, c] [d, e, f] [g, h, i] =
  [ [ (a, d, g), (b, e, h), (c, f, i) ]
  , [ (a, d, g), (b, e, i), (c, f, h) ]
  , [ (a, d, h), (b, e, i), (c, f, g) ]
  , [ (a, d, h), (b, e, g), (c, f, i) ]
  , [ (a, d, i), (b, e, g), (c, f, h) ]
  , [ (a, d, i), (b, e, h), (c, f, g) ]
  ... ]

On Mon, Mar 15, 2010 at 4:38 AM, Richard O'Keefe  wrote:
> The first question is "what does 'all the combinations' actually MEAN?"
>
> We are told that
>
>        f [a,b,c] [d,e,f] [g,h,i] =
>          [[(a,d,g),(b,e,h),(c,f,i)], ...]
>
> in which the first element of the result is just
> zip3 [a,b,c] [d,e,f], [g,h,i].  But what are the
> other elements?  Why is "all the combinations" a list
> of lists of tuples rather than a list of tuples?
>
> At first I thought you were after
>        f xs ys zs = [(x,y,z) | x <- xs, y <- ys, z <- zs]
> because that's what I would mean by "all the combinations",
> but the example shows that's not so.
>
> When you can explain clearly what you mean by "all the
> combinations", the code won't be far away.
>
>
>



-- 
竹密岂妨流水过
山高哪阻野云飞
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Binaries using shared libraries with cabal-install

2010-03-15 Thread Mathijs Kwik
Hi all,

I'm using cabal-install 0.8.0 on ghc 6.12.1 on linux
I switched on shared library support on cabal.

Does this enable -dynamic and -fPIC during compilation and -dynamic
-shared during linking?
Or does it work a little differently?

I noticed everything works for libraries. .so files get created, and
using ldd on them shows they depend on other haskell shared libraries.
But for binaries, it seems it still compiles them with everything included.
ldd'ing them shows no haskell-library dependencies and their size is
quite big as well.

Is it possible to tell cabal-install I want binaries to use shared libs instead?
And is there a way to specify which RTS to link binaries with? (debug,
threaded, normal)
Or a way to defer linking to an RTS so I can do this on execution
using LD_PRELOAD ?

Thanks for any help
Mathijs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe