Re: [GHC] #1958: collect2: ld terminated with signal 10 [Bus error]: Building parsec on a PPC Mac OS X 10.5 Leopard as part of GHC 6.9
#1958: collect2: ld terminated with signal 10 [Bus error]: Building parsec on a PPC Mac OS X 10.5 Leopard as part of GHC 6.9 -+-- Reporter: thorkilnaur | Owner: thorkilnaur Type: bug | Status: new Priority: high | Milestone: 6.8.3 Component: Compiler |Version: 6.9 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: powerpc Os: MacOS X | -+-- Comment (by eelco): Hi Thorkil, I encounter the dreaded 'Bus error' also when trying to build GHC 6.8.2 on PPC OS X 10.5. It fails on the network library when building with extralibs... {{{ ../../compiler/stage1/ghc-inplace -package-name network-2.1.0.0 -hide-all- packages -split-objs -i -idist/build/autogen -idist/build -i. -Idist/build -Iinclude -optc-DCALLCONV=ccall -#include HsNet.h -odir dist/build -hidir dist/build -stubdir dist/build -package base-3.0.1.0 -package parsec-2.1.0.0 -O -DCALLCONV=ccall -XCPP -idist/build -H16m -O -O -Rghc- timing -fgenerics -c Network.hs -o dist/build/Network.o -ohi dist/build/Network.hi collect2: ld terminated with signal 10 [Bus error] ghc: 99622432 bytes, 16 GCs, 4841188/7994224 avg/max bytes residency (3 samples), 21M in use, 0.00 INIT (0.00 elapsed), 1.03 MUT (5.71 elapsed), 0.42 GC (0.55 elapsed) :ghc make[2]: *** [dist/build/Network.o] Error 1 make[1]: *** [make.library.network] Error 2 make: *** [stage1] Error 2 }}} ... and when trying to link HSghc.o in stage 2 when building without the extralibs. {{{ make -C compiler stage=2 /usr/bin/ld -r -x -o HSghc.o stage2/basicTypes/BasicTypes.o ... make[2]: *** [HSghc.o] Bus error make[2]: *** Deleting file `HSghc.o' make[1]: *** [stage2] Error 2 make: *** [bootstrap2] Error 2 }}} I also tried using ld_classic, simply by running ./configure --with- ld=/usr/bin/ld_classic before making. Unfortunately, this causes GHC (stage1) to panic: {{{ ../../compiler/stage1/ghc-inplace -package-name base-3.0.1.0 -hide-all- packages -split-objs -i -idist/build/autogen -idist/build -i. -Idist/build -Iinclude -#include HsBase.h -odir dist/build -hidir dist/build -stubdir dist/build -package rts-1.0 -O -fglasgow-exts -package-name base -XCPP -idist/build -prof -hisuf p_hi -hcsuf p_hc -osuf p_o -H16m -O -O -Rghc- timing -fgenerics -c GHC/PrimopWrappers.hs -o dist/build/GHC/PrimopWrappers.p_o -ohi dist/build/GHC/PrimopWrappers.p_hi ghc-6.8.2: panic! (the 'impossible' happened) (GHC version 6.8.2 for powerpc-apple-darwin): lookupVers1 base:GHC.Prim Int#{tc} }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1958#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #2005: localhost on mac causes getnameinfo error in safari.
#2005: localhost on mac causes getnameinfo error in safari. -+-- Reporter: alex | Owner: Type: bug | Status: new Priority: normal| Milestone: Component: Compiler | Version: 6.8.2 Severity: normal|Keywords: network localhost ipv6 Difficulty: Unknown |Testcase: Architecture: x86 | Os: MacOS X -+-- apparently ruby suffered from this same bug. Some uses of localhost cause the mac to try to use IPv6. The workaround is to use 127.0.0.1 but that is not so nice. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2005 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #1958: collect2: ld terminated with signal 10 [Bus error]: Building parsec on a PPC Mac OS X 10.5 Leopard as part of GHC 6.9
#1958: collect2: ld terminated with signal 10 [Bus error]: Building parsec on a PPC Mac OS X 10.5 Leopard as part of GHC 6.9 -+-- Reporter: thorkilnaur | Owner: thorkilnaur Type: bug | Status: new Priority: high | Milestone: 6.8.3 Component: Compiler |Version: 6.9 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: powerpc Os: MacOS X | -+-- Comment (by eelco): Replying to [comment:6 eelco]: I also tried using ld_classic, simply by running ./configure --with- ld=/usr/bin/ld_classic before making. Unfortunately, this causes GHC (stage1) to panic: Sorry, this must have been caused by something else. A completely clean build with ld_classic fails with the bus error again. {{{ make -f Makefile.ghcbin -r HS_PROG=stage2/ghc-6.8.2 stage2/ghc-6.8.2 ../compiler/stage1/ghc-inplace -o stage2/ghc-6.8.2 -H16m -O -package ghc -Istage2 -cpp -fglasgow-exts -fno-generics -Rghc-timing -I. -IcodeGen -InativeGen -Iparser -Rghc-timing -DGHCI -threaded -fforce-recomp stage2/main/Main.o collect2: ld terminated with signal 10 [Bus error] ghc: 14764812 bytes, 4 GCs, 111888/111888 avg/max bytes residency (1 samples), 16M in use, 0.00 INIT (0.00 elapsed), 0.06 MUT (57.04 elapsed), 0.03 GC (0.07 elapsed) :ghc make[3]: *** [stage2/ghc-6.8.2] Error 1 make[2]: *** [stage2/ghc-6.8.2] Error 2 make[1]: *** [stage2] Error 2 make: *** [bootstrap2] Error 2 }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1958#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #1958: collect2: ld terminated with signal 10 [Bus error]: Building parsec on a PPC Mac OS X 10.5 Leopard as part of GHC 6.9
#1958: collect2: ld terminated with signal 10 [Bus error]: Building parsec on a PPC Mac OS X 10.5 Leopard as part of GHC 6.9 -+-- Reporter: thorkilnaur | Owner: thorkilnaur Type: bug | Status: new Priority: high | Milestone: 6.8.3 Component: Compiler |Version: 6.9 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: powerpc Os: MacOS X | -+-- Comment (by eelco): I finally succeeded doing a GHC 6.8.2 build by running ./configure --with- ld=/usr/bin/ld_classic and a mk/build.mk (copied from the sample) with build flavour 'quickest'. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1958#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #1699: Fix network wrt abstract unix sockets
#1699: Fix network wrt abstract unix sockets ---+ Reporter: [EMAIL PROTECTED] | Owner: Type: proposal | Status: new Priority: normal | Milestone: Not GHC Component: libraries/network |Version: 6.6.1 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: Multiple Os: Linux | ---+ Comment (by kolmodin): The first patch, attachment:network_aus.dpatch, included both switching the use of CInt into CSockLen, and the abstract namespace features, I'm not sure it applies any more. attachment:network_csocklen_cleanup.dpatch has only the CInt to CSockLen changes and should apply to the current darcs repo. The AUS extention will follow in a third patch, once we've decided how we want it structured. The issue is that it looks and behaves very similar to UnixSocket/SockAddrUnix, but only works under the linux platform, not all Unix. To use abstract unix sockets in C you do as usual with the unix socket, but let the address have a leading zero instead of a trailing zero, also it's more picky about the CSockLen as there is no other way to indicate the length of the path. This is also what the first patch reflects, it uses UnixSocket and expects you to prefix your address with byte zero. Is this what we want? Currently I'm more leaning towards adding a new constructor, UnixAbstractSocket/SockAddrAbstUnix, which only would be visible on linux system where the linux kernel feature actually exists. Thus client code using it would require preprocessing to use the constructor when only when adequate. This would make code using this feature on other platforms simply not compile. Good / bad? Let me know. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1699#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: whole program optimization
| Am Sonntag, 23. Dezember 2007 13:35 schrieb Isaac Dupree: | GHC optimizes less effectively when parts of a program are in different | modules, or are exported from a module. | | By the way, does GHC do cross-package optimization (not just cross-module | optimization within packages)? GHC does cross-package inlining just as it does cross-module inlining, which is I guess what you mean. This has the downside that you can't re-link with another version of the same package, even if it exports the same API. But it makes a huge difference to optimization. Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: External Core - my goal
Hi 2) Compile all the associate libraries and modules to generate separate GHC Core files for each. Convert each Core file to Yhc Core. Link the Yhc Core files together. Now that I've read this more carefully -- I think plan (2) is your best bet. In theory, you should be able to do (2) now, using the HEAD. In practice, I'm sure there are bugs in the API code that I just added (and I haven't tested multiple-module programs), so you should try it out and holler Fantastic, will do that in a few days time. (1) has the problem that you would have to implement a demodulizer for Core -- I don't think this would be all that hard, but there would be some of the same issues that exist for demodulizing Haskell, and it would take time. Of course, a Haskell demodulizer, HAllinOne, already exists, so that could be used as a guide. Demodulizing Core should be trivial compared to HAllinOne - but we can leave that for the moment if the other route is closer. Compiling the Core for the libraries should be easy enough. The way I've been doing it for my purposes is by creating a list of all the library Haskell source filenames, and running them through compileToCore (because GHC's automatic dependency-finding won't take care of this for me for package modules.) The main tricky bit for me has been dealing with GHC primitives. There are a lot of them. I don't know whether Catch needs to know what the semantics of the primitives are, though. Catch assumes if a primitive is given all non-_|_ arguments, it returns a non-_|_ result but assumes nothing more. This should be sufficient for most primitives. There is also a mechanism for overriding the definition of certain primitives. I don't expect primitives to be more than a days work, and I can ignore the vast majority of them. Thanks Neil ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: patch applied (cabal): make rawSystemStdout put its temp files in the temp dir rather than cwd
Hi Duncan, (Cross-posting to ghc-users since some of the issues were brought up there.) On Dec 2, 2007, at 5:04 PM, Duncan Coutts wrote: Sun Dec 2 14:06:20 PST 2007 Duncan Coutts [EMAIL PROTECTED] * make rawSystemStdout put its temp files in the temp dir rather than cwd Should fixe reported wierdness with finding program version numbers M ./Distribution/Simple/Utils.hs -2 +4 I saw this problem when trying to build 6.8.1 on a mac (Leopard/Intel) using 6.4 to build compiler. I edited rawSystemStdout to put the tmp files directory in /tmp instead of using getTemporaryDirectory. On this combination of compilers, moving the temporary file did not fix the problem of finding the program version number. The underlying error was that the temp file was reported to still be locked. Building 6.8.2 with another 6.8.2 eliminated the program version problem, but I have seen two other intermittent errors which seem to be related. (Reported in trac as issue #1992.) Building 6.8.2 with 6.8.2 using the MacPorts infrastructure, I get this error about half the time: ../compiler/stage1/ghc-inplace -M -optdep-f -optdep.depend-BASE - osuf o -I../includes -H16m -O -I/opt/local/include -I/usr/include -L/ opt/local/lib -L/usr/lib -iutils -ibasicTypes -itypes -ihsSyn - iprelude -irename -itypecheck -ideSugar -icoreSyn -ivectorise - ispecialise -isimplCore -istranal -istgSyn -isimplStg -icodeGen -imain -iprofiling -iparser -icprAnalysis -indpFlatten -iiface -icmm - inativeGen -ighci -Wall -fno-warn-name-shadowing -fno-warn-orphans - Istage2 -package hpc -package bytestring -DGHCI -package template- haskell -DGHCI_TABLES_NEXT_TO_CODE -package readline -DUSE_READLINE - cpp -fglasgow-exts -fno-generics -Rghc-timing -I. -Iparser -package unix -package Cabal -ignore-package lang -recomp -Rghc-timing -H16M '- #include cutils.h' -package-name ghc-6.8.2 -fgenerics basicTypes/ BasicTypes.lhs basicTypes/DataCon.lhs basicTypes/Demand.lhs basicTypes/ Id.lhs basicTypes/IdInfo.lhs basicTypes/Literal.lhs basicTypes/ MkId.lhs basicTypes/Module.lhs basicTypes/Name.lhs basicTypes/ NameEnv.lhs basicTypes/NameSet.lhs basicTypes/NewDemand.lhs basicTypes/ OccName.lhs basicTypes/RdrName.lhs basicTypes/SrcLoc.lhs basicTypes/ UniqSupply.lhs basicTypes/Unique.lhs basicTypes/Var.lhs basicTypes/ VarEnv.lhs basicTypes/VarSet.lhs cmm/CLabel.hs cmm/Cmm.hs cmm/ CmmBrokenBlock.hs cmm/CmmCPS.hs cmm/CmmCPSGen.hs cmm/CmmCallConv.hs cmm/CmmInfo.hs cmm/CmmLex.hs cmm/CmmLint.hs cmm/CmmLive.hs cmm/ CmmOpt.hs cmm/CmmParse.hs cmm/CmmProcPoint.hs cmm/CmmUtils.hs cmm/ Dataflow.hs cmm/MachOp.hs cmm/PprC.hs cmm/PprCmm.hs codeGen/Bitmap.hs codeGen/CgBindery.lhs codeGen/CgCallConv.hs codeGen/CgCase.lhs codeGen/ CgClosure.lhs codeGen/CgCon.lhs codeGen/CgExpr.lhs codeGen/ CgForeignCall.hs codeGen/CgHeapery.lhs codeGen/CgHpc.hs codeGen/ CgInfoTbls.hs codeGen/CgLetNoEscape.lhs codeGen/CgMonad.lhs codeGen/ CgParallel.hs codeGen/CgPrimOp.hs codeGen/CgProf.hs codeGen/ CgStackery.lhs codeGen/CgTailCall.lhs codeGen/CgTicky.hs codeGen/ CgUtils.hs codeGen/ClosureInfo.lhs codeGen/CodeGen.lhs codeGen/ SMRep.lhs coreSyn/CoreFVs.lhs coreSyn/CoreLint.lhs coreSyn/ CorePrep.lhs coreSyn/CoreSubst.lhs coreSyn/CoreSyn.lhs coreSyn/ CoreTidy.lhs coreSyn/CoreUnfold.lhs coreSyn/CoreUtils.lhs coreSyn/ ExternalCore.lhs coreSyn/MkExternalCore.lhs coreSyn/PprCore.lhs coreSyn/PprExternalCore.lhs cprAnalysis/CprAnalyse.lhs deSugar/ Check.lhs deSugar/Coverage.lhs deSugar/Desugar.lhs deSugar/ DsArrows.lhs deSugar/DsBinds.lhs deSugar/DsCCall.lhs deSugar/ DsExpr.lhs deSugar/DsForeign.lhs deSugar/DsGRHSs.lhs deSugar/ DsListComp.lhs deSugar/DsMeta.hs deSugar/DsMonad.lhs deSugar/ DsUtils.lhs deSugar/Match.lhs deSugar/MatchCon.lhs deSugar/ MatchLit.lhs ghci/ByteCodeAsm.lhs ghci/ByteCodeFFI.lhs ghci/ ByteCodeGen.lhs ghci/ByteCodeInstr.lhs ghci/ByteCodeItbls.lhs ghci/ ByteCodeLink.lhs ghci/Debugger.hs ghci/GhciMonad.hs ghci/GhciTags.hs ghci/InteractiveUI.hs ghci/Linker.lhs ghci/ObjLink.lhs ghci/ RtClosureInspect.hs hsSyn/Convert.lhs hsSyn/HsBinds.lhs hsSyn/ HsDecls.lhs hsSyn/HsDoc.hs hsSyn/HsExpr.lhs hsSyn/HsImpExp.lhs hsSyn/ HsLit.lhs hsSyn/HsPat.lhs hsSyn/HsSyn.lhs hsSyn/HsTypes.lhs hsSyn/ HsUtils.lhs iface/BinIface.hs iface/BuildTyCl.lhs iface/IfaceEnv.lhs iface/IfaceSyn.lhs iface/IfaceType.lhs iface/LoadIface.lhs iface/ MkIface.lhs iface/TcIface.lhs main/BreakArray.hs main/CmdLineParser.hs main/CodeOutput.lhs main/Config.hs main/Constants.lhs main/ DriverMkDepend.hs main/DriverPhases.hs main/DriverPipeline.hs main/ DynFlags.hs main/ErrUtils.lhs main/Finder.lhs main/GHC.hs main/ HeaderInfo.hs main/HscMain.lhs main/HscStats.lhs main/HscTypes.lhs main/InteractiveEval.hs main/Main.hs main/PackageConfig.hs main/ Packages.lhs main/ParsePkgConf.hs main/PprTyThing.hs main/ StaticFlags.hs main/SysTools.lhs main/TidyPgm.lhs nativeGen/ AsmCodeGen.lhs nativeGen/GraphBase.hs nativeGen/GraphColor.hs
Rank-2 polymorphism and pattern matching
The following won't compile for me isnull :: (forall a . [a]) - Bool isnull ([] :: forall b . [b]) = True Couldn't match expected type `forall b. [b]' against inferred type `[a]' In the pattern: [] Wrapping it in a constructor doesn't help, though I can define a null: data NullList = NullList (forall a . [a]) null = NullList [] isnull2 :: NullList - Bool isnull2 (NullList []) = True Why? Jim ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell] Postdoctoral position at INRIA Nancy (France)
Linguistic Field(s): Computational Linguistics Topic: Surface realisation and large scale over-generation detection Deadline: February 15, 2008. Employer: INRIA (French National Institute for Research in Computer Science) Nancy Grand Est (France) Job Description: The Lorraine Laboratory of IT Research and its Applications (Nancy, France) has a position for a Postdoctoral fellow to work on the development of a surface realiser for French. Applicants must have a ** recent doctoral degree ** (Doctoral thesis less than one year old before the recruitment's date) or defend their PhD before the end of 2008. They must have expertise in an area relevant to the project (linguistics, computational linguistics, computer science), strong hands-on experience in Natural Language Processing and a particular interest in NL generation. A good knowledge of Haskell is a necessity. Further particulars and details of how to apply are available at: http://www.loria.fr/~gardent The official closing date is February 15, 2007, but applications will be processed until the position is filled. Contact:Claire Gardent [EMAIL PROTECTED] -- Eric Kow PGP Key ID: 08AC04F9 ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
On Dec 27, 2007 2:20 PM, Jorge Marques Pelizzoni [EMAIL PROTECTED] wrote: The problem is, when you declare an empty instance, all functions (if any) assume their default definitions. Therefore, when you call show/showsPrec (even indirectly) you end up in an endless loop because of (ii). I agree with you that it'd be best if this sort of thing were detected at compile time, but it ultimately boils down to automatically detecting non-terminating programs... By the way, I haven't heard of a language that tackles the same problem differently. This is definitely not the same as detecting non-terminating programs, it's a case of wanting to add expressiveness so that the minimal instance defines either show or showsPrec could be placed in the code instead of in haddock, and ghc could at minimum generate a warning in this situation. Class designers would be delighted to be able to add this sort of information, and no longer have this tradeoff between making it easy to write correct instances and making it hard to write incorrect instances. The trouble, of course, is that classes could have rather complicated minimum instance requirements. Still, if someone came up with a decent syntax such as (but better than) class Foo f where foo :: f foo = bar bar :: f bar = foo requiring ( foo || bar ) it would be very nice. The trouble, of course, is deciding how expressive to make the requirements. David ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
David Roundy wrote: The trouble, of course, is that classes could have rather complicated minimum instance requirements. Still, if someone came up with a decent syntax such as (but better than) class Foo f where foo :: f foo = bar bar :: f bar = foo requiring ( foo || bar ) it would be very nice. The trouble, of course, is deciding how expressive to make the requirements. probably a pragma, since it only affects warnings. And it seems like each class only has a finite number of functions, so a Boolean expression should be able to express the full range of possibilities with ( || , , not , True , False ); and combinations that are complicated to express with those, aren't very common, due to the structure of the problem. class Foo f where {-# MINIMAL_INSTANCE foo || bar #-} foo :: f foo = bar bar :: f bar = foo I wonder whether it would be safe for the compiler to infer simply by the default methods mentioning each other in a cycle. It might miss some cases when (probably involving laziness) the default methods actually terminate and form an intended set of implemention, and warn when it shouldn't... which is bad, but does that ever happen? Isaac ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
Hi The trouble, of course, is that classes could have rather complicated minimum instance requirements. Still, if someone came up with a decent syntax such as (but better than) You don't need a syntax, the information is already there. You also don't need to do complicated non-termination analysis. Taking the slightly simpler example of: class Eq a where a == b = not (a /= b) a /= b = not (a == b) From this example its clear that (==) depends on (/=) and that (/=) depends on (==). i.e. its obvious they form a cycle. If the default methods form a cycle, and the user has not broken that cycle by inserting a real implementation, that's almost certainly a bug - I'd go as far as to say its an error rather than a warning. Thanks Neil ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
You may be interested in a trick relating to type classes which can address this issue, though it's not the Haskell way to do it. You can define Show as a data type, rather than a type class: type Show a = Either (a - String) (Int - a - String - String) show :: Show a - a - String show (Left s) x = s x show (Right sp) x = sp 0 x showsPrec :: Show a - Int - a - String - String showsPrec (Left s) n a str = s a ++ str showsPrec (Right sp) n a str = sp n a str A function using this class would take it as its first argument: print :: Show a - a - IO () The constructors for Show make explicit the two ways to define an instance. This technique also has the advantage of allowing multiple, non-conflicting instance declarations, selectable at runtime. Using Show as an example, you might have instances representing both formatted and unformatted display. An obvious disadvantage is that the instance needs a name and gets passed explicitly. Mike On Thu, Dec 27, 2007 at 04:34:06PM +, Hugo Macedo wrote: Dear all A student from a beginners course on Functional Programming came to me with a problem, he declared a type like: data WeekDay = Mon | Tue | Fri -- ... He had forgot to complete a Show instance definition. instance Show WeekDay where (empty) Then he complained about getting *** Exception: stack overflow when he tried to invoke some function on that type. After checking the Haskell98 grammar I found out that this is allowed syntactically and probably semantically too. Is there any reason to do that? Now I'm wondering: Shouldn't a class be an warranty of a well defined interface? Thus forcing the user to define the show function or showPrec? Am I missing any point? My best regards, Hugo ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
On Dec 28, 2007 5:14 PM, Mike Haskel [EMAIL PROTECTED] wrote: You can define Show as a data type, rather than a type class: type Show a = Either (a - String) (Int - a - String - String) ... The constructors for Show make explicit the two ways to define an instance. This technique also has the advantage of allowing multiple, non-conflicting instance declarations, selectable at runtime. Using Show as an example, you might have instances representing both formatted and unformatted display. An obvious disadvantage is that the instance needs a name and gets passed explicitly. Seems to me that using Either is entirely orthogonal from type-vs-class :-) class Show a where show0 :: Either (a - String) (Int - a - String - String) show :: Show a = a - String show = case show0 of Left s - s Right sp - \x - sp 0 x etc. - Benja ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
Isaac wrote: I wonder whether it would be safe for the compiler to infer simply by the default methods mentioning each other in a cycle. It might miss some cases when (probably involving laziness) the default methods actually terminate and form an intended set of implemention, and warn when it shouldn't... which is bad, but does that ever happen? mentioning each other in a cycle is too imprecise unfortunately at least for two reasons: a) we could face a well-designed mutual recursion. b) we could face co-induction. The ultimate solution is to extend type signatures by termination requirements and to have a termination checker enforcing them. For instance, Andreas Abel has done groundbreaking work on termination checking. Cheers, Ralf ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
Ralf Laemmel wrote: Isaac wrote: I wonder whether it would be safe for the compiler to infer simply by the default methods mentioning each other in a cycle. It might miss some cases when (probably involving laziness) the default methods actually terminate and form an intended set of implemention, and warn when it shouldn't... which is bad, but does that ever happen? mentioning each other in a cycle is too imprecise unfortunately at least for two reasons: a) we could face a well-designed mutual recursion. b) we could face co-induction. I know! I said so! My question is whether anyone has an example of doing either of those in mutually-recursive DEFAULT METHOD definitions? sorry for yelling You did not say anything that's imprecise about mentioning each other in a cycle, just the well-known fact that it's not equivalent to total termination checking (in fact, it's neither fully an overestimate nor underestimate of termination -- it's just an estimate that's likely to be right when used in the context of default method definitions). Isaac ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Empty instance declaration
Neil Mitchell wrote: The trouble, of course, is that classes could have rather complicated minimum instance requirements. Still, if someone came up with a decent syntax such as (but better than) You don't need a syntax, the information is already there. You also don't need to do complicated non-termination analysis. Taking the slightly simpler example of: class Eq a where a == b = not (a /= b) a /= b = not (a == b) From this example its clear that (==) depends on (/=) and that (/=) depends on (==). i.e. its obvious they form a cycle. Ah, but it's not clear at all :) How about something wicked like class UselessEq a where (==), (/=) :: Bool - a - Bool True == b = b a == b = not (a /= b) False /= b = b a /= b = not (a == b) This may be useless but I wouldn't be surprised if interesting examples utilizing polymorphic recursion or multi parameter type classes exist. Regards, apfelmus ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
You did not say anything that's imprecise about mentioning each other in a cycle, just the well-known fact that it's not equivalent to total termination checking (in fact, it's neither fully an overestimate nor underestimate of termination -- it's just an estimate that's likely to be right when used in the context of default method definitions). It's imprecise also in so far that you would need to define what you mean by it. Does it mean that we focus on the pattern f ... = g ... g ... = f ... ... or does it include the case f ... = h g ... g ... = f ... ... and that's still very imprecise because the dots don't mean anything proper. Are you willing to look at the pattern *after* overloading resolution. Let's have a proper termination checker! Btw, obviously a class by itself would not be checked (in terms of the default methods), but only an instance (with the defaults pulled in). Cheers, Ralf ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
Neil Mitchell wrote: If the default methods form a cycle, and the user has not broken that cycle by inserting a real implementation, that's almost certainly a bug - I'd go as far as to say its an error rather than a warning. I'd agree except that instance Num () where with no specified definitions is already allowed in Haskell and can only generate warnings in GHC already. Isaac ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
Ralf Laemmel wrote: You did not say anything that's imprecise about mentioning each other in a cycle, just the well-known fact that it's not equivalent to total termination checking (in fact, it's neither fully an overestimate nor underestimate of termination -- it's just an estimate that's likely to be right when used in the context of default method definitions). It's imprecise also in so far that you would need to define what you mean by it. Does it mean that we focus on the pattern f ... = g ... g ... = f ... ... or does it include the case f ... = h g ... g ... = f ... yes it does. It also probably includes f ... = ... where _ignored1 = g g ... = ... where _ignored2 = f Predictability is a good thing, I think although class where f ... = g ... g ... = h ... h ... = f ... gets more complicated, but 'h' does have to be defined in the same module or module-cycle, because it refers to the class and the class refers to it ... and that's still very imprecise because the dots don't mean anything proper. Are you willing to look at the pattern *after* overloading resolution. good point. I think GHC can know when it refers to the same instance. Let's have a proper termination checker! I think GHC already does, in its strictness analyzer? An incomplete checker of course, because termination checking of Haskell, like of most languages, is undecidable in general. Btw, obviously a class by itself would not be checked (in terms of the default methods), but only an instance (with the defaults pulled in). the class would at most be analyzed to see which were the minimal methods to implement -- it's warnings about instances that we've been talking about, anyway Isaac ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
On Dec 28, 2007, at 12:06 PM, Ralf Laemmel wrote: You did not say anything that's imprecise about mentioning each other in a cycle, just the well-known fact that it's not equivalent to total termination checking (in fact, it's neither fully an overestimate nor underestimate of termination -- it's just an estimate that's likely to be right when used in the context of default method definitions). [The hard general cases] ... and that's still very imprecise because the dots don't mean anything proper. Are you willing to look at the pattern *after* overloading resolution. Let's have a proper termination checker! It occurs to me to ask: would returns bottom given non-bottom arguments according to strictness analysis be good enough? Because that information is useful for other things as well, and relatively easy to compute using strictness analysis. Then extra pragmas might be as simple as pragmas saying yes, compiler, I expect the following function to return _|_---again an annotation that has other potential uses. -Jan-Willem Maessen ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
G'day all. Quoting Hugo Macedo [EMAIL PROTECTED]: After checking the Haskell98 grammar I found out that this is allowed syntactically and probably semantically too. Is there any reason to do that? One thing that hasn't come up yet is that empty instance declarations are the only decent option (that I know of) that we have in the absence of real class aliases. Here's an example from Dfa.lhs, which could probably be written slightly more simply now: {-# OPTIONS -fglasgow-exts #-} {-# OPTIONS -fallow-undecidable-instances #-} import Control.Monad.Identity import Control.Monad.Reader import Control.Monad.State data (Ord t) = ReRead t = {- detail unimportant -} data (Ord t) = ReState t = {- detail unimportant -} type ReM m t a = StateT (ReState t) (ReaderT (ReRead t) m) a class (Monad m, Ord t) = ReVars m t where { } instance (Monad m, Ord t) = ReVars m t where { } remNullSet :: (ReVars m t) = ReM m t (SimplRe t) {- etc -} class (ReVars m t, MonadIO m, Show t) = ReVarsIO m t where { } instance (ReVars m t, MonadIO m, Show t) = ReVarsIO m t where { } remDump :: (ReVarsIO m t) = ReM m t () {- etc -} Cheers, Andrew Bromage ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Empty instance declaration
G'day all. Quoting Isaac Dupree [EMAIL PROTECTED]: I know! I said so! My question is whether anyone has an example of doing either of those in mutually-recursive DEFAULT METHOD definitions? class (Eq a) = StupidEqList a where eqList :: [a] - [a] - Bool neqList :: [a] - [a] - Bool eqList [] [] = True eqList (x:xs) (y:ys) = x == y not (neqList xs ys) eqList _ _ = False neqList [] [] = False neqList (x:xs) (y:ys) = x /= y || not (eqList xs ys) neqList _ _ = True Stupid, but not illegal. Cheers, Andrew Bromage ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Re: Wikipedia on first-class object
There's no (valid) formalism that says that [n..]==[n..] is True. The formalism says that [n..] and [n..] are equal. But being equal does not mean that the Haskell (==) function returns True. The (==) function is just an approximation of semantic equality (by necessity). -- Lennart On Dec 28, 2007 3:38 AM, Albert Y. C. Lai [EMAIL PROTECTED] wrote: Achim Schneider wrote: [n..] == [m..], the first thing I notice is n == m n+1 == m+1 , which already expresses all of infinity in one instance and can be trivially cancelled to n == m , which makes the whole darn thing only _|_ if n or m is _|_, which no member of [n..] can be as long as n isn't or 1 or + has funny ideas. I finally begin to understand my love and hate relationship with formalisms: It involves cuddling with fixed points while protecting them from evil data and fixed points they don't like as well as reduction strategies that don't see their full beauty. There is a formalism that says [n..]==[n..] is true. (Look for co-induction, observational equivalence, bismulation, ...) There is a formalism that says [n..]==[n..] is _|_. We know of implemented programming languages that can give an answer according to the latter formalism. If you know of an implemented programming language that can give an answer according to the former formalism, and not just for the obvious [n..] but also map f xs == map g xs (for example), please spread the news. So it comes down to which formalism, not whether formalism. I have long known the problem with informalisms. They are full of I know, obviously, and ought to be. It is too tempting to take your wit for granted. When you make a deduction, you don't easily see whether it is one of a systemtic family of deductions or you are just cunning. You only see what you can do; you don't see what you can't do, much less what you can't make a computer do. Formalisms do not tolerate such self-deception. You think something ought to be obvious? Write them down as axioms. Now with all your obviousness nailed down black on white, you have a solid ground on which to ask: what can be done, what can't be done, what can be done on a computer, how practical is it? Humility and productivity are thus restored. ___ 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] Re: Wikipedia on first-class object
Questions: The fact that Haskell functions are monotone continuous functions on pointed complete partial orders imply this ? - every domain in Haskell is a pointed complete partial order, including domains of functions ? Right. - the structure of a domain is preserved in the result when you apply a Haskell function to it ? Right, if your structure means complete partial order. Note that (_|_) (the least element in this order) is not necessarily preserved. - every domain can be enumerated ? Ehm... No. Well, it depends on what you mean by enumeration. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
G'day all. Quoting Achim Schneider [EMAIL PROTECTED]: And if it wouldn't? After all, arguing that |N == |N is undefined because it takes too long to check would earn you a straight F in any math test. That's only because you spelled it incorrectly for the purpose of a maths test. Had you written this: \[ (\N =_w \N) = \bot \] you'd be on firmer ground. Cheers, Andrew Bromage ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
How can I test that partial order in Haskell ? You can't. It's kinda internal. More specifically, if you try to compute a value, which is not maximal in this order, you'll get an error or loop forever. But you still can use such values in your programs if you don't try to compute them. The point is, maximal values are the only interesting ones, and all others are just approximations. In fact, you only have to worry about non-maximal values when you use recursion. The fundamental property of Haskell is that it computes the least fixed point. For example, if f maps (_|_) to (_|_), then let x = f x in x will evaluate to (_|_) - and you loop forever, see above. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
Thank you. It sounds like a limit. xn -- x for n -- :-) How can I get that maximal value when I start from a non maximal one ? [1 .. ] and x=1:x are maximal ? On Fri, 28 Dec 2007 11:21:36 +0200, Miguel Mitrofanov [EMAIL PROTECTED] wrote: How can I test that partial order in Haskell ? You can't. It's kinda internal. More specifically, if you try to compute a value, which is not maximal in this order, you'll get an error or loop forever. But you still can use such values in your programs if you don't try to compute them. The point is, maximal values are the only interesting ones, and all others are just approximations. In fact, you only have to worry about non-maximal values when you use recursion. The fundamental property of Haskell is that it computes the least fixed point. For example, if f maps (_|_) to (_|_), then let x = f x in x will evaluate to (_|_) - and you loop forever, see above. Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On 28/12/2007, at 4:21 PM, Miguel Mitrofanov wrote: How can I test that partial order in Haskell ? You can't. It's kinda internal. More specifically, if you try to compute a value, which is not maximal in this order, you'll get an error or loop forever. But you still can use such values in your programs if you don't try to compute them. The point is, maximal values are the only interesting ones, and all others are just approximations. Right, so when I say to GHCi: Prelude take 5 [1..] and it says: [1,2,3,4,5] then it really has computed the entirety of the infinite sequence [1..], and not some approximation? Perhaps it is better to say that in a lazy language both approximations and maximal values (least upper bounds of a chain) are interesting. In a strict language we only get our hands on the latter. The take lemma nicely captures this kind of thinking. (Ask google about the generalised take lemma, it's a nice paper.) Also note that the notion of equality that's being thrown around is observational equality, i.e. x=y implies that for all contexts (some expression with a suitably-typed hole), if you plug 'x' into the hole, and 'y' into hole, then those two expressions denote the same value. ((Roughly) equivalently, you can use the idea of Leibniz equality: there is no function that distinguishes them. These notions may diverge in Haskell - does anyone know?) As Lennart observed, any (semi-)computable equality predicate is not going to be that strong. cheers peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
It sounds like a limit. xn -- x for n -- :-) Yeah, that's right. How can I get that maximal value when I start from a non maximal one ? Not a problem. For example, const 1 maps each value (even (_|_)) to the maximal value 1. [1 .. ] and x=1:x are maximal ? Yes. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 12:01:51 +0200, Miguel Mitrofanov [EMAIL PROTECTED] wrote: It sounds like a limit. xn -- x for n -- :-) Yeah, that's right. If xn is monotone, then I only have to worry when it is not bounded, right ? How can I get that maximal value when I start from a non maximal one ? Not a problem. For example, const 1 maps each value (even (_|_)) to the maximal value 1. [1 .. ] and x=1:x are maximal ? Can you give me some examples of non maximal ones ? Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
Thank you. This is what I understand so far: - the maximal values is what is usually called data - the non maximal are what is usually called code - in functional languages one can be given non maximal values (code) as input Is that right ? On Fri, 28 Dec 2007 12:01:51 +0200, Miguel Mitrofanov [EMAIL PROTECTED] wrote: It sounds like a limit. xn -- x for n -- :-) Yeah, that's right. How can I get that maximal value when I start from a non maximal one ? Not a problem. For example, const 1 maps each value (even (_|_)) to the maximal value 1. [1 .. ] and x=1:x are maximal ? Yes. Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 12:01:51 +0200, Miguel Mitrofanov [EMAIL PROTECTED] wrote: [1 .. ] and x=1:x are maximal ? Yes. How can a Haskell implementation recognize a maximal value ? x=1:x for example. Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
Right, so when I say to GHCi: Prelude take 5 [1..] and it says: [1,2,3,4,5] then it really has computed the entirety of the infinite sequence [1..], and not some approximation? Of course not! In fact, it doesn't even compute the value 1. It just juggles with the bytes somehow, so that it seems that it computes the whole sequence and then applies take 5. But does it really matter if it computes 5 integers, or 10, or the whole sequence, at least if we are not concerned about performance? Perhaps it is better to say that in a lazy language both approximations and maximal values (least upper bounds of a chain) are interesting. Well, that depends of your notion of interesting. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Wikipedia on first-class object
Cristian Baboi wrote: http://en.wikipedia.org/wiki/First-class_object The term was coined by Christopher Strachey in the context of “functions as first-class citizens” in the mid-1960's.[1] Depending on the language, this can imply: 1. being expressible as an anonymous literal value 2. being storable in variables 3. being storable in data structures 4. having an intrinsic identity (independent of any given name) 5. being comparable for equality with other entities 6. being passable as a parameter to a procedure/function 7. being returnable as the result of a procedure/function 8. being constructable at runtime 9. being printable 10. being readable 11. being transmissible among distributed processes 12. being storable outside running processes I'll guess that 5,9,12 does not apply to Haskell functions. Exactly, together with 10 and 11 (when the distributed processes are on different machines). But there is good reason that those things can't be done in Haskell. With extensional equality (two functions are considered equal if they yield the same result on every possible argument) number 5 is undecidable. Similarly, there cannot be functions print :: (Int - Int) - String compile :: String - (Int - Int) with compile . print = id A print function based on an intensional representation (assembly, byte code, etc.) would have to distinguish extensionally equal functions print f ≠ print g although f = g which is not allowed. More importantly, I don't quite understand your question. If you definitively need 9-12 for a practical problem at hand, then you may want to take a look at the functional language Clean http://clean.cs.ru.nl/ which is similar to Haskell but offers 9-12 in some form. In all other cases, an email thread is not a good (often not even successful) way to get a coherent world view on Haskell (or on something else) since this necessarily involves nitpicking philosophical questions. In my experience, interrogating one person in real-time in audio and interrogating books are the best ways to do that. Concerning books, maybe The Haskell Road to Logic, Maths and Programming http://www.cwi.nl/~jve/HR is for you. More books on http://haskell.org/haskellwiki/Books You don't have to buy them, borrow them from a library. Regards, apfelmus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
It sounds like a limit. xn -- x for n -- :-) Yeah, that's right. If xn is monotone, then I only have to worry when it is not bounded, right ? Sorry, don't understand what you mean. Yes, the monotone sequence has a limit. No, it's not necessarily maximal. [1 .. ] and x=1:x are maximal ? Can you give me some examples of non maximal ones ? let x = x+1 in x Or even let x = x in x In both cases, (_|_) is the least fixed point, and is non-maximal. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Doing some things right
Don Stewart wrote: A Wake Up Call for the Logic Programming Community Or what the logic programming community can learn from the Haskell community (in particular): http://www.cs.kuleuven.ac.be/%7Edtai/projects/ALP//newsletter/dec07/content/Articles/tom/content.html Interesting read! Haskell is the undisputed flagship of the FP community. Er... really? I thought Lisp and Erlang were both infinitely more popular and better known. Followed by Clean and O'Camal. Indeed, until I stumbled across an article on Wikipidia quite by chance, I'd never even *heard* of this thing called Haskell. (Note to self: Add more links to the Haskell page on Wikipedia...) [I actually heard a number of people tell me that learning LISP would change my life forever because LISP has something called macros. I tried to learn it, and disliked it greatly. It's too messy. And what the heck is cdr ment to mean anyway? To me, LISP doesn't even seem all that different from normal languages (modulo weird syntax). Now Haskell... that's FUN!] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] what does @ mean?.....
Hello, I wonder if someone could answer the following... The short question is what does @ mean in mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig The long version, explaining what everything means is here's a definition of multiplication on natural numbers I'm reading on a blog data Nat = Z | S Nat deriving Show one :: Nat one = (S Z) mulNat :: Nat - Nat - Nat mulNat _ Z = Z mulNat Z _ = Z mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig Haskell programmers seem to have a very irritating habit of trying to be overly concise...which makes learnign the language extremely hard...this example is actually relatively verbosebut anyway... Z looks like Zero...S is the successor function...Nat are the Natural numbers. mulNat _ Z = Z mulNat Z _ = Z translates to... x * 0 = 0fine... 0 * x = 0fine.. mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig is a bit more problematic... lets take a as 3 and b as 5... so now we have mulNat' 3 5 5 but what does the x@(S a) mean? in mulNat' x@(S a) y orig From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark Sent: 21 December 2007 17:47 To: David Menendez Cc: Jules Bean; haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] nice simple problem for someone struggling Let me resend the code...as it stands module Main where data SquareType numberType = Num numberType = SquareConstructor numberType class ShapeInterface shape where area :: Num numberType = shape-numberType data ShapeType = forall a. ShapeInterface a = ShapeType a instance (Num a) = ShapeInterface (SquareType a) where area (SquareConstructor side) = side * side and the errors are for the instance declaration... [1 of 1] Compiling Main ( Main.hs, C:\Documents and Settings\nichom\Haskell\Shapes2\out/Main.o ) Main.hs:71:36: Couldn't match expected type `numberType' against inferred type `a' `numberType' is a rigid type variable bound by the type signature for `area' at Main.hs:38:15 `a' is a rigid type variable bound by the instance declaration at Main.hs:70:14 In the expression: side * side In the definition of `area': area (SquareConstructor side) = side * side I'm becoming lost in errors I don't comprehend What bamboozles me is it seemed such a minor enhancement. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Menendez Sent: 21 December 2007 17:05 To: Nicholls, Mark Cc: Jules Bean; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] nice simple problem for someone struggling On Dec 21, 2007 11:50 AM, Nicholls, Mark [EMAIL PROTECTED] wrote: Now I have module Main where data SquareType numberType = Num numberType = SquareConstructor numberType This is a valid declaration, but I don't think it does what you want it to. The constraint on numberType applies only to the data constructor. That is, given an unknown value of type SquareType a for some a, we do not have enough information to infer Num a. For your code, you want something like: instance (Num a) = ShapeInterface (SquareType a) where area (SquareConstructor side) = side * side -- Dave Menendez [EMAIL PROTECTED] http://www.eyrie.org/~zednenem/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On 28/12/2007, at 5:50 PM, Miguel Mitrofanov wrote: Right, so when I say to GHCi: Prelude take 5 [1..] and it says: [1,2,3,4,5] then it really has computed the entirety of the infinite sequence [1..], and not some approximation? Of course not! In fact, it doesn't even compute the value 1. It just juggles with the bytes somehow, so that it seems that it computes the whole sequence and then applies take 5. But does it really matter if it computes 5 integers, or 10, or the whole sequence, at least if we are not concerned about performance? I'll bite. So what do you expect: take 5 [1,2,3,4,5,undefined] to do? How about: take 5 (1:2:3:4:undefined) ? So it does seem to matter how much of the list it evaluates... Perhaps it is better to say that in a lazy language both approximations and maximal values (least upper bounds of a chain) are interesting. Well, that depends of your notion of interesting. I defined it - I'm interested in things that are observationally equivalent. Please read the generalised-take-lemma paper. It will clear up some of this confusion. cheers peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what does @ mean?.....
@ works as an aliasing primitive for the arguments of a function f x@(Just y) = ... using x in the body of f is equivalent to use Just y. Perhaps in this case is not really useful, but in some other cases it saves the effort and space of retyping really long expressions. And what is even more important, in case an error is made when choosing the pattern, you only have to correct it in one place. On Dec 28, 2007 12:05 PM, Nicholls, Mark [EMAIL PROTECTED] wrote: Hello, I wonder if someone could answer the following… The short question is what does @ mean in mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig The long version, explaining what everything means is…. here's a definition of multiplication on natural numbers I'm reading on a blog data Nat = Z | S Nat deriving Show one :: Nat one = (S Z) mulNat :: Nat - Nat - Nat mulNat _ Z = Z mulNat Z _ = Z mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig Haskell programmers seem to have a very irritating habit of trying to be overly concise...which makes learnign the language extremely hard...this example is actually relatively verbosebut anyway... Z looks like Zero...S is the successor function...Nat are the Natural numbers. mulNat _ Z = Z mulNat Z _ = Z translates to... x * 0 = 0fine... 0 * x = 0fine.. mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig is a bit more problematic... lets take a as 3 and b as 5... so now we have mulNat' 3 5 5 but what does the x@(S a) mean? in mulNat' x@(S a) y orig From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark Sent: 21 December 2007 17:47 To: David Menendez Cc: Jules Bean; haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] nice simple problem for someone struggling Let me resend the code…as it stands…. module Main where data SquareType numberType = Num numberType = SquareConstructor numberType class ShapeInterface shape where area :: Num numberType = shape-numberType data ShapeType = forall a. ShapeInterface a = ShapeType a instance (Num a) = ShapeInterface (SquareType a) where area (SquareConstructor side) = side * side and the errors are for the instance declaration……. [1 of 1] Compiling Main ( Main.hs, C:\Documents and Settings\nichom\Haskell\Shapes2\out/Main.o ) Main.hs:71:36: Couldn't match expected type `numberType' against inferred type `a' `numberType' is a rigid type variable bound by the type signature for `area' at Main.hs:38:15 `a' is a rigid type variable bound by the instance declaration at Main.hs:70:14 In the expression: side * side In the definition of `area': area (SquareConstructor side) = side * side I'm becoming lost in errors I don't comprehend…. What bamboozles me is it seemed such a minor enhancement. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Menendez Sent: 21 December 2007 17:05 To: Nicholls, Mark Cc: Jules Bean; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] nice simple problem for someone struggling On Dec 21, 2007 11:50 AM, Nicholls, Mark [EMAIL PROTECTED] wrote: Now I have module Main where data SquareType numberType = Num numberType = SquareConstructor numberType This is a valid declaration, but I don't think it does what you want it to. The constraint on numberType applies only to the data constructor. That is, given an unknown value of type SquareType a for some a, we do not have enough information to infer Num a. For your code, you want something like: instance (Num a) = ShapeInterface (SquareType a) where area (SquareConstructor side) = side * side -- Dave Menendez [EMAIL PROTECTED] http://www.eyrie.org/~zednenem/ ___ 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] what does @ mean?.....
So in the example given... mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig Is equivalent to mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' (S a) y orig | (S a) == one = y | otherwise = mulNat' a (addNat orig y) orig ? -Original Message- From: Alfonso Acosta [mailto:[EMAIL PROTECTED] Sent: 28 December 2007 11:20 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] what does @ mean?. @ works as an aliasing primitive for the arguments of a function f x@(Just y) = ... using x in the body of f is equivalent to use Just y. Perhaps in this case is not really useful, but in some other cases it saves the effort and space of retyping really long expressions. And what is even more important, in case an error is made when choosing the pattern, you only have to correct it in one place. On Dec 28, 2007 12:05 PM, Nicholls, Mark [EMAIL PROTECTED] wrote: Hello, I wonder if someone could answer the following... The short question is what does @ mean in mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig The long version, explaining what everything means is here's a definition of multiplication on natural numbers I'm reading on a blog data Nat = Z | S Nat deriving Show one :: Nat one = (S Z) mulNat :: Nat - Nat - Nat mulNat _ Z = Z mulNat Z _ = Z mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig Haskell programmers seem to have a very irritating habit of trying to be overly concise...which makes learnign the language extremely hard...this example is actually relatively verbosebut anyway... Z looks like Zero...S is the successor function...Nat are the Natural numbers. mulNat _ Z = Z mulNat Z _ = Z translates to... x * 0 = 0fine... 0 * x = 0fine.. mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig is a bit more problematic... lets take a as 3 and b as 5... so now we have mulNat' 3 5 5 but what does the x@(S a) mean? in mulNat' x@(S a) y orig From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark Sent: 21 December 2007 17:47 To: David Menendez Cc: Jules Bean; haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] nice simple problem for someone struggling Let me resend the code...as it stands module Main where data SquareType numberType = Num numberType = SquareConstructor numberType class ShapeInterface shape where area :: Num numberType = shape-numberType data ShapeType = forall a. ShapeInterface a = ShapeType a instance (Num a) = ShapeInterface (SquareType a) where area (SquareConstructor side) = side * side and the errors are for the instance declaration... [1 of 1] Compiling Main ( Main.hs, C:\Documents and Settings\nichom\Haskell\Shapes2\out/Main.o ) Main.hs:71:36: Couldn't match expected type `numberType' against inferred type `a' `numberType' is a rigid type variable bound by the type signature for `area' at Main.hs:38:15 `a' is a rigid type variable bound by the instance declaration at Main.hs:70:14 In the expression: side * side In the definition of `area': area (SquareConstructor side) = side * side I'm becoming lost in errors I don't comprehend What bamboozles me is it seemed such a minor enhancement. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Menendez Sent: 21 December 2007 17:05 To: Nicholls, Mark Cc: Jules Bean; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] nice simple problem for someone struggling On Dec 21, 2007 11:50 AM, Nicholls, Mark [EMAIL PROTECTED] wrote: Now I have module Main where data SquareType numberType = Num numberType = SquareConstructor numberType This is a valid declaration, but I don't think it does what you want it to. The constraint on numberType applies only to the data constructor. That is, given an unknown value of type SquareType a for some a, we do not have enough information to infer Num a. For
Re: [Haskell-cafe] Re: Wikipedia on first-class object
Peter Gammie wrote: On 28/12/2007, at 5:50 PM, Miguel Mitrofanov wrote: Right, so when I say to GHCi: Prelude take 5 [1..] and it says: [1,2,3,4,5] then it really has computed the entirety of the infinite sequence [1..], and not some approximation? Of course not! In fact, it doesn't even compute the value 1. It just juggles with the bytes somehow, so that it seems that it computes the whole sequence and then applies take 5. But does it really matter if it computes 5 integers, or 10, or the whole sequence, at least if we are not concerned about performance? I'll bite. So what do you expect: take 5 [1,2,3,4,5,undefined] to do? How about: take 5 (1:2:3:4:undefined) ? So it does seem to matter how much of the list it evaluates... take evaluates as much as it needs of the spine but not any of the elements. Even then, take is a good producer, so take 1 . take 5 $ 1:2:3:4:undefined will converge. But I think you know all this and your questions are rhetorical :) Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what does @ mean?.....
2007/12/28, Alfonso Acosta [EMAIL PROTECTED]: @ works as an aliasing primitive for the arguments of a function f x@(Just y) = ... using x in the body of f is equivalent to use Just y. Perhaps in this case is not really useful, but in some other cases it saves the effort and space of retyping really long expressions. And what is even more important, in case an error is made when choosing the pattern, you only have to correct it in one place. And in plenty of case it will greatly boost your speed because you won't be reconstructing the objects against which you matched every time you want to return them unchanged. -- Jedaï ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what does @ mean?.....
2007/12/28, Nicholls, Mark [EMAIL PROTECTED]: So in the example given... mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig Is equivalent to mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' (S a) y orig | (S a) == one = y | otherwise = mulNat' a (addNat orig y) orig ? Yes, but in the second version, it has to reconstruct (S a) before comparing it to one where in the first it could do the comparison directly. In this cas there may be some optimisation involved that negate this difference but in many case it can do a real performance difference. The as-pattern (@ means as) is both practical and performant in most cases. -- Jedaï ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] what does @ mean?.....
Lovelythank you very muchanother small step forward. -Original Message- From: Chaddaï Fouché [mailto:[EMAIL PROTECTED] Sent: 28 December 2007 11:29 To: Nicholls, Mark Cc: Alfonso Acosta; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] what does @ mean?. 2007/12/28, Nicholls, Mark [EMAIL PROTECTED]: So in the example given... mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig Is equivalent to mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' (S a) y orig | (S a) == one = y | otherwise = mulNat' a (addNat orig y) orig ? Yes, but in the second version, it has to reconstruct (S a) before comparing it to one where in the first it could do the comparison directly. In this cas there may be some optimisation involved that negate this difference but in many case it can do a real performance difference. The as-pattern (@ means as) is both practical and performant in most cases. -- Jedaï ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Missing join and split
Hi! I am really missing the (general) split function built in standard Haskell. I do not understand why there is something so specific as words and lines but not a simple split? The same goes for join. Yes, I can of course define them but ... in an interactive mode it would be quite handy to have them there. Or am I wrong and are those hidden somewhere? So what are common ways to get around this? What are elegant definitions? Inline definitions? Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing join and split
Mitar wrote: Hi! I am really missing the (general) split function built in standard Haskell. I do not understand why there is something so specific as words and lines but not a simple split? The same goes for join. Yes, I can of course define them but ... in an interactive mode it would be quite handy to have them there. Or am I wrong and are those hidden somewhere? So what are common ways to get around this? What are elegant definitions? Inline definitions? As I understand it, they don't exist because nobody can agree on the best way to define them. For joining you probably want some combination of intersperse and concat, e.g. unlines = concat . intersperse \n For splitting, do we split on a given character? A predicate? Do we keep the splitting character or throw it away? Do we generate empty sublists or elide them? Apparently nobody can agree on these points, and writing a function with all possible options would be very messy... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: what does @ mean?.....
Nicholls, Mark wrote: Hello, I wonder if someone could answer the following… The short question is what does @ mean in mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig The @ means an as-pattern as defined in the Haskell 98 report section 3.17.1 http://www.haskell.org/onlinereport/exps.html#3.17.1 The 'x' binds to the whole (S a) and the 'a' binds to the parameter of the constructor 's'. There is a possible performance benefit here. Consider: zeroNothing Nothing = Nothing zeroNothing (Just n) = if n == 0 then Nothing else (Just n) versus zeroNothing Nothing = Nothing zeroNothing x@(Just n) = if n == 0 then Nothing else x The first example takes apart the (Just n) and later reconstructs (Just n). Unless the compiler is fairly clever, this will cause the new (Just n) to be a new allocation instead of reusing the input value. The second form uses an at-pattern to bind 'x' to the whole input parameter and the returned 'x' will not need to be reallocaed. -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what does @ mean?.....
On Dec 28, 2007 12:21 PM, Nicholls, Mark [EMAIL PROTECTED] wrote: So in the example given... Is equivalent ? Yes, it is ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 12:03:04 +0200, apfelmus [EMAIL PROTECTED] wrote: Cristian Baboi wrote: http://en.wikipedia.org/wiki/First-class_object The term was coined by Christopher Strachey in the context of “functions as first-class citizens” in the mid-1960's.[1] Depending on the language, this can imply: 1. being expressible as an anonymous literal value 2. being storable in variables 3. being storable in data structures 4. having an intrinsic identity (independent of any given name) 5. being comparable for equality with other entities 6. being passable as a parameter to a procedure/function 7. being returnable as the result of a procedure/function 8. being constructable at runtime 9. being printable 10. being readable 11. being transmissible among distributed processes 12. being storable outside running processes I'll guess that 5,9,12 does not apply to Haskell functions. Exactly, together with 10 and 11 (when the distributed processes are on different machines). But there is good reason that those things can't be done in Haskell. With extensional equality (two functions are considered equal if they yield the same result on every possible argument) number 5 is undecidable. I didn't know 5 as a number is undecidable :-) Similarly, there cannot be functions print :: (Int - Int) - String compile :: String - (Int - Int) with compile . print = id A print function based on an intensional representation (assembly, byte code, etc.) would have to distinguish extensionally equal functions print f ≠ print g although f = g which is not allowed. Ok. I understand that there cannot be pairs like (print,compile) above. But I was told that compile (quality number 10), can be defined. About print above, I do not intend to make a Haskell String from a Haskell function. This is why I said something about mixing levels of abstractions. More importantly, I don't quite understand your question. If you definitively need 9-12 for a practical problem at hand, then you may want to take a look at the functional language Clean http://clean.cs.ru.nl/ which is similar to Haskell but offers 9-12 in some form. How can be Clean similar to Haskell and at the same time satisfy 9-12 ? I tryed Clean. I like it very much. I have some silly little problems with it: - its only 32 bit - it doesn't support Unicode - I don't like those type adnotations. Look as ugly as Lisp () to me. - it's not free - the linux version seems abandoned. - there are some issues with # expressions (let before) that I don't fully understand - the IO seems easyer in Haskell than in Clean Otherwise I like it better than Haskell. In all other cases, an email thread is not a good (often not even successful) way to get a coherent world view on Haskell (or on something else) since this necessarily involves nitpicking philosophical questions. In my experience, interrogating one person in real-time in audio and interrogating books are the best ways to do that. In my experience, different people have different world views, and one cannot get that from books only. Concerning books, maybe The Haskell Road to Logic, Maths and Programming http://www.cwi.nl/~jve/HR is for you. Thank you. More books on http://haskell.org/haskellwiki/Books You don't have to buy them, borrow them from a library. I'l try borrow them when I'll be visiting Munich next year, but I don't think I'll have enough time to read them. Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On 28/12/2007, at 7:19 PM, Miguel Mitrofanov wrote: So what do you expect: take 5 [1,2,3,4,5,undefined] to do? Nothing! It's a value, not an instruction! Dang, I knew I'd choose at least one wrong word in all of that. :-P What is it's value, then? ... and what is the value of the other example I gave? (What would GHCi print? What is another, perhaps even simpler, expression it is equal to? ... a substantive answer please! Then please square that with your comment that we don't care how much of the list gets evaluated.) (Jules, thanks for your response. My questions are Socratic, not rhetorical. I'm benefiting by having to choose my words very, very carefully. :-) cheers peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
I'll bite. Please, don't. So what do you expect: take 5 [1,2,3,4,5,undefined] to do? Nothing! It's a value, not an instruction! So it does seem to matter how much of the list it evaluates... No, it's implementation details. I'm reasoning about values, not computations, and I use complete orders for reasoning. What really matters is that implementation gives me results that agree with this reasoning - until we consider performance issues. Well, that depends of your notion of interesting. I defined it - I'm interested in things that are observationally equivalent. That's your choice, and I certainly can't argue, but I can't help mentioning that this is a bit weird. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
Here is how I want print to be in Haskell print :: (a-b) - (a-b) with print = id, but the following side effect: - I want to call the print function today, and get the value tomorrow. On Fri, 28 Dec 2007 12:03:04 +0200, apfelmus [EMAIL PROTECTED] wrote: Cristian Baboi wrote: http://en.wikipedia.org/wiki/First-class_object The term was coined by Christopher Strachey in the context of “functions as first-class citizens” in the mid-1960's.[1] Depending on the language, this can imply: 1. being expressible as an anonymous literal value 2. being storable in variables 3. being storable in data structures 4. having an intrinsic identity (independent of any given name) 5. being comparable for equality with other entities 6. being passable as a parameter to a procedure/function 7. being returnable as the result of a procedure/function 8. being constructable at runtime 9. being printable 10. being readable 11. being transmissible among distributed processes 12. being storable outside running processes I'll guess that 5,9,12 does not apply to Haskell functions. Exactly, together with 10 and 11 (when the distributed processes are on different machines). But there is good reason that those things can't be done in Haskell. With extensional equality (two functions are considered equal if they yield the same result on every possible argument) number 5 is undecidable. Similarly, there cannot be functions print :: (Int - Int) - String compile :: String - (Int - Int) with compile . print = id A print function based on an intensional representation (assembly, byte code, etc.) would have to distinguish extensionally equal functions print f ≠ print g although f = g which is not allowed. Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
But I guess it won't work because the compiler will optimize it and the call will disappear. On Fri, 28 Dec 2007 14:58:53 +0200, Cristian Baboi [EMAIL PROTECTED] wrote: Here is how I want print to be in Haskell print :: (a-b) - (a-b) with print = id, but the following side effect: - I want to call the print function today, and get the value tomorrow. Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
take 5 [1,2,3,4,5,undefined] (What would GHCi print? [1,2,3,4,5] Then please square that with your comment that we don't care how much of the list gets evaluated.) I don't care if it evaluates it, reads it's answer from some internal table, or consult it's lawyer. I just want it to agree with my reasoning about complete partial orders; that's all I need. I don't know how to explain this clearer. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 15:29:00 +0200, Miguel Mitrofanov [EMAIL PROTECTED] wrote: take 5 [1,2,3,4,5,undefined] (What would GHCi print? [1,2,3,4,5] Then please square that with your comment that we don't care how much of the list gets evaluated.) I don't care if it evaluates it, reads it's answer from some internal table, or consult it's lawyer. I just want it to agree with my reasoning about complete partial orders; that's all I need. I don't know how to explain this clearer. This purity of Haskell will allways interfere with practical matters that cannot be described in Haskell. Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: what does @ mean?.....
ChrisK [EMAIL PROTECTED] wrote: zeroNothing Nothing = Nothing zeroNothing (Just n) = if n == 0 then Nothing else (Just n) versus zeroNothing Nothing = Nothing zeroNothing x@(Just n) = if n == 0 then Nothing else x versus zeroNothing Nothing = Nothing zeroNothing x = let (Just n) = x in if n == 0 then Nothing else x so, @ is kind of like a let, just with its arguments flipped. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
It won't work because haskell functions can't have side-effects. I'm not quite sure what you're trying to say here. Jules Cristian Baboi wrote: But I guess it won't work because the compiler will optimize it and the call will disappear. On Fri, 28 Dec 2007 14:58:53 +0200, Cristian Baboi [EMAIL PROTECTED] wrote: Here is how I want print to be in Haskell print :: (a-b) - (a-b) with print = id, but the following side effect: - I want to call the print function today, and get the value tomorrow. Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.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] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 16:10:15 +0200, Jules Bean [EMAIL PROTECTED] wrote: It won't work because haskell functions can't have side-effects. I'm not quite sure what you're trying to say here. Jules What I am trying to say is: - storing something to disk does not mean one must have a function to convert that something to a Haskell String - I want to be able to use a function defined in one process in other process even if the two does not run at the same time Cristian Baboi wrote: But I guess it won't work because the compiler will optimize it and the call will disappear. On Fri, 28 Dec 2007 14:58:53 +0200, Cristian Baboi [EMAIL PROTECTED] wrote: Here is how I want print to be in Haskell print :: (a-b) - (a-b) with print = id, but the following side effect: - I want to call the print function today, and get the value tomorrow. Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Wikipedia on first-class object
Jules Bean wrote: Cristian Baboi wrote: But I guess it won't work because the compiler will optimize it and the call will disappear. I'm not quite sure what you're trying to say here. (That's the world view on Haskell issue I mean. I know this feeling with physics: what the heck are they talking about, this is just mathematically wrong, ill-defined or otherwise void of contents?) Cristian Baboi wrote: How can be Clean similar to Haskell and at the same time satisfy 9-12 ? In Clean, print has the type print :: (Int - Int) - Dynamic but there is (hopefully) no equality on Dynamic . But it can be stored in a file or something store :: Dynamic - IO () and loaded back. Thanks to IO, we can think of the file contents to be a non-deterministically chosen intentional representation for a value with extensional equality. I don't know whether Clean really does store that way, it may do more and hence break the extensional semantics a bit. Regards, apfelmus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 16:34:23 +0200, apfelmus [EMAIL PROTECTED] wrote: Jules Bean wrote: Cristian Baboi wrote: But I guess it won't work because the compiler will optimize it and the call will disappear. I'm not quite sure what you're trying to say here. (That's the world view on Haskell issue I mean. I know this feeling with physics: what the heck are they talking about, this is just mathematically wrong, ill-defined or otherwise void of contents?) Let me ask you 3 simple questions. Can one use Haskell to make dynamically linked libraries (DLL on Windows, so on Linux) ? If yes, what is in them ? If not, why not ? Information from NOD32 This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing join and split
Hi all, On Dec 28, 2007 12:38 PM, Andrew Coppin [EMAIL PROTECTED] wrote: For joining you probably want some combination of intersperse and concat, e.g. unlines = concat . intersperse \n And that's what we have :-) Data.List.intercalate :: [a] - [[a]] - [a] Data.List.intercalate x = concat . intersperse x For splitting, do we split on a given character? A predicate? Do we keep the splitting character or throw it away? Do we generate empty sublists or elide them? Apparently nobody can agree on these points, and writing a function with all possible options would be very messy... If you use intercalate to join, I would presume that you would want to use an inverse of it to split. I'd write it like this: split :: Eq a = [a] - [a] - [[a]] split at xs | Just xs' - stripPrefix at xs = [] : split at xs' split at (x:xs) = (x:r) : rs where (r:rs) = split at xs split at [] = [[]] --with, if your version of the libraries is as old as mine and doesn't have Data.List.stripPrefix, stripPrefix (p:ps) (x:xs) | p == x = stripPrefix ps xs stripPrefix [] xs = Just xs stripPrefix _ _ = Nothing - Benja ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] translating some C# abstractions into Haskell....
Lets say I've got Interface IFooX,Y Where X : IBar Where Y : IBar { } Would seem to translate roughly to class (IBar x, IBar y) = IFoo foo x y ? (or does it?) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark Sent: 28 December 2007 11:30 To: Chaddaï Fouché Cc: haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] what does @ mean?. Lovelythank you very muchanother small step forward. -Original Message- From: Chaddaï Fouché [mailto:[EMAIL PROTECTED] Sent: 28 December 2007 11:29 To: Nicholls, Mark Cc: Alfonso Acosta; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] what does @ mean?. 2007/12/28, Nicholls, Mark [EMAIL PROTECTED]: So in the example given... mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig Is equivalent to mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' (S a) y orig | (S a) == one = y | otherwise = mulNat' a (addNat orig y) orig ? Yes, but in the second version, it has to reconstruct (S a) before comparing it to one where in the first it could do the comparison directly. In this cas there may be some optimisation involved that negate this difference but in many case it can do a real performance difference. The as-pattern (@ means as) is both practical and performant in most cases. -- Jedaï ___ 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] Missing join and split
On Dec 28, 2007 9:51 AM, Benja Fallenstein [EMAIL PROTECTED] wrote: If you use intercalate to join, I would presume that you would want to use an inverse of it to split. I'd write it like this: But alas, words and lines differ on how properly to split, so there's no hint from the standard library which is preferred. Of course, there is no inverse to intercalate, so if you want to use a logical approach, perhaps you'd want to define split first, and then define your join as the inverse of split. Darcs uses this latter approach, which gives us a version of lines that isn't quite the same as the one in the prelude. David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing join and split
On Dec 28, 2007 3:55 PM, David Roundy [EMAIL PROTECTED] wrote: On Dec 28, 2007 9:51 AM, Benja Fallenstein [EMAIL PROTECTED] wrote: If you use intercalate to join, I would presume that you would want to use an inverse of it to split. I'd write it like this: Of course, there is no inverse to intercalate Right; I misspoke. What I meant was that you would want a split such that intercalate a (split a xs) = a for finite, total (a,xs) (and, since it's achievable, even for infinite xs). Of course, (split a xs = [xs]) satisfies that, but if we add the requirement that split is also supposed to do its job :-) then I think split is fully specified except for whether (split a [] = []) or (split a [] = [[]]). The latter seems better to me; e.g., it satisfies split a (x ++ a ++ y) = split a x ++ split a y so if you want to use a logical approach, perhaps you'd want to define split first, and then define your join as the inverse of split. If your join comes out as being intercalate, I suppose it's six of one, half a dozen of the other :-) - Benja ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On Dec 28, 2007 5:58 AM, Cristian Baboi [EMAIL PROTECTED] wrote: Here is how I want print to be in Haskell print :: (a-b) - (a-b) with print = id, but the following side effect: - I want to call the print function today, and get the value tomorrow. You might be interested in the standard module Debug.Trace, which defines a function: trace :: String - b - b Which allows you to print something avoiding the IO monad as you seem to want. Then to get your print function, all you would need is a Show instance for a - b: print f = trace (show f) f Then the Show instance: instance Show (a - b) where show f = function And there you have it. It's not very useful, since it just prints function for every function, but there you go. I suspect you want to print some serialization of the function such that it can be read in again and executed later. You're not gonna get that any time soon. But I also suspect that there is another legitimate solution to your problem. Unless the problem has to do with transferring *arbitrary* functions (that is, your program knows nothing at all about what is transferred) between processes (not to be confused with threads, which Haskell is very good at). Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing join and split
On Dec 28, 2007 4:24 PM, Benja Fallenstein [EMAIL PROTECTED] wrote: Right; I misspoke. What I meant was that you would want a split such that intercalate a (split a xs) = a for finite, total (a,xs) (and, since it's achievable, even for infinite xs). Of course, (split a xs = [xs]) satisfies that, but if we add the requirement that split is also supposed to do its job :-) then I think split is fully specified except for whether (split a [] = []) or (split a [] = [[]]). I take that back; it doesn't specify whether (split xx xxx) should be [,x] or [x,]. I prefer the former, because working left-to-right seems natural, and because it makes split more lazy (it can yield (:_) before evaluating the input enough to see the third 'x'). The latter seems better to me; e.g., it satisfies split a (x ++ a ++ y) = split a x ++ split a y I take that back, too: split xx = [,,] split xx x ++ split xx xxx = [x] ++ [,x] (...but, still... :-)) - Benja ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: what does @ mean?.....
Achim Schneider wrote: ChrisK [EMAIL PROTECTED] wrote: zeroNothing Nothing = Nothing zeroNothing (Just n) = if n == 0 then Nothing else (Just n) versus zeroNothing Nothing = Nothing zeroNothing x@(Just n) = if n == 0 then Nothing else x versus zeroNothing Nothing = Nothing zeroNothing x = let (Just n) = x in if n == 0 then Nothing else x so, @ is kind of like a let, just with its arguments flipped. However, if x@(Just n) fails to match, the next clause is chosen, whereas the variable pattern x matches always. Thus, the last version works only because the other possible case (Nothing) has already been handled. IOW, in the second version of zeroNothing you may swap the order of patterns, but not in the third one. Cheers Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Wikipedia on first-class object
Am Freitag, 28. Dezember 2007 07:49 schrieben Sie: On Thu, 27 Dec 2007 18:19:47 +0200, Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Donnerstag, 27. Dezember 2007 16:34 schrieb Cristian Baboi: I'll have to trust you, because I cannot test it. let x=(1:x); y=(1:y) in x==y . I also cannot test this: let x=(1:x); y=1:1:y in x==y In these examples, x and y denote the same value but the result of x == y is _|_ (undefined) in both cases. So (==) is not really equality in Haskell but a kind of weak equality: If x doesn’t equal y, x == y is False, but if x equals y, x == y might be True or undefined. Thank you. I can only notice that y always has an even number of 1, which is not the case for x :-) Both have an infinite number of 1. Why do you say “always”? It seems that you think of x and y as “variables” whose values change over time. This is not the case. They both have a single value for all time: the infinite list consisting only of 1. Best wishes, Wolfgang ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Wikipedia on first-class object
Am Freitag, 28. Dezember 2007 07:49 schrieben Sie: On Thu, 27 Dec 2007 18:14:53 +0200, Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Donnerstag, 27. Dezember 2007 15:53 schrieb Cristian Baboi: On Thu, 27 Dec 2007 16:50:10 +0200, Lennart Augustsson [EMAIL PROTECTED] wrote: Absolutly. Every expression in Haskell denotes a value. Now, we've not agreed what value means, but to me it is a value. :) It is one value, or several ? It is one value with parts that are values themselves. It is one value or a SET of values ? What are the parts ? A set of values is again a value. So is a list of values. This is similar to C++ where a field of an object can again be an object. [1..] is a value of type [Int] and every element can be considered a part of this value. Best wishes, Wolfgang P.S.: Didn’t send this to the list in the first place. I don’t like mailing lists which don’t set the Reply-To: field. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Wikipedia on first-class object
Am Freitag, 28. Dezember 2007 08:12 schrieb Cristian Baboi: On Thu, 27 Dec 2007 17:35:54 +0200, Jonathan Cast [EMAIL PROTECTED] wrote: Only on Von Neuman machines. Haskell implementations are not required to run on Von Neuman machines. That's why the language is called functional. (Imperative languages, by contrast, are just abstractions of the underlying Von Neuman architecture, which is probably the source of your confusion). Can you tell me what is it that make a language imperative ? When I learned about formal grammars and languages, there was no discussion about this. This is because a formal language (set of words) only consideres the syntactic aspect and formal grammars are only about describing formal languages. In contrast, imperative vs. declarative is about semantics. A language is imperative if programs written in this language say how something should be done instead of what should be the outcome. This description is rather informal, of course. Best wishes, Wolfgang ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what does @ mean?.....
Jedaï wrote: [...] Yes, but in the second version, it has to reconstruct (S a) before comparing it to one where in the first it could do the comparison directly. In this cas there may be some optimisation involved that negate this difference but in many case it can do a real performance difference. The as-pattern (@ means as) is both practical and performant in most cases. Chris wrote: The first example takes apart the (Just n) and later reconstructs (Just n). Unless the compiler is fairly clever, this will cause the new (Just n) to be a new allocation instead of reusing the input value. The second form uses an I tend to believe that the '@' notation is mere syntactic sugar. Indeed, it seems to me that Haskell compilers need not to be very clever to share the identical sub-expressions, for one very simple reason implied by Haskell semantics: referential transparency. Am I right, or am I missing something? And, of course, I'm not saying that syntactic sugar is bad. As Alfonso noted, it saves some typing and avoids screwing up while trying to modify multiple occurrences of the same sub-expression. And, an even more important I think, a software engineering benefit: It emphasizes for the reader that we really are talking about the very same thing at two (or more) different places. --Serge No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.17.9/1198 - Release Date: 26/12/2007 17:26 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
Cristian Baboi wrote: Let me ask you 3 simple questions. Can one use Haskell to make dynamically linked libraries (DLL on Windows, so on Linux) ? The short answer is yes. The long answer is that this is not a feature of haskell, but rather a feature of certain programs, which happen to be mostly but not entirely written in haskell, in particular, the haskell compiler. GHC can produce dynamically linked libraries. If yes, what is in them ? Object code, mostly. Sometimes a little data. Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: FFIpointer data types question
Galchin Vasili wrote: If I am calling a ANSI function that requires a pointer to a C struct, which FFI pointer type should use? A commonly used technique is to declare an empty data type data MyStruct and then use Ptr MyStruct in the FFI call. This is useful if the C struct is opaque, or at least meant to be opaque (i.e. you are not allowed to access its elements directly). For non-opaque structs, use a Haskell record and make it an instance of class Storable . An example: struct timeval { __time_t tv_sec;/* Seconds. */ __suseconds_t tv_usec; /* Microseconds. */ }; --- data Timeval = Timeval { tv_sec :: TimeT, tv_usec :: USecondsT } (with suitable definitions of TimeT and USecondsT) instance Storable Timeval where ... and your FFI calls will get a Ptr Timeval as argument. HTH Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 18:32:05 +0200, Jules Bean [EMAIL PROTECTED] wrote: Cristian Baboi wrote: Let me ask you 3 simple questions. Can one use Haskell to make dynamically linked libraries (DLL on Windows, so on Linux) ? The short answer is yes. The long answer is that this is not a feature of haskell, but rather a feature of certain programs, which happen to be mostly but not entirely written in haskell, in particular, the haskell compiler. GHC can produce dynamically linked libraries. What you choose not to notice is the context in which I asked these questions. The context is: Haskell functions as first-class objects. What I am interested in the first place is dynamically linked libraries written in Haskell and used in Haskell. The interface with other languages like C come second. If yes, what is in them ? Object code, mostly. Sometimes a little data. What is the definition of an entry point in Haskell ? What is the semantics of those entry points ? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: what does @ mean?.....
Ben Franksen [EMAIL PROTECTED] wrote: Achim Schneider wrote: ChrisK [EMAIL PROTECTED] wrote: zeroNothing Nothing = Nothing zeroNothing (Just n) = if n == 0 then Nothing else (Just n) versus zeroNothing Nothing = Nothing zeroNothing x@(Just n) = if n == 0 then Nothing else x versus zeroNothing Nothing = Nothing zeroNothing x = let (Just n) = x in if n == 0 then Nothing else x so, @ is kind of like a let, just with its arguments flipped. However, if x@(Just n) fails to match, the next clause is chosen, whereas the variable pattern x matches always. Thus, the last version works only because the other possible case (Nothing) has already been handled. IOW, in the second version of zeroNothing you may swap the order of patterns, but not in the third one. Actually, I considered working it out to nothingIf :: (a - Bool) - Maybe a - Maybe a nothingIf f m = m = (\j - if f j then Nothing else Just j) nothingIf' :: (a - Bool) - Maybe a - Maybe a nothingIf' f m = m = (\j - if f j then Nothing else m) zeroNothing = nothingIf (== 0) zeroNothing' = nothingIf' (== 0) , but was too lazy. Hopefully only because it completely messes up my point. OTOH, zeroIf :: MonadPlus m = (a - Bool) - m a - m a zeroIf f m = m = (\nz - if f nz then mzero else m) zeroZero :: (MonadPlus m, Num a) = m a - m a zeroZero = zeroIf (==0) makes it interesting again as you can't construct a Just value with it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Missing join and split
Programmer with perl background would think split like: list of string = split regex original string Since regex is involved, it is specific to (Byte)String, not a generic list. Also it appears one would need help from Text.Regex(.PCRE) to do that. intercalate a (split a xs) = a This identity rule does not hold for perl's join/split if regex is used. Steve -Original Message- On Dec 28, 2007 4:24 PM, Benja Fallenstein [EMAIL PROTECTED] wrote: Right; I misspoke. What I meant was that you would want a split such that intercalate a (split a xs) = a -- Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu - direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what does @ mean?.....
Serge LE HUITOUZE wrote: I tend to believe that the '@' notation is mere syntactic sugar. Indeed, it seems to me that Haskell compilers need not to be very clever to share the identical sub-expressions, for one very simple reason implied by Haskell semantics: referential transparency. Am I right, or am I missing something? You are missing that modifying a program in a way which adds sharing can have disastrous performance effects. In particular, adding sharing can stop something being GCed, which can convert an algorithm which runs in linear time and constant space to one which runs in linear space (and therefore, perhaps, quadratic time). Therefore compilers have to be conservative about adding sharing. In general, sharing in GHC-compiled programs is specified rather explicitly: sharing is naming, so things which are names (let-bound or pattern-bound) are guaranteed shared and normally nothing else. You can *imagine* a compiler being cleverer about this. It turns out to be an interesting but hard problem. Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what does @ mean?.....
On Dec 28, 2007 9:35 AM, Jules Bean [EMAIL PROTECTED] wrote: In particular, adding sharing can stop something being GCed, which can convert an algorithm which runs in linear time and constant space to one which runs in linear space (and therefore, perhaps, quadratic time). I've heard of this before, but can you give an example? Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Wikipedia on first-class object
Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Freitag, 28. Dezember 2007 07:49 schrieben Sie: On Thu, 27 Dec 2007 18:19:47 +0200, Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Donnerstag, 27. Dezember 2007 16:34 schrieb Cristian Baboi: I'll have to trust you, because I cannot test it. let x=(1:x); y=(1:y) in x==y . I also cannot test this: let x=(1:x); y=1:1:y in x==y In these examples, x and y denote the same value but the result of x == y is _|_ (undefined) in both cases. So (==) is not really equality in Haskell but a kind of weak equality: If x doesn’t equal y, x == y is False, but if x equals y, x == y might be True or undefined. Thank you. I can only notice that y always has an even number of 1, which is not the case for x :-) Both have an infinite number of 1. Why do you say “always”? It seems that you think of x and y as “variables” whose values change over time. This is not the case. They both have a single value for all time: the infinite list consisting only of 1. Does that then mean that [1] = [1,1] ? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Doing some things right
Hallo, Andrew Coppin escreveu: [I actually heard a number of people tell me that learning LISP would change my life forever because LISP has something called macros. I tried to learn it, and disliked it greatly. It's too messy. And what the heck is cdr ment to mean anyway? To me, LISP doesn't even seem all that different from normal languages (modulo weird syntax). Now Haskell... that's FUN!] Macros are not the only thing that makes Lisp (it hasn't been called LISP for ages) great, but surely contributes for that. Unfortunately Lisp is like the Matrix, you can't be told how great it is, you have to see for yourself. Cheers, -alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
Am Freitag, 28. Dezember 2007 17:27 schrieb Achim Schneider: Both have an infinite number of 1. Why do you say “always”? It seems that you think of x and y as “variables” whose values change over time. This is not the case. They both have a single value for all time: the infinite list consisting only of 1. Does that then mean that [1] = [1,1] ? No, it means you cannot distinguish (repeat 1) from (cycle [1,1]). Is infinity an even number or an odd one? Cheers, Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Doing some things right
On Dec 28, 2007 6:05 AM, Andrew Coppin [EMAIL PROTECTED] wrote: [I actually heard a number of people tell me that learning LISP would change my life forever because LISP has something called macros. I tried to learn it, and disliked it greatly. It's too messy. And what the heck is cdr ment to mean anyway? To me, LISP doesn't even seem all that different from normal languages (modulo weird syntax). Now Haskell... that's FUN!] Contents of Data Register. Macros are like Template Haskell. One example of where they're useful is programmer definition of new binding forms. That's not possible in Haskell without Templates. Macros were invented in Lisp because the syntax is so easy for machine manipulation---they don't have a tenth the complexity of Template Haskell for about the same power. -Brian -- Brian T. Sniffen [EMAIL PROTECTED]or[EMAIL PROTECTED] http://www.evenmere.org/~bts ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Wikipedia on first-class object
This thread is obviously a source of much fun. I will play too. Cristian Baboi wrote: On Fri, 28 Dec 2007 18:32:05 +0200, Jules Bean [EMAIL PROTECTED] wrote: Cristian Baboi wrote: Let me ask you 3 simple questions. Can one use Haskell to make dynamically linked libraries (DLL on Windows, so on Linux) ? The short answer is yes. The long answer is that this is not a feature of haskell, but rather a feature of certain programs, which happen to be mostly but not entirely written in haskell, in particular, the haskell compiler. GHC can produce dynamically linked libraries. What you choose not to notice is the context in which I asked these questions. The context is: Haskell functions as first-class objects. What I am interested in the first place is dynamically linked libraries written in Haskell and used in Haskell. The interface with other languages like C come second. If yes, what is in them ? Object code, mostly. Sometimes a little data. What is the definition of an entry point in Haskell ? Haskell does not have such a concept. At all. An implementation may have such a concept. Most people on this list define Haskell as any attempt at an implementation of one of the standards which define Haskell, most recently the Hakell 98 standard. This can be nhc / yhc / ghc / hugs / winhugs / helium / jhc. Some of these compile to native code, some compile to byte code for a virtual machine. If an implementation can compile separately, then it might support dynamic libraries. If so then a specific version of that compiler will define its own implementation specific concept of an entry point. What is the semantics of those entry points ? It depends. For recent ghc versions, see its user manual: http://haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#ffi-library http://haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html Other note: An imperative language, such as C++ or Java, specified the binary output of any instance of the compiler. Class methods will have very specific names and addresses. In C++ you can even get the member-function pointer values and examine the byte offsets in the object. In Java one gets a very specific layout of bytecode in a class file. Haskell is a declarative language. It does not specify anything about the implementation's internals. It specifies only properties like non-strict. The fact that ghc uses lazy evaluation is merely an implementation detail, chosen as a way of satisfying the non-strict requirement of Haskell. The output of a Haskell compiler is free to take all the source code and implement things with jumps and branches that look absolutely nothing like function calls. -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Missing join and split
Lihn, Steve wrote: Programmer with perl background would think split like: list of string = split regex original string Since regex is involved, it is specific to (Byte)String, not a generic list. Also it appears one would need help from Text.Regex(.PCRE) to do that. intercalate a (split a xs) = a This identity rule does not hold for perl's join/split if regex is used. Steve Well, libpcre does not have a split function. One can already write a split that uses the high level Regex API. The only reason you might want to dig into regex-pcre's Text.Regex.PCRE would be if it would help efficiency. Specifically, regex-base defines a RegexContext instance which is: ( RegexLike a b = RegexContext a b (b, b, b) ) : The text before the match, the text of the match, the text after the match So you can iteratively generate the pieces that split returns. -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 18:27:29 +0200, Achim Schneider [EMAIL PROTECTED] wrote: Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Freitag, 28. Dezember 2007 07:49 schrieben Sie: On Thu, 27 Dec 2007 18:19:47 +0200, Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Donnerstag, 27. Dezember 2007 16:34 schrieb Cristian Baboi: I'll have to trust you, because I cannot test it. let x=(1:x); y=(1:y) in x==y . I also cannot test this: let x=(1:x); y=1:1:y in x==y In these examples, x and y denote the same value but the result of x == y is _|_ (undefined) in both cases. So (==) is not really equality in Haskell but a kind of weak equality: If x doesn’t equal y, x == y is False, but if x equals y, x == y might be True or undefined. Thank you. I can only notice that y always has an even number of 1, which is not the case for x :-) Both have an infinite number of 1. Why do you say “always”? It seems that you think of x and y as “variables” whose values change over time. This is not the case. They both have a single value for all time: the infinite list consisting only of 1. Does that then mean that [1] = [1,1] No. If you try to learn Haskell don't listen to me. :-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Doing some things right
Brian Sniffen wrote: On Dec 28, 2007 6:05 AM, Andrew Coppin [EMAIL PROTECTED] wrote: [I actually heard a number of people tell me that learning LISP would change my life forever because LISP has something called macros. I tried to learn it, and disliked it greatly. It's too messy. And what the heck is cdr ment to mean anyway? To me, LISP doesn't even seem all that different from normal languages (modulo weird syntax). Now Haskell... that's FUN!] Contents of Data Register. Macros are like Template Haskell. One example of where they're useful is programmer definition of new binding forms. That's not possible in Haskell without Templates. Macros were invented in Lisp because the syntax is so easy for machine manipulation---they don't have a tenth the complexity of Template Haskell for about the same power. -Brian There is also Likell, at http://liskell.org/ by Clemens Fruhwir, which translates Haskell source into a lisp style prefix syntax (will (all (the (parentheses. This is to allow macro-like analysis and transformation without template haskell. The main use of template haskell that I have seen mentioned on the mailing lists is to analyze a data declaration and auto-generate some new class and instance declarations. But I agree that template haskell has problems: (*) Its own syntax, as big and complicated as Haskell (*) Has historically been very poorly documented (that _might_ have changed) (*) Only works with ghc -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Wikipedia on first-class object
On Fri, 28 Dec 2007 19:18:33 +0200, ChrisK [EMAIL PROTECTED] wrote: This thread is obviously a source of much fun. I will play too. Well, it starts with Wikipedia ... :-) What is the definition of an entry point in Haskell ? Haskell does not have such a concept. At all. An implementation may have such a concept. Then a Haskell module know nothing about them. Most people on this list define Haskell as any attempt at an implementation of one of the standards which define Haskell, most recently the Hakell 98 standard. This can be nhc / yhc / ghc / hugs / winhugs / helium / jhc. Some of these compile to native code, some compile to byte code for a virtual machine. If an implementation can compile separately, then it might support dynamic libraries. If so then a specific version of that compiler will define its own implementation specific concept of an entry point. How can one make portable dynamic libraries then ? What is the semantics of those entry points ? It depends. For recent ghc versions, see its user manual: http://haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#ffi-library http://haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html The conclusion: Portable Haskell Dynamic libraries does not exists. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what does @ mean?.....
Luke Palmer wrote: On Dec 28, 2007 9:35 AM, Jules Bean [EMAIL PROTECTED] wrote: In particular, adding sharing can stop something being GCed, which can convert an algorithm which runs in linear time and constant space to one which runs in linear space (and therefore, perhaps, quadratic time). I've heard of this before, but can you give an example? Sure: foo (length (build_big_list 1 2 3)) (build_big_list 1 2 3) Here, foo is a function which operates on a list, but needs to know the length of the list for some reason. As written, build_big_list is called twice. This is potentially a waste of time, but it *does* mean that if the big list is very very big (larger than available memory) but build_big_list is a good producer, it can be produced and GCed in constant space - as long as length is a good consumer (which it is) and as long as foo is (can't tell without seeing the definition, obviously!) So, you can do a two-pass algorithm in two-passes, but in constant space. Now, if we automatically share those two, we get something like this: let l = build_big_list 1 2 3 in foo (length l) l which *looks* like an optimisation, but the shared 'l' will be kept around. The length will be calculated first (assuming foo uses the length, that is) and then the entire list kept in memory while foo processes it. Of course, it's hard to see this kind of problem with the simple x@(Just y) case we were talking about, but if your function calls itself recursively then it can. Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Doing some things right
Andrew Coppin [EMAIL PROTECTED] writes: http://www.cs.kuleuven.ac.be/%7Edtai/projects/ALP//newsletter/dec07/content/Articles/tom/content.html Haskell is the undisputed flagship of the FP community. Er... really? It depends on how you define the FP community, of course. The author counts participation at ICFP, so he probably has an academic slant. I thought Lisp and Erlang were both infinitely more popular and better known. Certainly not infinitely. Lisp isn't entirely functional, and while Erlang is an industrial success story, I think Haskell is seeing a wider range of application. [I actually heard a number of people tell me that learning LISP would change my life forever because LISP has something called macros. The close ties between data and code in Lisp gives some nice opportunities for your program to e.g. manipulate itself. For e.g. genetic programming. I think macros are used for bottom-up design (i.e. building EDSLs), where you would use higher-order functions in Haskell. (I don't really have a lot of Lisp experience, I'd be interested to hear if other people agree or not) -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] OT: ghc 6.8 in Debian?
It seems my emails to the Debian Haskell list (CC'd on this email as well) are silently dropped :-( Since I suspect the readers of /that/ list are likely to be on this one as well I thought I'd give this a try. What's happening with GHC 6.8 in Debian? There was an email about a month ago announcing the availability of the core package. Since then it seems very little has happened. What can I do to help, if anything? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus.therning@gmail.com http://therning.org/magnus What if I don't want to obey the laws? Do they throw me in jail with the other bad monads? -- Daveman signature.asc Description: OpenPGP digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Debian-haskell] OT: ghc 6.8 in Debian?
On Fri, 28 Dec 2007, Magnus Therning wrote: It seems my emails to the Debian Haskell list (CC'd on this email as well) are silently dropped :-( I don't believe that's the case; I've been getting them, and they're in the archive: http://urchin.earth.li/pipermail/debian-haskell/2007-December/thread.html Cheers, Ganesh ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Doing some things right
Brian Sniffen wrote: On Dec 28, 2007 6:05 AM, Andrew Coppin [EMAIL PROTECTED] wrote: [I actually heard a number of people tell me that learning LISP would change my life forever because LISP has something called macros. I tried to learn it, and disliked it greatly. It's too messy. And what the heck is cdr ment to mean anyway? To me, LISP doesn't even seem all that different from normal languages (modulo weird syntax). Now Haskell... that's FUN!] Contents of Data Register. Right. I've heard the story about why it came to be called that, but seriously... I can never remember whether I want cdr or car. It's a silly choice of name. [Sure, you can rename it. And then nobody but you will understand it.] Macros are like Template Haskell. Which, incidentally, I also don't use. ;-) Doesn't Derive cover most of the useful cases for TH? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Doing some things right
Hallo, Andrew Coppin escreveu: Brian Sniffen wrote: On Dec 28, 2007 6:05 AM, Andrew Coppin [EMAIL PROTECTED] wrote: [I actually heard a number of people tell me that learning LISP would change my life forever because LISP has something called macros. I tried to learn it, and disliked it greatly. It's too messy. And what the heck is cdr ment to mean anyway? To me, LISP doesn't even seem all that different from normal languages (modulo weird syntax). Now Haskell... that's FUN!] Contents of Data Register. Right. I've heard the story about why it came to be called that, but seriously... I can never remember whether I want cdr or car. It's a silly choice of name. [Sure, you can rename it. And then nobody but you will understand it.] In Common Lisp, standardised in 1984, there are the equivalent functions FIRST and REST, which everyone know what they mean. Cheers, -alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell-cafe reply-to etiquette
Justin Bailey wrote: When I joined the haskell-cafe mailing list, I was surprised to see the reply-to header on each message was set to the sender of a given message to the list, rather than the list itself. That seemed counter to other mailing lists I had been subscribed to, but I didn't think too much about it. In addition to agreeing with the article Reply-To Munging Considered Harmful, I want to remark that: A. This mailing list does not set the Reply-To header whatsoever. Not even to the author. When you hit reply, the destination is taken from From, not Reply-To. Thus I was surprised to see the reply-to header on each message was set to the sender was inaccurate. B. This mailing list sets the List-Post header: List-Post: mailto:haskell-cafe@haskell.org Progressive mail clients honour this, e.g., Evolution. Thus you are given three buttons: reply - Reply-To or From reply all - all found addresses reply to list - List-Post In my opinion this is the way to go. The semantics of List-Post is clear cut. The semantics of Reply-To is too overloaded to be relied on. I don't use Evolution - I am still at Thunderbird 1.5. It doesn't know the List-Post header. (But there may be plugins to add it.) But I do the little extra manual work of: reply all, then take out the author's address and just keep the list address. On the other hand, I completely don't mind receiving duplicates. In my opinion, if I choose to use dumb software, I should be the one making up for it, not ask the whole world to fudge semantics to please my dumb software. Lowest common denominators are evil. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing join and split
Mitar wrote: I am really missing the (general) split function built in standard Haskell. I do not understand why there is something so specific as words and lines but not a simple split? The same goes for join. Don't forget Text.Regex.splitRegex. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Function Stores
Here is what I was able to come up with: module Store where data FStore1 a b = Empty1 | FS1 ( a-b , FStore1 a b ) store1 :: (a-b) - (FStore1 a b) store1 f = let x = FS1 (f, x) in x data FStore2 a b = Empty2 | FS2 ( a-b , FStore2 a b, FStore2 a b ) store2 :: (a-b) - (FStore2 a b) store2 f = let x = FS2 (f,x,x) in x First I tryed store1, but after a while it went out of business. Second I tryed other business model with store2. Same result. Then I tryed to make a street of stores. After a while, they all went out of business. Then I tryed to make several streets of stores. After a while they all went out of business. Then I tryed to make an infinite street of stores. After a while they all went out of business. Then, following some rumors that there is a store on that street with some function in stock that might be willing to give it away, I noticed that the street disappeared, and I cannot go to that store. Can you help me find it ? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Doing some things right
I thought Lisp and Erlang were both infinitely more popular and better known. Certainly not infinitely. Lisp isn't entirely functional, and while Erlang is an industrial success story, I think Haskell is seeing a wider range of application. Well, it seems for me that Erlang is much less functional than Lisp. It's totally OO, in fact. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing join and split
Hi! On Dec 28, 2007 5:51 PM, Lihn, Steve [EMAIL PROTECTED] wrote: Since regex is involved, it is specific to (Byte)String, not a generic list. Oh, this gives me an interesting idea: making regular expressions more generic. Would not it be interesting and useful (but not really efficient) to have patterns something like: foo :: Eq a = a - ... foo (_{4}'b') = ... which would match a list with four elements ending with an element 'b'. Or: foo (_+';'_+';'_) = ... which would match a list with embedded two ';' elements. (Last _ matched the remaining of the list.) OK, maybe guards are not the proper place to implement this as would add a possibility to make a really messy Haskell programs. But extending regular expressions to work on any list of elements with type implementing Eq would be realy powerfull. And then we could use split in many other than just text processing contexts. Of course, the problem in both cases is implementing something like regular expressions efficiently, especially on lists, but this is why there are smart people around. :-) Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe