Re: [Haskell-cafe] The case of the missing module

2006-04-16 Thread Neil Mitchell
Hi,

 import Paths_haddock( getDataDir )

Haddock requires to be built with Cabal (which generates this module),
and as far as I can remember, its a Cabal that isn't released
anywhere. When I did some work on haddock I commented this out, and
made getDataDir return an empty list and then made sure to set the -l
flag (I think) and was able to work around this.

Of course, the solution is to get Cabal working. I broke Cabal long
ago, but you might have more luck.

Thanks

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


[Haskell-cafe] Re: [Haskell] ANNOUNCE: An index-aware linear algebra library in Haskell

2006-04-16 Thread Alberto Ruiz
It is really counterintuitive! I will study carefully your library and the 
Implicit Configurations paper. Using static dimension checking we can write 
very solid code for matrix computations...

However, I don't know how to write some definitions. For instance, this is ok:

m = $(dAM [[1,2,3]])

but with:

x = [[1,2,3]] :: [[Double]]
m1 = $(dAM x)
m2 = listMat x

main = do
print m1
print m2

I get:

Vector/examples.hs:35:11:
GHC stage restriction: `x'
  is used in a top-level splice, and must be imported, not defined locally
In the first argument of `dAM', namely `x'
In the definition of `m1': m1 = $[splice](dAM x)

Vector/examples.hs:40:10:
Inferred type is less polymorphic than expected
  Quantified type variable `m' escapes
  Quantified type variable `n' escapes
  Expected type: (v (L m, L n) - w) - t
  Inferred type: (forall n1 m1.
  (ReflectNum n1, ReflectNum m1) =
  v (L m1, L n1) - w)
 - w
In the first argument of `print', namely `m2'
In the result of a 'do' expression: print m2


I would also like to create a matrix from a data file:

main = do
let m1 = $(dAM [[1,2],[3,4::Double]])
s - readFile data.txt
let list = read s :: [[Double]]
--let m2 = $(dAM list)
let m2 = listMat list
print $ m2 * trans m1

But I get a similar error. Perhaps I must provide information about the 
expected dimensions, but I don't know how to do it.

--
Alberto

On Saturday 15 April 2006 22:09, Frederik Eaton wrote:
 Yes, certainly... Otherwise the library would not be much use! If it
 seems counterintuitive, as it did to me at first, you should check out
 the Implicit Configurations paper, which uses modular arithmetic as
 an example. My version of their code is in

 http://ofb.net/~frederik/futility/src/Prepose.hs

 The function I mainly use is:

 reifyIntegral :: Integral a = a - (forall s. ReflectNum s = s - w) - w

 which turns an integral value into a type of the ReflectNum class
 which represents that value, and calls the provided polymorphic
 function with a dummy value (actually 'undefined') of that type; then
 returning the function's result.

 Frederik

 On Sat, Apr 15, 2006 at 06:14:44PM +0200, Alberto Ruiz wrote:
  On Friday 14 April 2006 17:02, Frederik Eaton wrote:
   An index-aware linear algebra library in Haskell
 
  Excellent work!
 
  Is it possible to create a vector or matrix whose size is not known at
  compile time?
 

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


Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-16 Thread Daniel Fischer
I have added 'solve method F', aka X-wing, swordfish... 
(www.sudokusolver.co.uk) to my solver, that reduced the number of puzzles 
needing guesses to 5306, so I suppose that's it.
 I haven't yet implemented it efficiently, so it was devastating for 
performance - and solving thirteen puzzles more by pure logic (or should we 
rather say without using any assumptions except that the puzzle is solvable, 
uniquely or not?) isn't such a big step, I had hoped for more.

Cheers, 
Daniel

Am Freitag, 14. April 2006 21:40 schrieb Chris Kuklewicz:
  I believe if you change the representation of puzzles from [(pos,range)]
  to an Array, you'll get a significant speedup
 
  yet because I only recently removed a logic bug that slowed down the
  search instead of speading it up; ..). so the more interesting bit is
  that our solvers disagree on which are the most difficult puzzles
  (requiring the largest number of guesses):
 
  df
  puzzles involving guesses: 5319
 
  If that's not a typo, I'm baffled. My original needed to guess in 5309
 
  Rot! Typo in _my_ previous message, 5319 is correct.

 After posting my cleaned up dancing links solver, I went back to my logical
 solver.  I sent the 36628 line sudoku17 puzzle through it and it could
 solve 31322 of the puzzles, leaving 5306 resistant.  I haven't check my
 algorithms against your code, but it does not seem like I do any
 spectacularly more clever.

 I don't have any time to clean up my code, but I may try turning off some
 steps to see if one of them gives my the same 5319 number you are seeing.

-- 

In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt.
-- Blair P. Houghton

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


[Haskell-cafe] Re: [Haskell] ANNOUNCE: An index-aware linear algebra library in Haskell

2006-04-16 Thread Frederik Eaton
Hi Alberto,

Those are good questions, I've added some examples which hopefully
clarify the situation. Input and output of vectors is not a strong
point of the library, but I don't think there is a good alternative to
the way I do it.

  http://ofb.net/~frederik/futility/src/Vector/read-example.hs

(also, your example exposed some missing functionality. I've added
three new functions; in addition to listMat, now there are listMatCol,
listMatRow, and listMatSquare. Hopefully these should cover almost all
use cases.

  http://ofb.net/~frederik/futility/src/Vector/Base.hs
)

By the way, here is how I would download and run the thing, although
you seem to have figured it out:

$ wget http://ofb.net/~frederik/futility/futility-devel.tar.gz
$ tar -xvzf futility-devel.tar.gz
$ cd futility-devel/
$ ghc -fth --make Vector/read-example.hs -o read-example
$ ./read-example
# 11.0, 23.0; 14.0, 30.0; 15.0, 33.0; 18.0, 40.0 #
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0
# 1.0, 5.0; 2.0, 6.0; 3.0, 6.0; 4.0, 7.0 #
# 11.0, 23.0; 14.0, 30.0; 15.0, 33.0; 18.0, 40.0 #
# -3.0, -5.0; -5.0, -7.0 #
# 7.0, 10.0; 15.0, 22.0 #

As for your questions:

 Vector/examples.hs:35:11:
 GHC stage restriction: `x'
   is used in a top-level splice, and must be imported, not defined locally
 In the first argument of `dAM', namely `x'
 In the definition of `m1': m1 = $[splice](dAM x)

This is a shortcoming of Template Haskell - it will not let you call a
function from a splice if that function is defined in the same file as
the splice. It should be possible to remove this shortcoming, but I
don't know what is planned.

 m2 = listMat x

This is not how listMat is used, see the example file above.

listMat takes a list of lists and a function, and passes the matrix
version of the list of lists to the function.

 I would also like to create a matrix from a data file:

See 'v3' in the example.

Cheers,

Frederik

On Sun, Apr 16, 2006 at 05:06:55PM +0200, Alberto Ruiz wrote:
 It is really counterintuitive! I will study carefully your library and the 
 Implicit Configurations paper. Using static dimension checking we can write 
 very solid code for matrix computations...
 
 However, I don't know how to write some definitions. For instance, this is ok:
 
 m = $(dAM [[1,2,3]])
 
 but with:
 
 x = [[1,2,3]] :: [[Double]]
 m1 = $(dAM x)
 m2 = listMat x
 
 main = do
 print m1
 print m2
 
 I get:
 
 Vector/examples.hs:35:11:
 GHC stage restriction: `x'
   is used in a top-level splice, and must be imported, not defined locally
 In the first argument of `dAM', namely `x'
 In the definition of `m1': m1 = $[splice](dAM x)
 
 Vector/examples.hs:40:10:
 Inferred type is less polymorphic than expected
   Quantified type variable `m' escapes
   Quantified type variable `n' escapes
   Expected type: (v (L m, L n) - w) - t
   Inferred type: (forall n1 m1.
   (ReflectNum n1, ReflectNum m1) =
   v (L m1, L n1) - w)
  - w
 In the first argument of `print', namely `m2'
 In the result of a 'do' expression: print m2
 
 
 I would also like to create a matrix from a data file:
 
 main = do
 let m1 = $(dAM [[1,2],[3,4::Double]])
 s - readFile data.txt
 let list = read s :: [[Double]]
 --let m2 = $(dAM list)
 let m2 = listMat list
 print $ m2 * trans m1
 
 But I get a similar error. Perhaps I must provide information about the 
 expected dimensions, but I don't know how to do it.
 
 --
 Alberto
 
 On Saturday 15 April 2006 22:09, Frederik Eaton wrote:
  Yes, certainly... Otherwise the library would not be much use! If it
  seems counterintuitive, as it did to me at first, you should check out
  the Implicit Configurations paper, which uses modular arithmetic as
  an example. My version of their code is in
 
  http://ofb.net/~frederik/futility/src/Prepose.hs
 
  The function I mainly use is:
 
  reifyIntegral :: Integral a = a - (forall s. ReflectNum s = s - w) - w
 
  which turns an integral value into a type of the ReflectNum class
  which represents that value, and calls the provided polymorphic
  function with a dummy value (actually 'undefined') of that type; then
  returning the function's result.
 
  Frederik
 
  On Sat, Apr 15, 2006 at 06:14:44PM +0200, Alberto Ruiz wrote:
   On Friday 14 April 2006 17:02, Frederik Eaton wrote:
An index-aware linear algebra library in Haskell
  
   Excellent work!
  
   Is it possible to create a vector or matrix whose size is not known at
   compile time?
  
 

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


RE: [Haskell-cafe] Re: coherence when overlapping?

2006-04-16 Thread Martin Sulzmann

Coherence may also arise because of an ambiguous type.
Here's the classic example.

   class Read a where read :: String - a
   class Show a where show :: a - String

   f s = show (read s)

f has type String-String, therefore we can pick
some arbitrary Read/Show classes.

If you want to know more about coherence/ambiguity in the Haskell context.
Check out

@TechReport{jones:coherence,
  author =   M. P. Jones,
  title =Coherence for qualified types,
  institution =  Yale University, Department of Computer Science,
  year = 1993,
  month  =   September,
  type = Research Report,
  number =   YALEU/DCS/RR-989
}

and

@Article{overloading-journal,
  author =   {P.~J.~Stuckey and M.~Sulzmann },
  title ={A Theory of Overloading},
  journal =  {ACM Transactions on Programming Languages and Systems 
(TOPLAS)},
  publisher = ACM Press,
  year = 2005,
  pages = 1-54,
  volume = 27,
  number = 6,
  preprint =
{http://www.comp.nus.edu.sg/~sulzmann/chr/download/theory-journal.ps.gz}}


As far as I know, the term coherence was coined by

@article{breazu-tannen-etal:inhertiance-coercion,
author =  V. Breazu{-}Tannen and T. Coquand and C. Gunter
   and A. Scedrov,
title =   Inheritance as Implicit Coercion,
journal = Information and Computation,
volume =  93,
number =  1,
month =   jul,
year =1991,
pages =   172--221
}

Martin


william kim writes:
  Thank you Martin.
  
  Coherence (roughly) means that the program's semantics is independent
  of the program's typing.
  
  In case of your example below, I could type the program
  either use the first or the second instance (assuming
  g has type Int-Int). That's clearly bound.
  
  If g has type Int-Int, it is not hard to say the first instance should 
  apply.
  But how about g having a polymorphic type? In this case it seems to me 
  choosing the second instance is an acceptable choice as that is the only 
  applicable one at the moment. What is the definition of a coherent 
  behaviour here? Or is there one?
  
  
  Non-overlapping instances are necessary but not sufficient to
  obtain coherence. We also need that types/programs are unambiguous.
  
  Do you therefore imply that coherence is not defined without the 
  non-overlapping assumption?
  
  --william
  
  _
  Get MSN Hotmail alerts on your mobile. 
  http://mobile.msn.com/ac.aspx?cid=uuhp_hotmail
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe