Re: [Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-14 Thread Ketil Malde
braver  writes:

> In fact, the tag cafe2, when run on the full dataset, gets stuck at 11
> days, with RAM slowly getting into 50 GB

One tip might be to limit available heap memory by using +RTS -M2G (or
whatever your real memory is).  If (as seems likely) the RAM usage leads to
thrashing (the symptoms being 'top' showing substantially less than 100%
CPU usage, and a less responsive system), limiting heap will cause your
program to fail faster, which is always an advantage when debugging.

Unless you actually expect the working set to be fifty gig, that is.

-k
-- 
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] Terminology

2010-06-14 Thread Roman Cheplyaka
* Emmanuel Castro  [2010-06-15 00:10:09+0200]
> I am looking for the name of the property linking two functions f and g
> when :
> [f(a),f(b),f(c)] = g([a,b,c])
> 
> Is there a standard name?
> 
> In practice, g is an optimised version of f when working on large
> amount of elements.

Sometimes (particularly in Data Parallel Haskell, but also in other
languages) 'g' is called "vectorized version" of 'f'.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-14 Thread braver
In fact, the tag cafe2, when run on the full dataset, gets stuck at 11
days, with RAM slowly getting into 50 GB; a previous version caused
ghc 6.12.1 to segfault around day 12 -- -debug showing an assert
failure in Storage.c.  ghc 6.10 got stuck at 30 days for good, and
when profiling crashed twice with  a "strange closure" or a stack
overflow.  So allocation is a problem still.

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


Re: [Haskell-cafe] Terminology

2010-06-14 Thread Edward Z. Yang
Excerpts from Emmanuel Castro's message of Mon Jun 14 18:10:09 -0400 2010:
> I am looking for the name of the property linking two functions f and g
> when :
> [f(a),f(b),f(c)] = g([a,b,c])
> 
> Is there a standard name?
> 
> In practice, g is an optimised version of f when working on large
> amount of elements.

This is akin to a technique that data-parallel haskell uses; they call it
"chunking", but this is useful only when we were trying to evaluate elements of
the list in parallel, and generally the transformation will be more like
g([a,b,c]) ++ g([d,e,f]) etc.

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


Re: [Haskell-cafe] How to browse code written by others

2010-06-14 Thread Edward Z. Yang
Excerpts from Luke Palmer's message of Mon Jun 14 19:35:16 -0400 2010:
> If you go this route, I will shamelessly promote hothasktags instead
> of ghci.  It generates proper tags for qualified imports.

Ooh, that's a good time. (Ditches hasktags for hothasktags).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-14 Thread braver
OK, sample data is uploaded to data/sample in the git repo, and
README.md updated with the build and run command lines.  I've achieved
a bit more strictness, again with great help from @dons, @dafis, and
other great folks here and #haskell, but it's still slower than
Clojure and occupies a bit more RAM -- though not as much as before.
Now that the bangs are sprinkled around, it's slowed down.  I'll
profile this one tomorrow, but it works the 100K samples in a minute,
so is wide open to instrumentation!  Please help me build the fastest
Twitter graph miner in Haskell!  I'll keep the Clojure and an OCaml
version as a real-world shootout and welcome improvements at any
time.  I'm especially interested in bringing concurrency to bear on
it.


http://github.com/alexy/husky -- this post corresponds to tag cafe2
-- Alexy
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Reactive and 'real live' problem

2010-06-14 Thread Maciej Piechotka
I tried to experiment with reactive[1] and rewrite NeHe tutorials using
reactive-glut. However I run into problems.

I tried to write first tutorial and exit on escape. However there were 2
problems:

1. Optimized constant functions
2. Continuous behaviour

In reactive the final step is Behaviour which is 'function' from time to
something a. Here a = IO (). The problem is that it is not indifferent
how many time the same IO () was returned (we don't want to write to
file twice etc.).

I tried to workaround it in various ways but all I came up to was to
switch after switch with time + * where * is the difference between
times (unfortunately there is no function which give the next float).

As with every tick everything is executed -- unless everything gets
optimized to constant function.

Am I failing to find proper docs? How solve those problems? If they are
not easily solvable is there any general-purpose FRP library that allows
to use IO inside?

Regards

[1] http://hackage.haskell.org/package/reactive



signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Vague: Assembly line process

2010-06-14 Thread Alexander Solla


On Jun 14, 2010, at 4:40 PM, Luke Palmer wrote:


So hang on, what is the problem?  You have described something like a
vague model, but what information are you trying to get?  Say,
perhaps, a set of possible output lists from a given input list?


I think he's trying to construct a production possibility curve for a  
given set of inputs, and (probably) the most efficient production plan  
given the costs of his inputs.  This is a problem I am going to have  
to solve programmatically, too.  I intend on solving it by finding the  
input in a given category of necessary inputs with the lowest average  
cost per unit.  I'm not concerned about "hard" cost allocation limits  
-- i.e. it's okay for the firm to buy more of an input than might be  
necessary for another output as long as the average unit cost is the  
lowest (since all the inputs will be used eventually anyway).  Hard  
allocation complicates the problem, since you have an upper bound on  
what you can spend, and you want to spend it most effectively,  
presumably with as little "waste" of available cash as possibile.  Bin  
packing.


Martin:  You need to find a nice "normal form" for inputs and  
outputs.  If there aren't going to be many different types  of inputs,  
you can deal with interchangeability by making a type for each type of  
input.  (For example, if you were a jeweler, you could make:)



type Price = Integer  -- In cents, or a suitable denomination
type Quantity = Integer
data Mint   = Perth | CreditSuisse | Sunshine | Kitco deriving (Eq,  
Show)

data Gold   = Gold Mint Quantity Price deriving (Eq, Show)
data Silver = Silver Mint Quantity Price deriving (Eq, Show)

class AverageCost commodity where average_cost_per_unit :: commodity - 
> Price
instance (AverageCost commodity) => Ord commodity where -- I hope this  
isn't an undecidable instance
	left <= right = (average_cost_per_unit left) <=  
(average_cost_per_unit right)


data UnitOutput = UnitOutput { product :: Product,  requires ::  
Requirement }

data Requirement = Requirement { gold :: Gold, silver :: Silver }
data Product = GoldWatch { style :: ... } | GoldChain { style :: ... }  
| SilverWatch { style :: ... }


etc.  How you encode the style/product/output relationship is up to  
you (maybe products should know their necessary inputs.  Maybe not).   
If you have hard allocation limits, you can use a bin packing strategy.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Possible solution to the FGL naming/compatability issue

2010-06-14 Thread Ivan Miljenovic
Last night (AEST), Edward Kmett semi-convinced (in the sense that I'm
not sure whether his examples are really those that someone would
want/need or just thinking of possible future problems) me that some
users may have a need for FGL to keep having explicit graphs with kind
* -> * -> *.

With his prompting, I may have a possible solution: duplicate the classes.

We would have an InductiveGraph class (call it the parametric version)
that requires graphs to have kind * -> * -> *, and then another class
(call it the extended version) that removes this restriction.  The
parametric version would be closer to a drop-in replacement to the
current FGL setup (see below for more details) and the extended one
would provide all of the functionality requested, with some kind of
semi-automatic lifting/unlifting for graph types that are instances of
both.

Now, this parametric version will still not be a drop-in for the
current FGL, for several reasons:

* I want to have one overall InductiveGraph class rather than two
separate Graph and DynGraph classes

* Context will still be an actual data type rather than a 4-tuple and
LEdge would be come (Edge, Label) rather than (Node, Node, Label) [I'm
still debating whether to keep Edge as a datatype as needed for the
Type Familiy version or if it should just be a tuple).

* Some function names will be changed (e.g. fromContexts rather than buildGr).

* The Data.Graph.Inductive.Query stuff is going to be split out into
its own separate library, the Data.Graph.Inductive.Graphviz stuff is
going to be removed, etc.

* With the removal of the sub-libraries, I'm seriously considering
moving the class definitions from Data.Graph.Inductive.Graph to just
Data.Graph.Inductive.

There are also some caveats/design decisions with this solution:

* There will obviously be duplication.  With that said, do we try to
make the two classes semi-drop-ins (same class name, methods, etc. but
with different types) or think up new method names for the extended
version?

* How transparently can/will we make the lifting/unlifting?

* If we want the parametric version to still have the ability to
specify a custom node type, then it will still need either MPTCs +
fundeps or Type Families (i.e. extensions); otherwise we stick with
the current "type Node = Int" (or maybe replace it with some opaque
abstract type down the track as suggested by Heinrich Apfelmus).

* If we want to provide the ability to restrict the types of the
labels in the parametric version, then we would need MPTCs (Type
Families won't work since the label types won't be part of the class
definition then unless we use MPTCs, and in that case there's not
really any point in using Type Families).  Thus we once again need
extensions.

* My semi-end goal is to build a proper hierarchy of graph
types/libraries, such that the only thing FGL provides is the extra
aspect/concept of inductive graphs.  If we extend this parametric vs
extended split down to the set of base graph classes, then we're going
to have even more duplication and this kind of setup (where "Foo
depends on Bar" means "class (Bar a) => Foo a where ..."):

- fgl-parametric will depend on graph-parametric

- fgl-extended will depend on graph-extended

- There will be lifting/unlifting between graph-parametric and
graph-extended

- There will be lifting/unlifting between fgl-parametric and fgl-extended

As such, an FGL graph of kind * -> * -> * being treated as an extended
graph will have two possible ways (depending on the function in
question) will have two graph hierarchies two choose from, and two
possible points at which it can be lifted/unlifted (at the graph level
and the fgl level).  This could get confusing.

That said, there is one other benefit of this parametric vs extended
split: the types of the mapping functions in
http://code.haskell.org/FGL/fgl/Data/Graph/Inductive/Graph.hs won't be
as weird...

So, what are people's thoughts/opinions on this kind of setup?  Note
that I haven't started coding it yet, so I'm not sure how well it will
work in practice...

-- 
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] Vague: Assembly line process

2010-06-14 Thread Luke Palmer
So hang on, what is the problem?  You have described something like a
vague model, but what information are you trying to get?  Say,
perhaps, a set of possible output lists from a given input list?

Luke

On Mon, Jun 14, 2010 at 11:16 AM, Martin Drautzburg
 wrote:
> Hello all,
>
> this is a problem which has haunted me for some time. If this is simply
> hillarious, please tell me so. Or it may be some well known unsolvable
> problem...
>
> An assembly process takes inputs and produces outputs. I could say a Process
> is a function
>
> canProduce :: [Input]->[Output]->Bool
>
> which tells me if the outputs can be produced from the inputs
>
> There may be a similar function which tells me if the inputs are completely
> consumed to procude the output.
>
> The inputs do not determine the exact outputs. Think of a Process which
> combines a List of Ints into pairs, such that the input ints are consumed and
> each input Int occurs in only one position in the output. There are many ways
> to do this. Still for any set of input Ints and output pairs I could decide
> if the output can be produced from the input.
>
> Likewise the Input is not determined by the output. There may be lots of
> choices from what I could build my output (buy from different vendors).
>
> When I know more about the inputs and outputs my choices get more and more
> limited. I would like to to pass inputs and/or outputs to "something" and I
> would like to get a "something" which is more restricted, but still
> essentially a thing which tells me if the outputs can be produced from the
> inputs.
>
> I just cannot find a way to even THINK about this problem in a reasonable
> general way.
>
> --
> Martin
> ___
> 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 browse code written by others

2010-06-14 Thread Luke Palmer
On Mon, Jun 14, 2010 at 2:02 AM, Jean-Marie Gaillourdet
 wrote:
> Hello,
>
> On 13.06.2010, at 22:32, Martin Drautzburg wrote:
>
>> I need your advice about how to browse code which was written by someone else
>> (Paul Hudak's Euterpea, to be precise, apx. 1 LOC). I had set some hopes
>> on leksah, and it indeed shows me the interfaces, but I have not yet
>> convinced it to show me more than that.
>>
>> I ran haddock over the sources, and again I could not see more that just
>> signatures.
>>
>> I would be very happy with something like a Smalltalk browser. Something that
>> would let me zoom down to the source code, but with "search" and hyperlink
>> capabilities ("senders" and "implementers" in Smalltalk).
>>
>> Anyways, how do you guys do it, i.e. how to you dive into non-trivial foreign
>> code?
>
> I use the following tools:
>
> * haddock generated docs with hyperlinked sources
> * MacVim (or just vim) with Claus Reinke's haskellmode-vim, see: 
> http://projects.haskell.org/haskellmode-vim/index.html
>  Have a look at the screencasts to see documentation lookup, and code 
> navigation: http://projects.haskell.org/haskellmode-vim/screencasts.html
>  Make sure you know how to use tags inside of vim. ghci is able to generate 
> the tagsfiles for you. This allows you to jump to definitions of   
> identifiers.

If you go this route, I will shamelessly promote hothasktags instead
of ghci.  It generates proper tags for qualified imports.

> * SourceGraph, it generates an HTML report of a cabal projekt or of any 
> source tree. IMHO, great to get the overall picture.
>
> Regards,
> Jean-Marie
>
> ___
> 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] Terminology

2010-06-14 Thread Ivan Lazar Miljenovic
Philippa Cowderoy  writes:

> On 14/06/2010 23:17, Ivan Lazar Miljenovic wrote:
>> Emmanuel Castro  writes:
>>
>>> In practice, g is an optimised version of f when working on large
>>> amount of elements.
>>>  
>> It's a list, and map is lazy; not too sure you can get anything more
>> optimised than that for long lists.
>>
>>
>
> It may be possible to share calculations between instances of f, for
> example.

So its optimised for duplicate inputs, as well as for large amounts of
elements?

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

2010-06-14 Thread Philippa Cowderoy

On 14/06/2010 23:17, Ivan Lazar Miljenovic wrote:

Emmanuel Castro  writes:
   

In practice, g is an optimised version of f when working on large
amount of elements.
 

It's a list, and map is lazy; not too sure you can get anything more
optimised than that for long lists.

   


It may be possible to share calculations between instances of f, for 
example.


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


Re: [Haskell-cafe] Terminology

2010-06-14 Thread Ivan Lazar Miljenovic
Emmanuel Castro  writes:

> I am looking for the name of the property linking two functions f and g
> when :
> [f(a),f(b),f(c)] = g([a,b,c])
>
> Is there a standard name?

g = map f ?

>
> In practice, g is an optimised version of f when working on large
> amount of elements.

It's a list, and map is lazy; not too sure you can get anything more
optimised than that for long lists.

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

2010-06-14 Thread Emmanuel Castro
I am looking for the name of the property linking two functions f and g
when :
[f(a),f(b),f(c)] = g([a,b,c])

Is there a standard name?

In practice, g is an optimised version of f when working on large
amount of elements.

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


Re: [Haskell-cafe] Heist template splice functions and custom monad

2010-06-14 Thread Gregory Collins
Kevin Jardine  writes:

> I'd like to run Heist template splice functions in my own custom monad.
>
> I can define a splice function as:
>
> mySplice :: Splice MyMonad
>
> However, when I try to call functions that return values in my monad
> in mySplice, I get a compile error:
>
> Couldn't match expected type TemplateMonad MyMonad a 
> against inferred type MyMonad ()
>
> I've seen an example in the Heist documentation where the inner
> MyMonad is accessed using lift. But when I try that, I get another
> compile error:
>
> No instance for (Monad Trans TemplateMonad)
> arising from the use of 'lift'
>
> What do I do to get this to work?

You should post this to the Snap framework mailing list -- join here:
http://mailman-mail5.webfaction.com/listinfo/snap. Please follow up
there.

TemplateMonad does have a MonadTrans instance:

   
http://hackage.haskell.org/packages/archive/heist/0.2.0/doc/html/Text-Templating-Heist.html#t%3ATemplateMonad

Make sure you're using the "transformers"/"monads-fd" libraries and not
"mtl".

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


[Haskell-cafe] Heist template splice functions and custom monad

2010-06-14 Thread Kevin Jardine
I'd like to run Heist template splice functions in my own custom monad.

I can define a splice function as:

mySplice :: Splice MyMonad

However, when I try to call functions that return values in my monad in 
mySplice, I get a compile error:

Couldn't match expected type TemplateMonad MyMonad a 
against inferred type MyMonad ()

I've seen an example in the Heist documentation where the inner MyMonad is 
accessed using lift. But when I try that, I get another compile error:

No instance for (Monad Trans TemplateMonad)
arising from the use of 'lift'

What do I do to get this to work?

Kevin


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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Andrew Coppin

John Lato wrote:

I sort of agree with this, with some very large caveats.
  


Well, yes. If you don't know what a feature does, then you won't know 
that it solves the problem you have.



However, there's a lot to be said for both intellectual curiosity and
learning for the sake of knowledge. Just because you may never need
to use a feature doesn't mean you shouldn't be able to understand it.
  


There is that. However, in my experience, most of the advanced 
techniques tend to be described in language beyond my comprehension. 
(And most examples seem overly complex - although maybe that's just a 
reflection of the fact that simple problems don't require sophisticated 
techniques in the first place.) Having a specific problem to solve can 
be quite helpful. Unlike an example, you already understand what the 
problem is, and why it can't easily be solved any other way.


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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread John Lato
> From: Neil Brown 
>
> For example, if you find yourself writing the Nth boilerplate function
> that pattern-matches all cases in your ADT just to apply a function in
> its sub-types, that's when you'll want some form of generic programming
> like SYB.  And by that point you'll understand one of the problems that
> generic programming solves, which is halfway towards understanding the
> techniques themselves.

This is probably the most approachable description of generic
programming I've seen.  Every generic framework should have a
paragraph like this on the front page of the docs.

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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Andrew Coppin

Neil Brown wrote:

I'd second Ivan's suggestion to "learn-by-need".


I'd go along with that too.

The "advanced Haskell stuff" is a tool. It solves particular problems. 
You learn about it when you have one of the problems it's applicable to. 
If you don't have one of those problems, keep it simple. ;-)


I would also point out that some of this stuff is far, far less 
complicated than it seems. It's just very difficult to find 
comprehendable explanations for some of this stuff; people seem to 
assume that anybody who touches Haskell will "just know" what Skolem 
variables are, for example...


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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread John Lato
> From: Martijn van Steenbergen 
>
> On 6/14/10 10:39, Ivan Lazar Miljenovic wrote:
>> By being told that using them would solve some problem you're
>> complaining about on #haskell or the mailing lists, you look at
>> examples, read up on them, etc.
>>
>> Short version: don't worry about advanced concepts until you have to.
>> If all else fails, it doesn't hurt to write out the low-level version
>> yourself and then get told in a code review that it would be "easier" or
>> more elegant with an advanced technique.
>
> Exactly this. It's happened a few times now that I ran into a problem
> and then a bit later found out that feature XYZ was exactly what I
> needed. A feature I never understood but now suddenly had a good
> intuition for because it is a (or the) solution to a problem I had been
> thinking about for a while.

I sort of agree with this, with some very large caveats.  I would
agree that being faced with an actual problem provides a particularly
good learning environment for several reasons.  For the "pragmatic
programmer", this is probably the way to go.

However, there's a lot to be said for both intellectual curiosity and
learning for the sake of knowledge.  Nearly all of us specialize in
certain problem domains or areas and will likely never work on certain
problems (related to e.g. compilers, web servers, etc.) in anything
like a commercial environment.  Some of us may never work in a
commercial code environment at all.  Just because you may never need
to use a feature doesn't mean you shouldn't be able to understand it.

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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Stephen Tetley
On 14 June 2010 18:00, Patrick LeBoutillier
 wrote:
> Hi all,
>
>
> On Mon, Jun 14, 2010 at 1:42 AM, Aran Donohue  wrote:
>
>> resources. John Lato's recent Iteratee article is a notable exception*.
>
> Can anyone provide a link to the article (if it's available online)?
>

It was in the last issue of the Monad Reader...

http://themonadreader.wordpress.com/
http://themonadreader.files.wordpress.com/2010/05/issue16.pdf

Also Gerard Huet's original Zipper paper is a very clear read, the
paper seems to be on CiteSeer.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-14 Thread braver
On Jun 14, 11:40 am, Don Stewart  wrote:
> Oh, you'll want insertWith'.
>
> You might also consider bytestring-trie for the Graph, and IntMap for
> the AdJList ?

Yeah, I saw jsonb using Trie and thought there's a reason for it.  But
it's very API-poor compared with Map, e.g. there's not even a fold --
should one toListBy first?

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


[Haskell-cafe] Vague: Assembly line process

2010-06-14 Thread Martin Drautzburg
Hello all,

this is a problem which has haunted me for some time. If this is simply 
hillarious, please tell me so. Or it may be some well known unsolvable 
problem...

An assembly process takes inputs and produces outputs. I could say a Process 
is a function

canProduce :: [Input]->[Output]->Bool

which tells me if the outputs can be produced from the inputs

There may be a similar function which tells me if the inputs are completely 
consumed to procude the output.

The inputs do not determine the exact outputs. Think of a Process which 
combines a List of Ints into pairs, such that the input ints are consumed and 
each input Int occurs in only one position in the output. There are many ways 
to do this. Still for any set of input Ints and output pairs I could decide 
if the output can be produced from the input.

Likewise the Input is not determined by the output. There may be lots of 
choices from what I could build my output (buy from different vendors).

When I know more about the inputs and outputs my choices get more and more 
limited. I would like to to pass inputs and/or outputs to "something" and I 
would like to get a "something" which is more restricted, but still 
essentially a thing which tells me if the outputs can be produced from the 
inputs.

I just cannot find a way to even THINK about this problem in a reasonable 
general way.

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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Patrick LeBoutillier
Hi all,


On Mon, Jun 14, 2010 at 1:42 AM, Aran Donohue  wrote:

> resources. John Lato's recent Iteratee article is a notable exception*.

Can anyone provide a link to the article (if it's available online)?


Thanks,

Patrick
-- 
=
Patrick LeBoutillier
Rosemère, Québec, Canada
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Iteratee rest and monad instance

2010-06-14 Thread John Lato
> From: Tilo Wiklund 
>
> I am probably missing something obvious or something relating to
> optimisation/server software but defining iteratees as "Iteratee s a =
> Cont (s -> Either (s, a) (Iteratee s a))" seems to lead to a more
> natural monad instance, and does not suffer from (what seems to me to
> be an issue) having to make predictions about the stream it will be
> passed.
>
> My question is thus, why the "rest" stream has to be carried by an
> Iteratee constructor, rather then be part of the value of the
> continuation function.

Bas's reply is spot-on.  To directly answer your question, there is no
technical reason and both implementations are possible (among others).

The reasons for the choice (at least in the iteratee library) have to
do with the types that arise for enumerators and iteratee combinators
for a given implementation.  There is a good discussion of this in the
comments in Oleg's source code.

Currently I prefer the CPS-style.  It looks more complicated, and it
can't be written in Haskell-98, but otherwise it seems easier to use
with comparable (or better) performance.

Other factors (chunk size, chunk type) seem to have a much more
significant effect on performance than this.  There are performance
differences between the two IterateeG/IterGV implementations, but as
far as I know neither one is better overall.

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


[Haskell-cafe] Re: learning advanced haskell

2010-06-14 Thread John Lato
> From: Aran Donohue 
>
> Hi Cafe,
>
> I've been doing Haskell for a few months, and I've written some mid-sized
> programs and many small ones. I've read lots of documentation and many
> papers, but I'm having difficulty making the jump into some of the advanced
> concepts I've read about.
>
> How do people build intuitions for things like RankNTypes and arrows? (Is
> the answer "Get a PhD in type theory?") Normally I learn by coding up little
> exercise programs, but for these I don't have good intuitions about the
> kinds of toy problems I ought to try to solve that would lead me to
> understand these tools better.

I read as much as I can.  On the cafe, Planet Haskell, papers,
whatever.  If I don't understand a paper, I leave it be for a while
then come back to it in a few weeks/months.  Usually I'll be able to
make further headway.

Also don't try to read too much at once.  The literature is quite
dense and I find it useful to let things sit and percolate for a
while.

For the specific cases of RankNTypes and arrows I had nearly opposite
experiences.  I understood RankNTypes immediately, in that I expected
higher-rank behavior and was surprised when code didn't work that way.
 Arrows were particularly difficult for me (for much the same reason
as the Monoid class, incidentally).  I understood the concept of
arrows, but was unable to figure out how to actually *do* anything
with them for some time.  I'm still not sure that I have a great idea
of when arrows are useful as a computational abstraction; they seem to
be used more for the notation and convenience functions than anything
else.

> I understand the motivation for other concepts like iteratees, zippers and
> functional reactive programming, but there seem to be few entry-level
> resources. John Lato's recent Iteratee article is a notable exception*.

This is exactly what I was aiming for, so I really appreciate hearing
your comments.  I'm a beginner in many areas as well, so I also would
like to see more entry-level resources.

>
> Hints? Tips? "Here's how I did it"? ___ is a great program to write to
> get to learn __?
>

Stuff I have a decent understanding of:

RankNTypes - Look at this function

> makeString :: (Show b, Show c) => (a -> a) -> b -> c -> String
> makeString f b c = show (f b) ++ show (f c)

If you try to call it as e.g.

> makeString id 0 "foo"

GHC provides a type error.  This doesn't work because when GHC unifies
the types, it does something like this:

1) the first argument, f,  is a function with type a -> a
2) the function f is applied to an Integer, so f :: Integer -> Integer
3) the function f is applied to a String, so f :: String -> String
4) there are conflicting types for f, so bail out

Even though you declare f :: a -> a, that 'a' must be set to exactly
*one* value within the call, where makeString tries to apply it to
values with different types.  This is rank-1 polymorphism.  RankNTypes
fixes this by allowing us to specify that the "f" function is supposed
to be polymorphic within the makeString function (rank-2 polymorphism)
as opposed to the standard rank-1 polymorphism:

> makeString2 :: (Show b, Show c) => (forall a. a -> a) -> b -> c -> String

calling makeString2 does the right thing.  That's pretty much the
whole story of Rank2Polymorphism.  RankNPolymorphism is exactly the
same with nested levels of forall's.

One really useful feature of this is that it provides a sort of
inversion-of-control for polymorphism.  Typically the caller has the
ability to define the types when a function is called, as happens with
the b and c parameters to makeString2.  But in the first argument the
*callee* determines the type values of the function!  The caller knows
only that the function must take one argument and return a result of
the same type (which also means "id" is the only interesting function
of the appropriate type).  The callee is free to instantiate the given
function with *any types it wants*.  This is also what makes the ST
monad safe incidentally.

Arrows - Toy project: write a small program and use arrow notation to
combine functions.  Write the zipWith version of the "fib" function
with arrows.  Most of the stuff on the web is pretty readable IMHO.
Yampa is a good place to move beyond "Arrow" and into "ArrowLoop".

Zippers - Toy project: anything that keeps track of decisions in a
tree.  Mapping a path as in Theseus and the Zipper seems good.  I
learned it by implementing a user history function.

Template Haskell - Toy project: programatically generating data
declarations seems like a good starting point because it's relatively
simple and can't be done with normal code.  Instances are a good
follow-up.  Of course this is only a small portion of what TH can do,
but it's a start.  Bulat's tutorials are the best on this topic I'm
aware of.

I left out a lot of stuff that I'm still working with myself (SYB,
Finally Tagless, category-extras, ...).

> Thanks in advance,
> Aran
>
> * Even in this article

Re: [Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-14 Thread Don Stewart
deliverable:
> I've supplied a profile report there.  Since I load the graphs in
> memory and then walk them a lot, the time seems expected.  It
> allocates a lot, though.  The main graph type is
> 
> 
> type Graph = M.Map User AdjList
> type AdjList = M.Map Day Reps
> type User = B.ByteString
> type Day = Int
> type Reps = M.Map User Int
> 
> and I walk it with M.foldWithKey.  Folks said it's not strict enough,
> hence I tried to seq the step function, but to no avail so far.

Oh, you'll want insertWith'.

You might also consider bytestring-trie for the Graph, and IntMap for
the AdJList ?

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


Re: [Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-14 Thread John Van Enk
Would it be possible to use an IntMap instead of your OrdMap? Perhaps zip
your users with [0..] and key off the integer?

As a side note, I threw this package onto Hackage a while ago and may suit
your needs if you decide to move to something like IntMap:
http://hackage.haskell.org/package/EnumMap

It does have a performance hit over an IntMap, but I'm not entirely sure how
large it is.

/jve

On Mon, Jun 14, 2010 at 10:27 AM, braver  wrote:

> I've supplied a profile report there.  Since I load the graphs in
> memory and then walk them a lot, the time seems expected.  It
> allocates a lot, though.  The main graph type is
>
>
> type Graph = M.Map User AdjList
> type AdjList = M.Map Day Reps
> type User = B.ByteString
> type Day = Int
> type Reps = M.Map User Int
>
> and I walk it with M.foldWithKey.  Folks said it's not strict enough,
> hence I tried to seq the step function, but to no avail so far.
> ___
> 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 browse code written by others

2010-06-14 Thread Job Vranish
I've been using the geany  editor recently and I was
shocked to find that it has decent source browsing capabilities (that work
with haskell even!). You can find where something is defined and find other
usages of things. It's a bit crude, but gets the job done well enough.

- Job


On Sun, Jun 13, 2010 at 4:32 PM, Martin Drautzburg  wrote:

> Hello all,
>
> I need your advice about how to browse code which was written by someone
> else
> (Paul Hudak's Euterpea, to be precise, apx. 1 LOC). I had set some
> hopes
> on leksah, and it indeed shows me the interfaces, but I have not yet
> convinced it to show me more than that.
>
> I ran haddock over the sources, and again I could not see more that just
> signatures.
>
> I would be very happy with something like a Smalltalk browser. Something
> that
> would let me zoom down to the source code, but with "search" and hyperlink
> capabilities ("senders" and "implementers" in Smalltalk).
>
> Anyways, how do you guys do it, i.e. how to you dive into non-trivial
> foreign
> code?
>
>
> --
> Martin
> ___
> 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] Re: Mining Twitter data in Haskell and Clojure

2010-06-14 Thread braver
I've supplied a profile report there.  Since I load the graphs in
memory and then walk them a lot, the time seems expected.  It
allocates a lot, though.  The main graph type is


type Graph = M.Map User AdjList
type AdjList = M.Map Day Reps
type User = B.ByteString
type Day = Int
type Reps = M.Map User Int

and I walk it with M.foldWithKey.  Folks said it's not strict enough,
hence I tried to seq the step function, but to no avail so far.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] parsec: how to get end location

2010-06-14 Thread Martijn van Steenbergen

On 6/14/10 0:10, Roman Cheplyaka wrote:

Of course most parsers don't consume trailing newlines. But I was
writing general function to use in many places in the code which would
recover the end location. In most cases it just subtracts 1 from the
column number, but what if it just happened so that column number is 1?


Parsers can be composed of lots of functions, but eventually all the 
actual consumption of symbols boils down to calls to 
Text.Parsec.Prim.tokenPrimEx. This is where you need to address your 
problem: find the places in your code where this function is called (or 
the derived tokenPrim or token) and intercept there. Hopefully you have 
defined your own 'satisfy' function and need only change that one.


Once you've found those places, there's multiple ways to solve the 
problem. For example, you could keep track of the last interesting 
(=non-whitespace) position. Or you could parse the whitespace in a 
separate phase.


There is no way to retroactively intercept these calls, which I think is 
a flaw in the design of Parsec. It would have been nice to have a 
'runParsecWith myTokenPrimEx', or better yet capture the Parsec 
primitives in a type class.


Groetjes,

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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Ivan Lazar Miljenovic
Martijn van Steenbergen  writes:
>
> 1) What's a type of this function? I say *a* type because there are
> multiple correct answers.
>
>> debugWith f = do
>>   putStrLn (f True)
>>   putStrLn (f 'c')
>
> Don't ask the compiler to infer the type for you; it won't be able
> to. One of the characteristics of RankNTypes is that the compiler
> needs you, the programmer, to supply the type.

I randomly guess something like "(forall a. a -> String) -> IO ()" (but
haven't done anything myself with existentials so I'm quite possibly
wrong).

> 2) What would be a good argument to debugWith?

Does "show" suffice?

> 3) What's one reason the compiler can't infer the type for you?

foralls are tricksy little devils? :p

-- 
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] learning advanced haskell

2010-06-14 Thread Martijn van Steenbergen

On 6/14/10 10:39, Ivan Lazar Miljenovic wrote:

By being told that using them would solve some problem you're
complaining about on #haskell or the mailing lists, you look at
examples, read up on them, etc.

Short version: don't worry about advanced concepts until you have to.
If all else fails, it doesn't hurt to write out the low-level version
yourself and then get told in a code review that it would be "easier" or
more elegant with an advanced technique.


Exactly this. It's happened a few times now that I ran into a problem 
and then a bit later found out that feature XYZ was exactly what I 
needed. A feature I never understood but now suddenly had a good 
intuition for because it is a (or the) solution to a problem I had been 
thinking about for a while.


But sometimes a feature looks really interesting and you really want to 
run into a problem to which the feature is the solution. If this is the 
case for you with RankNTypes, here is such a problem:


1) What's a type of this function? I say *a* type because there are 
multiple correct answers.



debugWith f = do
  putStrLn (f True)
  putStrLn (f 'c')


Don't ask the compiler to infer the type for you; it won't be able to. 
One of the characteristics of RankNTypes is that the compiler needs you, 
the programmer, to supply the type.


2) What would be a good argument to debugWith?

3) What's one reason the compiler can't infer the type for you?

Hope this helps!

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


Re: [Haskell-cafe] Re: Difficulties with tagless - create "primitives" or compose them

2010-06-14 Thread Jacques Carette

Günther Schmidt wrote:
I have recently found something new that might also prove to be useful 
for EDSLs.

http://blog.sigfpe.com/2009/05/three-projections-of-doctor-futamura.html

Dan's blog post doesn't give any code or implementation but in a way 
it tackles the same problem, and since you also mention partial 
evaluation and transformation you might also find this interesting.


Actually, we tried to do the 2nd Futamura projection in tagless-final 
style -- and could not.  This paper

http://www.daimi.au.dk/~ko/papers/pldi142_rendel1.pdf [1]
documents why we were not able to: such self-embeddings need "infinite 
type towers", which neither Haskell not O'Caml have.  We did have a 
work-around using both a object-language-level 'let' and a 
meta-language-level 'let', but it was unsatisfactory and, in the end, we 
cut that whole section out of the JFP paper.


It would be interesting to see if using the techniques of 
Atkey-Lindley-Yallop [2]

http://homepages.inf.ed.ac.uk/slindley/papers/unembedding.pdf
would make this easier.  I have not had a chance to try.

Jacques

[1]

@inproceedings{1542509,
author = {Rendel, Tillmann and Ostermann, Klaus and Hofer, Christian},
title = {Typed self-representation},
booktitle = {PLDI '09: Proceedings of the 2009 ACM SIGPLAN conference on 
Programming language design and implementation},
year = {2009},
isbn = {978-1-60558-392-1},
pages = {293--303},
location = {Dublin, Ireland},
doi = {http://doi.acm.org/10.1145/1542476.1542509},
publisher = {ACM},
address = {New York, NY, USA},
}

[2]

@inproceedings{1596644,
author = {Atkey, Robert and Lindley, Sam and Yallop, Jeremy},
title = {Unembedding domain-specific languages},
booktitle = {Haskell '09: Proceedings of the 2nd ACM SIGPLAN symposium on 
Haskell},
year = {2009},
isbn = {978-1-60558-508-6},
pages = {37--48},
location = {Edinburgh, Scotland},
doi = {http://doi.acm.org/10.1145/1596638.1596644},
publisher = {ACM},
address = {New York, NY, USA},
}



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


Re: [Haskell-cafe] Re: Haddock Problem

2010-06-14 Thread David Waern
2010/6/14 Dominic Steinitz :

> So I created one and copied our custom package databse into it but still no
> luck:
>
> ..\ThirdParty\Haskell_Platform\2010.1.0.0\bin\haddock.exe -B
> c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages
> backendc\PAD2C.hs
> haddock: internal Haddock or GHC error:
> C:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages\package.
> conf.d\package.cache: openBinaryFile: does not exist (No such file or 
> directory)
>
> I'm not what this file is. Is it the same as the index file that cabal uses?

I don't know exactly what that file is, but -B is actually for
pointing Haddock at the GHC lib dir, so it's not surprising that it
doesn't work. I thought that perhaps the package.conf.d file is the
only thing it needs from that directory, but that doesn't seem to be
the case.

I think using --optghc=-package-conf is the correct way to point to
another package DB, so I'll look into why it doesn't work.

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


[Haskell-cafe] Re: Haddock Problem

2010-06-14 Thread Dominic Steinitz
David Waern  gmail.com> writes:

> 
> 2010/6/14 David Waern  gmail.com>:
> >
> > OK, it seems like the path from the ghc-paths package overrided what
> > you specified. I'm not sure this will work, but you could try:
> >
> >  haddock -B 
c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages\fpf.pack
age.conf
> 
> Sorry, that should be
> 
>   haddock -B 
c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages
> 
> David
> 
Better but no cigar.

..\ThirdParty\Haskell_Platform\2010.1.0.0\bin\haddock.exe
-B 
c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages\fpf.pack
age.conf
backendc\PAD2C.hs
haddock.exe: can't find a package database at 
C:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages\fpf.pack
age.conf\package.conf.d

And indeed I do not have a directory called package.conf.d.

So I created one and copied our custom package databse into it but still no 
luck:

..\ThirdParty\Haskell_Platform\2010.1.0.0\bin\haddock.exe -B 
c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages 
backendc\PAD2C.hs
haddock: internal Haddock or GHC error: 
C:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages\package.
conf.d\package.cache: openBinaryFile: does not exist (No such file or directory)

I'm not what this file is. Is it the same as the index file that cabal uses?

Dominic.






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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Neil Brown

On 14/06/10 06:42, Aran Donohue wrote:

Hi Cafe,

I've been doing Haskell for a few months, and I've written some 
mid-sized programs and many small ones. I've read lots of 
documentation and many papers, but I'm having difficulty making the 
jump into some of the advanced concepts I've read about.


How do people build intuitions for things like RankNTypes and arrows? 
(Is the answer "Get a PhD in type theory?") Normally I learn by coding 
up little exercise programs, but for these I don't have good 
intuitions about the kinds of toy problems I ought to try to solve 
that would lead me to understand these tools better.


For systems like Template Haskell and SYB, I have difficulty judging 
when I should use Haskell's simpler built-in semantic abstractions 
like functions and typeclasses and when I should look to these other 
mechanisms.


I'd second Ivan's suggestion to "learn-by-need".  For SYB and Template 
Haskell, and probably for most other fancy abstractions, you can get on 
happily without them in most cases.  When you start to think "there must 
be a better way!" while coding, that's when you should start looking for 
advanced features.


For example, if you find yourself writing the Nth boilerplate function 
that pattern-matches all cases in your ADT just to apply a function in 
its sub-types, that's when you'll want some form of generic programming 
like SYB.  And by that point you'll understand one of the problems that 
generic programming solves, which is halfway towards understanding the 
techniques themselves.


Hope that helps,

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


Re: [Haskell-cafe] parsec: how to get end location

2010-06-14 Thread Stephen Tetley
Hi Roman

You would need different behaviour for the /lexeme/ parser in
Parsec.Token at least - this is the combinator that promotes a parser
to also consume trailing whitespace.

I suspect you would have to recode most of Parsec.Token module - the
TokenParser is a parameterized module (in the sense of Sheard and
Pasalic [1]), unfortunately /lexeme/ is not one of the parameters and
other combintators are defined using it within the makeTokenParser
function which instantiates the parameterized module.


Alternative you could remake a set of token parsers - this is covered
in the Parsec manual [2] - section 2.11 "Advanced: Separate scanners".

[1] http://web.cecs.pdx.edu/~sheard/papers/JfpPearl.ps
[2] http://legacy.cs.uu.nl/daan/download/parsec/parsec.pdf

Best wishes

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


Re: [Haskell-cafe] Re: Haddock Problem

2010-06-14 Thread David Waern
2010/6/14 David Waern :
>
> OK, it seems like the path from the ghc-paths package overrided what
> you specified. I'm not sure this will work, but you could try:
>
>  haddock -B 
> c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages\fpf.package.conf

Sorry, that should be

  haddock -B 
c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages

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


Re: [Haskell-cafe] Re: Haddock Problem

2010-06-14 Thread David Waern
2010/6/14 Dominic Steinitz :
>> Try "--optghc=-package-conf --optghc=", to point Haddock at the custom
> DB.
>
> Hi David, Thanks for the quick response. No dice I am afraid. Dominic. BTW 
> this
> (using optghc) used to work on previous versions of haddock (iirc 2.4 and 
> 2.5).
>
> ..\ThirdParty\Haskell_Platform\2010.1.0.0\bin\haddock.exe
> --optghc=-package-conf
> --optghc=c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell
> _packages\fpf.package.conf
> backendc\PAD2C.hs
>
> haddock.exe: can't find a package database at E:\ghc\ghc-6.12.1
> \lib\package.conf.d

OK, it seems like the path from the ghc-paths package overrided what
you specified. I'm not sure this will work, but you could try:

  haddock -B 
c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell_packages\fpf.package.conf

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


[Haskell-cafe] Re: Haddock Problem

2010-06-14 Thread Dominic Steinitz
> Try "--optghc=-package-conf --optghc=", to point Haddock at the custom 
DB.

Hi David, Thanks for the quick response. No dice I am afraid. Dominic. BTW this 
(using optghc) used to work on previous versions of haddock (iirc 2.4 and 2.5).

..\ThirdParty\Haskell_Platform\2010.1.0.0\bin\haddock.exe
--optghc=-package-conf
--optghc=c:\p4wksp\steinitd_fpf_exdate_ws\FPF_Dev.br\ThirdParty\haskell
_packages\fpf.package.conf
backendc\PAD2C.hs

haddock.exe: can't find a package database at E:\ghc\ghc-6.12.1
\lib\package.conf.d

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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Ivan Lazar Miljenovic
Aran Donohue  writes:

> I've been doing Haskell for a few months, and I've written some mid-sized
> programs and many small ones. I've read lots of documentation and many
> papers, but I'm having difficulty making the jump into some of the advanced
> concepts I've read about.
>
> How do people build intuitions for things like RankNTypes and arrows?

By being told that using them would solve some problem you're
complaining about on #haskell or the mailing lists, you look at
examples, read up on them, etc.

Short version: don't worry about advanced concepts until you have to.
If all else fails, it doesn't hurt to write out the low-level version
yourself and then get told in a code review that it would be "easier" or
more elegant with an advanced technique.

-- 
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] How to "Show" an Operation?

2010-06-14 Thread Claus Reinke
As others have pointed out, you can't go from operation to 
representation,

but you can pair operations and expressions with their representations.


This idea is also implemented in my little 'repr' package:

http://hackage.haskell.org/package/repr


And probably more completely/comfortably!-) The version I 
pointed to, which I have occasionally mentioned here over the 
years, was deliberately simplified and reduced. I think Lennart 
also had a fairly complete version. Wasn't there also a version

in one of the IRC bots?

This kind of trick also comes up in embedded DSLs, especially 
if used for embedded compilers / code generators (eg, I used 
to generate VRML and Javascript from a Haskell DSEL, and by 
changing the expression representation to Javascript, running

the Haskell-embedded expression would generate Javascript).

I first encountered this idea when learning about type classes: I
was trying to convince myself that overloading does not break
referential transparency, even though this example clearly
shows that the same expression can have different meanings,
depending only on type context.

Claus


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


Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Chris Eidhof
On 14 jun 2010, at 07:42, Aran Donohue wrote:

> Hi Cafe,
> 
> I've been doing Haskell for a few months, and I've written some mid-sized 
> programs and many small ones. I've read lots of documentation and many 
> papers, but I'm having difficulty making the jump into some of the advanced 
> concepts I've read about.
> 
> How do people build intuitions for things like RankNTypes and arrows? (Is the 
> answer "Get a PhD in type theory?") Normally I learn by coding up little 
> exercise programs, but for these I don't have good intuitions about the kinds 
> of toy problems I ought to try to solve that would lead me to understand 
> these tools better. 

I learned my advanced stuff in two ways:

1. I followed excellent courses at Utrecht University, where they teach (among 
other things) advanced functional programming.
2. I just read a lot, which is a lot slower than 1.
3. By building my own programs, I inevitably find my self stuck and while 
searching for a solution, sometimes these concepts are the answer. For example, 
once I had a monadic program and I wanted to serialize/inspect the program, 
which turned out to be impossible in my case. The solution was to write it down 
using arrows (thus I had to learn arrows and also arrow-notatation). I think 
(for me) this is the most powerful way to learn new advanced concepts. I need 
practical problems to keep myself motivated.

> For systems like Template Haskell and SYB, I have difficulty judging when I 
> should use Haskell's simpler built-in semantic abstractions like functions 
> and typeclasses and when I should look to these other mechanisms.

Sometimes Template Haskell or SYB is the answer, and it's a matter of style, 
but I try to avoid them as much as possible. I find that generic programming in 
the style of regular [1] or emgm [2] is often much simpler.

Some more tips: subscribe to planet haskell, if you haven't done that already. 
Try to find ICFP/JFP/etc papers online that interest you.

-chris

[1]: http://hackage.haskell.org/package/regular
[2]: 
http://hackage.haskell.org/package/emgm___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haddock Problem

2010-06-14 Thread David Waern
2010/6/14 Dominic Steinitz :
> ..\ThirdParty\Haskell_Platform\2010.1.0.0\bin\haddock.exe BackendC\Core.hs
>
> haddock.exe: can't find a package database at
> E:\ghc\ghc-6.12.1lib\package.conf.d
>
> But if I do haddock --help there is no option to set the package database and 
> I
> don't even have an E: drive.
>
> I'm on windows in case that wasn't obvious and we have a custom package
> database which we point e.g. ghc and cabal at.

Try "--optghc=-package-conf --optghc=", to point Haddock at the custom DB.

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


Re: [Haskell-cafe] How to browse code written by others

2010-06-14 Thread Jean-Marie Gaillourdet
Hello,

On 13.06.2010, at 22:32, Martin Drautzburg wrote:

> I need your advice about how to browse code which was written by someone else 
> (Paul Hudak's Euterpea, to be precise, apx. 1 LOC). I had set some hopes 
> on leksah, and it indeed shows me the interfaces, but I have not yet 
> convinced it to show me more than that.
> 
> I ran haddock over the sources, and again I could not see more that just 
> signatures.
> 
> I would be very happy with something like a Smalltalk browser. Something that 
> would let me zoom down to the source code, but with "search" and hyperlink 
> capabilities ("senders" and "implementers" in Smalltalk).
> 
> Anyways, how do you guys do it, i.e. how to you dive into non-trivial foreign 
> code?

I use the following tools:

* haddock generated docs with hyperlinked sources
* MacVim (or just vim) with Claus Reinke's haskellmode-vim, see: 
http://projects.haskell.org/haskellmode-vim/index.html
  Have a look at the screencasts to see documentation lookup, and code 
navigation: http://projects.haskell.org/haskellmode-vim/screencasts.html
  Make sure you know how to use tags inside of vim. ghci is able to generate 
the tagsfiles for you. This allows you to jump to definitions of   identifiers.
* SourceGraph, it generates an HTML report of a cabal projekt or of any source 
tree. IMHO, great to get the overall picture.

Regards, 
Jean-Marie

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


[Haskell-cafe] Haddock Problem

2010-06-14 Thread Dominic Steinitz
..\ThirdParty\Haskell_Platform\2010.1.0.0\bin\haddock.exe BackendC\Core.hs

haddock.exe: can't find a package database at
E:\ghc\ghc-6.12.1lib\package.conf.d

But if I do haddock --help there is no option to set the package database and I 
don't even have an E: drive.

I'm on windows in case that wasn't obvious and we have a custom package 
database which we point e.g. ghc and cabal at.

Can someone tell me what I am doing wrong?

Many thanks, Dominic.


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


[Haskell-cafe] GeneralizedNewtypeDeriving and TypeFamilies

2010-06-14 Thread Max Cantor
So I understand from http://hackage.haskell.org/trac/ghc/ticket/4083 that 
GeneralizedNewtypeDeriving doesn't play well with TypeFamilies.

But, if a typeclass is only using type synonyms, is there any reason why 
newtype deriving would not work?  For a toy example:

class Cls a where
type MyType a
foo :: MyType a ->

in this case, if you have something like:

instance Cls () where
type MyType () = ()
foo = id

would:

newtype Bar = Bar () deriving (Cls)

be well defined?

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