Re: [Haskell-cafe] pointfree-trouble
There you have it: fully- and semi-pointfree versions of reMatr. A heads up: aggressively pursuing pointfreeness without type signatures guarantees a courtesy call from the monomorphism restriction, pace ()-garlic aficionados. As for your question on why the original code doesn't typecheck: if you explain how you arrived at it, perhaps we can figure out where you tripped up. Daniel Fischer for instance, *calculated* for you the right answer. Habeas calculus and all that. slemi wrote: > > thanks, that's a really neat syntactic sugar :) > > however, my original question was how to make the reMatr function > pointfree, as > reMatr = Matr . (flip (.) unMatr) > is not working. any ideas/explanation why it doesnt work? > > > Kim-Ee Yeoh wrote: >> >> Here's another way of writing it: >> >> data Matrix a = Matr {unMatr :: [[a]]} | Scalar a deriving (Show, Eq) >> -- RealFrac constraint removed >> >> reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) >> reMatr f = Matr . f . unMatr -- this idiom occurs a lot, esp. with >> newtypes >> >> Affixing constraints to type constructors is typically deprecated. >> >> >> >> slemi wrote: >>> >>> i have trouble making a function pointfree: >>> >>> data RealFrac a => Matrix a = Matr [[a]] | Scalar a >>> deriving (Show, Eq) >>> >>> unMatr :: RealFrac a => Matrix a -> [[a]] >>> unMatr = (\(Matr a) -> a) >>> >>> reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) >>> reMatr a = Matr . (flip (.) unMatr) a >>> >>> this works fine, but if i leave the 'a' in the last function's >>> definition like this: >>> reMatr = Matr . (flip (.) unMatr) >>> it gives an error. can anybody tell me why? (i'm using ghci) >>> >> >> > > -- View this message in context: http://old.nabble.com/pointfree-trouble-tp26881661p26897626.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] install-dirs on Mac OS X
Mark Lentczner wrote: On Dec 22, 2009, at 12:35 PM, Duncan Coutts wrote: One thing I think I've seen said before however is that things in /Library and ~/Library are supposed to be app bundles or frameworks or some other special OSX packaging thing, rather than traditional Unix-style installations. Nope - not true. There are all sorts of things under the Library directories. Again, note the list of other languages that store things under /Library. In those cases, those systems are storing installed packages in just the normal way they would on Linux or other unix systems. Those languages ---Perl, Python, Java--- are all used internally by the OSX system itself in order to run startup scripts, maintain the system, etc. That is, they are provided *by* the system, *for* the system. Users are free to use them, but they should not alter them in any way. If you want a newer version of Perl installed, everyone in the Perl community agrees that it should go into /usr/local or similar. Overriding the system Perl installation is known to cause issues with some of the system scripts, often resulting in very obscure kinds of breakage. Apple provides a Java6 bundle for OSX 10.5 on Intel CPUs (though Java6 is not available by any other reliable means for any other combination of versions and architectures). While it is possible to instruct OSX to switch to using the Java6 bundle for its internal work, this is again known to cause problems and is highly discouraged. I'm not as familiar with the use of Python internally, but I'm sure it's more of the same. /Library is only for the system to use and for bundle/framework installs. Thus, if we are to install things there, then the installation should use the bundle/framework installer. ~/Library is a bit more liberal since that's where all user apps dump their preferences. But again, ~/Library is intended more for system stuff and GUI stuff; it's not intended for commandline *nix applications. There are some tools which cross over between command line and GUI and they will occasionally put things in ~/Library (e.g., a couple LaTeX distros) but there are murmurs about that not always working out so well. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: install-dirs on Mac OS X
Tom Tobin wrote: On Tue, Dec 22, 2009 at 4:49 AM, Heinrich Apfelmus wrote: Likewise, ~/Library/Haskell seems to be the best place for user installs. While I don't mind the /Library/Haskell path for global installs, I'm not sure how I feel about this for local installs. It usually drives me crazy when my more "Unix-y" tools stick stuff in my ~/Library/ directory; for instance, I had to actively fight with my copy of Aquamacs Emacs in order to get everything running from ~/.emacs.d/ rather than ~/Library/Preferences/Aquamacs Emacs/. Seconded. At the very least, Haskell developers on OSX should be able to choose between a standard *nix installation scheme and the OSX internals approach, without breaking anything. The OSX internals approach makes some amount of sense for folks who just want to run Haskell programs as end users, but the *nix approach makes a lot more sense for active developers. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] install-dirs on Mac OS X
Mark Lentczner wrote: Taking a cue from the various preinstalled language systems on Mac OS X, up over in /Library might be a better place: Python puts installed packages in: /Library/Python//site-packages Ruby puts installed packages in: /Library/Ruby/Gems/ /Library/Ruby/Site/ Java appears to use /Library/Java/Extensions and has a link to the packages that come the framework as: /Library/Java/Home Which is just part of the symlink chain: /Library/Java/Home /System/Library/Frameworks/JavaVM.framework/Home /System/Library/Frameworks/JavaVM.framework/Versions/Current/Home /System/Library/Frameworks/JavaVM.framework/Versions//Home /System/Library/Frameworks/JavaVM.framework/Versions//Home Which is rather convoluted, but is designed to allow switching over the default Java used internally by OSX. (Java6 is only available on 10.5+intel. And it's not recommended to switch the version registered for OSX, though it's fine to munge your $PATH to pick the new one since OSX internals doesn't use $PATH to resolve things.) Overall, I'd like taking the cue to break things out by version number and then have some symlinking (or tool) in order to select one of many installed versions. This would be helpful for people who want to have multiple versions installed for debugging purposes. Even though the compiler version is already interposed on the lib dir path, giving a high-level separation by version makes it easier to deal with the different sets of libraries compiled by/for each version*compiler. However, I would be opposed to storing anything in /Library or /System. Those are for system use and sysadmin experience tells me never to mess with the system installs. For things used by the system, it's liable to break the system; and for everything, it's liable to be broken on system upgrade. OSX does have their framework packaging system, which has been used successfully in previous versions of GHC; if anything happens in /Library or /System then it has to go through the framework packaging system IMO, which means having someone as the OSX maintainer. But I think the framework system isn't really a great option for the kinds of development we end up doing. I.e., many Haskell hackers are devoted developers and many of the packages require other *nix tools to be installed as well. Because of that, I think it'd be a lot nicer to try to integrate with the way other *nix installs are done on OSX: that is, via Fink or MacPorts, or in /usr/local. Besides, if we used something like a $HASKELL_PATH, or a tool for querying and recording installation paths, then it doesn't really matter where the default is since people can choose their own. All that matters is the structure of the tree rooted there. 2) Structure of package pieces I notice that cabal/cabal-install's default layout of where a package's pieces go, and GHC's layout of its base packages don't agree. Further, cabal/cabal-install's are not set up so that one can easily delete an installed package without hunting down its parts. Again, it's good not to mess with system internals (where GHC is the "system" here). In general we *want* Cabal to install things in a different location than the GHC base libraries. Cabal packages can be upgraded and removed and maybe even have multiple versions installed. If someone borks their set of Cabal packages, they shouldn't have to reinstall GHC as well in order to fix things. Similarly, the libraries used by Cabal itself should be separate from the packages for users to use. Both GHC and Cabal libraries could be accessible if the user packages can't satisfy some dependency, but their maintenance should be kept distinct. I'm not saying the current Cabal defaults are the best or shouldn't be changed, but those questions are orthogonal to the issue of interacting with GHC's base libraries. I think it best if everything for a package is in one place - making removal very easy: executables: --prefix--/packages/--pkgid--/bin libraries: --prefix--/packages/--pkgid--/lib/--compiler-- data:--prefix--/packages/--pkgid--/share doc: --prefix--/packages/--pkgid--/doc html:--prefix--/packages/--pkgid--/doc I put the "packages" level at the top, so that other things, like a master Haddock index dir could be put easily directly under the prefix. I would be supportive of a setup with ./packages// as the root of 's files. This is the strategy used by stow[1], as well as texmf trees for LaTeX[2]. It works really well for avoiding and resolving conflicts. There's some development overhead for setting up a tool for merging the trees, but I think it's worth it (i.e., I'd be willing to help write it). The stow approach to tree merging is to symlink everything together into one canonical directory, but that's not the only option. The texmf approach is to direct querie
Re: [Haskell-cafe] install-dirs on Mac OS X
On Dec 22, 2009, at 12:35 PM, Duncan Coutts wrote: > One thing I think I've seen said before however is that things in /Library > and ~/Library are supposed to be app bundles or frameworks or some other > special OSX packaging thing, rather than traditional Unix-style installations. Nope - not true. There are all sorts of things under the Library directories. Again, note the list of other languages that store things under /Library. In those cases, those systems are storing installed packages in just the normal way they would on Linux or other unix systems. On Dec 22, 2009, at 11:49 AM, Tom Tobin wrote: > It usually drives me crazy when my more "Unix-y" tools stick stuff in my > ~/Library/ directory; for instance, I had to actively fight with my copy of > Aquamacs Emacs in order to get everything running from ~/.emacs.d/ rather > than ~/Library/Preferences/Aquamacs Emacs/. I don't know the details, but that sounds inappropriate. If there is no graphic UI for such settings, then ~/Library/Preferences is the wrong place. Apple guidelines[*] are that users should generally not have to poke into ~/Library for normal tasks (such as editing their preferences). As for Haskell, I would suggest that ~/.cabal/config continue to be the location of the user configuration file. Only the installed packages themselves, if installed "--user", would go into ~/Library - since these are files users don't edit or alter once installed. Of course, you'd still be free to easily reconfigure the location back to under ~/.cabal if you like, since those entries would still be in config for your editing, and ghc-pkg doesn't, thankfully, actually care where things are, once told. On Dec 22, 2009, at 2:49 AM, Heinrich Apfelmus wrote: > +1 Excellent. Since there seems to be somewhat an interest in working this out, I've set up a wiki page: http://www.haskell.org/haskellwiki/Mac_OS_X_Common_Installation_Paths - Mark (mtnviewmark) [*] The Apple guidelines for the /Library and ~/Library files are here: http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFileSystem/Articles/LibraryDirectory.html#//apple_ref/doc/uid/20002282-BAJHCHJI Mark Lentczner http://www.ozonehouse.com/mark/ m...@glyphic.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 6.12 on OS X 10.5
Aaron Tomb wrote: I've come across the issue with iconv, as well. The problem seems to be that some versions of iconv define iconv_open and some related functions as macros (that then call libiconv_open, etc.), and some versions of iconv have exported functions for everything. In particular, the iconv bundled with OS X (1.11) defines iconv_open, but the iconv installed with MacPorts (1.13) does not. The binary package for GHC 6.12.1 seems to have been compiled on a system without MacPorts, and therefore references iconv_open (etc.) from the Apple-distributed version of the library. If you set up an installation of GHC 6.12 on OS X (I've only tried 10.5) with no references to /opt/local/lib, everything works fine. If you include /opt/local/lib in the extra-lib-dirs field of your .cabal/config file, it tries to link with the MacPorts version and fails with undefined references. Is this a problem with *versions* of iconv, or with branches/forks? If it's versions, then it seems like migrating to >=1.13 would be good for everyone. If it's just branches, do you know whether this afflicts Fink users as well as MacPorts users, or should I be the guinea pig to test that? -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is it just me... or is cabal/hackage a little broken?
On Dec 22, 2009, at 18:14 , Bardur Arantsson wrote: Warning: This package indirectly depends on multiple versions of the same package. This is highly likely to cause a compile failure. The thing is, I got the same message while trying to compile locally and it turned out that all I had to do was to $ cabal install on all the packages that cabal complained about. So why doesn't hackage do this automagically when I upload a package? How am I supposed to know which versions of my package's dependencies (or their dependencies) are the most recently compiled by hackage? You got lucky; your case can be solved that way. In the general case, you can have packages that work only with certain versions of other packages, and you can potentially end up with nasty unsolvable dependency loops as a result. (Look for "diamond dependency problem" on Google if you want the ugly details.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Children elements with HXT
Adding (a_remove_whitespace,v_1) as a parser option when running solves it. Silly me. Tony Morris wrote: > I am trying to parse XML using HXT following > http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XML > > Here is my XML file (way.xml): > > version="3" changeset="1368552" user="Matt" uid="70"> > > > > > The problem is when parsing, by reading the entries into the > list held by the Way data structure, I cannot get anything but an > empty list. > > Here is my parsing code: > > import Text.XML.HXT.Arrow > > newtype Way = Way { > tags :: [Tag] > } deriving (Eq, Show) > > xpWay :: PU Way > xpWay = xpElem "way" (xpWrap (Way, tags) (xpList xpTag)) > > data Tag = Tag { > k :: String, > v :: String > } deriving (Eq, Show) > > xpTag :: PU Tag > xpTag = xpElem "tag" (xpWrap (uncurry Tag, k &&& v) (xpPair (xpAttr > "k" xpText) (xpAttr "v" xpText))) > > When I run, I get the following result: > > Main> run = runX (xunpickleDocument xpWay [] "way.xml") > [Way {tags = []}] > > Why is the tags list empty instead of holding two entries? > > > -- Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Are functional dependencies around to stay?
The referenced writings are a bit old. I wonder, what are the current plans and decisions (or at least dominating opinions) on FD and TF. And when the equality constraint will be ready. Andrey Stephen Tetley-2 wrote: > > 2009/12/22 Eduard Sergeev : > >> As was previously noted they are supposed to be replaced by type >> families, > > Hi Eduard > > Currently this seems a more like a rumour than a fact - from [1] Type > Families and Fun Deps are equivalently expressive which seems a > worthwhile point to restate. From [2] the Haskell prime committee want > one or the other but not both, and will resolve matters sometime in > the future. > > Best wishes > > Stephen > > [1] > http://www.haskell.org/pipermail/haskell-cafe/2009-February/055890.html > [2] http://www.haskell.org/pipermail/haskell-prime/2008-April/002434.html > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/Are-functional-dependencies-around-to-stay--tp26873777p26895997.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
[Haskell-cafe] Children elements with HXT
I am trying to parse XML using HXT following http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XML Here is my XML file (way.xml): The problem is when parsing, by reading the entries into the list held by the Way data structure, I cannot get anything but an empty list. Here is my parsing code: import Text.XML.HXT.Arrow newtype Way = Way { tags :: [Tag] } deriving (Eq, Show) xpWay :: PU Way xpWay = xpElem "way" (xpWrap (Way, tags) (xpList xpTag)) data Tag = Tag { k :: String, v :: String } deriving (Eq, Show) xpTag :: PU Tag xpTag = xpElem "tag" (xpWrap (uncurry Tag, k &&& v) (xpPair (xpAttr "k" xpText) (xpAttr "v" xpText))) When I run, I get the following result: Main> run = runX (xunpickleDocument xpWay [] "way.xml") [Way {tags = []}] Why is the tags list empty instead of holding two entries? -- Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is it just me... or is cabal/hackage a little broken?
Hi all, Sorry about the inflammatory title, but I just got this message from an uploaded package ("hums"): Warning: This package indirectly depends on multiple versions of the same package. This is highly likely to cause a compile failure. The thing is, I got the same message while trying to compile locally and it turned out that all I had to do was to $ cabal install on all the packages that cabal complained about. So why doesn't hackage do this automagically when I upload a package? How am I supposed to know which versions of my package's dependencies (or their dependencies) are the most recently compiled by hackage? For the record: I did do a "Check package" upload first. It didn't complain. Is this an intractable problem? Am I being overly demanding (probably)? Cheers, Bárður ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with cabal install zlib
On Tue, 2009-12-22 at 21:48 +, Ozgur Akgun wrote: > What about this part: > > -o dist/build/Codec/Compression/ > Zlib/Stream.hs Codec/Compression/Zlib/Stream.hsc > > Isn't it passing multiple (two in this case) output parameters? Or am > I missing sth? No, that's one -o flag and a single additional non-flag argument which is the input file. It's like: $ command input -o output but with the order reversed as: $ command -o output input Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what happend with the docs of base-libs in 6.10.4
On Tue, 22 Dec 2009, Günther Schmidt wrote: Hi, I was just trying to consult my html-documentation of ghc-6.10.4 libraries on Windows. Almost all of the Standard Monads are missing, State, Writer etc. They are (and already were) part of the mtl package. You may install 'mtl' manually (or you may consider 'transformers' alternatively which is Haskell 98).___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] what happend with the docs of base-libs in 6.10.4
Hi, I was just trying to consult my html-documentation of ghc-6.10.4 libraries on Windows. Almost all of the Standard Monads are missing, State, Writer etc. What happened, how do I get them back? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Visible space with lhs2tex
Hello! Does anyone know if it is possible to turn spaces inside strings to visible spaces. That is, format " test" as "\textvisiblespace{}test" With the 'listings' package there's the option 'showspaces'. However, unfortunately this and obvious variations don't work: %format " " = "\textvisiblespace" Thanks in advance! :) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with cabal install zlib
What about this part: -o dist/build/Codec/Compression/ Zlib/Stream.hs Codec/Compression/Zlib/Stream.hsc Isn't it passing multiple (two in this case) output parameters? Or am I missing sth? 2009/12/22 Duncan Coutts > On Mon, 2009-12-21 at 23:08 +, Ozgur Akgun wrote: > > > So what's the recommended thing to do now? > > Please file a ticket in the ghc trac with as much detail as is necessary > for someone else to reproduce this. > > Given what we have at the moment I cannot see the cause of the problem. > >From what you've pasted we can see that Cabal is only calling hsc2hs > with a single -o flag and yet hsc2hs is complaining that we're passing > it multiple -o flags. > > Duncan > > > My output (untouched this time) is as follows: > > > > Preprocessing library zlib-0.5.0.0... > > Creating dist/build/Codec/Compression/Zlib (and its parents) > > /usr/bin/hsc2hs --cc=/usr/bin/gcc --ld=/usr/bin/gcc > > --cflag=-D__GLASGOW_HASKELL__=610 --lflag=-lz > > > --cflag=-I/Users/ozgurakgun/.cabal/lib/bytestring-0.9.1.5/ghc-6.10.4/include > --cflag=-I/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-4.1.0.0/include > --cflag=-I/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include > --lflag=-L/Users/ozgurakgun/.cabal/lib/bytestring-0.9.1.5/ghc-6.10.4 > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-4.1.0.0 > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/integer-0.1.0.1 > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/ghc-prim-0.1.0.0 > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4 > --lflag=-lm --lflag=-lffi --lflag=-lgmp --lflag=-ldl -o > dist/build/Codec/Compression/Zlib/Stream.hs > Codec/Compression/Zlib/Stream.hsc > > Only one output file may be specified > > > > -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Happstack with XML-RPC
Hello, has anybody ever used Happstack as XML-RPC-Server? Perhaps in conjunction with HaXR? I like the architecture of Happstack and would like to use it in a project where I have to use HTML as well as XML-RPC, now to me it would make sense to integrate XML-RPC abilities into Happstack, since HaXR only provides a CGI-based server. Any experiences? BTW, what's the status of HaXR? Is it being actively developed? regards Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] sizeOf on a type
On Fri, 18 Dec 2009, Gregory Crosswhite wrote: Yay, advancePtr is exactly what I needed! I totally missed that one in the docs. Also thanks to those of you who pointed me to the scoped type variables feature, since I had figured that a feature liked that had to exist but I just didn't know where to look for it. You do not need the Scoped Type Variables feature here, although it may simplify writing. I remember we had a similar thread here, recently. A solution can be: sizeOfPtr :: Ptr a -> a -> Int sizeOfPtr _ x = sizeOf x to be called by (sizeOfPtr ptr undefined). I have added this example to: http://www.haskell.org/haskellwiki/Scoped_type_variables#Avoiding_Scoped_Type_Variables But in order to be found in Category:FAQ we might need a different title. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 6.12 on OS X 10.5
On Tue, 2009-12-22 at 07:39 -0800, Aaron Tomb wrote: > Do we need some more flexible options to GHC, giving users more > control on the ordering of libraries on the linker command line? I don't think there is any single ordering that will work. Different packages need libs from different directories. I posted my thoughts about this to the ghc users list: http://haskell.org/pipermail/glasgow-haskell-users/2009-December/018180.html Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with cabal install zlib
On Mon, 2009-12-21 at 23:08 +, Ozgur Akgun wrote: > So what's the recommended thing to do now? Please file a ticket in the ghc trac with as much detail as is necessary for someone else to reproduce this. Given what we have at the moment I cannot see the cause of the problem. >From what you've pasted we can see that Cabal is only calling hsc2hs with a single -o flag and yet hsc2hs is complaining that we're passing it multiple -o flags. Duncan > My output (untouched this time) is as follows: > > Preprocessing library zlib-0.5.0.0... > Creating dist/build/Codec/Compression/Zlib (and its parents) > /usr/bin/hsc2hs --cc=/usr/bin/gcc --ld=/usr/bin/gcc > --cflag=-D__GLASGOW_HASKELL__=610 --lflag=-lz > --cflag=-I/Users/ozgurakgun/.cabal/lib/bytestring-0.9.1.5/ghc-6.10.4/include > --cflag=-I/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-4.1.0.0/include > > --cflag=-I/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include > --lflag=-L/Users/ozgurakgun/.cabal/lib/bytestring-0.9.1.5/ghc-6.10.4 > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-4.1.0.0 > > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/integer-0.1.0.1 > > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/ghc-prim-0.1.0.0 > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4 > --lflag=-lm --lflag=-lffi --lflag=-lgmp --lflag=-ldl -o > dist/build/Codec/Compression/Zlib/Stream.hs Codec/Compression/Zlib/Stream.hsc > Only one output file may be specified ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] install-dirs on Mac OS X
On Mon, 2009-12-21 at 22:55 -0800, Mark Lentczner wrote: > I suggest that the default place for global installs on Mac OS X be: > /Library/Haskell/ As I've mentioned I'm mostly an OSX ignoramus. One thing I think I've seen said before however is that things in /Library and ~/Library are supposed to be app bundles or frameworks or some other special OSX packaging thing, rather than traditional Unix-style installations. If that's the case then I guess we would also want to do that, but I've no idea how much work that is to support in Cabal (and if it would need any extra package info over and above what .cabal files provide). Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with cabal install zlib
That's verrry correct. Sorry for the confusion again. Any more suggestions by the way? 2009/12/22 Tom Tobin > On Mon, Dec 21, 2009 at 5:08 PM, Ozgur Akgun wrote: > > Oh sorry for that character. I wanted to make that part underlined in > gmail > > which uses (i guess) *'s to denote it. Just to emphasise the problematic > > part. > > Yikes — I just checked what Gmail sends as the plain-text alternative > with an HTML email, and it does indeed use asterisks. Many people > have their email clients set to show only the plain-text version of > any email they get, so it's probably best to always use plain text in > the first place for technical discussions. ^_^ > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with cabal install zlib
On Mon, Dec 21, 2009 at 5:08 PM, Ozgur Akgun wrote: > Oh sorry for that character. I wanted to make that part underlined in gmail > which uses (i guess) *'s to denote it. Just to emphasise the problematic > part. Yikes — I just checked what Gmail sends as the plain-text alternative with an HTML email, and it does indeed use asterisks. Many people have their email clients set to show only the plain-text version of any email they get, so it's probably best to always use plain text in the first place for technical discussions. ^_^ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: install-dirs on Mac OS X
On Tue, Dec 22, 2009 at 4:49 AM, Heinrich Apfelmus wrote: > Likewise, ~/Library/Haskell seems to be the best place for user installs. While I don't mind the /Library/Haskell path for global installs, I'm not sure how I feel about this for local installs. It usually drives me crazy when my more "Unix-y" tools stick stuff in my ~/Library/ directory; for instance, I had to actively fight with my copy of Aquamacs Emacs in order to get everything running from ~/.emacs.d/ rather than ~/Library/Preferences/Aquamacs Emacs/. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 6.12 on OS X 10.5
On Dec 22, 2009, at 9:33 AM, Brandon S. Allbery KF8NH wrote: On Dec 22, 2009, at 10:39 , Aaron Tomb wrote: On Dec 21, 2009, at 5:03 PM, Thomas Schilling wrote: It's probably just the search path ordering, no? I.e., if you add something on the command line or in .cabal/config it gets added to the beginning of the search path. Then again, there are cases where you'd want the macports version and others where you'd want the default version. Yes, it's almost certainly just the search path ordering. The problem is to get GHC to use the correct ordering. I've tried exporting LD_LIBRARY_PATH=/usr/lib:/opt/local/lib On OSX you want DYLD_LIBRARY_PATH. Ah, right you are. For the record, though, setting DYLD_LIBRARY_PATH doesn't help, either. Aaron ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: Hemkay, the 100% Haskell MOD player
Patai Gergely schrieb: >> I would do resampling (with some of the Interpolation routines) and >> mixing in two steps, that is I would prepare (lazy) storable vectors >> with the resampled sounds and mix them. > And is that straightforward considering the peculiarities of tracked > music? After all, frequency can change between ticks thanks to > portamento effects, and samples can loop or end in the middle of a tick. > Do I have to trim and pad the samples manually to be able to describe > these transformations? I see no problem. I would generate a frequency and a volume control curve for each channel and apply this to the played instrument, then I would mix it. It is the strength of Haskell to separate everything into logical steps and let laziness do things simultaneously. Stream fusion can eliminate interim lists, and final conversion to storable vector using http://hackage.haskell.org/package/storablevector-streamfusion/ can eliminate lists at all. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] An old package and the new Cabal.
Thanks; this should be enough for me to get it working again. -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Are functional dependencies around to stay?
Hi, Not everyone in the community is keen on replacing functional dependencies with type families. My advice would be to use whichever language construct seems more suitable to your problem and disregard the occasional posts by people claiming that functional dependencies are obsolete or deprecated. -Iavor On Tue, Dec 22, 2009 at 9:18 AM, Eduard Sergeev wrote: > > Hi Stephen, > > > Stephen Tetley-2 wrote: >> Currently this seems a more like a rumour than a fact - from [1] Type >> Families and Fun Deps are equivalently expressive which seems a >> worthwhile point to restate. > > I've got the same impresion initially and was keen to use TF in favor to FD. > And I'm probably missing something here... but here is wiki example which, I > think, gives an example of the 'difference' I was refering to: > http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap (see '2 Notes and > variations', last part). > > As an additional example I can point to Oleg Kiselyov's TypeCast > implementation (http://okmij.org/ftp/Haskell/deepest-functor.lhs), here is > its slightly modified version: > > {-# OPTIONS -fglasgow-exts #-} > {-# OPTIONS -fallow-undecidable-instances #-} > {-# OPTIONS -fallow-overlapping-instances #-} > > module FMAP where > > data Atom > > -- Check if a type is a collection type. This is the only typeclass that > -- needs overlapping instances > class IsCollection t coll | t -> coll > instance IsCollection (m a) (m ()) > instance Atom ~ coll => IsCollection t coll > > -- The desired deep functor. Needs no overlapping instances > class Funct a b c1 c2 | c1 -> a, c1 b -> c2 where > f_map :: (a -> b) -> c1 -> c2 > > instance (IsCollection c1 coll, Funct' coll a b c1 c2) > => Funct a b c1 c2 where > f_map = f_map' (undefined::coll) > > class Funct' coll a b c1 c2 | coll c1 -> a, coll c1 b -> c2 where > f_map' :: coll -> (a -> b) -> c1 -> c2 > > instance Funct' Atom a b a b where > f_map' _ = id > > instance (Functor m, Funct a b c d) => Funct' (m ()) a b (m c) (m d) where > f_map' _ = fmap . f_map > > > test1 = f_map (+1) [[[1::Int,2,3]]] > test2 = f_map not [[True], [False]] > test3 = f_map not (Just [Just True, Nothing]) > test4 = f_map not (print "here" >> > return (Just (Just [Just [True], Nothing]))) > >>= print > > > Still I am not sure how to rewrite this example using Type Families.. > > > -- > View this message in context: > http://old.nabble.com/Are-functional-dependencies-around-to-stay--tp26873777p26891353.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 > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] powering of new types
slemi wrote: > oh well thats pretty straight-forward:) > > the next thing i don't understand is how ghci turns 1 into (Scalar 1). > 1 == (Scalar 1) returns True, which is logical in a way (NOT), but if i > change the type definition to > data Matrix a = Matr {unMatr :: [[a]]} | Lol a | Scalar a > then > 1 == (Scalar 1) still returns True, but > 1 == (Lol 1) returns False, no matter in what order I put them in the > definition... o.O Numeric literals in Haskell are overloaded. 1 really means fromInteger 1. The function fromInteger is defined by instances of Num. This is why you can use a numeric literal wherever your program expects a Double, Int, Integer, and so on. This includes your own type. You have probably defined fromInteger = Scalar for your type. Cheers, Jochem -- Jochem Berndsen | joc...@functor.nl | joc...@牛在田里.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] powering of new types
oh well thats pretty straight-forward:) the next thing i don't understand is how ghci turns 1 into (Scalar 1). 1 == (Scalar 1) returns True, which is logical in a way (NOT), but if i change the type definition to data Matrix a = Matr {unMatr :: [[a]]} | Lol a | Scalar a then 1 == (Scalar 1) still returns True, but 1 == (Lol 1) returns False, no matter in what order I put them in the definition... o.O Felipe Lessa wrote: > > On Tue, Dec 22, 2009 at 09:03:44AM -0800, slemi wrote: >> this allows me to use the (^^) powering operator, which works fine with >> non-zero exponents. >> however to my surprise when i try (^^ 0) the answer is (Scalar 1), and >> not >> the identity matrix as expected. >> does this mean that (a ^^ 0) is not defined as (a ^^ 1 * a ^^ (-1)) (or >> better yet (a / a)) in the prelude? >> if so, can i redefine it so that it gives the right answer? >> i am also very interested in how ghci got the answer (Scalar 1), it seems >> quite magical:) > > (^^ 0) == const 1, see this link: > > http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/src/GHC-Real.html#%5E > > -- > Felipe. > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/powering-of-new-types-tp26891202p26891742.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] powering of new types
On Tue, Dec 22, 2009 at 09:03:44AM -0800, slemi wrote: > this allows me to use the (^^) powering operator, which works fine with > non-zero exponents. > however to my surprise when i try (^^ 0) the answer is (Scalar 1), and not > the identity matrix as expected. > does this mean that (a ^^ 0) is not defined as (a ^^ 1 * a ^^ (-1)) (or > better yet (a / a)) in the prelude? > if so, can i redefine it so that it gives the right answer? > i am also very interested in how ghci got the answer (Scalar 1), it seems > quite magical:) (^^ 0) == const 1, see this link: http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/src/GHC-Real.html#%5E -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 6.12 on OS X 10.5
On Dec 22, 2009, at 10:39 , Aaron Tomb wrote: On Dec 21, 2009, at 5:03 PM, Thomas Schilling wrote: It's probably just the search path ordering, no? I.e., if you add something on the command line or in .cabal/config it gets added to the beginning of the search path. Then again, there are cases where you'd want the macports version and others where you'd want the default version. Yes, it's almost certainly just the search path ordering. The problem is to get GHC to use the correct ordering. I've tried exporting LD_LIBRARY_PATH=/usr/lib:/opt/local/lib On OSX you want DYLD_LIBRARY_PATH. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: Haddock 2.6.0
-- Haddock 2.6.0 A new version of Haddock, the Haskell documentation tool, is out! This is the version that comes with GHC 6.12.1. It contains the main results of Isaac Dupree's Summer of Code project, which are: * Cross-package documentation (exporting something that comes from another package is handled correctly. The full documentation of that thing shows up in your documentation) * Lexing and parsing of Haddock comment markup is moved from GHC back into Haddock. This will make it easier to make changes to the markup format We have decided to drop compatibility with older GHC versions in order to speed up development. -- Full list of changes in version 2.6.0 * Drop support for GHC 6.10.* * Add support for GHC 6.12.1 * Cross-package documentation * Move lexing and parsing of the Haddock comment markup back to Haddock * Slightly prettier printing of instance heads * Support platforms for which GHC has no native code generator * Add a flag --print-ghc-libdir * Minor bug fixes -- Links Homepage: http://www.haskell.org/haddock Hackage page: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haddock-2.6.0 Bugtracker and wiki: http://trac.haskell.org/haddock Mailing list: hadd...@projects.haskell.org Code repository: http://code.haskell.org/haddock -- Contributors The following people contributed patches to this release: Isaac Dupree Ian Lynagh Simon Peyton-Jones David Waern -- Get Involved We would be very happy to get more contributors. To get involved, start by grabbing the code: http://code.haskell.org/haddock Then take a look at the bug and feature tracker for things to work on: http://trac.haskell.org/haddock ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Are functional dependencies around to stay?
Hi Stephen, Stephen Tetley-2 wrote: > Currently this seems a more like a rumour than a fact - from [1] Type > Families and Fun Deps are equivalently expressive which seems a > worthwhile point to restate. I've got the same impresion initially and was keen to use TF in favor to FD. And I'm probably missing something here... but here is wiki example which, I think, gives an example of the 'difference' I was refering to: http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap (see '2 Notes and variations', last part). As an additional example I can point to Oleg Kiselyov's TypeCast implementation (http://okmij.org/ftp/Haskell/deepest-functor.lhs), here is its slightly modified version: {-# OPTIONS -fglasgow-exts #-} {-# OPTIONS -fallow-undecidable-instances #-} {-# OPTIONS -fallow-overlapping-instances #-} module FMAP where data Atom -- Check if a type is a collection type. This is the only typeclass that -- needs overlapping instances class IsCollection t coll | t -> coll instance IsCollection (m a) (m ()) instance Atom ~ coll => IsCollection t coll -- The desired deep functor. Needs no overlapping instances class Funct a b c1 c2 | c1 -> a, c1 b -> c2 where f_map :: (a -> b) -> c1 -> c2 instance (IsCollection c1 coll, Funct' coll a b c1 c2) => Funct a b c1 c2 where f_map = f_map' (undefined::coll) class Funct' coll a b c1 c2 | coll c1 -> a, coll c1 b -> c2 where f_map' :: coll -> (a -> b) -> c1 -> c2 instance Funct' Atom a b a b where f_map' _ = id instance (Functor m, Funct a b c d) => Funct' (m ()) a b (m c) (m d) where f_map' _ = fmap . f_map test1 = f_map (+1) [[[1::Int,2,3]]] test2 = f_map not [[True], [False]] test3 = f_map not (Just [Just True, Nothing]) test4 = f_map not (print "here" >> return (Just (Just [Just [True], Nothing]))) >>= print Still I am not sure how to rewrite this example using Type Families.. -- View this message in context: http://old.nabble.com/Are-functional-dependencies-around-to-stay--tp26873777p26891353.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] Are functional dependencies around to stay?
Semi Off Topic: If the ultimate nature of reality is mathematical, as many physicist say, then everything is mathematical. Then the question must be rephrased to ¿is this or that isomorphic with a mathematical structure powerful enough (general enough, simple enough, but not more) or is out there another better structure?. How much of mathematical discovery, rather than engineering, are in programming languages design ? Merry christmas! 2009/12/22 Stephen Tetley > 2009/12/22 Eduard Sergeev : > > > As was previously noted they are supposed to be replaced by type > families, > > Hi Eduard > > Currently this seems a more like a rumour than a fact - from [1] Type > Families and Fun Deps are equivalently expressive which seems a > worthwhile point to restate. From [2] the Haskell prime committee want > one or the other but not both, and will resolve matters sometime in > the future. > > Best wishes > > Stephen > > [1] > http://www.haskell.org/pipermail/haskell-cafe/2009-February/055890.html > [2] http://www.haskell.org/pipermail/haskell-prime/2008-April/002434.html > ___ > 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
[Haskell-cafe] powering of new types
hey there and thanks for the replies to my earlier question, here is the next one: i have defined both the (*) and (/) operators for my new type data Matrix a = Matr {unMatr :: [[a]]} | Scalar a deriving (Show, Eq) (*) being matrix multiplication and (/) being multiplication with inverse i also defined them for scalars this allows me to use the (^^) powering operator, which works fine with non-zero exponents. however to my surprise when i try (^^ 0) the answer is (Scalar 1), and not the identity matrix as expected. does this mean that (a ^^ 0) is not defined as (a ^^ 1 * a ^^ (-1)) (or better yet (a / a)) in the prelude? if so, can i redefine it so that it gives the right answer? i am also very interested in how ghci got the answer (Scalar 1), it seems quite magical:) here are my operator definitions: instance RealFrac a => Num (Matrix a) where (Matr as) * (Matr bs) = Matr $ timesH as bs (Scalar a) * (Matr b) = Matr $ timesSH a b (Matr a) * (Scalar b) = Matr $ timesSH b a (Scalar a) * (Scalar b) = Scalar (a * b) instance RealFrac a => Fractional (Matrix a) where (Scalar a) / (Scalar b) = Scalar (a / b) (Matr a) / (Scalar b) = Matr $ map (map (/ b)) a a / b | a == b = idM a | otherwise = a * (inv b) liftMatr = (Matr .) . (. unMatr) transH = foldr (zipWith (:)) (repeat []) timesH :: RealFrac a => [[a]] -> [[a]] -> [[a]] timesH as bs = map (\p -> map (foldr1 (+) . zipWith (*) p) (transH bs)) as timesSH :: RealFrac a => a -> [[a]] -> [[a]] timesSH a = map (map (a *)) idM :: RealFrac a => Matrix a -> Matrix a idM = liftMatr idMH idMH :: RealFrac a => [[a]] -> [[a]] idMH as = let n = length as in take n . map (take n) . iterate (0 :) $ 1 :repeat 0 -- View this message in context: http://old.nabble.com/powering-of-new-types-tp26891202p26891202.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] Are functional dependencies around to stay?
2009/12/22 Eduard Sergeev : > As was previously noted they are supposed to be replaced by type families, Hi Eduard Currently this seems a more like a rumour than a fact - from [1] Type Families and Fun Deps are equivalently expressive which seems a worthwhile point to restate. From [2] the Haskell prime committee want one or the other but not both, and will resolve matters sometime in the future. Best wishes Stephen [1] http://www.haskell.org/pipermail/haskell-cafe/2009-February/055890.html [2] http://www.haskell.org/pipermail/haskell-prime/2008-April/002434.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 6.12 on OS X 10.5
On Dec 21, 2009, at 5:03 PM, Thomas Schilling wrote: It's probably just the search path ordering, no? I.e., if you add something on the command line or in .cabal/config it gets added to the beginning of the search path. Then again, there are cases where you'd want the macports version and others where you'd want the default version. Yes, it's almost certainly just the search path ordering. The problem is to get GHC to use the correct ordering. I've tried exporting LD_LIBRARY_PATH=/usr/lib:/opt/local/lib so that /usr/lib comes first. This doesn't seem to help. And it certainly is true that in some cases you want to prefer the MacPorts version, and in some cases you want to prefer the system version. Do we need some more flexible options to GHC, giving users more control on the ordering of libraries on the linker command line? Aaron ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Are functional dependencies around to stay?
Günther Schmidt wrote: > I'm wondering if there is any chance that functional dependencies will > not be around in the future. As was previously noted they are supposed to be replaced by type families, but for me the crucial difference between these two now is that currently type families do not allow overlapping instances "at all" while fundeps can be used with overlapping instances in GHC with -XOverlappingInstances flag.. Not sure how this difference is going to be changed in the future, but I am currently using fundeps because of it (I'd prefer type families otherwise). -- View this message in context: http://old.nabble.com/Are-functional-dependencies-around-to-stay--tp26873777p26889879.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] pointfree-trouble
Am Dienstag 22 Dezember 2009 15:09:34 schrieb slemi: > hello everybody, i'm a newbie this is my first post here.. > > i have trouble making a function pointfree: > > data RealFrac a => Matrix a = Matr [[a]] | Scalar a > deriving (Show, Eq) > > unMatr :: RealFrac a => Matrix a -> [[a]] > unMatr = (\(Matr a) -> a) > > reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) > reMatr a = Matr . (flip (.) unMatr) a > > this works fine, but if i leave the 'a' in the last function's definition > like this: > reMatr = Matr . (flip (.) unMatr) > it gives an error. can anybody tell me why? (i'm using ghci) You want reMatr f = Matr . f . unMatr = (.) Matr (f . unMatr) = (.) Matr ((.) f unMatr) = (.) Matr (flip (.) unMatr f) = (.) Matr ((flip (.) unMatr) f) = (((.) Matr) . (flip (.) unMatr)) f So reMatr = ((.) Matr) . (flip (.) unMatr) Or, as I prefer it, reMatr = (Matr .) . (. unMatr) The point is that g = flip (.) unMatr [or (. unMatr)] takes two arguments, the function f and a matrix m, to yield an argument fitting for Matr, so we need to apply one argument before we can compose it with Matr, hence we compose it with (compose with Matr) = (.) Matr = (Matr .): (Matr .) . g ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How can i set the seed random number generator ?
On Tue, Dec 22, 2009 at 1:16 PM, Scott Turner <1hask...@pkturner.org> wrote: >> In haskell, i just use the following function to get the random number. It >> seems i donot need to set the seed of random number generator manually? >> >> rollDice :: Int -> IO Int >> rollDice n = randomRIO(1,n) > > That's correct. randomRIO uses the global random number generator which is > automatically initialized with a different seed each time your program starts > up. but you can always change it with setStdGen, and you can always use the non-IO part of System.Random (or even another random library altogether, particularly recommended if you need performances as System.Random is more than slow). -- Jedaï ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pointfree-trouble
On Tue, Dec 22, 2009 at 3:09 PM, slemi <0sle...@gmail.com> wrote: > this works fine, but if i leave the 'a' in the last function's definition > like this: > reMatr = Matr . (flip (.) unMatr) The correct point free version would be : > reMatr = (Matr .) . (. unMatr) -- Jedaï ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pointfree-trouble
On Tue, Dec 22, 2009 at 09:27:47AM -0500, Keith Sheppard wrote: > Hello, I didn't try to understand what the function is doing, but just > quickly noticed that > > > reMatr a = Matr . (flip (.) unMatr) a > > can be written as > > reMatr a = Matr . ((flip (.) unMatr) a) ...and then > reMatr a = (Matr .) ((flip (.) unMatr) a) > reMatr a = (Matr .) $ (flip (.) unMatr) a > reMatr = (Matr .) . (flip (.) unMatr) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pointfree-trouble
On Tue, Dec 22, 2009 at 12:50:26AM -0800, Kim-Ee Yeoh wrote: > reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) > reMatr f = Matr . f . unMatr -- this idiom occurs a lot, esp. with > newtypes And usually we would call this 'liftMatr' or something along these lines. The function "lifts" one function from one domain to another one. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pointfree-trouble
Hello, I didn't try to understand what the function is doing, but just quickly noticed that > reMatr a = Matr . (flip (.) unMatr) a can be written as > reMatr a = Matr . ((flip (.) unMatr) a) but that > reMatr = Matr . (flip (.) unMatr) can be written as > reMatr a = (Matr . (flip (.) unMatr)) a so because of precedence rules a different function is being applied to 'a' in the 2 versions Best Keith On Tue, Dec 22, 2009 at 9:13 AM, slemi <0sle...@gmail.com> wrote: > > thanks, that's a really neat syntactic sugar :) > > however, my original question was how to make the reMatr function pointfree, > as > reMatr = Matr . (flip (.) unMatr) > is not working. any ideas/explanation why it doesnt work? > > > Kim-Ee Yeoh wrote: >> >> Here's another way of writing it: >> >> data Matrix a = Matr {unMatr :: [[a]]} | Scalar a deriving (Show, Eq) >> -- RealFrac constraint removed >> >> reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) >> reMatr f = Matr . f . unMatr -- this idiom occurs a lot, esp. with >> newtypes >> >> Affixing constraints to type constructors is typically deprecated. >> >> >> >> slemi wrote: >>> >>> i have trouble making a function pointfree: >>> >>> data RealFrac a => Matrix a = Matr [[a]] | Scalar a >>> deriving (Show, Eq) >>> >>> unMatr :: RealFrac a => Matrix a -> [[a]] >>> unMatr = (\(Matr a) -> a) >>> >>> reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) >>> reMatr a = Matr . (flip (.) unMatr) a >>> >>> this works fine, but if i leave the 'a' in the last function's definition >>> like this: >>> reMatr = Matr . (flip (.) unMatr) >>> it gives an error. can anybody tell me why? (i'm using ghci) >>> >> >> > > -- > View this message in context: > http://old.nabble.com/pointfree-trouble-tp26881661p26888978.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 > -- keithsheppard.name ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pointfree-trouble
thanks, that's a really neat syntactic sugar :) however, my original question was how to make the reMatr function pointfree, as reMatr = Matr . (flip (.) unMatr) is not working. any ideas/explanation why it doesnt work? Kim-Ee Yeoh wrote: > > Here's another way of writing it: > > data Matrix a = Matr {unMatr :: [[a]]} | Scalar a deriving (Show, Eq) > -- RealFrac constraint removed > > reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) > reMatr f = Matr . f . unMatr -- this idiom occurs a lot, esp. with > newtypes > > Affixing constraints to type constructors is typically deprecated. > > > > slemi wrote: >> >> i have trouble making a function pointfree: >> >> data RealFrac a => Matrix a = Matr [[a]] | Scalar a >> deriving (Show, Eq) >> >> unMatr :: RealFrac a => Matrix a -> [[a]] >> unMatr = (\(Matr a) -> a) >> >> reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) >> reMatr a = Matr . (flip (.) unMatr) a >> >> this works fine, but if i leave the 'a' in the last function's definition >> like this: >> reMatr = Matr . (flip (.) unMatr) >> it gives an error. can anybody tell me why? (i'm using ghci) >> > > -- View this message in context: http://old.nabble.com/pointfree-trouble-tp26881661p26888978.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
[Haskell-cafe] pointfree-trouble
hello everybody, i'm a newbie this is my first post here.. i have trouble making a function pointfree: data RealFrac a => Matrix a = Matr [[a]] | Scalar a deriving (Show, Eq) unMatr :: RealFrac a => Matrix a -> [[a]] unMatr = (\(Matr a) -> a) reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) reMatr a = Matr . (flip (.) unMatr) a this works fine, but if i leave the 'a' in the last function's definition like this: reMatr = Matr . (flip (.) unMatr) it gives an error. can anybody tell me why? (i'm using ghci) -- View this message in context: http://old.nabble.com/pointfree-trouble-tp26881661p26881661.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] How can i set the seed random number generator ?
On Monday 21 December 2009 20:37:30 zaxis wrote: > In erlang, first i use the following function to set the seed: > new_seed() -> > {_,_,X} = erlang:now(), > {H,M,S} = time(), > H1 = H * X rem 32767, > M1 = M * X rem 32767, > S1 = S * X rem 32767, > put(random_seed, {H1,M1,S1}). > > then use random:uniform/1 to get the random number. > > In haskell, i just use the following function to get the random number. It > seems i donot need to set the seed of random number generator manually? > > rollDice :: Int -> IO Int > rollDice n = randomRIO(1,n) That's correct. randomRIO uses the global random number generator which is automatically initialized with a different seed each time your program starts up. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: install-dirs on Mac OS X
Mark Lentczner wrote: > I have been thinking about the location of installed Haskell package > files on Mac OS X. The choice of location affects: GHC & other > Haskell implementations Haskell Platform Cabal & cabal-install > Haddock If all those agreed on directory locations and layouts, I > think the state of Haskell on Mac OS X would be nicer for users. In > particular, my hope is for users to end up with an automatically > complete Haddock documentation incorporating everything they install. > > > 1) Packages the user installs --global > > [...] > > I suggest that the default place for global installs on Mac OS X be: > /Library/Haskell/ +1 Likewise, ~/Library/Haskell seems to be the best place for user installs. > 2) Structure of package pieces > > I notice that cabal/cabal-install's default layout of where a > package's pieces go, and GHC's layout of its base packages don't > agree. Further, cabal/cabal-install's are not set up so that one can > easily delete an installed package without hunting down its parts. > > I think it best if everything for a package is in one place - making > removal very easy +1 With this scheme, a package could be changed from user to global by simply drag & drop to the other directory, though that won't work anyway due to dependencies. > 3) Symlinks for binaries > > This does suggest that it would be nice for the symlink-bindir > facility (is that in cabal itself, or added by cabal-install?) to > have a version for --global installs. Users could then either set > something like: symlink-global-bindir: /usr/local/bin in > .cabal/config. > > Or symlink-global-bindir: /Library/Haskell/bin and then put that in > their PATH +1 , considering that folks may also want to install their GHC with MacPorts. Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pointfree-trouble
Here's another way of writing it: data Matrix a = Matr {unMatr :: [[a]]} | Scalar a deriving (Show, Eq) -- RealFrac constraint removed reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) reMatr f = Matr . f . unMatr -- this idiom occurs a lot, esp. with newtypes Affixing constraints to type constructors is typically deprecated. slemi wrote: > > i have trouble making a function pointfree: > > data RealFrac a => Matrix a = Matr [[a]] | Scalar a > deriving (Show, Eq) > > unMatr :: RealFrac a => Matrix a -> [[a]] > unMatr = (\(Matr a) -> a) > > reMatr :: RealFrac a => ([[a]] -> [[a]]) -> (Matrix a -> Matrix a) > reMatr a = Matr . (flip (.) unMatr) a > > this works fine, but if i leave the 'a' in the last function's definition > like this: > reMatr = Matr . (flip (.) unMatr) > it gives an error. can anybody tell me why? (i'm using ghci) > -- View this message in context: http://old.nabble.com/pointfree-trouble-tp26881661p26885392.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] install-dirs on Mac OS X
On Mon, 2009-12-21 at 22:55 -0800, Mark Lentczner wrote: > I have been thinking about the location of installed Haskell package > files on Mac OS X. The choice of location affects: > > [..] > > Thoughts? I'd be happy to help by supplying patches for various tools > to normalize all this on some agreed upon layout. I admit that I'm a > bit unclear where the directory choices are being made: Haskell > Platform's build process, or GHC's? Cabal's defaults or > cabal-install's? And then clearly parts of Haddock. Given the number > of tools that need to agree, seems best that we hash it out (here or > in the wiki) first, before making patches. I just want to say that I think it's great that you're thinking about this. For Cabal the goal is to do the "Right Thing"tm on each platform, so if all you OSX people agree what that right thing is then I'm happy to adjust Cabal's defaults. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe