Re: [Haskell-cafe] Adding gcc type options with cabal (e.g. -mno-cygwin)

2008-02-04 Thread bbrown
On Mon, 4 Feb 2008 14:24:12 -0800, Don Stewart wrote
 bbrown:
  Is there a way to pass misc options to the cabal, ghc process.
  
  I tried the following:
  
  extra-libraries: sqlite3
  extra-lib-dirs:  C:\cygwin\lib
  include-dirs:C:\cygwin\usr\include
  ghc-options: -mno-cygwin
  
  runhaskell Setup.lhs build --ghc-options=-mno-cygwin -v
 
 ghc-options: -optc-mno-cygwin
 cc-options:  -mno-cygwin
 
 or 
 ghc-options: -O2 -Wall
 cc-options:  -Wall
 
 or via the foo.buildinfo file.
 
 Ghc-options: [EMAIL PROTECTED]@
 Cc-options:  @CPPFLAGS@
 
 Writing a binding to sqlite3?
 
 -- Don

 Writing a binding to sqlite3?

No, one already exists.  Trying to compile that one.  My googling powers are
crippled with haskell.  I couldn't find how to add those options.

Thanks for the quick response.

--
Berlin Brown
email: berlin-dot-brown-AT-gmail-dot-com
http://botspiritcompany.com/botlist/

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


[Haskell-cafe] Adding gcc type options with cabal (e.g. -mno-cygwin)

2008-02-04 Thread bbrown
Is there a way to pass misc options to the cabal, ghc process.

I tried the following:

extra-libraries: sqlite3
extra-lib-dirs:  C:\cygwin\lib
include-dirs:C:\cygwin\usr\include
ghc-options: -mno-cygwin

runhaskell Setup.lhs build --ghc-options=-mno-cygwin -v

No dice, doesn't show up.

--
Berlin Brown
email: berlin-dot-brown-AT-gmail-dot-com
http://botspiritcompany.com/botlist/

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


Re: [Haskell-cafe] Adding gcc type options with cabal (e.g. -mno-cygwin)

2008-02-04 Thread bbrown
On Mon, 4 Feb 2008 17:27:30 -0500, bbrown wrote
 On Mon, 4 Feb 2008 14:24:12 -0800, Don Stewart wrote
  bbrown:
   Is there a way to pass misc options to the cabal, ghc process.
   
   I tried the following:
   
   extra-libraries: sqlite3
   extra-lib-dirs:  C:\cygwin\lib
   include-dirs:C:\cygwin\usr\include
   ghc-options: -mno-cygwin
   
   runhaskell Setup.lhs build --ghc-options=-mno-cygwin -v
  
  ghc-options: -optc-mno-cygwin
  cc-options:  -mno-cygwin
  
  or 
  ghc-options: -O2 -Wall
  cc-options:  -Wall
  
  or via the foo.buildinfo file.
  
  Ghc-options: [EMAIL PROTECTED]@
  Cc-options:  @CPPFLAGS@
  
  Writing a binding to sqlite3?
  
  -- Don
 
  Writing a binding to sqlite3?
 
 No, one already exists.  Trying to compile that one.  My googling 
 powers are crippled with haskell.  I couldn't find how to add those options.
 
 Thanks for the quick response.
 
 --
 Berlin Brown
 email: berlin-dot-brown-AT-gmail-dot-com
 http://botspiritcompany.com/botlist/

I couldn't get hsql-sqlite (other unix libraries?) to compile on cygwin.  I
tried though.

It looks like it is passing the option.  The sqlite3 library is installed and
setup.  From googling, it looks there is an issue with compatibility between
cygwin/ and whatever ghc was compiled with.

But then again, I guess I could not try using cygwin?  I built the library
(sqlite3 under cygwin). Download ghc6.8.2 straight from the haskell.org.

Creating dist\build (and its parents)
Creating dist\build\autogen (and its parents)
Preprocessing library hsql-sqlite3-1.7...
Creating dist\build\Database\HSQL (and its parents)
c:\projects\tools\home\projects\tmp3\ghc-6.8.2\bin\hsc2hs.exe --cc=c:\projects\t
ools\home\projects\tmp3\ghc-6.8.2\bin\ghc.exe --ld=c:\projects\tools\home\projec
ts\tmp3\ghc-6.8.2\bin\ghc.exe --cflag=-optc-mno-cygwin --cflag=-package --cflag=
base-3.0.1.0 --cflag=-package --cflag=hsql-1.7 --cflag=-IC:\cygwin\usr\include -
-lflag=-optl-LC:\cygwin\lib --lflag=-optl-lsqlite3 -o dist\build\Database\HSQL\S
QLite3.hs Database\HSQL\SQLite3.hsc
dist/build/Database/HSQL/SQLite3_hsc_make.o(.text+0x5d):SQLite3_hsc_make.c: unde
fined reference to `_impure_ptr'
dist/build/Database/HSQL/SQLite3_hsc_make.o(.text+0xa1):SQLite3_hsc_make.c: unde
fined reference to `_impure_ptr'
dist/build/Database/HSQL/SQLite3_hsc_make.o(.text+0xc9):SQLite3_hsc_make.c: unde
fined reference to `_impure_ptr'
dist/build/Database/HSQL/SQLite3_hsc_make.o(.text+0xfd):SQLite3_hsc_make.c: unde
fined reference to `_impure_ptr'
dist/build/Database/HSQL/SQLite3_hsc_make.o(.text+0x131):SQLite3_hsc_make.c: und
efined reference to `_impure_ptr'
dist/build/Database/HSQL/SQLite3_hsc_make.o(.text+0x16d):SQLite3_hsc_make.c: mor
e undefined references to `_impure_ptr' follow
collect2: ld returned 1 exit status
linking dist\build\Database\HSQL\SQLite3_hsc_make.o failed
command was: c:\projects\tools\home\projects\tmp3\ghc-6.8.2\bin\ghc.exe -optl-LC
:\cygwin\lib -optl-lsqlite3 dist\build\Database\HSQL\SQLite3_hsc_make.o -o dist\
build\Database\HSQL\SQLite3_hsc_make.exe


--
Berlin Brown
email: berlin-dot-brown-AT-gmail-dot-com
http://botspiritcompany.com/botlist/

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


[Haskell-cafe] Issues with hsql-sqllite build; errors from the hackage download

2008-02-01 Thread bbrown
There seems to be an issue with the hsql-sqlite3.  Anyone have a fix.  Should
I use what is from darcs?

Index of /packages/archive/hsql-sqlite3/1.7/logs/failure

The Glorious Glasgow Haskell Compilation System, version 6.8.1

$ runhaskell Setup.lhs configure

Setup.lhs:7:33:
Module
`Distribution.Simple.Utils'
does not export
`rawSystemVerbose'

--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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


[Haskell-cafe] Instance classes and error (also, related to Data.Binary.GET)

2008-01-03 Thread bbrown
I am using the Data.Binary module and having some issues reading big endian
files (actually, just reading the file).  I can read the header but not the
rest of the data which contains a set of row information.  Also, go ahead and
make fun my style of coding.

Anyway, This is the my code and the error at the bottom.


The issue stems from here, it says I didn't define an instance, but I did:

instance Binary URLSet where
put _ = do BinaryPut.putWord8 0
get = do
  remainingByteData - BinaryGet.getRemainingLazyByteString
  i :: URLInfo - decode remainingByteData
  j :: TitleInfo - decode remainingByteData
  k :: DescrInfo - decode remainingByteData
  x :: KeywordsInfo - decode remainingByteData
  return (URLSet {urlinfo=i, titleinfo=j, 
  descrinfo=k, keywordsinfo=x})

-

module Main where

import Data.Word
import Data.Binary
import qualified Data.ByteString.Lazy.Char8 as BSLC8
import Data.ByteString.Lazy (ByteString)
import Data.Binary.Get as BinaryGet
import Data.Binary.Put as BinaryPut
import IO
import Text.Printf
import System.Environment
import Control.Monad (replicateM, liftM)

{- *
 Define the Database Data Types
 SpiderDatabase represents a singleton wrapper for an
 entire database.
   * -}
data SpiderDatabase =  SpiderDatabase { 
  magicNumberA :: Word16,
  magicNumberB :: Word16,
  majorVers :: Word16,
  minorVers :: Word16,
  headerTag :: Word16,
  poolLen :: Word16,
  spiderpool :: [URLSet]
}
data URLSet = URLSet {
  urlinfo :: URLInfo,
  titleinfo :: TitleInfo,
  descrinfo :: DescrInfo,
  keywordsinfo :: KeywordsInfo
}
data URLInfo = URLInfo {
  tag :: Word8,
  urlid :: Word16,
  urllen :: Word16,
  url :: ByteString
}
data TitleInfo = TitleInfo {
  titletag :: Word8,  
  titlelen :: Word16,
  title :: ByteString
}
data DescrInfo = DescrInfo {
  descrtag :: Word8,  
  descrlen :: Word16,
  descr :: ByteString
}
data KeywordsInfo = KeywordsInfo {
  keywordstag :: Word8,  
  keywordslen :: Word16,
  keywords :: ByteString
}
{- *
 Class instances
   * -}
instance Show SpiderDatabase where
show db = let magicb = (magicNumberB db)
  header = (headerTag db)
  poolct = (poolLen db)
  in Database Content\n ++
 (((printf Magic: %X %X\n) (magicNumberA db)) (magicNumberB
db)) ++
 printf URL Pool Count: %d\n poolct ++
 End

instance Binary URLInfo where
put _ = do BinaryPut.putWord8 0
get = do
  urltag - getWord8
  idx - getWord16be
  len - getWord16be
  strdata - BinaryGet.getLazyByteString (fromIntegral len)
  return (URLInfo {tag=urltag, urlid=idx, 
   urllen=len, url=strdata})
instance Binary DescrInfo where
put _ = do BinaryPut.putWord8 0
get = do
  tag - getWord8
  len - getWord16be
  strdata - BinaryGet.getLazyByteString (fromIntegral len)
  return (DescrInfo {descrtag=tag,
 descrlen=len, 
 descr=strdata})
instance Binary TitleInfo where
put _ = do BinaryPut.putWord8 0
get = do
  tag - getWord8
  len - getWord16be
  strdata - BinaryGet.getLazyByteString (fromIntegral len)
  return (TitleInfo {titletag=tag,
 titlelen=len, 
 title=strdata})
instance Binary KeywordsInfo where
put _ = do BinaryPut.putWord8 0
get = do
  tag - getWord8
  len - getWord16be
  strdata - BinaryGet.getLazyByteString (fromIntegral len)
  return (KeywordsInfo {keywordstag=tag,
keywordslen=len, 
keywords=strdata})
instance Binary URLSet where
put _ = do BinaryPut.putWord8 0
get = do
  remainingByteData - BinaryGet.getRemainingLazyByteString
  i :: URLInfo - decode remainingByteData
  j :: TitleInfo - decode remainingByteData
  k :: DescrInfo - decode remainingByteData
  x :: KeywordsInfo - decode remainingByteData
  return (URLSet {urlinfo=i, titleinfo=j, 
  descrinfo=k, keywordsinfo=x})
  
instance Binary SpiderDatabase where
put _ = do BinaryPut.putWord8 0
get = do 
  magicnumbera - BinaryGet.getWord16be
  magicnumberb - BinaryGet.getWord16be
  major - BinaryGet.getWord16be
  minor - BinaryGet.getWord16be
  header - BinaryGet.getWord16be
  poolct - BinaryGet.getWord16be
  -- ***
  -- Get the remaining byte string data,
  -- So that we can use lazy bytestring to load to load the
  -- the data types.
  -- ***

[Haskell-cafe] Browser action and new http library

2007-11-26 Thread bbrown

I am trying to use the HTTP library 3001 for ghc 6.8 and cant figure out how
to use a proxy to do a GET request as I am behind a proxy server.  My thinking
is that I could use the setProxy method it looks like it returns a
BrowserAction?  What do I do with that.  Here is the current code (I havent
really used the setProxy yet).

--
-- HTTP LIBRARY version: HTTP-3001.0.2

import Data.Char (intToDigit)
import Network.HTTP
import Network.URI
import Network.Browser (defaultGETRequest)
import System.Environment (getArgs)
import System.Exit (exitFailure)
import System.IO (hPutStrLn, stderr)

main = 
do
args - getArgs
case args of 
[addr] - case parseURI addr of
   Nothing - err Could not parse URI
   Just uri - do
   cont - get uri
   putStr cont
_ - err Usage: lman url

err :: String - IO a
err msg = do 
  hPutStrLn stderr msg
  exitFailure

get :: URI - IO String
get uri =
do
eresp - simpleHTTP (defaultGETRequest uri)
resp - handleErr (err . show) eresp
case rspCode resp of
  (2,0,0) - return (rspBody resp)
  _ - err (httpError resp)
where
  showRspCode (a,b,c) = map intToDigit [a,b,c]
  httpError resp = showRspCode (rspCode resp) ++   ++ rspReason resp

--
-- Handle Connection Errors
handleErr :: Monad m = (ConnError - m a) - Either ConnError a - m a
handleErr h (Left e) = h e
handleErr _ (Right v) = return v

-- End of File


--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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


[Haskell-cafe] (general question) Approaches for storing large amount of simple data structures

2007-11-15 Thread bbrown
I have a project where I want to store a data structure on a file, binary or
ascii.  And I want to use haskell to read and write the file. I will have
about half a million records so it would be nice if the format was able to
load quickly.  I guess I could, but I kind of want to avoid using XML.

I have the following structure in pseudo code.

A URL - id
  - keywords associated with that URL
  - title associated with that URL
  - links contained in that URL. (0 ... N)

What is an approach for saving 500 thousand of those types of records and
where I can load the data into a haskell data type.

--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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


[Haskell-cafe] Back on opengl win32 again? no window

2007-10-22 Thread bbrown
Ok, sorry to bring this back up again.  I asked before and kind of went to a 
working linux system. 

My question;  On Win32, has anyone seen where you try to run the application 
but the window will not stay open.  There are no errors, the window with 3D 
objects will not stay open.  I was using a recent haskell 6.6.1 (ghc-6.6.1-
i386-windows.exe).

I asked before it seemed like the others suggested I use freeglut and use 
that.  But I dont really need freeglut extensions.  I am using basic opengl.  
I noticed that opengl is included in the ghc (mingw) I downloaded.  Also, the 
code compiles, just doesnt run.  The machine itself is a 3.2ghz, nvidia 
machine (win2k).  I know opengl code should work.

You can see the source here:
http://octanemech.googlecode.com/svn/trunk/octanemech/src/misc/camera/

I compiled with:
ghc --make MechCamera.hs -prof -auto-all -o $@

Basically the initialization aspect:

import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
import Data.IORef

mechLaunchGLWindow = do
  getArgsAndInitialize
  -- Initialize with the following settings
  -- Double buffer, RGBA color
  -- Alpha components supported, Depth buffer
  initialDisplayMode $= [ DoubleBuffered, RGBAMode, WithDepthBuffer, 
 WithAlphaComponent ]
  initialWindowSize $= Size mechScreenWidth mechScreenHeight
  createWindow mechWindowTitle
   
  mechInitGL
  let mainCamera = initCamera (1.4, 4.2, -4.5) (0,0,0) (0,0,0)
  mainMech = initMech (0, 0, 0) (0, 0, 0)
  mainCameraRef - newIORef(mainCamera)
  mainMechRef - newIORef(mainMech)

  -- Set the OpenGL callbacks
  displayCallback $= displayGameLoop mainCameraRef mainMechRef

  -- Set the keyboard callback for handling actions
  keyboardMouseCallback $= Just (mechKeyPressed mainCameraRef)

  idleCallback $= Just idle
  mainLoop


--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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


Re: [Haskell-cafe] Re: Data types, opengl display loop and readIORef/writeIORef

2007-10-08 Thread bbrown
On Mon, 08 Oct 2007 17:41:12 +0200, apfelmus wrote
 bbrown wrote:
  This is more an aesthetics question, I have a simple opengl application 
that 
  has a singleton like object I need to pass around to the display loop and 
  possibly to the keyboard action handler. (pseudo code)
  
  data SimpleMech = SimpleMech {
mechPos :: !MVector,
mechRot :: !MVector
  } deriving (Read)
  
  mainMech = initMech (0, 0, 0) (0, 0, 0)
  mainMechRef - newIORef(mainMech)
  
  displayCallback $= displayGameLoop mainMechRef
  
  
  rotateMech :: (Double, SimpleMech) - SimpleMech
  rotateMech (angle, mech) =
-- Calculate a new rotation
let (xrot,yrot,zrot) = (mechRot mech)
newyrot = newyrot + angle
 
 ^^^
 That should be
  newyrot = yrot + angle
 
in SimpleMech { mechRot = (xrot, newyrot, zrot),
mechPos = (mechPos mech) }
  
  
  displayGameLoop mechRef = do
  mech - get mechRef
  mechRef $= (rotateMech (0.1, mech))
  
  
  
  For some reason in that code above, the mechRef doesnt update the value 
I 
  want to change.  It is like I am getting an instance of the initial 
valyue 
  back.  Also, when I use writeIORef, eg writeIORef mechRef  (rotateMech 
(0.1, 
  mech)
  
  I get stack overflow exceptions.
 
 The bug above is probably responsible for both the stack overflows 
 with writeIORef and for a $= that doesn't update (it wants to update,
  but the program is trapped in an infinite loop).
 
 Btw, you don't need parenthesis about function applications, you can 
 use record update syntax and functions with several arguments are 
 usually written in curried form:
 
-- Calculate a new rotation
rotateMech :: Double - SimpleMech - SimpleMech
rotateMech angle mech =
   mech { mechRot = (xrot, yrot + angle, zrot) }
   where
  (xrot,yrot,zrot) = mechRot mech
 
mainMech = initMech (0, 0, 0) (0, 0, 0)
 
main = do
   mainMechRef - newIORef mainMech
   displayCallback $= displayGameLoop mainMechRef
 
displayGameLoop mechRef = do
   mech - get mechRef
   mechRef $= rotateMech 0.1 mech
 
 The latter can also be written as
 
displayGameLoop mechRef = do
   mechRef $~ rotateMech 0.1
 
 Regards,
 apfelmus
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


That should be 
newyrot = yrot + angle 


Thanks, I can't believe I missed that bug.  I laughed out loud when I saw 
that.

--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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


[Haskell-cafe] Data types and field labels and Show

2007-09-27 Thread bbrown
I am trying to print the data from a data type and also get the field 
values.  How would I reference those values if I am declaring a Show function.

I should probably use a class for this, but so far it is working.

I have something along the lines of this.

data SimplePlayer = SimplePlayer { 
  shape :: MechShape,
  angle :: GLfloat,
  posX :: GLfloat,
  posY :: GLfloat
}

and then to use Show, I was declaring this.

instance Show SimplePlayer where
show a = Simple posX [ ++ show a{posX} ++ ]

Of course, this didn't compile.

How should I change this code to get the field label values of the type.

Tests/GLTests.hs:20:42: parse error on input `}'


--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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


Re: [Haskell-cafe] Data types and field labels and Show

2007-09-27 Thread bbrown
On Thu, 27 Sep 2007 11:41:00 -0700, Don Stewart wrote
 bbrown:
  I am trying to print the data from a data type and also get the field 
  values.  How would I reference those values if I am declaring a Show 
function.
  
  I should probably use a class for this, but so far it is working.
  
  I have something along the lines of this.
  
  data SimplePlayer = SimplePlayer { 
shape :: MechShape,
angle :: GLfloat,
posX :: GLfloat,
posY :: GLfloat
  }
  
  and then to use Show, I was declaring this.
  
  instance Show SimplePlayer where
  show a = Simple posX [ ++ show a{posX} ++ ]
  
  Of course, this didn't compile.
  
  How should I change this code to get the field label values of the type.
  
  Tests/GLTests.hs:20:42: parse error on input `}'
 
 Just derive Show. Types with records will be printed with their labels.
 You can then also derive Read, and get serialisation for free.
 
 data SimplePlayer = SimplePlayer
 { shape :: MechShape
 , angle :: GLfloat
 , posX  :: GLfloat
 , posY  :: GLfloat }
 
deriving (Read,Show)
 
 *M show $ SimplePlayer square pi 1.0 (exp 1)
 
 SimplePlayer {shape = \square\
   , angle = 3.1415927
   , posX = 1.0
   , posY = 2.7182817}

I did this too:

instance Show SimplePlayer where
show simpleEntity = Simple posX [ ++ show (posX simpleEntity) ++ 
] posY [ ++ show (posY 
simpleEntity) ++ ]


--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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


[Haskell-cafe] Opengl and Haskell GLdouble/GLfloat vs. Double/Float

2007-09-27 Thread bbrown
I am going to be doing a lot of opengl stuff in haskell and so far one thing 
has irked me.  Why does haskell keep the GLFloat and GL types and not just 
the Haskell types.  

--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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


[Haskell-cafe] Packages and how to load them

2007-09-27 Thread bbrown
If I have a set of haskell code and I create a directory with the source that 
has the following imports.

(some_dir/MyLib.hs)
module MyLib where

And then I want to use that set of code at the top level directory, eg:

MyTest.hs

import MyLib

How would I compile with ghc such that it loads the code from some_dir 
without it having to have the module as module some_dir.MyLib.  I think 
this is a basic packaging question but couldnt figure it out.


--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

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