Re: [Haskell-cafe] Linker problems linking FFI import call in Windows

2008-07-16 Thread Olivier Boudry
On Tue, Jul 15, 2008 at 11:51 PM, PJ Durai [EMAIL PROTECTED] wrote:
 I am trying to import some functions from a windows DLL. I am getting
 strange errors. (This used to work with previous versions of GHC.  6.6
 I think.).

You may have to create an import library for the DLL. I had a similar
problem and solved it that way.

Look at http://www.emmestech.com/moron_guides/moron1.html for advices
on how to create such a library.

My problem was that the exports in the dll were prefixed with an
underscore. I had to remove them from the .def file before creating
the import library.

Best regards,

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


Re: [Haskell-cafe] CAL (OpenQuark) and enterprise

2008-07-16 Thread fero

Nice:)



Daniil Elovkov wrote:
 
 fero wrote:
 And what if writing new application? Has anybody experience with
 enterprise
 application in functional language? Is it really clearer? I can see a
 advantage in using Scala but it doesn't have some features from Haskell
 or
 CAL or requires more code to write. Or better has anybody experience with
 the same and functional language for JVM? And what about ORM (e.g.
 Hibernate)? And what about objects, they are stateful itself. And CRUD is
 a
 very common part of enterprise applications and I think it's easier in
 imperative style (client is declarative of course but it assigns values
 to
 fields). I am interested in ours opinions/experience in business logic
 (not
 any infrastructure or client stuff) for apps such as
 accounting/bank/insurance/document management... systems in functional
 languages. Sometimes the rules for these kind of apps is more complex
 that
 it seem to be and such systems are maintained for many years (some even
 decades) so it needs to be readable. Rule engines are very popularized
 among
 java community now but I think many logic can be expressed clearer in
 functions. It is maybe useful for some kind of logic (e.g. calculate
 price
 with discounts) but for what I do I can write the same clearer in java
 that
 in rule engine (and much clearer in Haskell and I am only beginner. What
 will come after few years coding;). 
 
 
 You may start writing more obscure code.
 
 Look at this:
 http://www.willamette.edu/~fruehr/haskell/evolution.html
 
 This is humour, of course.
 
 
 Miles Sabin wrote:
 On Wed, Jul 9, 2008 at 6:28 PM, Neil Mitchell [EMAIL PROTECTED]
 wrote:
 On the Haskell list I think its fair to say everyone recommends you
 should use Haskell.
 Not necessarily. If the OP has a significant body of existing Java
 code (s)he has to work with (which is what the question suggests) then
 Scala would most likely be a very good place to look.

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

-- 
View this message in context: 
http://www.nabble.com/CAL-%28OpenQuark%29-and-enterprise-tp18366397p18483627.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-16 Thread Chris Kuklewicz

Thanks Roberto!

Roberto Zunino wrote:

Chris Kuklewicz wrote:

There is no way to create a A.hs-boot file that has all of
  (1) Allows A.hs-boot to be compiled without compiling B.hs first
  (2) Allows B.hs (with a {-# SOURCE #-} pragma) to be compiled after 
A.hs-boot

  (3) Allows A.hs to compiled after A.hs-boot with a consistent interface


I thought the following A.hs-boot would suffice:

module A(A) where
data A

There's no need to provide the data constructors for type A. Does this 
violate any of the goals above?


Regards,
Zun.



I tried that experiment.  The failure is complicated, and triggers be a ghc bug.

Hmmm... the bug for


module A(A) where
data A
  deriving Show


using ghc -c -XGeneralizedNewtypeDeriving A.hs-boot is


A.hs-boot:2:0:ghc-6.8.3: panic! (the 'impossible' happened)
  (GHC version 6.8.3 for powerpc-apple-darwin):
newTyConEtadRhs main:A.A{tc r5z}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug


Is this a known bug?

But now I see that


module A(A(..)) where
import B(B)
data A = A B | End
  deriving Show



does work.  And avoids the bug!

--
Chris

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


[Haskell-cafe] Re: Euler 201 performance mystery

2008-07-16 Thread apfelmus

[EMAIL PROTECTED] wrote:

Dear Group,

I've spend the last few days figuring out the solution to Euler Problem 201 in
haskell.  I first tried a relatively elegant approach based on Data.Map but
the performance was horrible.  I never actually arrived at the answer.  I then
rewrote the same algorithm using STUArrays and it was lightning.  I have
posted both versions of the code at:
http://www.maztravel.com/haskell/euler_problem_201.html
and would appreciate any insights that you master haskellers can provide on
why the speed difference is so huge.  Thanks in advance.
Henry Laxen


First, you may want to change the map type to

  type SumMap = Map (Int,Int) Int

since you're working with pairs (length, sum), not lists. I mean, you're doing 
the same with  STUArray (Int,Int) Int .



Did you try to estimate the running time of both data structures? Calculating 
the number of big-O operations on the back of an envelope is a very good 
guideline. So,  Data.Map.insert  takes O(log (size of map)) operations and so 
on. A rule of thumb is that a computer can perform 10 million operations per 
second (maybe 100, that was five years ago :)). Granted, this rule works best 
for C programs whereas Haskell is quite sensitive to constant factors, in 
particular concerning memory and cache effects. So, the rule is pretty accurate 
for an STUArray but you may have to multiply with 10 to get the right order of 
magnitude for Data.Map.



As you have noted, the choice of data structure (Map, STUArray, something else) 
is important (Map only touches existing sums, but STUArray has O(1) access and 
uses a tight representation in memory). But in the following, I want to discuss 
something what you did implicitly, namely how to *calculate* the general 
algorithm in a mechanical fashion. This follows the lines of Richard Bird's 
work, of which the book Algebra of Programming


http://web.comlab.ox.ac.uk/oucl/research/pdt/ap/pubs.html#Bird-deMoor96:Algebra

is one of the cornerstones. The systematic derivation of dynamic programming 
algorithms has been rediscovered in a more direct but less general fashion in


   http://bibiserv.techfak.uni-bielefeld.de/adp/


Euler problem 201 asks to calculate the possible sums you can form with 50 
elements from the set of square numbers from 1^2 to 100^2. Hence, given a function


  subsets [] = [[]]
  subsets (x:xs) = map (x:) (subsets xs) ++ subsets xs

that returns all subsets of a set, we can implement a solution as follows:

  squares   = map (^2) [1..100]
  euler201  = map sum . filter ((==50) . length) . subsets $ squares

While hopelessly inefficient, this solution is obviously correct! In fact, we 
did barely more than write down the task.


Ok ok, the solution is *not correct* because  map sum  may generate 
*duplicates*. In other words,  subsets  generates a lot of sets that have the 
same sum. But that's the key point for creating a better algorithm: we could be 
a lot faster if merging subsets with the same sum and generating these subsets 
could be interleaved.


To that end, we first have to move the length filter to after the summation:

   map sum . filter ((==50) . length)
 = map snd . filter ((==50) . fst) . map (length  sum)

The function () is very useful and defined as

  (length  sum) xs = (length xs, sum xs)

You can import (a generalization of) of it from Control.Arrow. In other words, 
our solution now reads


  euler201 = map snd . filter ((==50) . fst) . subsums $ squares
 where
 subsums = map (length  sum) . subsets

and our task is to find a definition of  subsums  that fuses summation and 
subset generation.


But this is a straightforward calculation! Let's assume that we have an 
implementation of Sets that we can use for merging duplicates. In other words, 
we assume operations


  singleton :: a - Set a
  union :: Set a - Set a - Set a
  map   :: (a - b) - Set a - Set b

so that  subsets  becomes

  subsets [] = singleton []
  subsets (x:xs) = map (x:) (subsets xs) `union` subsets xs

Now, let's calculate:

  subsums []
  =  { definition }
map (length  sum) (subsets   [])
  =  { subsets }
map (length  sum) (singleton [])
  =  { map }
singleton ((length  sum) [])
  =  { length  sum }
singleton (0,0)


  subsums (x:xs)
  =  { definition }
map (length  sum) (subsets (x:xs))
  =  { subsets }
map (length  sum) (map (x:) (subsets xs) `union` subsets xs)
  =  { map preserves unions }
 map (length  sum) (map (x:) subsets xs)
`union`  map (length  sum) (subsets xs)
  =  { map fusion }
 map (length  sum . (x:)) (subsets xs)
`union`  map (length  sum)(subsets xs)
  =  { move (length  sum) to the front, see footnote }
 map ((\(n,s) - (n+1,s+x)) . (length  sum)) (subsets xs)
`union`  map (length  sum) (subsets xs)
  =  { reverse map fusion }
 map (\(n,s) - (n+1,s+x)) (map (length  sum) (subsets xs))
`union`  map (length  sum) (subsets xs)
  =  { 

RE: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-16 Thread Sittampalam, Ganesh
Hi,

 module A(A) where
 data A
   deriving Show

I think you should use instance Show A rather than deriving Show.
All the boot file needs to do is say that the instance exists, not
explain how it is constructed.

Cheers,

Ganesh

==
Please access the attached hyperlink for an important electronic communications 
disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==

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


[Haskell-cafe] Re: Strange space leak

2008-07-16 Thread apfelmus

Grzegorz Chrupala wrote:


   split DOC . words . map toLower = (:[]) . words . map toLower

Since you converted everything to lowercase, the string DOC will 
never appear in the text, resulting in a single huge document. 



Oops, that should have been obvious, sorry for the dumb question.
Thanks,


No problem, it was not obvious to me and I had fun trying to figure it out :)


Regards,
apfelmus

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


[Haskell-cafe] win32: haddock: internal Haddock or GHC error?

2008-07-16 Thread Dmitri O.Kondratiev
Using GHC 6.8.2 and haddock 2.0.0.0. in WinXP (SP3) I am trying to follow
instructions from How to write a Haskell
programhttp://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program#Build_some_haddock_documentation
.
Everything goes well, until I try to generate html documentation for the
project. Then I get the following errors:

C:\wks\haqrunhaskell Setup.lhs haddock --executables
Preprocessing executables for haq-0.0...
Running Haddock for haq-0.0...
Preprocessing executables for haq-0.0...
Warning: Cannot read C:/usr/ghc-6.8.2/doc/libraries/base\base.haddock:
   Magic number mismatch: couldn't load interface file:
C:/usr/ghc-6.8.2/doc/li
braries/base\\base.haddock
Skipping this interface.
Warning: main:Main: could not find link destinations for:
GHC.IOBase.IO
haddock: internal Haddock or GHC error:
c:/builds/haddock-2/install\haddock-2.0.
0.0/html/haddock.css: openFile: does not exist (No such file or directory)

Any ideas how to solve this?
Thanks!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] win32: haddock: internal Haddock or GHC error?

2008-07-16 Thread Neil Mitchell
Hi Dmitri,

How did you obtain Haddock 2.0? Did you download it off hackage and
install it, using the standard cabal bits?

Can you also do runhaskell Setup configure -v, so we can see which
Haddock Cabal is attempting to use.

Thanks

Neil


 C:\wks\haqrunhaskell Setup.lhs haddock --executables
 Preprocessing executables for haq-0.0...
  Running Haddock for haq-0.0...
 Preprocessing executables for haq-0.0...
 Warning: Cannot read
 C:/usr/ghc-6.8.2/doc/libraries/base\base.haddock:
Magic number mismatch: couldn't load interface file:
 C:/usr/ghc-6.8.2/doc/li
  braries/base\\base.haddock
 Skipping this interface.
 Warning: main:Main: could not find link destinations for:
 GHC.IOBase.IO
 haddock: internal Haddock or GHC error:
 c:/builds/haddock-2/install\haddock-2.0.
  0.0/html/haddock.css: openFile: does not exist (No such file or directory)

 Any ideas how to solve this?
 Thanks!

 ___
  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] win32: haddock: internal Haddock or GHC error?

2008-07-16 Thread Dmitri O.Kondratiev
Neil,
Thanks for the quick response! I got haddock from its site (
http://haskell.org/haddock/#Download )using the link that says:
Windows: a binary
distribution http://haskell.org/haddock/dist/haddock-2.0.0.0-Win32.zip is
available, just unzip and go. 

My configuration:

C:\wks\haqrunhaskell Setup.lhs configure -v
Configuring haq-0.0...
Dependency base-any: using base-3.0.1.0
Using compiler: ghc-6.8.2
Using install prefix: C:\Program Files\Haskell
Binaries installed in: C:\Program Files\Haskell\bin
Libraries installed in: C:\Program Files\Haskell\haq-0.0\ghc-6.8.2
Private binaries installed in: C:\Program Files\Haskell\haq-0.0
Data files installed in: C:\Program Files\Haskell\haq-0.0
Documentation installed in: C:\Program Files\Haskell\doc\haq-0.0
No alex found
Using ar found on system at: C:\usr\ghc-6.8.2\bin\ar.exe
No c2hs found
No cpphs found
No ffihugs found
Using ghc version 6.8.2 found on system at: C:\usr\ghc-6.8.2\bin\ghc.exe
Using ghc-pkg version 6.8.2 found on system at:
C:\usr\ghc-6.8.2\bin\ghc-pkg.exe

No greencard found
Using haddock version 2.0.0.0 found on system at: C:\usr\haddock\haddock.exe
No happy found
No hmake found
Using hsc2hs version 0.66-ghc found on system at:
C:\usr\ghc-6.8.2\bin\hsc2hs.ex
e
No hscolour found
No hugs found
No jhc found
Using ld found on system at: C:\usr\ghc-6.8.2\gcc-lib\ld.exe
No nhc98 found
No pfesetup found
No pkg-config found
No ranlib found
No tar found

On Wed, Jul 16, 2008 at 4:45 PM, Neil Mitchell [EMAIL PROTECTED] wrote:

 Hi Dmitri,

 How did you obtain Haddock 2.0? Did you download it off hackage and
 install it, using the standard cabal bits?

 Can you also do runhaskell Setup configure -v, so we can see which
 Haddock Cabal is attempting to use.

 Thanks

 Neil


  C:\wks\haqrunhaskell Setup.lhs haddock --executables
  Preprocessing executables for haq-0.0...
   Running Haddock for haq-0.0...
  Preprocessing executables for haq-0.0...
  Warning: Cannot read
  C:/usr/ghc-6.8.2/doc/libraries/base\base.haddock:
 Magic number mismatch: couldn't load interface file:
  C:/usr/ghc-6.8.2/doc/li
   braries/base\\base.haddock
  Skipping this interface.
  Warning: main:Main: could not find link destinations for:
  GHC.IOBase.IO
  haddock: internal Haddock or GHC error:
  c:/builds/haddock-2/install\haddock-2.0.
   0.0/html/haddock.css: openFile: does not exist (No such file or
 directory)
 
  Any ideas how to solve this?
  Thanks!
 
  ___
   Haskell-Cafe mailing list
   Haskell-Cafe@haskell.org
   http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 




-- 
Dmitri O. Kondratiev
[EMAIL PROTECTED]
http://www.geocities.com/dkondr
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Strange space leak

2008-07-16 Thread Jacques Carette

apfelmus wrote:

Grzegorz Chrupala wrote:


   split DOC . words . map toLower = (:[]) . words . map toLower

Since you converted everything to lowercase, the string DOC will 
never appear in the text, resulting in a single huge document.


Oops, that should have been obvious, sorry for the dumb question.
Thanks,


No problem, it was not obvious to me and I had fun trying to figure it 
out :)


Speaking of not obvious: Haskell's type system catches a lot of bugs -- 
but still gives no help with this particular 'problem'.  But one can 
easily imagine an extension to a type system which could have detected 
that DOC can never occur in the result of words . map toLower, and 
then with a bit more work [type-level Nat], the type of the full 
expression could have encoded that the result is always going to be of 
length 1.  That would surely have been a good hint that something 
non-trivial was going on.


Whether a Haskell-friendly type system extension could be 
created/implemented which would cover this example, I don't know.  
However, I have had a lot of fun with the underlying idea: anytime 
someone encounters a bug in their code (and relates the debugging story 
on haskell-cafe), try to imagine how the type system could be extended 
to automate that.  In most cases, I don't mean to have the type system 
reject the code, but rather to have an inferred type that would make it 
obvious that the code did not behave as expected.


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


[Haskell-cafe] Re: Euler 201 performance mystery

2008-07-16 Thread apfelmus

apfelmus wrote:

In other words, we have now calculated the more efficient program

  euler201 = map snd . filter ((==50) . fst) . subsums $ squares
 where
 subsums [] = singleton (0,0)
 subsums (x:xs) = map (\(n,s) - (n+1,s+x)) (subsums xs) `union` subsums xs


I forgot something very important, namely that the common subexpression 
subsums xs  has to be shared


  euler201 = map snd . filter ((==50) . fst) . subsums $ squares
 where
 subsums [] = singleton (0,0)
 subsums (x:xs) = let s = subsums xs in map (\(n,s) - (n+1,s+x)) s `union`s

Otherwise, this exercise would be pointless and the runtime exponential ... :O


Regards,
apfelmus

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


Re: [Haskell-cafe] uvector and the stream interface

2008-07-16 Thread stefan kersten

On 14.07.2008, at 20:48, Don Stewart wrote:

Yes, we have long been discussing a generic Stream library to which
the various sequence structures can be translated to and from. Already
it is useful to say, stream bytestrings into uvectors and out to  
lists.


could the Stream interface be made public in uvector for writing  
custom adapters?



If people are using uvector or stream-fusion (the list version) and
are interested in interop please let Roman, Duncan and I know, so we
can think more about how best to make it all play together.


i'd be interested, just have to gather a little more infrastructure  
before i start working on real algorithms.


sk

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


Re: [Haskell-cafe] Linker problems linking FFI import call in Windows

2008-07-16 Thread PJ Durai
On 7/16/08, Olivier Boudry [EMAIL PROTECTED] wrote:
 On Tue, Jul 15, 2008 at 11:51 PM, PJ Durai [EMAIL PROTECTED] wrote:
  I am trying to import some functions from a windows DLL. I am getting
  strange errors. (This used to work with previous versions of GHC.  6.6
  I think.).

 You may have to create an import library for the DLL. I had a similar
 problem and solved it that way.

 Look at http://www.emmestech.com/moron_guides/moron1.html for advices
 on how to create such a library.

 My problem was that the exports in the dll were prefixed with an
 underscore. I had to remove them from the .def file before creating
 the import library.

I do have the import library. It came with the DLL. It links properly
when I use CCALL on the haskell import statements. Doesnt link when I
use STDCALL. It looks for  function name with something like '@4 or
@8' tacked on at the end. Not sure what that is all about.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Linker problems linking FFI import call in Windo ws

2008-07-16 Thread Steve Schafer
On Wed, 16 Jul 2008 10:22:46 -0600, you wrote:

I do have the import library. It came with the DLL. It links properly
when I use CCALL on the haskell import statements. Doesnt link when I
use STDCALL. It looks for  function name with something like '@4 or
@8' tacked on at the end. Not sure what that is all about.

This is known as name mangling. See the Wikipedia article for more info:

http://en.wikipedia.org/wiki/Name_mangling

Steve Schafer
Fenestra Technologies Corp.
http://www.fenestra.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Fixed-Point Combinators

2008-07-16 Thread Adrian Neumann

Hello,

while studying for a exam I came across this little pearl:

Y = (L L L L L L L L L L L L L L L L L L L L L L L L L L L L)
where
L = λabcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e d p o i n  
t c o m b i n a t o r))


posted by Cale Gibbard to this list. Now I'm wondering how exactly  
does one finde such awesome λ expressions? Is there some mathemagical  
background that lets one conjure such beasts?


Adrian

PGP.sig
Description: Signierter Teil der Nachricht
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Fixed-Point Combinators

2008-07-16 Thread Bulat Ziganshin
Hello Adrian,

Wednesday, July 16, 2008, 11:17:05 PM, you wrote:

 L = ?abcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e d p o i n
 t c o m b i n a t o r))
 does one finde such awesome ? expressions? Is there some mathemagical
 background that lets one conjure such beasts?

full search? :)

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


RE: [Haskell-cafe] A type signature inferred by GHCi that is rejected when written explicitly

2008-07-16 Thread Simon Peyton-Jones
|  I myselft  don't understand why GHCi doesn't accept the type it
|   infered as an explicit signature ...

I've known about this confusing behavior for some time, and the design goal 
that the compiler should not infer a type that it can't check seems Clearly 
Right.  Stupidly, though, I had not previously realized that it's all a 
consequence of GHC's rather relaxed approach to ambiguity.  Here's a little 
section from a some notes I'm working on that may clarify.  Bottom line: I 
intend to change GHC (I hope for 6.10) so that if a definition gets an inferred 
type that could not appear as a type signature, the definition will be rejected 
as ambiguous.

Comments welcome.  (Do cc me since I no longer guarantee to read all of the 
wisdom of Haskell Café.)

Simon

Consider this
\begin{code}
  class C a b where
op :: b - a - a

  instance C [a] b
op _ x = x

  instance Ord b = C (Maybe a) b
op _ x = x

  f x = op undefined x
\end{code}
GHC currently infers the type
\begin{code}
  f :: C a b = a - a
\end{code}
Despite the fact that @b@ is not mentioned after the @=@, nor is
there a functional dependency, @f@ can be called unambiguously, thus
\begin{code}
  f [True]
\end{code}
This call gives rise to the constraint @(C [Bool] b)@, for some undetermined
type @b@, and the instance declaration fires happily.  However, the call
@(f Nothing)@ will give the constraint @(Ord b)@, which cannot be discharged
without knowing @[EMAIL PROTECTED]  Some calls are ambiguous and some are not.  
GHC
defers this choice to the caller, unless it can readily see that every
call will be ambiguous.

However, this relaxed approach has a big disadvantage: \emph{you cannot
write a type signature for @[EMAIL PROTECTED]:
\begin{code}
  f :: C a c = a - a
  f x = op undefined x
\end{code}
Now GHC has no way to prove that the given constraint @(C a c)@
proves the wanted constraint @(C a b)@, using plain syntactic matching.

So we propose the following:
\begin{itemize}
\item Every inferred type (and every type written by the programmer)
must be unambiguous.
\item A type $\forall \overline{a}.C \Rightarrow \rho$ is unambiguous iff
from $C$ we can deduce $C[\overline{b'/b}]$ where $\overline{b} = \overline{a} 
\setminus fv(\rho)$,
and $\overline{b'}$ are fresh.  That is, freshen the variables in $C$ that
are not mentioned in the type $\rho$, and check that you can can deduce
the freshened $C'$ from $C$.
\end{itemize}
This would reject the definition @f@, either with or without a type
signature.

| -Original Message-
| From: [EMAIL PROTECTED] [mailto:haskell-cafe-
| [EMAIL PROTECTED] On Behalf Of Pablo Nogueira
| Sent: 08 July 2008 09:03
| To: Alfonso Acosta
| Cc: Haskell-Cafe
| Subject: Re: [Haskell-cafe] A type signature inferred by GHCi that is
| rejected when written explicitly
|
|  I myselft  don't understand why GHCi doesn't accept the type it
|   infered as an explicit signature ...
|
| I think it has to do with the following:
|
| Looking at the type errors, they seem to indicate that the type
| checker is being general and does not assume the |From| and |To|
| relations are between
| a type |t| and (s (t x) x)| but, in general, between |t| and |s (t' x) x|.
|
| Given that
|
| from   :: (From a1 c1 x) = a1 x - c1 x
|  to :: (To   a2 c2 y) = c2 y - a2 y
| bimap  :: Bifunctor s = (t1 - t3) - (t2 - t4) - s t1 t2 - s t3 t4
|
| During type checking the following equations spring up:
|
| c2 y   = s t3 t4
| c1 x   =  s t1 t2
| t2   = x
| t4   = y
| t1   = a1 x
| t3   = a2 y
|
| That'd give the same type as that inferred, but somehow new variables
| |a11| and |a12| appear.
|
|   caused by a lack of functional dependencies.
|   class From a c x | a - c where
|  class To a c y | c - a where
|  ... hushes GHCi. The question now is, of course, if the new
|   dependencies are too restrictive for your problem.
|
| They are of little avail given the instances I define:
|
|  instance Bifunctor s = From (Fix s) (s (Fix s x)) x where
|  from = out
|
|  instance Bifunctor s = To (Fix s) (s (Fix s y)) y where
|  to   = In
| ___
| 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] Re: Haskell on ARM (was Re: ANN: Topkata)

2008-07-16 Thread Simon Peyton-Jones
| Linux Nokia-N810-42-19 2.6.21-omap1 #2 Fri Nov 16 16:24:58 EET 2007
| armv6l unknown
|
| I would love a working GHC implementation on it, if for nothing else
| than how awesome it would be. Whether that means using a C back-end or
| native compilation doesn't matter to me so much.
|
| I might be one to attempt this, as I know C and ARM-ish asm decently
| well and have a powerful desktop to compile on. I have no familiarity
| with GHC internals, though. Lastly, I won't have anything like the time
| to attempt this seriously until mid-September or so.

That's good.  John Dias is hard at work on GHC's back end, and we should be in 
reasonable shape by mid Sept.  Better still a month later...   Keep us posted 
with what you do.

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


[Haskell-cafe] curl installation

2008-07-16 Thread Thomas Fuhrmann
Hello,

I'm trying to install the curl package 1.3.2.1 for haskell, I'm using Ubuntu and
I've already installed curl-7.18.2. I can't get rid of the configuration error.
According to the log entry the curl.h doesn't exist.

Shell output:

runghc Setup.hs configure
Configuring curl-1.3.2.1...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
configure: error: curl libraries not found, so curl package cannot be built
See `config.log' for more details.

Part of Log entry:

configure:2439: gcc -E  conftest.c
conftest.c:9:23: error: curl/curl.h: No such file or directory
configure:2445: $? = 1
configure: failed program was:
| /* confdefs.h.  */
| 
| #define PACKAGE_NAME Haskell curl package
| #define PACKAGE_TARNAME curl
| #define PACKAGE_VERSION 1.1
| #define PACKAGE_STRING Haskell curl package 1.1
| #define PACKAGE_BUGREPORT [EMAIL PROTECTED]
| /* end confdefs.h.  */
| #include curl/curl.h
configure:2469: error: curl libraries not found, s
o curl package cannot be built
See `config.log' for more details.

Any ideas?


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


[Haskell-cafe] Haskell Weekly News: Issue 77 - July 16, 2008

2008-07-16 Thread Brent Yorgey
---
Haskell Weekly News
http://sequence.complete.org/hwn/20080716
Issue 77 - July 16, 2008
---

   Welcome to issue 77 of HWN, a newsletter covering developments in the
   [1]Haskell community.

Announcements

   Takusen 0.8.3. Alistair Bayley [2]announced the release of [3]Takusen
   0.8.3, with ODBC support, more Cabal improvements, bug fixes, and some
   basic result-set validation.

   Launching Haskell Group in Vancouver, Canada. Jon Strait [4]announced
   that a [5]Haskell Programmers Group has been created in Vancouver; the
   first meeting is scheduled for next Monday, July 21st. Feel free to
   join the Google Groups list to be notified of future events, or just
   show up to a meeting to bounce ideas and questions off of other Haskell
   programmers.

   Sphinx full-text searching client on Hackage. Chris Eidhof [6]announced
   work on a [7]client for the [8]sphinx full-text search engine. Help
   hacking on it, testing it or improving documentation is welcome.

   haskell-src-exts 0.3.5. Niklas Broberg [9]announced that the
   [10]haskell-src-exts package is now updated to understand the current
   version of Template Haskell syntax. Bug reports welcome.

   Prime time for Haskell. Janis Voigtlaender [11]announced that Haskell
   STM is featured in an [12]article in this month's Communications of the
   ACM.

   vector 0.1 (efficient arrays with lots of fusion). Roman Leshchinskiy
   [13]announced an initial release of the [14]vector library, which will
   eventually provide fast, Int-indexed arrays with a powerful fusion
   framework.

   Galois Tech Talks: Stream Fusion for Haskell Arrays. Don Stewart
   [15]announced that he was giving this week's Galois Tech Talk, on
   stream fusion for Haskell arrays. The talk was yesterday, July 15, but
   hopefully some sort of recording or slides will be made available.

   protocol-buffers. Chris Kuklewicz [16]announced a very early version of
   the [17]protocol-buffers package, a Haskell interface to Google's newly
   released [18]data interchange format.

   GHC IRC meeting. Simon Marlow [19]announced the (first weekly?) IRC
   meeting to discuss GHC, a scheduled time when the developers turn up on
   #ghc, discuss current topics around GHC, and users can chime in with
   questions, points for discussion, complaints and so on. The first
   meeting took place on July 16 at 1600 BST (UTC +1)/0800 PDT
   (UTC-7)/1100 EDT (UTC-4), in the #ghc channel on chat.freenode.net;
   hopefully this will become a weekly event.

Google Summer of Code

   Progress updates from participants in the 2008 [20]Google Summer of
   Code.

   GHC API. Thomas Schilling (nominolo) is working on [21]improvements to
   the GHC API. He recently [22]asked for comments on a proposed
   refactoring to the GHC API, creating a new Ghc monad to capture error
   handling and single-threaded use of Sessions.

   GHC plugins. Max Bolingbroke is working on dynamically loaded plugins
   for GHC. [23]This week, he wrote a ton of Haddock documentation for GHC
   internals. He also added the ability for compiler plugins to generate
   their own source annotations, to allow plugins to use intermediate
   results from previous plugins. He's currently working on an exciting,
   secret feature: tune in next week to find out what it is!

   Generic tries. Jamie Brandon is working on a library for efficient maps
   using generalized tries. Jamie is [24]currently working on, tweaking
   the [25]api, writing tests and writing reference implementations on
   sorted and unsorted association lists.

   Hoogle 4. Neil Mitchell (ndm) is working on [26]Hoogle 4. [27]This
   week, he worked on type search and database generation. Next week he
   plans to finish up type search and release and command-line version.

   Language.C. Benedikt Huber (visq) is [28]working on Language.C, a
   standalone parser/pretty printer library for C99.

   DPH physics engine. Roman Cheplyaka (Feuerbach) is working on a
   [29]physics engine using [30]Data Parallel Haskell.

   Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a
   [31]make-like dependency analysis framework for Cabal.

Libraries

   Proposals and extensions to the [32]standard libraries.

   adding split to Data.List. Gwern Branwen [33]proposed adding some
   split-like functions to Data.List. Will they actually get added this
   time? Will people be able to agree on one of the seventeen possible
   sets of semantics? Tune in next time...

Discussion

   GHC API: monad and error handling. Thomas Schilling [34]asked for
   comments on a proposed refactoring to the GHC API, creating a new Ghc
   monad to capture error handling and single-threaded use of Sessions.

Jobs

   Research positions on Modeling and Analyzing Software Adaptation,
   University of Koblenz. Ralf Lammel [35]announced two research

Re: [Haskell-cafe] curl installation

2008-07-16 Thread Don Stewart
noahaon:
 Hello,
 
 I'm trying to install the curl package 1.3.2.1 for haskell, I'm using Ubuntu 
 and
 I've already installed curl-7.18.2. I can't get rid of the configuration 
 error.
 According to the log entry the curl.h doesn't exist.
 
 Shell output:
 
 runghc Setup.hs configure
 Configuring curl-1.3.2.1...
 checking for gcc... gcc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables... 
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ANSI C... none needed
 checking how to run the C preprocessor... gcc -E
 configure: error: curl libraries not found, so curl package cannot be built
 See `config.log' for more details.
 
 Part of Log entry:
 
 configure:2439: gcc -E  conftest.c
 conftest.c:9:23: error: curl/curl.h: No such file or directory
 configure:2445: $? = 1
 configure: failed program was:
 | /* confdefs.h.  */
 | 
 | #define PACKAGE_NAME Haskell curl package
 | #define PACKAGE_TARNAME curl
 | #define PACKAGE_VERSION 1.1
 | #define PACKAGE_STRING Haskell curl package 1.1
 | #define PACKAGE_BUGREPORT [EMAIL PROTECTED]
 | /* end confdefs.h.  */
 | #include curl/curl.h
 configure:2469: error: curl libraries not found, s
 o curl package cannot be built
 See `config.log' for more details.

Check where curl/curl.h is on your system. It is possible the
development headers are missing?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: curl installation

2008-07-16 Thread Thomas Fuhrmann
Marco Túlio Gontijo e Silva marcot at riseup.net writes:

 
 Em Qua, 2008-07-16 às 19:50 +, Thomas Fuhrmann escreveu:
  Hello,
 
 Hello.
 
  conftest.c:9:23: error: curl/curl.h: No such file or directory
 

http://packages.ubuntu.com/search?searchon=contentskeywords=curl.hmode=exactfilenamesuite=hardyarch=any
 
 Hope it helps.
 

Thanks a lot, the GnuTLS package wasn't yet installed.

Bye







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


AW: [Haskell-cafe] Fixed-Point Combinators

2008-07-16 Thread Holger Siegel
--- Adrian Neumann [EMAIL PROTECTED] schrieb am Mi, 16.7.2008:

 Von: Adrian Neumann [EMAIL PROTECTED]
 Betreff: [Haskell-cafe] Fixed-Point Combinators
 An: Haskell Cafe mailing list haskell-cafe@haskell.org
 Datum: Mittwoch, 16. Juli 2008, 21:17
 Hello,
 
 while studying for a exam I came across this little pearl:
 
 Y = (L L L L L L L L L L L L L L L L L L L L L L L L L L L
 L)
 where
 L = λabcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e
 d p o i n  
 t c o m b i n a t o r))
 
 posted by Cale Gibbard to this list. Now I'm wondering
 how exactly  
 does one finde such awesome λ expressions? Is there some
 mathemagical  
 background that lets one conjure such beasts?

Have a look at http://citeseer.ist.psu.edu/251224.html

In this paper Jeroen Fokker describes how to derive a one-combinator basis from 
the SKI combinators in a systematic way. Maybe it can give you some hints how 
to treat this kind of problem.




  __
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata)

2008-07-16 Thread Braden Shepherdson

Simon Peyton-Jones wrote:

| Linux Nokia-N810-42-19 2.6.21-omap1 #2 Fri Nov 16 16:24:58 EET 2007
| armv6l unknown
|
| I would love a working GHC implementation on it, if for nothing else
| than how awesome it would be. Whether that means using a C back-end or
| native compilation doesn't matter to me so much.
|
| I might be one to attempt this, as I know C and ARM-ish asm decently
| well and have a powerful desktop to compile on. I have no familiarity
| with GHC internals, though. Lastly, I won't have anything like the time
| to attempt this seriously until mid-September or so.

That's good.  John Dias is hard at work on GHC's back end, and we should be in 
reasonable shape by mid Sept.  Better still a month later...   Keep us posted 
with what you do.

Simon


Well, I've documented three attempts in detail on the ArmLinuxGhc Trac 
page[1]. In short, it doesn't work.


6.8 and 6.9 fail, expectedly, since bootstrapping is known to be 
broken[2]. 6.6 might be made to work, but it didn't work with moderate 
effort and so it seems foolish to invest that sort of energy into an old 
version when the back end is being overhauled.


As it appears that the task will be much easier after the back end 
changes, this project is effectively on hold until the 6.10 release. In 
particular, bootstrapping needs to work. There is a bug[2] about this 
with milestone set to 6.10.1. Hopefully a quick-and-dirty unregisterised 
 port will be easy after that, with registerised and possibly even 
native code-gen on the horizon.


One question that has come up is, what external tools does GHC need to 
build binaries on a given platform? When going via-c, is a complete C 
toolchain necessary? When doing native code-gen, are ld or ar required, 
or other binutils? If we magically had a 6.9 that would generate ARM 
binaries, what would it take to run binaries built in the dev 
environment on the device? Would it take more to run GHC itself on the 
device?




Braden Shepherdson
shepheb


[1] http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc
[2] http://hackage.haskell.org/trac/ghc/ticket/1346

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


[Haskell-cafe] FFI and struct arguments

2008-07-16 Thread Felipe Lessa
Hi,

I tried googling and searching the haskellwiki about this but wasn't
lucky enough. My question is: is there a way to send struct arguments
to C functions via the FFI or do I need to create a C wrapper? I guess
there isn't, and while I can live without it, I'd like to leave no
doubt.


Details:

I have something like


typedef struct vect {
float x,y;
} vect;

void func(vect v);
=

on the C side and


-- Please disregard float /= Float, just an example :)
data Vector = Vector Float Float

instance Storable Vector where
...


on the Haskell side, and I want to call func with Vector as argument.
Now, Vector isn't a basic FFI type, although it implements Storable.
So does that mean that I need to create something like


void funcWrapper(vect *v) {
func(*v);
}


and then allocate some temporary memory on the Haskell side to use func?

Cheers!

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