Re: [Haskell-cafe] A bug of groupBy implement

2009-12-07 Thread Matthijs Kooijman
Hi,

 I have tested it in GHC 6.10.4 (Win XP) and GHC 6.8.3 (Linux), both give the 
 wrong result (categaried):
 
 7 = 3 ?: False
 3 = 5 ?: True
 3 = 9 ?: True
 3 = 6 ?: True
 3 = 8 ?: True
 3 = 3 ?: True
 3 = 5 ?: True
 3 = 4 ?: True
 [[7],[3,5,9,6,8,3,5,4]]
What exactly is wrong with this result? All of the above comparisons seem to
get the right result, and they say 7 is not in the same categorie as 3, but
all other numbers are in the same category as 3. So the returned list looks ok
too.

Perhaps you had expected another output list (please tell us what you think
you've found a bug!)? In fact, it seems that any output list would have been
correct, since you're using a comparison function that is not symmetrical.

In other words, you're say 7 should be in the same category as 3, but 3 should
not be in the same category as 7. Since nothing is guaranteed about the order
in which groupBy compares elements, any grouping could be achieved by letting
groupBy choose the right ordering.

So, it seems your comparison function is wrong since it does not satisfy the
(unwritten) requirement of symmetry?

Gr.

Matthijs


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


Re: [Haskell-cafe] Status of TypeDirectedNameResolution proposal?

2009-11-17 Thread Matthijs Kooijman
 I've added an informal straw poll to the bottom of [1] to allow you to 
 express an opinion.

[1]: ?


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


Re: [Haskell-cafe] Cabal install on Windows 7

2009-09-10 Thread Matthijs Kooijman
Hi Regis,

 - use windows API for requesting elevation during the process (ugly)
Why is this ugly? This seems like an elegant solution, to get privileges only
when you actually need them?

Gr.

Matthijs


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


Re: [Haskell-cafe] IMO ghc 6.8.2 misleading warning messages

2009-06-23 Thread Matthijs Kooijman
Hi Vasili,

 IMO the warning messages should be reversed! (parseOptional was never used
 .. called ... but I would strongly prefer the type signature warning first.
Can you motivate why? Any order looks fine to me...

Gr.

Matthijs


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


Re: Forward compatibility (was Re: [Haskell-cafe] GHCi infers a type but refuses it as type signature)

2009-06-23 Thread Matthijs Kooijman
Hi Luke,

   Simple: the definition of MonadState uses those extensions.
  [Snip question: Is this extension supported by all compilers]
 You should treat all compilers the same way as a universal quantifier in
 mathematics.  It's not just all the compilers you know about, but all
 possible compilers.  In which case the answer to your question is of course
 no.

I think the reasoninging here is the following: If MonadState is part of the
standard library and it needs this extension to work, then all compilers must
support this extension.

I'm not completely sure how standard the MonadState class is though. Also,
it might be that there could be implementations of MonadState that do not use
the extension?

If the latter is not the case, so MonadState will always require this
extension, than it seems that using the extension in your code gives you the
same portability as using the MonadState class. Not using the extension to
improve your portability only makes sense if you also stop using the
MonadState class, right?

Gr.

Matthijs


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


Re: [Haskell-cafe] ANNOUNCE: The Haskell Platform 2009.2.0.1

2009-06-03 Thread Matthijs Kooijman
Hi Don,

 We're pleased to announce the second release of the Haskell Platform: a
 single, standard Haskell distribution for everyone.
is there a changelog somewhere?

Gr.

Matthijs


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


Re: [Haskell-cafe] Reply to

2009-05-06 Thread Matthijs Kooijman
Hi Ashok,

 I feel that the haskell mailing lists must have the reply-to field set, so 
 that
 a person can reply to the list by just clicking reply.
Most email clients have a followup or reply-to-all feature, that will do
this. Better email clients also support (setting and reading) the
Mail-Followup-To header, which can prevents duplicates from being sent to
someone who is also subscribed to the list and ensure that replies are sent
directly to someone who is not on the list.

Using the reply-to header for this purpos is really wrong IMHO, since that
prevents people from easily replying directly to the author (and usually makes
personal email end up on the list as well) and makes it impossible for people
to use the Reply-To header for the purpose it was really meant for.

See also http://cr.yp.to/proto/replyto.html

Gr.

Matthijs


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


Re: [Haskell-cafe] Reply to

2009-05-06 Thread Matthijs Kooijman
Hi David,

 - Do you use To for the mailing list or for the parent?  
 - Do you ever include the grand-parent in the recipient list? 
I use whatever my mail client does when I hit list-reply :-)

For me (using mutt), that means to include any recipients and senders from the
original message (so mailing list, parent and grand-parent in your example),
unless the sender of the message I'm replying to has set the Mail-Followup-To
header. My client sets the Mail-Followup-To properly to include all recipients
and include myself when I am not subscribed to the list, and exclude myself
when I am subscribed to the list. This is the only proper solution, since you
can't guess from the addresses alone if someone is subscribed to the list and
should thus be included or not.

 - What's the difference between To and CC?
Just a matter of style I guess, functionally they are the same AFAIK.

 - If you send to only the mailing list, does it break the message thread? (it 
 seems like sometimes it does, sometimes it doesn't)
 - Does the mailing list do some kind of processing of the email headings sent 
 (I don't get how kmail managed to know your message was in reply to Magnus 
 Therning's message, since you didn't include him as a recipient)
These two questions are the same: This is handled by email clients entirely.
They set the In-Reply-To header, which refers to the message ID of the
replied-to message, for proper threading. Alternatively, some clients (can)
use the subject for guessing threads, but the mailing list doesn't handle this
in any way (it doesn't have any info that the recipients don't have either).

 - Is kmail's mailing list management completely bonkers (eg what is the 
 difference between Reply and Reply to mailing list)?
Dunno, but it seems so from your example.

 And don't get me started on whether to use html or plain text in messages! 
 (seen both pretty often here)
As long as messages have a decent text/plain part, feel free to use anything
as far as I'm concerned (flash, anyone? :-p)

 Anyway, I can't see why we still use mailing lists when we have reddit, which 
 has all the good parts of mailing lists (nested messages), while it also:
Hmm, what's this reddit thing? *googles*

At first glance, the reddit frontpage looks very crowded and incapable of
conveying information to me...

At second glance, it looks like some kind of giant forum with random topics
and links to other forums/news sites/blogs? There's probably some way to
organize threads belonging to a single topic that becomes evident when you
login?

 - is much simpler to use
Can't say, never used it...
 - allows voting up/down of good/inaccurate messages
 - allows voting up/down of interesting/boring topics
That's cool for when you're reading a topic back (ie would be nice on email
archives) but not really useful for new questions and messages (which is what
our mailing lists are usually about, right?).

 - has a good web interface (mail-archive.com doesn't even come close)
Nice, but does it have a non-web-interface? The only way I can actually
manage all email traffic coming my way from a couple dozen mailing lists, is
because mutt is so darn efficient when it comes to reading and processing
mail. I would't want to do all that in a webinterface.

 - uses markdown (no more html vs plain text problems)
That's cool :-) Though you can also just write markdown in plain text email,
looks pretty as well :-p

 - allows messages to be edited after being sent
You can always just reply with corrections. Editing messages after writing
them only makes things confusing (since you probably won't be able to edit
them before someone has read them...).

 - has rss feeds for article comments, and sub reddit topics
Aren't RSS feeds just invented to turn the normal pull information flow of a
website to a sortof push flow (or rather, to automate the polling of a
website for new info). The cool thing about email is that it's push by design!

 - sends notifications when someone replies to one of your comments
Like, via email? :-p 

Seriously though, I guess something like reddit has some merit, but I see that
mostly for archival and/or discussions that have a longer lasting value. A lot
of traffic on mailing lists is useful for as long as the question that's asked
is unsolved and after that it's done. Also, no webinterface is not a
substitute for a decent mail client, especially a heavily customized one.

If you're serious about using reddit for haskell discussions, could you
perhaps enlighten us with how that would work? I've been browsing a bit more,
and reddit really looks like a collection of links to articles and topics, not
like an actual discussion medium?

Gr.

Matthijs


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


Re: Is 78 characters still a good option? Was: [Haskell-cafe] breaking too long lines

2009-04-23 Thread Matthijs Kooijman
   Some material I've read on typography -- can't find the
   reference now -- suggests ~65 is the best number of characters
   per line. The advice was, if your page is larger than that,
   you should make columns.
That fits my observations. In particular, I noticed that your emails were
particularly comfortable to read, which might also be partly be caused by the
extra indent at the start of your lines, which also seems comfortable. Not
sure how applicabable all this is to code, though :-)

Gr.

Matthijs


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


Re: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

2009-04-07 Thread Matthijs Kooijman
Hi Claus,

 http://projects.haskell.org/haskellmode-vim/
The download link on this page seems to use \ instead of /, making it not
work.

For anyone eager to download it, just replace \ (or %5C) in your address bar
with \ and it should work.

Gr.

Matthijs


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


Re: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

2009-04-07 Thread Matthijs Kooijman
Hi Claus,

I've installed the vimball, and it spit a few errors at me. In particular, it
couldn't find the haddock documentation directory. A quick look at
haskell_doc.vim shows that it should autodetect the directory. However, for
some reason my ghc-pkg command returns the doc directory twice:

  $ ghc-pkg field base haddock-html
  haddock-html: /usr/local/ghc-6.10.1/share/doc/ghc/libraries/base
  haddock-html: /usr/local/ghc-6.10.1/share/doc/ghc/libraries/base

The haskell_doc.vim contains the following line, which seems to deal with
multiple lines:

  let field = substitute(system(g:ghc_pkg . ' field base 
haddock-html'),'\n','','')

However, this simply concats the lines, which obviously makes a mess of the
output and makes the detection fail. I've made things work by throwing away
everything except for the first line, by replacing the above line with:

  let field = substitute(system(g:ghc_pkg . ' field base 
haddock-html'),'\n.*','','')

This solution works for me, though it might be better to iterate all lines and
try each of them in turn, for the case that ghc-pkg returns different paths? I
can't really think of a case why this would be needed, though.

Gr.

Matthijs


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


Re: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

2009-04-07 Thread Matthijs Kooijman
Hi Claus,

I've found two more little bugs. The first is that version comparison is
incorrect. It now requires that all components are greater, so comparing
6.10.1 = 6.8.2 returns false (since 1  2).

Also, there is a ghc-pkg field * haddock-html call, but here the * will be
expanded by the shell into the files in the current directory. To prevent
this, the * should be escaped.

Both of these are fixed in the attached patch.

I'm also looking at the Qualify() function, which allows you to select a
qualification using tab completion. However, when there is only a single
choice, its a bit silly to have to use tabcompletion. At the very least, the
value should be prefilled, but ideally the qualification should just happen.

Also, I think that a dropdown menu is also available in text mode vim (at
least with vim7), which would be nice for multiple choices (since you can see
all choices in one glance).

I'll have a look at these things as well, expect another patch :-)

Gr.

Matthijs


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 get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]

2009-03-16 Thread Matthijs Kooijman
Hi Martin,

 Only to avoid misunderstandings, you only use the ghc-api to get the AST
 of a CoreModule which you translate into your own data structure (VHDL).
That's correct.

 At this point, you don't use type information, right?
I use some typing information, but that's mostly hidden away. In particular,
when creating Signals using genSignalId I annotate them with the type of the
expression the signal models. Later on, I translate this type to a VHDL type.

To get at the type of an expression, I use the CoreUtils.exprType function,
which gives you the type of any CoreExpr.

Gr.

Matthijs


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 get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]

2009-03-13 Thread Matthijs Kooijman
Hi Martin,

 Could anybody tell me, where to start in the ghc-api? It's pretty hard,
 when you don't know where to look. Hoogle doesn't know anything about
 it. I found following DT describing the core language, but as far as I
 see, there are no type in there either.
I've been working on parsing core in the past few months. For an example, look
here:
  
http://git.stderr.nl/gitweb?p=matthijs/projects/fhdl.git;a=blob;f=Translator.hs;h=8072f85925ad1238

The loadModule and findBind functions are interesting. As for iterating the
AST, have a look at Flatten.hs.

Good luck, any questions are welcome!

Gr.

Matthijs


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


Re: [Haskell-cafe] Using FosSyDe to translate haskell to VHDL.

2009-03-10 Thread Matthijs Kooijman
Hi Hany,

 *Plus2 writeVHDL plus2SysDef
 *** Exception: VHDL Compilation Error: Untranslatable function: where 
 constructs are not supported in functions:
 where addOnef_0 = n_1 GHC.Num.+ 1
 in process function `addTwof' (created in Plus2)  used by  process 
 `plus2Proc' belonging to system definition `plus2' (created in unkown)
I don't know much about ForSyDe, but it seems that where clauses simply aren't
supported. Perhaps let expressions are?

The would mean something like the following:

  addTwof :: ProcFun (Int32 - Int32)
  addTwof = $(newProcFun [d|addTwof :: Int32 - Int32
let addOnef = n +1 in
addTwof n = addOnef+1
 |])

(Not sure if this is completely valid code, I'm not too familiar with TH..).

Gr.

Matthijs


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


Re: [Haskell-cafe] Re: base-4 + gtk2hs-0.10.0 licensing

2009-02-26 Thread Matthijs Kooijman
Hi all,

 An easy thing to do here would be to get a written statement from the
 author about the interpretation with regard to what you intend to do -
 like Duncan posted.
AFAIK this only works when the code has a single author (or, you get a written
statement from each author). In practice, many open source projects have lots
of untrackable authors, each of which have contributed code only under the
terms of the license as it was published when they contributed. The main
project maintainer can't technically change the license (because that is what
a written statement about the intent really does) for the code it does not own
copyright over.

Gr.

Matthijs


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


Re: [Haskell-cafe] haddock-2.3.0 error: file name does not match module name

2009-01-29 Thread Matthijs Kooijman
 I assume that it's procesing file Database.Enumerator.lhs when it
 emits this, but I'm puzzled because the module name in
 Database.Enumerator.lhs is certainly Database.Enumerator, and not
 Main.
Any chance the module statement in the file is wrong? I think I remember
seeing this error once when I accidentally typed Module instead of module.
Apparently ghc assumes Main when there is no valid module statement.

Gr.

Matthijs


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


Re: [Haskell-cafe] Gentle introduction questions / comments

2009-01-27 Thread Matthijs Kooijman
Hi Cristiano,

 Mmmmhhh... this seems the signature of the liftM function, whose
 purpose is to make a function operate on monadic values instead of
 pure values. Notice that this is different from the lift function
 you described above. A computation is a monadic value (i.e. an object
 of the type Monad m = m a) and the lift function wraps that value
 into a monad transformer, making it a new monadic value (i.e. an
 object of the type MonadTrans t, Monad m = t m a).
Thanks for clarifying. I don't have my terminology straight yet I guess :-)

Can you fix the issues?

Gr.

Matthijs


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


[Haskell-cafe] Core questions

2009-01-24 Thread Matthijs Kooijman
Hi all,

for my Master's thesis, I'm looking into functional hardware
descriptions, and in particular to translate haskell code into VHDL that
can be programmed into an FPGA.

For this, I'm using the GHC API to load the haskell source and give me
(simplified) core representation. I then walk over the core tree and
translate it to VHDL.

On the whole the GHC API has been very useful to me. It took me some
time to get used to all the (deeply) nested (algebraic) types (I didn't
have any previous haskell experience when I started a month or so ago),
but things are working out by now.

However, there are two issues bothering me still. The first is that the
Core types (in particular CoreExpr) are not instances of Show. They are
instances of Outputable, which allows them to be pretty printed.
However, this pretty printing is good to view the structure of the
expression that the CoreExpr represents, but doesn't show the structure
of the CoreExpr itself. For example, tuple construction is printed
simply as (a, b), while the actual core expression is a nested
application of two types, and a and b to the GHC.Tuple.(,) function
(or datacon?). Also, the exact constructors used are not quite clear,
which made it harder to work with the Core language for me. Instead of
looking at the structure of the CoreExpr and write the appropriate
patterns, I had to resort to a lot of trial and error.

I tried deriving show for CoreExpr myself, but that required me to
derive Show for a dozen other types and resulted in type errors beyond
my understanding.

Is there any compelling reason that CoreExprs are not instances of Show?


My second question concerns typle construction. Since tuple types are
not primitive types, but dependent types defined in various places
(GHC.Tuple and Base IIRC), code working with tuples is not fundamentally
different from code working with other (user defined) dependent types
and thus not trivial to recognize. I've found that there are some
predicate functions that can tell me if a type is a tuple type, but I've
had no such luck for the actual tuple construction.

In particular, when an expression creates a tuple of two Ints (a, b),
this is represented in Core as the application of the element types and
the element values to the (,) function (or data constructor? Not sure
about this, in Core it's just a Var and the isDataConName [IIRC]
predicate crashes when run on the Var).

For now, I've manually matched the Var's name to GHC.Tuple.(,) and
removed all type arguments to get at the actual values in the tuple.
This is of course completely non-portable, to tuples with more than two
elements, or unboxed tuples, etc.

Is there some predicate function that can do this for me in a more
portable way?

Gr.

Matthijs


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