Re: [Haskell-cafe] FFI: how to handle external dll crashes
On Mon, 23 Sep 2013 15:32:35 +0200 Miro Karpis miroslav.kar...@gmail.com wrote: Thanks for that. I checked forkProcess - which is packed in POSIX module. I'm building under windows. Do I need to go via cygwin, is there some other way for creating new OS process? Windows doesn't support fork(), you'll need to either use cygwin or move your code to a helper binary and launch it with System.Process. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCE] fficxx : haskell-C++ FFI binding generator
Any progress on Qt bindings yet? On Sat, 8 Jun 2013 18:00:36 -0400 Ian-Woo Kim ianwoo...@gmail.com wrote: Dear Haskellers, Hello. I am very happy to announce the first version of fficxx (http://ianwookim.org/fficxx, also, please look at http://github.com/wavewave/fficxx ) fficxx is a haskell Foreign Function Interface (FFI) generator to C++. This tool automatically generates haskell FFI package for a given C++ class structure. It has been used for generating my haskell binding to the ROOT library [1] called HROOT [2]. Now I made it as a separate tool to benefit everyone trying to make a haskell-C++ binding. I am going to explain how to use the library/tool one by one in my blog ( http://ianwookim.org/blog ). Currently, in the fficxx cabal package, I provide a very simple sample in the sample directory. If interested, please try this and give me some comments on it in the discussion mailing list: http://ianwookim.org/fficxx/discuss.html I hope that this is useful to many haskellers. Have fun with it! Thanks, Ian-Woo Kim (wavewave) [1] : http://root.cern.ch [2] : http://ianwookim.org/HROOT ___ 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] Template Haskell and Haddock
On Wed, 31 Jul 2013 15:18:32 +0200 Jose A. Lopes jabolo...@google.com wrote: Is there a way to access docstrings through Template Haskell ? For example, access the docstring of a function declaration ? No, but I believe you can access comments and annotations using a ghc plugin. See https://github.com/thoughtpolice/strict-ghc-plugin for example. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
Test triggers the bug, only zeros and ones like you said, but only for native-sized types: -O2: Int 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 Int32 41 37 25 85 27 84 70 8 70 32 36 1 14 92 1 74 17 28 38 76 Int64 37 77 57 75 17 58 28 77 23 51 1 13 50 35 21 11 70 43 6 5 Word 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 Word32 52 45 86 4 85 44 71 59 91 10 65 89 41 78 84 88 3 60 71 0 Word64 12 82 25 1 11 14 76 58 1 77 9 25 57 20 41 8 2 29 21 29 ghci: Int 53 13 24 58 66 71 19 16 73 54 95 87 2 34 62 67 2 45 56 2 Int32 41 37 25 85 27 84 70 8 70 32 36 1 14 92 1 74 17 28 38 76 Int64 37 77 57 75 17 58 28 77 23 51 1 13 50 35 21 11 70 43 6 5 Word 41 19 99 69 27 58 92 45 9 38 51 39 50 14 2 21 25 94 96 2 Word32 52 45 86 4 85 44 71 59 91 10 65 89 41 78 84 88 3 60 71 0 Word64 12 82 25 1 11 14 76 58 1 77 9 25 57 20 41 8 2 29 21 29 I run a 32-bit system, as I've said before. Gentoo Linux _i686_ 3.8.2-pf Could perhaps be something with my system, I'll test on Ubuntu later today, and if there are no problems with compiling mwc-random on ghc git — on it too. On Wed, 17 Jul 2013 12:19:29 +0400 Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 10 July 2013 14:10, kudah kudahkuka...@gmail.com wrote: Yes, it does. Without optimizations the result is ndgorsfesnywaiqraloa, while with optimizations the result is always aabb. Sorry for taking so long. So problem is uniformR. You can reproduce bug reliably and I cannot. Are you on 32-bit system? I only tested on 64-bit ones. If this isn't the case I'm out of ideas. I finally wrote test case that doesn't depends on anything besides mwc-random (it's in attachment). Could you check whether it still triggers the bug ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
Yes, it does. Without optimizations the result is ndgorsfesnywaiqraloa, while with optimizations the result is always aabb. On Wed, 10 Jul 2013 02:21:10 +0400 Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 10.07.2013 01:38, kudah wrote: I've attached the script that I had trouble with. It tries to replicate one directory structure in another directory, while replacing filenames and file contents with random data. When compiled with -O1 or -O2 resulting file and directory names are composed only of a's and b's, but file contents seem properly randomized. No luck. On my computer script works correctly with and without optimizations. My best guess that uniformR is problematic. Does (\g - randName g 20) = create show different behavior with and without optimizations? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Correct way to catch all exceptions
I think that new SomeAsyncException type in base is supposed to make it possible to ignore all asynchronous exceptions. https://github.com/ghc/packages-base/blob/master/GHC/IO/Exception.hs#L113 On Wed, 10 Jul 2013 09:28:12 +0300 Michael Snoyman mich...@snoyman.com wrote: There's a pattern that arises fairly often: catching every exception thrown by code. The naive approach is to do something like: result - try someCode case result of Left (e :: SomeException) - putStrLn $ It failed: ++ show e Right realValue - useRealValue This seems perfectly valid, except that it catches a number of exceptions which seemingly should *not* be caught. In particular, it catches the async exceptions used by both killThread and timeout. I think it's fair to say that there's not going to be a single function that solves all cases correctly, but it is a common enough situation that people need to write code that resumes work in the case of an exception that I think we need to either have some guidelines for the right approach here, or perhaps even a utility function along the lines of: shouldBeCaught :: SomeException - Bool One first stab at such a function would be to return `False` for AsyncException and Timeout, and `True` for everything else, but I'm not convinced that this is sufficient. Are there any thoughts on the right approach to take here? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
Same here, I used mwc-random to generate random strings. It works in ghci and when compiled with -O0, but with -O1 and -O2 I've been getting exclusively a's and b's. On Sun, 17 Mar 2013 18:48:06 +0500 Azeem -ul-Hasan aze...@live.com wrote: I am using GHC 7.6.1 mwc-random 0.12.0.1 vector 0.9.1 primitive 0.4.1 Azeem On 16.03.2013 13:31, Azeem -ul-Hasan wrote: Nope that isn't the case either. Even if I make use of defaultSeed through create the problem still remains. The problem seems to be in the generation of a vector of (a,a) i.e in the part V.generateM ((round $ p*(fromIntegral $ l*z)) `div` 2) (\i- R.uniformR ((0,0) , (l-1,l-1)) gen) in line 16. Thanks again. I've tried to run you program and I've got approximately same results regardless of optimization level. Which versions of GHC, mwc-random, vector and primitive do you use? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
I've attached the script that I had trouble with. It tries to replicate one directory structure in another directory, while replacing filenames and file contents with random data. When compiled with -O1 or -O2 resulting file and directory names are composed only of a's and b's, but file contents seem properly randomized. ghc-7.6.2, vector-0.10.0.1, primitive-0.5.0.1, mwc-random-0.12.0.1, Gentoo Linux i686 3.8.2-pf. On Tue, 09 Jul 2013 22:43:36 +0400 Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 09.07.2013 22:10, kudah wrote: Same here, I used mwc-random to generate random strings. It works in ghci and when compiled with -O0, but with -O1 and -O2 I've been getting exclusively a's and b's. It looks like MWC generates only 0 and 1 for some reason. I've tried to write simple test but everything works fine. Could you post test case and compiler/libraries/OS versions you use? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-imports #-} module Main where import Shelly import Filesystem.Path.CurrentOS (splitDirectories, encodeString, decodeString) import qualified Filesystem as F import qualified Data.Text as T import qualified Data.ByteString as B import Control.Monad.IO.Class import System.Random.MWC import Control.Monad.Primitive import Control.Monad import Control.Applicative import Prelude hiding (FilePath) import Data.String import System.Environment rands :: (PrimMonad m, Variate a) = Gen (PrimState m) - Int - m [a] rands gen i = replicateM i (uniform gen) randRs :: (PrimMonad m, Variate a) = Gen (PrimState m) - Int - (a, a) - m [a] randRs gen i z = replicateM i (uniformR z gen) lastElemLength :: FilePath - Int lastElemLength fd = case splitDirectories fd of [] - error $ Empty filepath ++ show fd g - T.length $ toTextIgnore $ last g randName :: Gen (PrimState IO) - Int - IO FilePath randName gen l = decodeString . map toEnum $ randRs gen l (fromEnum 'a', fromEnum 'z') main :: IO () main = do g - getArgs case g of [inDir, outDir] - withSystemRandom . asGenIO $ \gen - do shellyNoDir $ do escaping False $ do -- verbosely $ do out - absPath (decodeString outDir) in' - absPath (decodeString inDir) descent gen out in' _ - putStrLn Specify input directory and output directory descent :: Gen (PrimState IO) - FilePath - FilePath - Sh () descent gen outDir fd = do isDir - test_d fd if isDir then do n - liftIO $ randName gen $ lastElemLength fd let newDir = outDir / n mkdir_p newDir chdir fd $ do filesOrDirs - ls . mapM_ (descent gen newDir) filesOrDirs else do file - absPath fd liftIO $ do size - F.getSize file newFname - randName gen $ lastElemLength file bs - B.pack $ rands gen (fromInteger size) B.writeFile (encodeString $ outDir / newFname) bs ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Flip around type parameters?
No. You'll have to use a newtype. Type parameter order is a huge deal for some types, e.g. monad transformers, you'd better think about it beforehand. On Thu, 09 May 2013 19:39:12 -0800 Christopher Howard christopher.how...@frigidcode.com wrote: Hi. Does Haskell allow you to flip around type parameters somehow? I was playing around with toy code (still learning the fundamentals) and I came up with a class like this: code: class Rotatable2D a where rotate :: (Num b) = (a b) - b - (a b) It was easy to make an instance of a generic single-parameter type: code: data Angle a = Angle a deriving (Show) instance Rotatable2D Angle where rotate (Angle a) b = Angle (a + b) But let's say I have something a little more complicated: code: data CircAppr a b = CircAppr a a b -- radius, rotation angle, number of points I think I need something like so: instance Rotatable2D (\x - CircAppr x a) where rotate (CircAppr a b c) d = CircAppr a (b + d) c But I tried that and it isn't valid syntax. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Markdown extension for Haddock as a GSoC project
On Mon, 29 Apr 2013 18:04:47 +1200 Richard A. O'Keefe o...@cs.otago.ac.nz wrote: so that there is no possibility of catching errors early; by definition in that processor there are no errors. Haddock's markup isn't any better in that regard. I spent two hours on my first day with haddock figuring out that I needed an empty comment line before a code block. It didn't issue any warnings or errors either. To be perfectly honest, most of the time when looking at a Haddock page, I end up clicking on the Source button because there are things I need to know that are in the source but not the documentation. Besides fixities, orphan instances, type family instances and partially exported records? It would be beneficial of Haddock to list orphan instances on top of the page. In red. Iff adding markdown doesn't require a major restructuring of haddock, then a GSOC might be better spent adding support for all of these instead; someone else could add markdown later on their own after ML bikeshedding came to some conclusion. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Why are QuasiQuotes allowed in SafeHaskell?
In GHC User's Guide, the reason to disable TemplateHaskell is as follows: TemplateHaskell — Is particularly dangerous, as it can cause side effects even at compilation time and can be used to access constructors of abstract data types. Doesn't the same apply to quasi-quotes? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] unsafeInterleaveST (and IO) is really unsafe [was: meaning of referential transparency]
On Thu, 11 Apr 2013 12:49:40 +1200 Richard A. O'Keefe o...@cs.otago.ac.nz wrote: And most of the alternatives (like conduits) hurt my head I've understood conduits when I've read the awesome pipes tutorial. http://hackage.haskell.org/packages/archive/pipes/3.2.0/doc/html/Control-Proxy-Tutorial.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bug in Network package
There's actually a comment near the definition of PortNumber http://hackage.haskell.org/packages/archive/network/latest/doc/html/src/Network-Socket-Types.html#PortNumber -- newtyped to prevent accidental use of sane-looking -- port numbers that haven't actually been converted to -- network-byte-order first. Why the hell isn't it exported to haddocks is beyond me. On Wed, 10 Apr 2013 16:51:23 -0400 Jeffrey Shaw shawj...@gmail.com wrote: This is a case where a line of documentation could save a lot of people a lot of trouble. Anyone have a clone of network handy that they could make a pull request from? Jeff On Wed, Apr 10, 2013 at 4:31 PM, Florian Hofmann fhofm...@techfak.uni-bielefeld.de wrote: Ah ok ... thanks for the clarification 2013/4/10 Brandon Allbery allber...@gmail.com On Wed, Apr 10, 2013 at 3:26 AM, Florian Hofmann fhofm...@techfak.uni-bielefeld.de wrote: I might be mistaken, but is there a bug in the Show instance of PortNum? Not a bug, an annoying misdesign (IMO). A PortNum is actually in network byte order. If you extract it, you get the original port; if you simply show it, you see it byteswapped on little-endian platforms. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net ___ 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] Is there an escape from MonadState+MonadIO+MonadError monad stack?
On Sun, 7 Apr 2013 01:02:12 +0300 Ömer Sinan Ağacan omeraga...@gmail.com wrote: I'm not happy with this design because to me it was like I'm missing the point of using a 'functional' language. You kind of do, e.g. you might not be able to test parts of your program independently. For instance, in most parts of my code I can actually do IO. You can disable IO in parts of your code by making it polymorphic over monad. {-# LANGUAGE RankNTypes #-} type MonadStack = ErrorT Err (StateT St IO) type MonadStackNoIO = forall m. Monad m = ErrorT Err (StateT St m) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GSoC Project Proposal: Markdown support for Haddock
A sane markup for haddock would be greatly appreciated. I've grown tired of noticing highlighted words arising from unescaped quotes all over hackage. On Thu, 4 Apr 2013 09:49:04 -0700 Johan Tibell johan.tib...@gmail.com wrote: Hi all, Haddock's current markup language leaves something to be desired once you want to write more serious documentation (e.g. several paragraphs of introductory text at the top of the module doc). Several features are lacking (bold text, links that render as text instead of URLs, inline HTML). I suggest that we implement an alternative haddock syntax that's a superset of Markdown. It's a superset in the sense that we still want to support linkifying Haskell identifiers, etc. Modules that want to use the new syntax (which will probably be incompatible with the current syntax) can set: {-# HADDOCK Markdown #-} on top of the source file. Ticket: http://trac.haskell.org/haddock/ticket/244 -- Johan ___ 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] ifdef based on which OS you're on
__WIN32__ use mingw32_HOST_OS __MACOSX__ darwin_HOST_OS On Sat, 16 Feb 2013 01:05:13 +1100 Andrew Cowie and...@operationaldynamics.com wrote: I've got a piece of code that looks like this: baselineContextSSL :: IO SSLContext baselineContextSSL = do ctx - SSL.context SSL.contextSetDefaultCiphers ctx #if defined __MACOSX__ SSL.contextSetVerificationMode ctx SSL.VerifyNone #elif defined __WIN32__ SSL.contextSetVerificationMode ctx SSL.VerifyNone #else SSL.contextSetCADirectory ctx /etc/ssl/certs SSL.contextSetVerificationMode ctx $ SSL.VerifyPeer True True Nothing #endif return ctx all very nice (this being necessary because apparently the non-free operating systems don't store their certs in a reliably discoverable place; bummer). That, however, is not the problem. After all, this sort of thing is what #ifdefs are for. The problem is needing to get an appropriate symbol based on what OS you're using defined. I naively assumed there would be __LINUX__ and __MACOSX__ and __WIN32__ defined by GHC because, well, that's just the sort of wishful thinking that powers the universe. So my question is: what's an appropriate Haskell mechanism for building code that is OS / arch / distro specific? It's not like I have autoconf running generating me a config.h I could #include, right? This feels simple and an appropriate use of CPP; even the symbol names look just about like what I would have expected; stackoverflow said so, must be true. Just need to get the right symbol defined at build time. Any suggestions? AfC Sydney ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FFI - Approaches to C/C++
I'd object to your implication that Haskell is completely ready for use in general soft real-time systems. I was unable to implement a multi-threaded application which does a some IO-work in background threads in a way so that its GUI won't die. Worker threads simply starve the GUI, because Haskell doesn't have thread priorities. And even if it had, it would still lag on Windows, due to lack of IO manager. Ezyang had, in fact, made a new scheduler, which seems to address the problem; and joeyadams tries to make IO-manager for windows, but all this isn't going to see the light of day for a while, at least until 7.8.1. 2013/1/31 Ertugrul Söylemez e...@ertes.de: That used to be true, but the reason has nothing to do with the language. The problem was that the libraries weren't there. Nowadays you can write all sorts of interactive applications in Haskell, including GUIs, TUIs, games, simulations and web applications. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FFI - Approaches to C/C++
I used gtk2hs, because I couldn't find a free software design tool that was at least as good as glade3. Last time I tried to compile wxHaskell, wxc produced an enormous dynamic library which also linked to every wxWidgets library out there(e.g. wxwebkit), so that the resulting mess couldn't be reasonably distributed in binaries. 2013/2/5 Carlo Hamalainen carlo.hamalai...@gmail.com: On Tue, Feb 5, 2013 at 1:56 PM, kudah kudahkuka...@gmail.com wrote: I'd object to your implication that Haskell is completely ready for use in general soft real-time systems. I was unable to implement a multi-threaded application which does a some IO-work in background threads in a way so that its GUI won't die. Worker threads simply starve the GUI, because Haskell doesn't have thread priorities. And even if it had, it would still lag on Windows, due to lack of IO manager. Ezyang had, in fact, made a new scheduler, which seems to address the problem; and joeyadams tries to make IO-manager for windows, but all this isn't going to see the light of day for a while, at least until 7.8.1. What did you use for the GUI? WxWidgets? I'm interested in this case because I develop a cross-platform Python GUI application and would like to see how a Haskell implementation would behave. -- Carlo Hamalainen http://carlo-hamalainen.net ___ 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] FFI - Approaches to C/C++
I followed dmwit's guide on threaded gtk2hs, all GUI interaction is in the main thread, which is always bounded. This shouldn't really impact the lag, as soon as gtk2hs calls back to haskell, nothing stops the RTS from delaying main thread's peaceful return to C-land for arbitrary amount of time. 2013/2/5 Ertugrul Söylemez e...@ertes.de: Be sure to compile with -threaded. Also note that GUI libraries often want to run in a bound thread. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Feedback on FFI bindings for C++ library
I'd suggest to first look at how other C++-bindings for haskell are implemented. e.g. wxHaskell is the most mature Haskell C++ binding out there. hogre tries to generate bindings from headers. And a number of (rather minimal) bindings to some libs were made as part of Nikki and the Robots. On Thu, 17 Jan 2013 18:48:02 +0100 Nathan Hüsken nathan.hues...@posteo.de wrote: Hey, I would like to write FII bindings in haskell for cocos2d-x (http://www.cocos2d-x.org/), which is a C++ library. Since I have little experience with this, I would like some feedback before I discover that concept is bad half way. In cocos2d there is a base class with much functionality: CCNode Many classes derive from it (i.E. CCLayer) and use the virtual functions of CCNode (i.E. setPosition). How do I map this to haskell? The general Idea: I have a typeclass, in which everything that is derived from CCNode is an instance: class NodeDerived a where toNode :: a - Node setPosition :: a - (Double,Double) - IO () setPosition a pos = setNodePosition (toNode a) pos instane NodeDerived Layer where toNode = layerToNode and layerToNode :: Layer - Node would be implemented in C++ as: CCNode* layerToNode(CCLayer* l) { return dynamic_castCCNode*(l); } This way I would have only to implement toNode for every class derived from CCNode and get all the functions CCNode defines. What do you think if this Idea? How would you do it? Thanks! Nathan ___ 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] Feedback on FFI bindings for C++ library
I'd suggest to first look at how other C++-bindings for haskell are implemented. e.g. wxHaskell is the most mature Haskell C++ binding out there. hogre tries to generate bindings from headers. And a number of (rather minimal) bindings to some libs were made as part of Nikki and the Robots. On Thu, 17 Jan 2013 18:48:02 +0100 Nathan Hüsken nathan.hues...@posteo.de wrote: Hey, I would like to write FII bindings in haskell for cocos2d-x (http://www.cocos2d-x.org/), which is a C++ library. Since I have little experience with this, I would like some feedback before I discover that concept is bad half way. In cocos2d there is a base class with much functionality: CCNode Many classes derive from it (i.E. CCLayer) and use the virtual functions of CCNode (i.E. setPosition). How do I map this to haskell? The general Idea: I have a typeclass, in which everything that is derived from CCNode is an instance: class NodeDerived a where toNode :: a - Node setPosition :: a - (Double,Double) - IO () setPosition a pos = setNodePosition (toNode a) pos instane NodeDerived Layer where toNode = layerToNode and layerToNode :: Layer - Node would be implemented in C++ as: CCNode* layerToNode(CCLayer* l) { return dynamic_castCCNode*(l); } This way I would have only to implement toNode for every class derived from CCNode and get all the functions CCNode defines. What do you think if this Idea? How would you do it? Thanks! Nathan ___ 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] LGPL and Haskell (Was: Re: ANNOUNCE: tie-knot library)
On Wed, 12 Dec 2012 10:06:23 +0100 Petr P petr@gmail.com wrote: 2012/12/12 David Thomas davidleotho...@gmail.com Yet another solution would be what David Thomas suggest: To provide the source code to your users, but don't allow them to use the code for anything but relinking the program with a different version of the library (no distribution, no modification etc.). You can also provide object code for linking, though I'm sure this will not work with Haskell object files. Providing alternative distribution of your program linked dynamically, or a promise to provide one on notice, also satisfies the LGPL as long as dynamic-version is as functional as the static and can be dropped-in as a replacement. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Maintainer of fixpoint
On Wed, 5 Dec 2012 20:22:32 +0100 Petr P petr@gmail.com wrote: Or is there a way how to take over an orphaned package? You can just upload a new version, if you're sure that the original maintainer won't protest. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal configure cabal build cabal install
On Tue, 27 Nov 2012 02:20:35 -0500 Albert Y. C. Lai tre...@vex.net wrote: When cabal build succeeds, it always says: (older) registering name-version (newer) In-place registering name-version That's what it says. But use ghc-pkg and other tests to verify that no registration whatsoever has happened. It doesn't register in user package-db, it registers in it's own dist/package.conf.inplace. If it didn't you wouldn't be able to build an executable and a library in one package such that executable depends on the library. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal configure cabal build cabal install
On Mon, 26 Nov 2012 18:21:33 -0500 Albert Y. C. Lai tre...@vex.net wrote: Lastly, there is no Setup install. Use copy and register. $ runghc Setup.hs --help This Setup program uses the Haskell Cabal Infrastructure. See http://www.haskell.org/cabal/ for more information. Usage: Setup.hs COMMAND [FLAGS] or: Setup.hs [GLOBAL FLAGS] Global flags: -h --helpShow this help text -V --version Print version information --numeric-version Print just the version number Commands: configure Prepare to build the package. build Make this package ready for installation. install Copy the files into the install locations. Run register. copy Copy the files into the install locations. haddock Generate Haddock HTML documentation. clean Clean up after a build. sdist Generate a source distribution file (.tar.gz). hscolour Generate HsColour colourised code, in HTML format. register Register this package with the compiler. unregisterUnregister this package with the compiler. test Run the test suite, if any (configure with UserHooks). bench Run the benchmark, if any (configure with UserHooks). help Help about commands For more information about a command use Setup.hs COMMAND --help Typical steps for installing Cabal packages: Setup.hs configure Setup.hs build Setup.hs install On Mon, 26 Nov 2012 18:21:33 -0500 Albert Y. C. Lai tre...@vex.net wrote: cabal configure cabal build cabal register --inplace (newer) cabal build registers inplace automatically. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal failures...
Personally, I successfully use Wine to build, ship and test for Windows. There are some pitfalls related to -optl-mwindows and encodings, but, if you launch your program with $LANG set to proper windows encoding like cp1251 and the std handles closed with 0- 1- 2-, it should crash on related errors the same way as on windows. I am not (yet) aware of any Haskell programs that don't run under Wine. On Wed, 21 Nov 2012 13:05:45 +1100 Erik de Castro Lopo mle...@mega-nerd.com wrote: So is it difficult for an open source contributor to test on windows? Hell yes! You have no idea how hard windows is in comparison to say FreeBSD. Even Apple's OS X is easier than windows, because I have friends who can give me SSH access to their machines. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal failures...
On Sat, 24 Nov 2012 13:46:37 +1100 Erik de Castro Lopo mle...@mega-nerd.com wrote: kudah wrote: Personally, I successfully use Wine to build, ship and test for Windows. There are some pitfalls related to -optl-mwindows and encodings, but, if you launch your program with $LANG set to proper windows encoding like cp1251 and the std handles closed with 0- 1- 2-, it should crash on related errors the same way as on 1windows. I am not (yet) aware of any Haskell programs that don't run under Wine. Thats a very interesting solution. I use Wine to run the test suite when I cross compile one of my C projects from Linux to Wine. Would you consider documenting the process of setting everything up to build Haskell programs under Wine on the Haskell Wiki? Erik Aside from what I posted above it's same as on Windows, just install Haskell Platform. There's already a page on Haskell Wiki http://www.haskell.org/haskellwiki/GHC_under_Wine though it seems very outdated. I can update it with my own observations when I get an HW account, they seem to have switched to manual registration while I wasn't looking. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] class Bytestringable or ToBytestring
Why not use http://hackage.haskell.org/packages/archive/newtype/0.2/doc/html/Control-Newtype.html instead? On Thu, 22 Nov 2012 14:15:00 + Vincent Hanquez t...@snarc.org wrote: Hi cafe, I've been adding lots of types recently that looks more or less like: newtype A = A ByteString data B = B ByteString This is great for extra type safety and letting the compiler do its job, however getting the bytestring back requires boiler plate. At the moment either you give access to the constructor, which is not always wanted, or you use the record syntax to create a function to extract just the bytestring. The latter is fine for 1 or 2 types, but the scheme fall apart when having many of those types and do pollute namespace. I'm basically after something that looks like this: class ToByteString a where toByteString :: a - ByteString Before anyone suggest the Serialize interface from cereal or the Binary interface from binary which both looks quite similar (from far away): - serialize work in the put monad, and you have to define a get instance: which is something that is not required or possible sometime. - binary works with lazy bytestrings and got the same problem as cereal. - a serialize instance that just do a single putByteString is really slow: 12 ns to 329 ns (26x time slower) on the same exact data on one isolated bench) - neither of those packages are in the platform. If that doesn't exists, could it be a worthy addition to bytestring ? is this a good idea in general ? is there any other way ? Thanks, ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] class Bytestringable or ToBytestring
On Thu, 22 Nov 2012 21:14:31 + Vincent Hanquez t...@snarc.org wrote: can't find any library on hackage that use it http://packdeps.haskellers.com/reverse/newtype ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe