Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Anyone have problems with cabal and SDL? (Stephen Tetley) 2. Having trouble defining type correctly (Chris Bolton) 3. Re: Anyone have problems with cabal and SDL? (Alvaro Vilanova) 4. Re: HUnit - testing for failed pattern match (Xavier Shay) 5. Re: HUnit - testing for failed pattern match (Edward Z. Yang) 6. Re: HUnit - testing for failed pattern match (Xavier Shay) 7. Very basic question on monads (black...@pro-ns.net) 8. Help with GHC Packages Installation on Fedora 14 (Hong Yang) ---------------------------------------------------------------------- Message: 1 Date: Tue, 22 Feb 2011 18:29:44 +0000 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: [Haskell-beginners] Anyone have problems with cabal and SDL? Cc: beginners@haskell.org Message-ID: <aanlktikbraqurf16or-kndvfyutjswr9e3a81qqnj...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi Tom Thanks for the update. It looks like you have the SDL runtime library installed but not the development extras. If you have the sdl-devel extras they're not on your search path. On 22 February 2011 14:53, Tom Murphy <amin...@gmail.com> wrote: [CHOP] > checking for sdl-config... no > checking for sdl11-config... no > configure: error: *** SDL not found! Get SDL from www.libsdl.org. > If you already installed it, check it's in the path. If problem remains, > please send a mail to the address that appears in ./configure --version > indicating your platform, the version of configure script and the problem. > cabal: Error: some packages failed to install: ------------------------------ Message: 2 Date: Tue, 22 Feb 2011 11:51:37 -0800 From: Chris Bolton <chris...@saikonet.org> Subject: [Haskell-beginners] Having trouble defining type correctly To: beginners@haskell.org Message-ID: <aanlktinoqhgco6yar1vplpfjmpmztwo2rsqmq3cfk...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Ok, so here's my current code: http://paste.pocoo.org/show/342949/ My basic problem is I'm not quite sure how to define Command. When a user calls the script they can either call add, remove, update, or query, which all have different type signatures, which is why I need Command so it'll pass through haskell's type checking. If I get rid of query, A definition of { data Command m = Save m | Rem m } seemed to work, from what I can tell, but query screws it up, so I'm trying to define exactly what Save, Rem, etc. should be, which I've taken directly from the MongoDB API, but it just keeps throwing errors, as seen here: http://paste.pocoo.org/show/342924/ Also, I'm very new to haskell and programming in general, so sorry for the possibly messy code / noobish question, but anyone have any ideas here? :P -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110222/e8d6d231/attachment-0001.htm> ------------------------------ Message: 3 Date: Tue, 22 Feb 2011 22:05:13 +0100 From: Alvaro Vilanova <alv...@gmail.com> Subject: Re: [Haskell-beginners] Anyone have problems with cabal and SDL? To: Tom Murphy <amin...@gmail.com> Cc: beginners@haskell.org Message-ID: <AANLkTi=RCgyysT3Yq=6ngq7zhgf-8fetsnpm44rkf...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" The log says that configuration SDL tool `sdl-config` is not installed, probably, due to you have installed SDL framework. Cabal, or the SDL package (I dont know who has the problem here) doesn't take into account that the system is a MacOs so it doesn't search the library as a framework. To solve this, you have to compile the library manually, just `./configure && make && sudo make install` or install it with MacPorts. Then you will be able to compile SDL projects. Nothing more. If you want to link and run your own Haskell SDL projects on MacOs you have to dive in the next odyssey: SDL has a tricky way to enable C `main` function to run graphic applications on all systems. So first, we need a C function wich is going to be hooked by SDL, and this function is going to run our Haskell application. We put this main function in c_main.c [1]. To be compatible with all other plataforms we have keep our Main Haskell function, so we rename this function in a FFI Module which will be compiled only on MacOS, named HS_Main.hs [2]. Now we have to compile c_main.c with: gcc -c c_main.c `sdl-config --cflags` -framework GHC But, surprise, the GHC framework seems that is not well-formed, so gcc can not get the header and you have to search it manually. In my case: find / -name "HsFFI.h" ... /Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.3/include/HSffi.h ... gcc -c c_main.c `sdl-config --cflags` -I/Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.3/include/ And now we have a c_main.o. Next, we have to compile our HSMain which imports our Main module which contains the default main function. ghc --make HSMain.hs -no-hs-main c_main.o -framework Cocoa And if you have the default Haskell plataform for MacOs you are going to get one surprise more: Linking ./Main ... ld: warning: in c_main.o, file was built for unsupported file format which is not the architecture being linked (i386) ld: warning: in /usr/local/lib/libSDLmain.a, file was built for unsupported file format which is not the architecture being linked (i386) ld: warning: in /usr/local/lib/libSDL.dylib, file was built for unsupported file format which is not the architecture being linked (i386) This means that you have a 32 bits GHC but gcc compiles to 64 bits. You have 3 options: give up, cross-compile c_main.c and sdl to 32 bits, compile and install a custom haskell-plataform enabling 64 bits support. Good luck, you will need it! PD: With cabal is a little more easy, see TimePiece as example [3]. [1] https://gist.github.com/839329 [2] https://gist.github.com/839340 [3] http://hackage.haskell.org/package/TimePiece 2011/2/21 Tom Murphy <amin...@gmail.com> > When I use Cabal to get any program which depends on the SDL library, this > is the error I get. > > " > checking for sdl-config... no > checking for sdl11-config... no > configure: error: *** SDL not found! Get SDL from www.libsdl.org. > If you already installed it, check it's in the path. If problem remains, > please send a mail to the address that appears in ./configure --version > indicating your platform, the version of configure script and the problem. > cabal: Error: some packages failed to install: > Raincat-1.1.1.2 depends on SDL-0.6.2 which failed to install. > SDL-0.6.2 failed during the configure step. The exception was: > exit: ExitFailure 1 > SDL-image-0.6.1 depends on SDL-0.6.2 which failed to install. > SDL-mixer-0.6.1 depends on SDL-0.6.2 which failed to install. > " > > > I have SDL 1.2.14 (correctly) installed on my system. > I'd really appreciate any help with this. > > Tom > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110222/db55054b/attachment-0001.htm> ------------------------------ Message: 4 Date: Wed, 23 Feb 2011 08:34:39 +1100 From: Xavier Shay <xavier-l...@rhnh.net> Subject: Re: [Haskell-beginners] HUnit - testing for failed pattern match To: beginners@haskell.org Message-ID: <4d642bef.9080...@rhnh.net> Content-Type: text/plain; charset=UTF-8; format=flowed > Excerpts from Xavier Shay's message of Tue Feb 22 05:59:12 -0500 2011: >> Given the following contrived function: >> >> giveMeThree x >> | x == 3 = True >> >> How do I test with HUnit that 2 is invalid input? >> >> giveMeThreeTests = >> [ "Likes 3" ~: True ~=? giveMeThree 3 >> , "Dislikes 2" ~: ..... -- what? >> ] >> >> I couldn't find anything mentioned in the HUnit user guide. References >> to appropriate documentation appreciated. On 23/02/11 1:31 AM, Edward Z. Yang wrote: > > A partial function will emit an exception, which must be caught from > IO. I'm sure HUnit has an appropriate mechanism for handling this, > but I strongly suggest you redesign your function to be total: instead > of omitting pattern matches, change it to use Maybe and return Nothing > in the 'otherwise' case. In this case, the inputs I am giving to the function are totally invalid - they should never occur in a running app. For context, the function takes a state, applies a transition, and returns the new state. There are certain invalid transitions. In other languages I would throw an ArgumentError or similar ... would the Haskell way be to return Nothing instead? To me this seems to be complicating my types (Maybe instead of a vanilla type) for a benefit that I don't see. What are the benefits to using Maybe in this case rather than throwing an exception? Cheers, Xavier ------------------------------ Message: 5 Date: Tue, 22 Feb 2011 18:35:38 -0500 From: "Edward Z. Yang" <ezy...@mit.edu> Subject: Re: [Haskell-beginners] HUnit - testing for failed pattern match To: Xavier Shay <xavier-l...@rhnh.net> Cc: beginners <beginners@haskell.org> Message-ID: <1298417639-sup-631@ezyang> Content-Type: text/plain; charset=UTF-8 What you describe is one of the cases when a partial function is ok (though it's probably better to do something like: giveMeThree x | x == 3 = True | otherwise = error "giveMeThree: not three" It's frequently not possible, but if you can arrange your types so that the invalid values are not possible, even better.) Cheers, Edward ------------------------------ Message: 6 Date: Wed, 23 Feb 2011 12:25:28 +1100 From: Xavier Shay <xavier-l...@rhnh.net> Subject: Re: [Haskell-beginners] HUnit - testing for failed pattern match To: beginners@haskell.org Message-ID: <4d646208.5010...@rhnh.net> Content-Type: text/plain; charset=UTF-8; format=flowed On 23/02/11 10:35 AM, Edward Z. Yang wrote: > What you describe is one of the cases when a partial function is ok > (though it's probably better to do something like: > > giveMeThree x > | x == 3 = True > | otherwise = error "giveMeThree: not three" > > It's frequently not possible, but if you can arrange your types so that > the invalid values are not possible, even better.) ah that's good, I can give a helpful error message. Still would like a way to test it though... ------------------------------ Message: 7 Date: Tue, 22 Feb 2011 21:30:18 -0800 From: <black...@pro-ns.net> Subject: [Haskell-beginners] Very basic question on monads To: <beginners@haskell.org> Message-ID: <cea7ab33b04a49f94bed56b9e06e6...@iphouse.com> Content-Type: text/plain; charset=UTF-8; format=flowed I'm working through the "Write Yourself a Scheme" wikibook and having trouble with one of the exercises. For the function parseNumber :: Parser LispVal, both parseNumber = liftM (Number . read) $ many1 digit parseNumber' = do digits <- many1 digit return $ (Number . read) digits work. But parseNumber'' = many1 digit >>= liftM read >>= liftM Number complains "couldn't match expected type Char against inferred type [Char]". Is liftM engaging the list monad? How do I fix this? ------------------------------ Message: 8 Date: Tue, 22 Feb 2011 23:31:06 -0600 From: Hong Yang <hyang...@gmail.com> Subject: [Haskell-beginners] Help with GHC Packages Installation on Fedora 14 To: beginners@haskell.org Message-ID: <AANLkTikVEdx-BW_az=5tm8z14nyw0ghx4f66bpsbn...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi, I installed a Fedora 14 virtual machine on my home Windows desktop. Then I tried to install GHC packages on Fedora by typing "yum install ghc" as root, and got the following error: "Error: Cannot retrieve repository metadata (repomd.xml) for repository: fedora. Please verify its path and try again." What should I do now to fix this error? Thanks, Hong -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110222/5e66a688/attachment.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 32, Issue 42 *****************************************