RE: internal error: eval_thunk_selector: strange selectee 29
(Apologies for the repeated message, the moderator seems to be out at the moment, so I just subscribed to the list and resent it, this time with a bit more information) Trying to run profiling (+RTS -p -RTS), I get: xsactp: internal error: eval_thunk_selector: strange selectee 29 Please report this as a bug to [EMAIL PROTECTED], or http://www.sourceforge.net/projects/ghc/ Command exited with non-zero status 254 Can you send the code, or is it too large? Cheers, Simon ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: ghc 6.0.1 and Mac OS X 10.2.6 build
Hi Wolfgang, Thanks again for the prompt reply. I did exactly as you noted below (removed the framework support check from configure.in, ran autoconf and ./configure, then built. Everything works appears to work correctly but ghci. (For example, I can build a network test program that queries a web server. It runs correctly.) I even did everything twice to make sure I hadn't done something foolish. So now we are to the entirely strange problem. I'm running dlcompat-20030522. It works as you mention below, calling NSIsSymbolDefined and NSLookupAndBindSymbol. Now that I look at it, there are differences between the dlfcn.h headers. The dlsym prototypes diff is -extern void * dlsym(void * handle, const char *symbol); +extern void * dlsym(void * dl_restrict handle, const char * dl_restrict symbol) dl_restrict is just defined as the __restrict type qualifier. Perhaps a pointer aliasing issue? I'll look into it some more later today. Best Wishes, Greg On Thursday, August 7, 2003, at 03:46 AM, Wolfgang Thaller wrote: I should note that I've done the build without Wolfgang's HaskellSupportFramework, by setting the include and library paths in build.mk. This is more compatible with the automated packing scheme of DarwinPorts. Of course. The HaskellSupport.framework isn't necessary when the user already has DarwinPorts installed; be sure to note somewhere that GHC-compiled programs will require gmp and dlcompat. by setting the include and library paths in build.mk. The official way to disable the HaskellSupport.framework is to modify configure.in (yes, I should really add a --configure option for that): Lines 978 to 991 read: dnl ** (Mac OS X only: check for HaskellSupport.framework) HaveFrameworkHaskellSupport=NO if test $HostPlatform = powerpc-apple-darwin; then AC_MSG_CHECKING([for HaskellSupport.framework]) save_libs=$LIBS LIBS=-framework HaskellSupport AC_TRY_LINK_FUNC(__gmpz_fdiv_qr, HaveFrameworkHaskellSupport=YES,) if test $HaveFrameworkHaskellSupport = YES; then AC_DEFINE(HAVE_FRAMEWORK_HASKELLSUPPORT) fi; LIBS=$save_libs AC_MSG_RESULT([$HaveFrameworkHaskellSupport]) fi; AC_SUBST(HaveFrameworkHaskellSupport) Change that to just: HaveFrameworkHaskellSupport=NO AC_SUBST(HaveFrameworkHaskellSupport) Then rerun autoconf and ./configure. The error message comes from ghc/rts/Linker.c. Apparently dlsym couldn't find the symbol _free from libSystem. Which is entirely strange. I see no reason why that could possibly happen. I suspect that doing things this way I have to link HSbase_cbits.o (and its siblings) with -lSystem, Is that correct, or is this a different problem? The ghci executable is already linked with -lSystem, otherwise it wouldn't work at all. And Linker.c calls dlsym on the program handle, which means that it just has to find _free. What version of dlcompat are you using? dlcompat's dlsym should just call NSIsSymbolNameDefined and NSLookupAndBindSymbol when dlsym is called with the program handle. Cheers, Wolfgang ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: ghc 6.0.1 and Mac OS X 10.2.6 build
I should note that I've done the build without Wolfgang's HaskellSupportFramework, by setting the include and library paths in build.mk. This is more compatible with the automated packing scheme of DarwinPorts. Of course. The HaskellSupport.framework isn't necessary when the user already has DarwinPorts installed; be sure to note somewhere that GHC-compiled programs will require gmp and dlcompat. by setting the include and library paths in build.mk. The official way to disable the HaskellSupport.framework is to modify configure.in (yes, I should really add a --configure option for that): Lines 978 to 991 read: dnl ** (Mac OS X only: check for HaskellSupport.framework) HaveFrameworkHaskellSupport=NO if test $HostPlatform = powerpc-apple-darwin; then AC_MSG_CHECKING([for HaskellSupport.framework]) save_libs=$LIBS LIBS=-framework HaskellSupport AC_TRY_LINK_FUNC(__gmpz_fdiv_qr, HaveFrameworkHaskellSupport=YES,) if test $HaveFrameworkHaskellSupport = YES; then AC_DEFINE(HAVE_FRAMEWORK_HASKELLSUPPORT) fi; LIBS=$save_libs AC_MSG_RESULT([$HaveFrameworkHaskellSupport]) fi; AC_SUBST(HaveFrameworkHaskellSupport) Change that to just: HaveFrameworkHaskellSupport=NO AC_SUBST(HaveFrameworkHaskellSupport) Then rerun autoconf and ./configure. The error message comes from ghc/rts/Linker.c. Apparently dlsym couldn't find the symbol _free from libSystem. Which is entirely strange. I see no reason why that could possibly happen. I suspect that doing things this way I have to link HSbase_cbits.o (and its siblings) with -lSystem, Is that correct, or is this a different problem? The ghci executable is already linked with -lSystem, otherwise it wouldn't work at all. And Linker.c calls dlsym on the program handle, which means that it just has to find _free. What version of dlcompat are you using? dlcompat's dlsym should just call NSIsSymbolNameDefined and NSLookupAndBindSymbol when dlsym is called with the program handle. Cheers, Wolfgang ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: internal error: eval_thunk_selector: strange selectee 29
--make is just too pleasant not to be used. I can always clean out things in case of weird errors. Would you like me to submit subsequent reports if I encounter further problems? If you get into a state where --make produces a crashing program, then it's a good idea to take a snapshot of the directory at that point. Then make clean, build from scratch again, and if that works then send us the original snapshot. Cheers, Simon ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: internal error: eval_thunk_selector: strange selectee 29
Simon Marlow [EMAIL PROTECTED] writes: Can you send the code, or is it too large? Both of the above. :-) There is something really fishy going on; I checked out the same code in a different directory, and built it in the same way, without getting the same behaviour. Hmm. Profiling isn't deterministic though, because heap samples happen based on a timer interrupt, so you might get different results if you run it multiple times. I'm not quite sure what kind of confusion that led to the error (or the fact that my run times suddenly were tripled); possibly some old .o or .hi file got copied in by mistake? Possibly, or possibly a recompilation bug (are you using --make?). Compiling with -optl-static should only affect the linking stage, shouldn't it? (I.e. the *.o etc. files should be identical?) Right. Cheers, Simon ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: internal error: eval_thunk_selector: strange selectee 29
Simon Marlow [EMAIL PROTECTED] writes: There is something really fishy going on; I checked out the same code in a different directory, and built it in the same way, without getting the same behaviour. Hmm. Profiling isn't deterministic though, because heap samples happen based on a timer interrupt, so you might get different results if you run it multiple times. I'm not quite sure what kind of confusion that led to the error (or the fact that my run times suddenly were tripled); possibly some old .o or .hi file got copied in by mistake? Possibly, or possibly a recompilation bug (are you using --make?). Yes, I am. I got the error several times, but when I cleaned everything up, it seems to have gone away -- as did the tripled running times (and yes, they were user/system times, not just wall clock). Very puzzling. Unfortunately, a 'make clean' removed all the evidence -- if I stumble over it again, I'll make a copy first. -kzm -- If I haven't seen further, it is by standing in the footprints of giants ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: very strange behavior (crashes!) with Dynamics
This hasn't yet been posted, but I've actually whittled it down quite a bit. All we need is to import the Util.DynamicMap and do: dm1 = addToDM emptyDM (Range 1 2) showDM :: DShow - DynamicMap - ShowS showDM sd = foldDM (\d b - case sd d of { Nothing - b ; Just s - s . b }) id and do the show definition for Coref and then we get: Compiling ReadCorefData( c:/home/t-hald/projects/PennUtil/ReadCorefData.hs, interpreted ) Ok, modules loaded: ReadCorefData, PennUtil.Util, Util.DynamicMap, NLP.PennParser, NLP.FiniteMap, NLP.String, NLP.Util, Common. *ReadCorefData showDM corefDShow dm1 Loading package haskell98 ... linking ... done. *ReadCorefData :!touch ReadCorefData.hs *ReadCorefData :r Compiling ReadCorefData( c:/home/t-hald/projects/PennUtil/ReadCorefData.hs, interpreted ) Ok, modules loaded: ReadCorefData, PennUtil.Util, Util.DynamicMap, NLP.PennParser, NLP.FiniteMap, NLP.String, NLP.Util, Common. *ReadCorefData showDM corefDShow dm1 Coref=Coref 1 2 Process ghci exited abnormally with code 5 interestingly it seems to be trying to read this as the range (since the two ints are the same as the initial ones)... -- Hal Daume III | [EMAIL PROTECTED] Arrest this man, he talks in maths. | www.isi.edu/~hdaume -Original Message- From: Hal Daume Sent: Thursday, August 14, 2003 12:37 PM To: '[EMAIL PROTECTED]' Subject: very strange behavior (crashes!) with Dynamics First, I apologize for the length of this message. Unfortunately, I cannot whittle this down to a smaller example. I'm dealing with parse trees, whose datatype looks like: data AnnTree a = Term{ treeTag :: PackedString, treeText :: PackedString , treeAnn :: a } | NonTerm { treeTag :: PackedString, treeChildren :: [AnnTree a], treeAnn :: a } deriving (Eq, Ord) In particular, I parameterize these over a DynamicMap datatype, which looks like: import Data.Dynamic type DynamicMap = FiniteMap String Dynamic -- cuz TypeRep \not \in Ord :( This supports, for instance: stypeOf x = show (typeOf x) ttypeOf (x :: T a) = stypeOf (undefined :: a) emptyDM :: DynamicMap emptyDM = emptyFM addToDM :: Typeable a = DynamicMap - a - DynamicMap addToDM dm a = addToFM dm (stypeOf a) (toDyn a) lookupDM :: Typeable a = DynamicMap - Maybe a lookupDM dm :: Maybe a = case lookupFM dm (stypeOf (undefined :: a)) of Nothing - Nothing Just x - fromDynamic x as well as a few other of the standard FM functions that I need. I have a type synonym: type DTree = AnnTree DynamicMap so that I can add whatever types of annotations I want to the tree. I also provide methods of showing the trees with various annotations shown, based on a DShow type: type DShow = Dynamic - Maybe ShowS dshowLabel :: Typeable a = (a - ShowS) - DShow dshowLabel x d = case fromDynamic d of Nothing - Nothing Just v - Just (shows (typeOf v) . showChar '=' . x v) showDTreeWith :: DShow - DTree - ShowS showDTreeWith shws t = showChar '(' . showString (unpackPS (treeTag t)) . showChar ' ' . showAnn (treeAnn t) . (if isTerm t then showString (unpackPS (treeText t)) else showChildren (treeChildren t)) . showChar ')' where showChildren [] = showString EMPTY showChildren [ch] = showDTreeWith shws ch showChildren (ch:chl) = showDTreeWith shws ch . showChar ' ' . showChildren chl showAnn a = showList (foldDM showAnn' [] a) showAnn' dyn acc = case shws dyn of Nothing - acc Just ss - showChar '{' . ss . showChar '}' : acc showList [] = id showList [x] = showChar '{' . x . showChar '}' . showChar ' ' showList (x:xs) = showChar '{' . x . showList' xs . showChar '}' . showChar ' ' showList' [] = id showList' (x:xs) = showChar ';' . x . showList' xs Basically, what this does is it is given a DShow (which can be combined, of course, using non-shown functions), and prints the tree with the dynamic annotations shown in braces. The dshowLabel function takes a shows function and creates a DShow function based on it. For instance, I have a coreference data type, which looks like: data Coref = Coref Int Int Bool (Maybe String) -- Id, ref, in-min; eventually we cannonicalize these -- and we can assume id= ref, type deriving (Eq, Ord, Show) We make this an instance of Typeable so we can put it in dynamic maps: corefTypeCon = mkTyCon Coref ; corefTypeRep = mkAppTy corefTypeCon [] instance Typeable Coref where typeOf _ = corefTypeRep {-# NOINLINE corefTypeCon #-} {-# NOINLINE corefTypeRep #-} Now, we have another annotation type, Range, which specifies what subset of the sentence a given node covers. data Range = Single Int | Range Int Int instance Show Range where
RE: very strange behavior (crashes!) with Dynamics
Okay, this is the last spam from me. Here's exactly what you need to do to get the bug. Create three modules, DynamicMap.hs, Range.hs and Coref.hs, containing the following: DynamicMap.hs module DynamicMap ( DynamicMap, emptyDM, addToDM, foldDM ) where import Data.FiniteMap import Data.Dynamic type DynamicMap = FiniteMap String Dynamic -- cuz TypeRep \not \in Ord :( stypeOf x = show (typeOf x) emptyDM :: DynamicMap emptyDM = emptyFM addToDM :: Typeable a = DynamicMap - a - DynamicMap addToDM dm a = addToFM dm (stypeOf a) (toDyn a) foldDM :: (Dynamic - b - b) - b - DynamicMap - b foldDM f = foldFM (const f) -- Range.hs --- module Range where import Data.Dynamic data Range = Single Int | Range Int Int minRange (Single x) = x minRange (Range x _) = x maxRange (Single x) = x maxRange (Range _ x) = x instance Show Range where showsPrec _ (Single i) = shows i showsPrec _ (Range i j) = shows i . showChar '^' . shows j instance Eq Range where Single i == Single k = i == k Single i == Range k l = i == k k == l Range i j == Range k l = i == k j == l Range i j == Single k = i == k j == k instance Read Range where readsPrec i s | '^' `elem` s = let n1 = takeWhile (/='^') s n2 = drop (length n1+1) s in [(Range l h, rest) | (l,[]) - readsPrec i n1, (h,rest) - readsPrec i n2] | otherwise = map (\ (a,s) - (Single a,s)) (readsPrec i s) instance Ord Range where r `compare` s = case minRange r `compare` minRange s of EQ - maxRange r `compare` maxRange s x - x rangeTypeCon = mkTyCon Range ; rangeTypeRep = mkAppTy rangeTypeCon [] instance Typeable Range where typeOf _ = rangeTypeRep {-# NOINLINE rangeTypeCon #-} {-# NOINLINE rangeTypeRep #-} rangeDShow :: DShow rangeDShow = dshowLabel (shows :: Range - ShowS) type DShow = Dynamic - Maybe ShowS dshow0 :: DShow dshow0 = const Nothing dshowLabel :: Typeable a = (a - ShowS) - DShow dshowLabel x d = case fromDynamic d of Nothing - Nothing Just v - Just (shows (typeOf v) . showChar '=' . x v) -- Coref.hs --- module Coref where import DynamicMap import Data.Dynamic import Range data Coref = Coref Int Int Bool (Maybe String) deriving (Eq, Ord, Show) corefTypeCon = mkTyCon Coref ; corefTypeRep = mkAppTy corefTypeCon [] instance Typeable Coref where typeOf _ = corefTypeRep {-# NOINLINE corefTypeCon #-} {-# NOINLINE corefTypeRep #-} corefDShow = dshowLabel (shows :: Coref - ShowS) showDM :: DShow - DynamicMap - ShowS showDM sd = foldDM (\d b - case sd d of { Nothing - b ; Just s - s . b }) id dm1 = addToDM emptyDM (Range 1 2) --- Now, load Coref.hs in GHCi: ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.0, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \/\/ /_/\/|_| Type :? for help. Loading package base ... linking ... done. Loading package lang ... linking ... done. Prelude :load c:/home/t-hald/projects/Bugs/Coref.hs Compiling DynamicMap ( DynamicMap.hs, interpreted ) Compiling Range( Range.hs, interpreted ) Compiling Coref( c:/home/t-hald/projects/Bugs/Coref.hs, interpreted ) Ok, modules loaded: Coref, Range, DynamicMap. *Coref showDM corefDShow dm1 *Coref :!touch Coref.hs *Coref :r Compiling Coref( c:/home/t-hald/projects/Bugs/Coref.hs, interpreted ) Ok, modules loaded: Coref, Range, DynamicMap. *Coref showDM corefDShow dm1 Coref=Coref 1 2 Process ghci exited abnormally with code 5 for some reason having the DShow definitions in the same file as Range is important (I originally tried having the DShow definitions in their own file, imported by all the others, but that didn't exhibit the bug). -- Hal Daume III | [EMAIL PROTECTED] Arrest this man, he talks in maths. | www.isi.edu/~hdaume -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hal Daume Sent: Thursday, August 14, 2003 3:46 PM To: Hal Daume; [EMAIL PROTECTED] Subject: RE: very strange behavior (crashes!) with Dynamics This hasn't yet been posted, but I've actually whittled it down quite a bit. All we need is to import the Util.DynamicMap and do: dm1 = addToDM emptyDM (Range 1 2) showDM :: DShow - DynamicMap - ShowS showDM sd = foldDM (\d b - case sd d of { Nothing - b ; Just s - s . b }) id and do the show definition for Coref and then we get: Compiling ReadCorefData( c:/home/t-hald/projects/PennUtil/ReadCorefData.hs, interpreted ) Ok, modules loaded: ReadCorefData, PennUtil.Util, Util.DynamicMap, NLP.PennParser, NLP.FiniteMap, NLP.String, NLP.Util, Common. *ReadCorefData showDM corefDShow dm1 Loading package haskell98 ... linking ...
RE: very strange behavior (crashes!) with Dynamics
Okay, I know I promised that was the last one, but you can actually get it simpler. Remove all the dynamic map stuff. Just have two files, Range.hs and Coref.hs, with: module Range where import Data.Dynamic data Range = Single Int | Range Int Int deriving (Eq, Ord, Show) rangeTypeCon = mkTyCon Range ; rangeTypeRep = mkAppTy rangeTypeCon [] instance Typeable Range where typeOf _ = rangeTypeRep {-# NOINLINE rangeTypeCon #-} {-# NOINLINE rangeTypeRep #-} rangeDShow :: DShow rangeDShow = dshowLabel (shows :: Range - ShowS) type DShow = Dynamic - Maybe ShowS dshowLabel :: Typeable a = (a - ShowS) - DShow dshowLabel x d = case fromDynamic d of Nothing - Nothing Just v - Just (shows (typeOf v) . showChar '=' . x v) and module Coref where import Data.Dynamic import Range data Coref = Coref Int Int Bool (Maybe String) deriving (Eq, Ord, Show) corefTypeCon = mkTyCon Coref ; corefTypeRep = mkAppTy corefTypeCon [] instance Typeable Coref where typeOf _ = corefTypeRep {-# NOINLINE corefTypeCon #-} {-# NOINLINE corefTypeRep #-} corefDShow = dshowLabel (shows :: Coref - ShowS) now load Coref, do 'Monad.liftM ($) (corefDShow (toDyn (Range 1 1)))' which works fine (returns Nothing), then touch it and reload it and do the same thing and you'll crash. -- Hal Daume III | [EMAIL PROTECTED] Arrest this man, he talks in maths. | www.isi.edu/~hdaume -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hal Daume Sent: Thursday, August 14, 2003 4:06 PM To: Hal Daume; [EMAIL PROTECTED] Subject: RE: very strange behavior (crashes!) with Dynamics Okay, this is the last spam from me. Here's exactly what you need to do to get the bug. Create three modules, DynamicMap.hs, Range.hs and Coref.hs, containing the following: DynamicMap.hs module DynamicMap ( DynamicMap, emptyDM, addToDM, foldDM ) where import Data.FiniteMap import Data.Dynamic type DynamicMap = FiniteMap String Dynamic -- cuz TypeRep \not \in Ord :( stypeOf x = show (typeOf x) emptyDM :: DynamicMap emptyDM = emptyFM addToDM :: Typeable a = DynamicMap - a - DynamicMap addToDM dm a = addToFM dm (stypeOf a) (toDyn a) foldDM :: (Dynamic - b - b) - b - DynamicMap - b foldDM f = foldFM (const f) -- Range.hs --- module Range where import Data.Dynamic data Range = Single Int | Range Int Int minRange (Single x) = x minRange (Range x _) = x maxRange (Single x) = x maxRange (Range _ x) = x instance Show Range where showsPrec _ (Single i) = shows i showsPrec _ (Range i j) = shows i . showChar '^' . shows j instance Eq Range where Single i == Single k = i == k Single i == Range k l = i == k k == l Range i j == Range k l = i == k j == l Range i j == Single k = i == k j == k instance Read Range where readsPrec i s | '^' `elem` s = let n1 = takeWhile (/='^') s n2 = drop (length n1+1) s in [(Range l h, rest) | (l,[]) - readsPrec i n1, (h,rest) - readsPrec i n2] | otherwise = map (\ (a,s) - (Single a,s)) (readsPrec i s) instance Ord Range where r `compare` s = case minRange r `compare` minRange s of EQ - maxRange r `compare` maxRange s x - x rangeTypeCon = mkTyCon Range ; rangeTypeRep = mkAppTy rangeTypeCon [] instance Typeable Range where typeOf _ = rangeTypeRep {-# NOINLINE rangeTypeCon #-} {-# NOINLINE rangeTypeRep #-} rangeDShow :: DShow rangeDShow = dshowLabel (shows :: Range - ShowS) type DShow = Dynamic - Maybe ShowS dshow0 :: DShow dshow0 = const Nothing dshowLabel :: Typeable a = (a - ShowS) - DShow dshowLabel x d = case fromDynamic d of Nothing - Nothing Just v - Just (shows (typeOf v) . showChar '=' . x v) -- Coref.hs --- module Coref where import DynamicMap import Data.Dynamic import Range data Coref = Coref Int Int Bool (Maybe String) deriving (Eq, Ord, Show) corefTypeCon = mkTyCon Coref ; corefTypeRep = mkAppTy corefTypeCon [] instance Typeable Coref where typeOf _ = corefTypeRep {-# NOINLINE corefTypeCon #-} {-# NOINLINE corefTypeRep #-} corefDShow = dshowLabel (shows :: Coref - ShowS) showDM :: DShow - DynamicMap - ShowS showDM sd = foldDM (\d b - case sd d of { Nothing - b ; Just s - s . b }) id dm1 = addToDM emptyDM (Range 1 2) --- Now, load Coref.hs in GHCi: ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.0, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \/\/ /_/\/|_| Type :? for help. Loading package base ... linking ... done. Loading package lang ... linking ...
AWARD NOTIFICATION.
LOTTERY LA PRIMITIVA. C/GUZMAN EL BUENO,137 MADRID - ESPAÑA. TEL: +34-645-633-391 AND FAX +34-660-697-521 FROM: THE DESK OF THE PROMOTIONS MANAGER, INTERNATIONAL PROMOTIONS/PRIZE AWARD DEPARTMENT, REF: LP/26510460037/02 BATCH: 24/00319/IPD. ATTN: ( CONGRATULATION) DEAR SIR, AWARD NOTIFICATION FINAL NOTICE. We are pleased to inform you of the announcement, of winners of the LOTTERY PRIMITIVA SWEEPSTAKES/INTERNATIONAL PROGRAMS held on 31TH JULY,2003. Your name is attached to ticket number 004-05117963-198, with serial number 99375 drew no 03/61,the winning numbers 06-11 -13-27-40-49, and consequently won the lottery in the 6th category. You have therefore been approved for a lump sum pay out of UROS 705.366,80 Thousand in cash credited to file No:LP/26510460037/02.This is from total prize money of EUROS 3,000,000.00 shared among the six international winners in this category. All participants were selected through a computer ballot system drawn form 25,000 names from Australia, New Zealand, America, Europe, North America and Asia as part of International Promotions Program, which is conducted annually. CONGRATULATIONS!!! Your fund is now insured to your name. Due to the mix up of some numbers and names, we ask that you keep this award strictly from public notice until your claim has been processed and your money remitted to your account. This is part of our security protocol to avoid double claiming or unscrupulous acts by participants of this program. We hope with a part of you prize, you will participate in our end of year high stakes Euros1.1 billion International Lottery. To begin your claim, please contact your claims agent, Mr Tony Santos(+34 676 538 701) FOREIGN OPERATION MANAGERS, Email: [EMAIL PROTECTED]):WEBSITE(www.thelotter.com). For due processing and remittance of your prize money to a designated account with our bankers. Remember, all prize money must be claimed not later than 30TH SEPTEMBER, 2003. After this date, all funds will be returned as unclaimed. NOTE: In order to avoid unnecessary delays and complications, please remember to quote your reference and batch numbers in every of your correspondences with your agent. Furthermore, should there be any change of your address, do inform your claims agent as soon as possible. Congratulations again from all our staff and thank you for being part of our promotions programm. ( CONGRATULATION) BEST REGARDS, DR. CLIFFORD F. LOPEZ. (DIRECTOR EXTERNAL AFFAIRS) ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
ASSISTANCE PLEASE
Dear Greetings,I am John Malanbo Vaye {A Liberian}who has just gotten off the hands of Rebels fighting against the regime of President Charles Taylor. My Father who was then a minister in the Cabinet of President Taylor was his confidant in matter of diamond trade between the Sierra Leone authorities, and they usually smuggled them out through my country, Liberia with the help of PresidentTaylor and my father, who was killed by the Rebels about ten days ago. On the intervension of President Obasanjo, we were released and presently staying in a refugee camp in Ghana.Before my father's death, he notify me of a Huge amount he hurriedly deposited with a Security Company here in Ghana[during the war].He gave me the documents and Authority to claim the Consignment from the Company.The amount involve in the Consignmemt is $31.5m[Thirty one, million Five Hundred Thousand US Dollars] as well as some quantity of gold and diamond. He lodged it with the Company as Jeweleries. I got your contact,from an expartirate friend here in Ghana, who visited the refugee camp here, and normally travels on Business to your Country.I told him of my need for a foriegn Partner and my intensions to invest in Europe,Asia or USA.He told me of how reliable and trustworthy you are.This is how far he knows of my intensions. The Security Company is prepared to help me carry my consignment[Money] out of Africa.This Security Company Officials,do travel Abroad on official assignment and with Diplomatic Immunity.I want you to assist me and as my Partner to help me receive the Consignment over there and keep in a safe place.You will then send me a letter of Invitation,in other for me to get my Visa to join you up. I am also interested in buying a house as I will be coming to settle down there with my familly and you shall advice me on a profitable Business in yourCountry. For your assistant I'm prepared to compensate you with 10% of the money,5% will be set aside for Extra expenditure,during the cause of this transaction.While the rest will be for my investment. Please let me know your intension immedaitely by mail, as I do not have a phone yet. NOTE:please treat this as Confidential,as I have not told anybody except you even the friend who gave me your contact, and no one knows that I am here in Ghana, for security reasons. Waiting to hear from you, as I am afraid of the horrors in my country and this part of the world. Yours Truly, Bennard William Molanbo ( In Distress) ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: link statically with libc?
Is it possible to link libc statically with GHC? My Linux box has been upgraded, and compiled binaries no longer work on older systems. :-( -optl-static should do the trick. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Polymorphic kinds
On Tuesday 05 August 2003 4:00 pm, Simon Peyton-Jones wrote: | id# :: (a :: # ) - a | id# x = x That should really be rejected. You couldn't call it because you'd have to instantiate 'a' to Int# or Double#, and that would mean different code for different calls. GHC (after modifying the parser to allow # to stand for the kind of unlifted type) seems to behave very nicely with this definition - it does not generate any code for it, and inlines its uses; so the problem never actually arises (but I expect it would for more complex code). I guess I shouldn't rely on that, anyhow. One clue: take a look at the UArray library. http://www.haskell.org/ghc/docs/latest/html/base/Data.Array.Unboxed.html UArray is parameterised by Int, Float, Double, but it describes arrays that hold Int#, Float#, Double# respectively. Maybe you could re-use ideas from there? Interesting! It seems that just writing wrappers around my new primitive operations, that do boxing and unboxing as appropriate, works out just fine - GHC does all the expected unboxing. So it is not worth trying to work with boxed values directly. Great, thanks! :-) -- Sebastien ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: link statically with libc?
Simon Marlow [EMAIL PROTECTED] writes: I don't know how the Ada guys do it. Perhaps they have an alternate set of compiled libraries with bounds-checking turned off? Me neither, I've just heard the idea discussed, not the actual technology. I suppose I can do it by wrapping array accesses in a class or otherwise, with a safe and an unsafe implementation, and switch when I'm satisfied things work. Yes, that would do it. Moving to unsafeAt gained me a couple of percent in my application. Throwing in a -fliberate-case gave me a miniscule, but possibly positive gain. However, linking statically (with -optl-static) causes my program to stack overflow!? Sounds very strange to me, but I don't have time to investigate that further today. I'll look into it a bit more tomorrow. Large file support will be in 6.2. Goodie! -kzm -- If I haven't seen further, it is by standing in the footprints of giants ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
link statically with libc?
Hi, Is it possible to link libc statically with GHC? My Linux box has been upgraded, and compiled binaries no longer work on older systems. :-( -kzm -- If I haven't seen further, it is by standing in the footprints of giants ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
URGENT ASSISTANCE
ANTHONY EDMUNDS. EMAILl: [EMAIL PROTECTED] FAX:+34 MADRID-SPAIN: Dear Sir AN APPEAL FOR ASSISTANCE My name is Anthony Edmundo a liberian nacional I was a former minister in the Government of President Charles Taylor. I am on the run due to the iminent collapse of the Government in liberia as a result of the war. My purpose of writing you is to solicit assistance from you for the safe keeping of some money which I was able to bring out of liberia. This money,a total of $ 21.5m (twenty_one million,five hundred thousand U.S. Dollars)only,is part of the proceeds we made from illegal sale of diamonds while in government. I already have this money in a safe deposit with a security company here in Madrid. The company has agreed to help me set up an account where I could deposit the Fund,but for security reasons I can not set up such bank account in my name now. Your country being my final destination with my family,it therefore became natural for Me to look for someone trustworthy in the your country who can keep custody of the fund until my entire family is out of liberia and finally settle in your country I find it convinient to provide all logistics for a smooth trnasfer of the ownership of the fund to you,and the subsequent transfer to your bank account, I will reward you very handsomly with 17% of the total sum upon completion. I would therefore propose a meeting in Madrid with you in order to discuss and also draw a working agreement between the two of us.If you are satisfied with the agreement,we may conclude the transfer of ownership at the same time, so that the money could be transfered to your account pending my arrival in there for final disbursement. I look forward to hearing your decision on this matter very quick . Please I beg of you to keep this piece of information with you and treat it with maximum confidentiality even in the event that you are not able to assist me. Thank you and God blees . Yours sincerely, Anthony Edmunds. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: strange behaviour
My point here is to know, what's the reason for the different behaviour, rather than discussing the correctness of using unsafePerformIO. The reason is this: GHC uses a lazy evaluation strategy, as opposed to fully-lazy. Under lazy evaluation, the unsafePerformIO expression in your example will be evaluated each time main is invoked. When -O is turned on, GHC performs some transformations on the code that have the effect of changing the evaluation strategy to almost fully-lazy. That is, there will be some more sharing, but not necessarily as much as you would get in a compiler that implements fully-lazy evaluation. Indeed, even without -O, you might get a bit more sharing than you would under pure lazy evaluation. Of course, you should never write any code that depends on any of this. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
preemptive getLine on cygwin?
I seem to have some problems understanding preemptive getLine behaviour on cygwin, and wonder whether this is a known/fixed bug/feature (I haven't switched to ghc-6.. yet), or whether anyone has experience with this (behaviour on solaris, with an even older ghc is more or less as expected). Claus -- consider the following example. compile, run, and whenever the -- program waits for input, enter the next natural number, starting -- from 1. note that the program preempts the first input and may -- or may not accept input after the second output.. module Main where import IO main = do hGetBuffering stdin = print hGetLine stdin = print hGetLine stdin = print --- win98, cygwin $ ./Getline LineBuffering 1 1 $ cat | ./Getline BlockBuffering Nothing 1 1 2 2 3 $ ghc --version The Glorious Glasgow Haskell Compilation System, version 5.04.2 --- solaris $ ./GetLine LineBuffering 1 1 2 2 $ cat | ./GetLine BlockBuffering Nothing 1 1 2 2 3 $ ghc --version The Glorious Glasgow Haskell Compilation System, version 5.02.3 ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Data.Tree.Tree Show instance
On Mon, Aug 11, 2003 at 07:16:08PM +0200, Tomasz Zielonka wrote: I think it would be better to derive Show instance for Tree instead of providing a pretty printing one. Then it would be possible to have a complementing Read instance. The pretty printing function could be provided under a different name (eg. drawTree). Thanks -- I've changed it as you suggest. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: preemptive getLine on cygwin?
I seem to have some problems understanding preemptive getLine behaviour on cygwin, and wonder whether this is a known/fixed bug/feature (I haven't switched to ghc-6.. yet), or whether anyone has experience with this (behaviour on solaris, with an even older ghc is more or less as expected). You're running a fairly old version of GHC. With 5.04.3 here I get different behaviour, although strangely it seems that stdin and stdout don't default to LineBuffering in a cygwin shell window. So that's a third variant of runtime behaviour, then, for the same trivial program (probably cygwin on a more modern windows?)!? What do other GHC versions say? And, more importantly, what _should_ they do? Strangely, with Blockbuffering the program seems to be slightly better behaved than with LineBuffering in cygwin, so the cat-hack helps a bit (strangely, because I'm reading lines, so I'd usually explicitly set LineBuffering.., and slightly better, because it's still not quite as I would have expected). I'd still like to understand what's going on and how to get my Haskell programs to behave (this arises in a debugging mode of a larger app and means that, at the moment, I can't easily use this for debugging, which makes life slightly difficult, but at least it doesn't seem to cause the bug*..). Cheers, Claus * just checked in an ms-dos-console, which works as expected. So it seems that the issue is an interaction of ghc/cygwin? Getline LineBuffering 1 1 2 2 ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: preemptive getLine on cygwin?
So that's a third variant of runtime behaviour, then, for the same trivial program (probably cygwin on a more modern windows?)!? What do other GHC versions say? And, more importantly, what _should_ they do? GHC 5.04.3 behaves as I'd expect, except that it defaults to BlockBuffering for stdin/stdout in a cygwin window. In a DOS window it defaults to LineBuffering as expected. This appears to be because mingw's implementation of isatty() only detects DOS windows, which is reasonable. Strangely, with Blockbuffering the program seems to be slightly better behaved than with LineBuffering in cygwin, so the cat-hack helps a bit (strangely, because I'm reading lines, so I'd usually explicitly set LineBuffering.., and slightly better, because it's still not quite as I would have expected). I'd still like to understand what's going on and how to get my Haskell programs to behave (this arises in a debugging mode of a larger app and means that, at the moment, I can't easily use this for debugging, which makes life slightly difficult, but at least it doesn't seem to cause the bug*..). I think just upgrading your GHC should fix things. If not, we'll look into it. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Polymorphic kinds
On Tuesday 05 August 2003 1:51 pm, Simon Peyton-Jones wrote: The real question is: why does GHC distinguish kind * from kind #? For example, Int has kind * Int# has kind # The main reason is this: a polymorphic function assumes that values of type 'a' are represented by a pointer. For example: const :: a - b - a const assumes that its arguments are represented by pointers. The machine instructions simply would not work if it was passed (say) two double-precision floats, of type Double#. All right. I do expect the compiler to yell if a polymorphic function is ever effectively applied to an unboxed value. Does this mean that forcing kinds to # will not work, for example as in id# :: (a :: # ) - a id# x = x ? For some reason GHC does not produce any code for this definition, although it seems to be able to inline it and simplify it away. In the particular case I am considering, I do expect all polymorphic functions to have been inlined and simplified away. Would it make sense to have GHC complain about polymorphic functions being applied to unboxed values as late as possible? Since it really is an implementation issue, couldn't the restriction be postponed until after inlining and simplification (since GHC does a great job there)? I understand that it would make it difficult for a programmer to know when some piece of code will be accepted or rejected. So maybe I should just use Template Haskell for those portions of the code that have to avoid manipulating boxed values. I guess that would allow me to use do-notation. Thanks for the clarifications! -- Sebastien ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: link statically with libc?
I don't know how the Ada guys do it. Perhaps they have an alternate set of compiled libraries with bounds-checking turned off? Me neither, I've just heard the idea discussed, not the actual technology. I know O'Caml does this too (-unsafe as a compiler flag gives you unsafe array accesses). I've found in that context, I get as much as a 15% speedup over not having -unsafe. Admittedly this is on an extremely array-intensive application, but it certainly can be a win. On a related note, I know that the IBM Java compiler (I'm blanking on the name right now) gets a lot of its speedups over Sun by lifting bounds checks out of loops. That is, if you have: for (int i=0; i1000; i++) { acc += arr[i]; } in traditional Sun javac, you get something that basically looks like: for (int i=0; i1000; i++) { if i outside of arr bounds, throw exception acc += arr[i]; } but the IBM compiler will lift this out (under certain circumstances -- for instance, if 'acc' is not in scope of the catch) to: if 0 outside of arr bounds || 999 outside of arr bounds, throw exception for (int i=0; i1000; i++) { // look ma, no checks acc += arr[i]; } does GHC do anything similar to this, or are we getting hit with array checks at each and every read/write (modulo, of course, full laziness)? - Hal ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
URGENT ASSISTANCE
ANTHONY EDMUNDS. EMAILl: [EMAIL PROTECTED] FAX:+34 MADRID-SPAIN: Dear Sir AN APPEAL FOR ASSISTANCE My name is Anthony Edmundo a liberian nacional I was a former minister in the Government of President Charles Taylor. I am on the run due to the iminent collapse of the Government in liberia as a result of the war. My purpose of writing you is to solicit assistance from you for the safe keeping of some money which I was able to bring out of liberia. This money,a total of $ 21.5m (twenty_one million,five hundred thousand U.S. Dollars)only,is part of the proceeds we made from illegal sale of diamonds while in government. I already have this money in a safe deposit with a security company here in Madrid. The company has agreed to help me set up an account where I could deposit the Fund,but for security reasons I can not set up such bank account in my name now. Your country being my final destination with my family,it therefore became natural for Me to look for someone trustworthy in the your country who can keep custody of the fund until my entire family is out of liberia and finally settle in your country I find it convinient to provide all logistics for a smooth trnasfer of the ownership of the fund to you,and the subsequent transfer to your bank account, I will reward you very handsomly with 17% of the total sum upon completion. I would therefore propose a meeting in Madrid with you in order to discuss and also draw a working agreement between the two of us.If you are satisfied with the agreement,we may conclude the transfer of ownership at the same time, so that the money could be transfered to your account pending my arrival in there for final disbursement. I look forward to hearing your decision on this matter very quick . Please I beg of you to keep this piece of information with you and treat it with maximum confidentiality even in the event that you are not able to assist me. Thank you and God blees . Yours sincerely, Anthony Edmunds. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strange behaviour
On 2003-08-11 at 11:44+0200 David Sabel wrote: module Main(main) where import System.IO.Unsafe main = case unsafePerformIO (print test) of () - main ok, probably I use unsafePerformIO in an unsafe way and so on, but executing the program prints infinitely often test on the screen, but I think it would be correct to do so one time? It's correct behaviour to print test any number of times. Haskell is non-strict, which only means that things aren't evaluated unless needed. It's not (defined to be) lazy, which would mean that named expressions would be evaluated at most once (though ghc meets this). It's also not defined to be fully lazy meaning that unnamed expressions would be evaluated at most once in any given closure. So GHC is entirely within its rights to evaluate unsafePerformIO (print test) any number of times, or possible even none, since it knows that that expression always returns the same value (). So you /have/ used it in an unsafe way, and the above discussion illustrates why unsafePerformIO really is completely unsafe. Jón -- Jón Fairbairn [EMAIL PROTECTED] ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: preemptive getLine on cygwin?
I seem to have some problems understanding preemptive getLine behaviour on cygwin, and wonder whether this is a known/fixed bug/feature (I haven't switched to ghc-6.. yet), or whether anyone has experience with this (behaviour on solaris, with an even older ghc is more or less as expected). You're running a fairly old version of GHC. With 5.04.3 here I get different behaviour, although strangely it seems that stdin and stdout don't default to LineBuffering in a cygwin shell window. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Data.Tree.Tree Show instance
On Tue, Aug 12, 2003 at 12:30:27PM +0200, Johannes Waldmann wrote: On Mon, 11 Aug 2003, Tomasz Zielonka wrote: The Tree datatype in new Data.Tree module has a Show instance ... [...] On the other hand, it is my opinion that for a clean program design, you should normally define your own `data' (or `newtype') types, rather than use exisiting ones by `type' synonyms. this may lead to somewhat larger program texts, but you'll find that they are more readable, and extendable. (Compare adding another component to a tuple, and to a record). this also gives you the opportunity to define class instances in any way you want. I agree with you. I often define my own types using 'data' and 'newtype', even for things like IP adresses and numeric identifiers, because I don't need and don't want many operations that integral types provide but are meaningles in these applications. I also find datatypes with named fields convenient. And I rarely define type synonyms, probably only for some involved combinations of monad transformers. However, I think that there are some types so generic, that they deserve including in standard libraries. One example is a list - how often do you define your own list type? But lists form a subset of trees, and trees form a subset of graphs, so it would be nice to have them delivered with GHC even if they would only be used in toy applications. Best regards, Tom -- .signature: Too many levels of symbolic links ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Data.Tree.Tree Show instance
On Mon, 11 Aug 2003, Tomasz Zielonka wrote: The Tree datatype in new Data.Tree module has a Show instance ... I agree that Read/Show should normally come as a pair. It is debatable whether a library should contain a Show instance that makes it rather impossible to write the corresponding Read instance. Even more so since no library user can later change this: by the Haskell definition, if you import a module that contains a data type definition, then you also inherit all its instances from that module. (Section 5.4 of the report, http://haskell.org/onlinereport/modules.html) the workaround would be to move the `instance Show Tree' into a separate library module. On the other hand, it is my opinion that for a clean program design, you should normally define your own `data' (or `newtype') types, rather than use exisiting ones by `type' synonyms. this may lead to somewhat larger program texts, but you'll find that they are more readable, and extendable. (Compare adding another component to a tuple, and to a record). this also gives you the opportunity to define class instances in any way you want. best regards, -- -- Johannes Waldmann http://www.informatik.uni-leipzig.de/~joe/ -- -- [EMAIL PROTECTED] -- phone/fax (+49) 341 9732 204/209 -- ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Timing repeated function calls
Malcom Wallace wrote: Since you aren't interested in absolute timings, just the algorithmic complexity, then you could try using a less smart compiler (e.g. nhc98) which will not automatically optimise away the repeated calls. Thanks very much, I will try this. I'm seriously interested in using Haskell in a commercial venture, and this kind of discussion helps me see what techniques we would have in our toolkit. In the past (20 years of imperative programming) I have occasionally found it useful to be able to get timings for some little function that is in the inner loops of an application. I would be very interested to hear if there are any theoretically pure ways to get timing measurements for a very short-running function. The problem, I think, is that you want to apply the function to the same arguments repeatedly so as not to spend all your time creating arguments. Jeff ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Data.Tree.Tree Show instance
Hi! The Tree datatype in new Data.Tree module has a Show instance that works like shown below: Prelude Data.Tree print (Node 'a' [Node 'b' [], Node 'c' []]) - 'a' -+- 'b' | `- 'c' I use a similar module for Trees in conjunction with WASH for generating web pages. WASH session management relies on the ability to read back previously showed values. Writing a Read instance for such Show would be a weird thing to do. I think it would be better to derive Show instance for Tree instead of providing a pretty printing one. Then it would be possible to have a complementing Read instance. The pretty printing function could be provided under a different name (eg. drawTree). The other tiny problem is that the current instance is not recursion-proof: Prelude Data.Tree let f x = Node x [Node x [], Node x []] Prelude Data.Tree print (f (f 1)) - - 1 -+- 1 | `- 1 -+- - 1 -+- 1 | `- 1 | `- - 1 -+- 1 | `- 1 Best regards, Tom -- .signature: Too many levels of symbolic links ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strange behaviour
Ok, thanks for all your comments. But I think that the examples haven't much to do with the core-to-core optimisations, because I've also used a modified version --modified be me ;-) -- of ghc5.04.3, where only a modified simplifying is done. The modifications are small: Do Inlining only for values, do only trivial eta-expansion (not for case, let and so on) , and some other small things. But with this modified compiler, the same problem comes up. I didn't modify things after simplifying, espcially generating STG-Code or transforming (optimising) this code. I think it has something to do with the STG-Code generation or with normal code generation, and it depends on the fact, if the function is exported or not. Any hints in this direction??? Thanks, David - Original Message - From: Simon Marlow [EMAIL PROTECTED] To: David Sabel [EMAIL PROTECTED]; Jon Fairbairn [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, August 11, 2003 12:40 PM Subject: RE: strange behaviour My point here is to know, what's the reason for the different behaviour, rather than discussing the correctness of using unsafePerformIO. The reason is this: GHC uses a lazy evaluation strategy, as opposed to fully-lazy. Under lazy evaluation, the unsafePerformIO expression in your example will be evaluated each time main is invoked. When -O is turned on, GHC performs some transformations on the code that have the effect of changing the evaluation strategy to almost fully-lazy. That is, there will be some more sharing, but not necessarily as much as you would get in a compiler that implements fully-lazy evaluation. Indeed, even without -O, you might get a bit more sharing than you would under pure lazy evaluation. Of course, you should never write any code that depends on any of this. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strange behaviour
On 2003-08-11 at 11:44+0200 David Sabel wrote: module Main(main) where import System.IO.Unsafe main = case unsafePerformIO (print test) of () - main ok, probably I use unsafePerformIO in an unsafe way and so on, but executing the program prints infinitely often test on the screen, but I think it would be correct to do so one time? It's correct behaviour to print test any number of times. Haskell is non-strict, which only means that things aren't evaluated unless needed. It's not (defined to be) lazy, which would mean that named expressions would be evaluated at most once (though ghc meets this). It's also not defined to be fully lazy meaning that unnamed expressions would be evaluated at most once in any given closure. So GHC is entirely within its rights to evaluate unsafePerformIO (print test) any number of times, or possible even none, since it knows that that expression always returns the same value (). Thanks for your comments. Ok, Haskell is not lazy, an referential transparency allows you to evalute (unsafePerformIO print test) as often you want. But GHC provides to to do sharing in some sense and the compilation should be Work-safe. My point here is to know, what's the reason for the different behaviour, rather than discussing the correctness of using unsafePerformIO. So you /have/ used it in an unsafe way, and the above discussion illustrates why unsafePerformIO really is completely unsafe. Jón -- Jón Fairbairn [EMAIL PROTECTED] ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: link statically with libc?
I must have misremembered it from somewhere, perhaps confusing it with -fliberate-case-threshold mentioned a while ago (which probably belongs in the experimental category?) Turing off bounds checking could be fairly useful, I think, if there is a significant speedup to be gained. My impression is that the typical Ada programmer tests the program thoroughly with bounds checking, but compiles without for deployment. (Of course, we would rather *know* a priori that we're not going out of bounds, rather than just test for it, but it seems to work all right for them) I don't know how the Ada guys do it. Perhaps they have an alternate set of compiled libraries with bounds-checking turned off? There are array operations that avoid bounds checking, however (eg. unsafeRead, unsafeWrite). I suppose I can do it by wrapping array accesses in a class or otherwise, with a safe and an unsafe implementation, and switch when I'm satisfied things work. Yes, that would do it. -kzm PS: is large file support in the vicinity yet? Large file support will be in 6.2. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: link statically with libc?
(PS: Am I looking in the wrong places, or are a lot of GHC options undocumented? I seem to remember options being brandished about (turn of array bounds checking, tuning unboxing and stuff) that I'm unable to find documented anywhere.) There might be one or two undocumented optimisation knobs, but I believe everything that is actually useful is documented. Anything undocumented is either broken or experimental. There isn't a flag to turn off array bounds checking - it would require compiling against different libraries. There are array operations that avoid bounds checking, however (eg. unsafeRead, unsafeWrite). The flags that affect automatic boxing/unboxing are -funbox-strict-fields and -fno-strictness. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: link statically with libc?
Simon Marlow [EMAIL PROTECTED] writes: -optl-static should do the trick. That worked nicely, thanks! (PS: Am I looking in the wrong places, or are a lot of GHC options undocumented? I seem to remember options being brandished about (turn of array bounds checking, tuning unboxing and stuff) that I'm unable to find documented anywhere.) -kzm -- If I haven't seen further, it is by standing in the footprints of giants ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: Polymorphic kinds
| All right. I do expect the compiler to yell if a polymorphic function is | ever effectively applied to an unboxed value. Does this mean that | forcing kinds to # will not work, for example as in | id# :: (a :: # ) - a | id# x = x That should really be rejected. You couldn't call it because you'd have to instantiate 'a' to Int# or Double#, and that would mean different code for different calls. | In the particular case I am considering, I do expect all polymorphic | functions to have been inlined and simplified away. | Would it make sense to have GHC complain about polymorphic | functions being applied to unboxed values as late as possible? | Since it really is an implementation issue, couldn't the restriction | be postponed until after inlining and simplification (since GHC | does a great job there)? One could imagine that, but the error messages would be utterly opaque -- because they'd refer to code that was quite different to what the programmer wrote. I don't know how to make this work nicely, I'm afraid. One clue: take a look at the UArray library. http://www.haskell.org/ghc/docs/latest/html/base/Data.Array.Unboxed.html UArray is parameterised by Int, Float, Double, but it describes arrays that hold Int#, Float#, Double# respectively. Maybe you could re-use ideas from there? Simon | | I understand that it would make it difficult for a programmer to | know when some piece of code will be accepted or rejected. | So maybe I should just use Template Haskell for those portions | of the code that have to avoid manipulating boxed values. | I guess that would allow me to use do-notation. | | Thanks for the clarifications! | | -- | Sebastien ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: overlapping instances and functional dependencies
G'day all. On Sat, Aug 09, 2003 at 01:32:49AM +0200, Wolfgang Jeltsch wrote: ghci -fglasgow-exts -fallow-overlapping-instances compiles it without complaint If it helps, ghci will complain the first time you actually try to use it. Cheers, Andrew Bromage ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
CfP: SNPD'03 Workshop on High-Level Approaches to Parallel and Distributed Computing
Please apologize in case you receive multiple copies of this information. == CALL FOR PAPERS Workshop on High-Level Approaches to Parallel and Distributed Computing held in the context of the Fourth ACIS International Conference on Software Engineering, Artificial Intelligence, Networking, and Parallel/Distributed Computing (SNPD'03) October 16th - 18th, 2003 Luebeck, Germany http://www.isp.uni-luebeck.de/snpd03/Workshop/ws02/index.htm == Scope and Topics: == Today parallel and distributed computing systems are readily available and provide a continuously improving price/performance ratio. However, this technological breakthrough in hardware is not accompanied by similar progress in software technology. Parallel and distributed programming is still dominated by low-level techniques such as explicit message passing. This low level of abstraction makes programming these systems exceedingly difficult, time-consuming, and error-prone. Hence, parallel and distributed computing requires new programming models which liberate programmers from low-level concerns and increase programming productivity while maintaining reasonable trade-offs between level of abstraction and runtime performance. Topics of interest include, but are not limited to - methodologies for high-level parallel programming, - parallel programming languages, - high-level libraries for parallel computing, - compilers and runtime systems for parallel computing, - implementation aspects of high-level parallel programming environments, - compiler-based optimization and parallelization, - experience with high-level parallel programming environments, - support for debugging and performance analysis, - concurrent array programming, - programming concepts for the grid. This workshop provides a forum for researchers and practitioners interested in the design, implementation, and evaluation of high-level parallel programming concepts. It aims at creating some focus within the otherwise broad spectrum of the SNPD'03 conference. Workshop Chair and Organizer: == Clemens Grelck University of Luebeck Institute of Software Technology and Programming Languages Seelandstr. 1A 23569 Luebeck, Germany E-Mail: [EMAIL PROTECTED] Papers and Publication: Original, unpublished papers in English not exceeding 8 pages in ACIS double column format are solicited. For detailed formatting instructions see the SNPD'03 conference web site at http://www.isp.uni-luebeck.de/snpd03/index.htm Please send your papers as PDF documents by electronic mail directly to the workshop chair: [EMAIL PROTECTED] Please indicate your paper submission by the subject SNPD03 WORKSHOP SUBMISSION Accepted papers will be published in the conference proceedings with ISBN. A selection of excellent papers presented at the conference including its workshops will be published in a special issue of the International Journal of Computer and Information Science. Important Deadlines: = Full paper submission due:August, 30th Notification of acceptance: September, 10th Camera-ready papers due: September, 24th ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Solution to the monomorphism restriction/implicit parameter problem
Complications: * In my examples it's easy to tell whether all uses of the implicit parameter refer to the same explicit binding, but it may be difficult when recursion is involved. This problem has already arisen in the case of type class constraints, and has been solved, so I'm confident it can be solved for implicit parameters too. Unfortunately, the two cases are not quite the same: f :: (Num a) = a - b f x = f (x+1) g :: (?x :: Int) - b g = g {?x = ?x+1} Here all calls of f use the same implicit argument, but calls of g use different ones. * It might be harder to pre-apply the implicit value if it's not in scope at the early application point, as in: let g = ?x in ([deeply nested expr...] let ?x = [...] in g) But referential transparency means that it can always be done; it's just tricky. * It's not really necessary for safety that all uses of the implicit parameter refer to the same explicit binding; they just need to refer to the same value. So this could be accepted: let ?x = 1 in (let g = ?x in (g, let ?x = 1 in g)) even though it would be rejected if one of the 1s were changed to something else. Cases like this would be rare, though, and it's not clear that programs of this type should really be accepted anyway, since the safety is rather fragile. None of these complications threatens the overall validity of the monomorphism restriction, because the algorithm on which the monomorphism restriction is based is heuristic anyway: the only requirement is that when it says a reduction is safe, it mustn't be wrong. If the complicated cases end up being too complicated, it's perfectly acceptable to give up and say they're unsafe. This one is a slightly different story: * Pre-application might introduce space leaks. My intuition says to ignore this issue, because (1) let-abstraction always has the potential of introducing space leaks, and (2) Even if you explicitly write something like length [1..100] + length (tail [1..100]) the compiler is allowed to combine the two lists without telling you, even though this introduces a space leak. -- Ben ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Haskell and algebra
Gustavo Villavicencio wrote: Hi all, I am trying to understand the algebraic laws and operators behind a functional expression... f = g \equiv g* . f in the Kleisli Star context. Is this right? Yep. If it is so, can I combine g*.f with a fork for example? What do you mean by a fork? Regards, Frank ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
loop through the list...
hi again... :) Ok assume i got this list of tuples [(10,1),(20,2),(30,3)] where i in (i,j) is a index, i want to go through the list and add a number witch matches the best index. Like 18 should give me [(10,1),(20,3),(30,3)] since 18 are over 10 and under 20... aky? something like [if (thenumber index) then (index,int+1) \and break\ else (index,int) | (index,int) - [thelist]] My problem is that i dont know how to do the break thing! next time the value gonna be smaller than the 30 and ++ the int. Can i use some help-boolean to set it false when we have counted up once? and include that one in the if-stmt?? How do i do that? I guess your laughing your pants wet right now coz there are of-corz some smart built-in functions in haskell to do this kind of silly ting, so please tell me! :) Respect the rock! //Fredde ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: literate scripts.
Ghc should not accept this code, because, no matter how the unliterating is achieved, it is illegal for a literal string to contain a literal newline character. Known bug in GHC. In the testsuite, but unfortunately not documented. Cheers, Simon ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: Solution to the monomorphism restriction/implicit parameter problem
On Tue, 5 Aug 2003, Simon Peyton-Jones wrote: I'm afraid that I have not read all of the recent exciting flood of messages carefully, Hi, I'm glad to see that you're around, and I'm very much looking forward to any comments you may have about my proposal. You say that All implementations should be changed so that they do the right thing. If only we knew what the Right Thing is! My solution *is* the Right Thing. :-) It really did exist all along. I think that once you read and understand my implicit parameter proposal this will become clear. Comments from TcSimplify Question 3: monomorphism There's a nasty corner case when the monomorphism restriction bites: z = (x::Int) + ?y The argument above suggests that we *must* generalise over the ?y parameter, to get z :: (?y::Int) = Int, No, it's not necessary that z have that type, just that it behave exactly as though it had that type. The reason the expression let f = () in (f 'a' 'b', f 'a' 'b') is not rejected even with the monomorphism restriction turned on is that there's a monomorphic specialization of f that behaves exactly as the polymorphic f would have *in this particular expression* -- and that's what actually gets used. Similarly, the expression let z = x + ?y in z+z need not be rejected, because there's a monomorphic specialization of z that behaves exactly as the polymorphic version would have in this expression -- namely z = (x + ?y) {?y = @y}. (See my implicit parameter proposal for a definition of the new syntax.) -- Ben ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Implicit parameters, second draft
0. Introduction This is a complete rewrite of my implicit-parameter proposal, with a lot more motivating text and examples, as well as discussions of the tradeoffs involved in making various changes to the existing system. It incorporates various changes which came up in the discussion which followed my original post, as well as some which haven't been posted before. This document is pretty dry, which is deliberate; I'm trying to write a research paper this time instead of flippantly tossing out an idea. If you're not interested in the theory you can skip to section 3, where I lay out my specific suggestions for changes to the existing implementations. 1. The new framework I will develop the idea of implicit parameters using a different approach from that of the original paper by Lewis et al. (hereafter LSML). In my approach implicit parameters will be treated directly as implicitly- propagated function parameters, and not via an analogy with LISP's dynamic environment. I think that this new approach, by more closely modeling the way implicit parameters really work, suggests reasonable solutions to a variety of problems which are difficult to analyze within the LSML framework. It also raises some new questions which, though they apply to LSML also, may not have been noticed before. 1.1. Explicit labeled parameters Implicit named parameters differ from ordinary parameters in two ways: they are implicit (i.e. automatically propagated through function calls in some way), and they have names instead of ordinal positions. I will introduce these two properties into the language separately. First we consider explicit (or ordinary) labeled parameters. I'll start with some examples to illustrate their expected behavior, as well as the new syntactic forms that I'll be using for them in this document: cons {head = h} {tail = t} = h : t \ cons {tail = t} {head = h} = h : tall equivalent defs. cons {head = h, tail = t} = h : t / cons {head = 'h'} {tail = ello} == hello cons {tail = ello}== partially-applied function cons 'h' ello == error cons {tail = ello} {head = 'h'} == hello cons {tail = ello, head = 'h'}== hello cons :: (head :: a, tail :: [a]) = [a] cons {head = 'h'} :: (tail :: String) = String elem :: (predicate :: a - b - Bool) = a - [b] - Bool elem item list {predicate = p} = ...\ elem item {predicate = p} list = ... all equivalent elem {predicate = p} item list = .../ In function definitions, labeled parameters have two identifiers associated with them: the one on the left of the {...=...} form is the external (interface) name, or label, which appears in the type and is used by other functions to refer to the formal parameter, while the one on the right is the internal (implementation) name, which is used within the function to refer to the actual argument. Ordinary positional parameters have only the internal name. Since these two kinds of identifiers never appear in the same context, they may be placed in different namespaces. In particular, we may without ambiguity introduce a punning notation for function definitions, such as cons :: (head :: a, tail :: [a]) = [a] cons {head, tail} = head : tail However, aside from being potentially confusing, punning causes notational difficulties because it interferes with alpha-conversion (internal names must sometimes be renamed, but labels must never be renamed). I will not use punning in this document. Note that internal bindings have lexical extent, while labels have global extent. 1.2. Implicit parameters When we write a declaration such as mysort list = sortBy ?comparator list the explicit parameter list is mentioned twice, once at its abstraction or binding point and once at its reference or usage point. However, the implicit parameter introduced by ?comparator is mentioned only once, at the reference point. We expect the corresponding abstraction to be propagated automatically toward the root of the expression tree, where list is already explicitly mentioned. Then, at call time, the actual argument should be propagated down again, along the same path, to the point of use. Secondly, when we write something like myWeirdSort list = sortBy ?comparator list ++ reverse (sortBy ?comparator list) we expect the two ?comparator forms to denote a single implicit argument. That is, the implicit abstractions should be merged by name as they're propagated up. This is not the only possible behavior; one can envision an implicit-parameter system in which equally-named labels are kept separate, as in section 2.1. Probably such a system wouldn't be useful; at any rate I won't consider it here. 1.3. Auto-lifted labels With this motivation, I introduce a special kind of label which I'll call auto-lifted. Auto-lifted labels are like ordinary labels except that, when used in lambda
Re: Calling Haskell from Java
Brandon == Brandon Michael Moore [EMAIL PROTECTED] writes: Brandon Is it fine if the interface uses JNI? The jvm-bridge is Brandon an excellent tool if you can use JNI thanks, I'll check out the jvm bridge stuff. Brandon What are you trying to do? There was an interesting story in C/C++ users journal about the Eclipse Platform (www.eclipse.org). Extension of Eclipse is achieved by adding (Java-based) plugins. An ide for haskell should be possible but to use the Language.Haskell.* stuff you would have to call Haskell from Java. This is just a hobby project (I am condemned to writing C/C++ for a living) so I can't promise to deliver anything. Greetz Immanuel -- *** It makes me uncomfortable to see An English spinster of the middle class Describe the amorous effects of `brass', Reveal so frankly and with such sobriety The economic basis of society. W.H. Auden -- Immanuel Litzroth Software Development Engineer Enfocus Software Kleindokkaai 3-5 B-9000 Gent Belgium Voice: +32 9 269 23 90 Fax : +32 9 269 16 91 Email: [EMAIL PROTECTED] web : www.enfocus.be *** ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Haskell and algebra
Frank Atanassow said: Gustavo Villavicencio wrote: Hi all, I am trying to understand the algebraic laws and operators behind a functional expression... f = g \equiv g* . f in the Kleisli Star context. Is this right? Yep. If it is so, can I combine g*.f with a fork for example? What do you mean by a fork? Jeremy Gibbons in Conditional in distributive categories, among others, calls fork to the operator typed as f /_\ g : A - B x C where f : A - B and g : A - C. In other literature it is also called split operador: f,g So, the question is, if i have f : A - T B and g : A - T C where T is a monad, i.e. an endofunctor, can i combine f and g as f,g : A - T (BxC) knowing that T involves side effects? Regards, Frank Regards, gustavo ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Announce: release candidate 1 of buddha version 1.0
Announcing buddha version 1.0 release candidate 1 - www.cs.mu.oz.au/~bjpop/buddha Buddha is a declarative debugger for Haskell 98. It is based on program transformation and relies on GHC version 5.04 or greater (but not version 6 yet). It also needs GHC's libraries compiled for profiling. This is the first candidate release of buddha version 1.0 New features include: - a more user friendly interface than previous versions, - the ability to show higher-order arguments by name or by value (similar to Hood), - deriving Ix is now supported (all standard deriving statements should work now). This is a release candidate. There will probably be a number of candidates before the final version 1.0 is done. Other candidates will not be announced to this list. This candidate has been tested only on Linux (Debian and Mandrake). Previous versions have worked on OS X and Solaris x86, but I don't have access to those machines at the moment. GHC version 6.0 is still not supported by buddha. If there is a great demand for this then I will sort it out faster. Cheers, Bernie. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: overlapping instances and functional dependencies
Suppose somewhere we have an instance: instance C Int Bool Int when the first instance decl you have says we also have instance C Int (x,y,Bool) Int in this case, Int + (x,y,Bool) should uniq. specify Int. however, we also have: instance C a (a,c,b) c where, if we let a=Int, b=Bool, c=Char, then we get that Int + (Int,Char,Bool) should uniq. specify Char. these two confict because if, in the first case, we instantiate x to Int and y to Char, then one says that the third param should be a Bool and the other says the third param should be a Char. (or at least this is my understanding -- someone might correct me) - Hal -- Hal Daume III | [EMAIL PROTECTED] Arrest this man, he talks in maths. | www.isi.edu/~hdaume -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wolfgang Jeltsch Sent: Friday, August 08, 2003 4:33 PM To: The Haskell Mailing List Subject: overlapping instances and functional dependencies Hello, I have this code: class C a b c | a b - c where f :: a - b - c instance C a b c = C a (x,y,b) c where f a (_,_,b) = f a b instance C a (a,c,b) c where f _ (_,c,_) = c ghci -fglasgow-exts -fallow-overlapping-instances compiles it without complaint but hugs -98 +o says: ERROR ClassProblem.hs:7 - Instances are not consistent with dependencies *** This instance: C a (a,b,c) b *** Conflicts with : C a (b,c,d) e *** For class: C a b c *** Under dependency : a b - c Can anyone tell me what the reason for this is and, maybe, how to avoid these problems with Hugs? Wolfgang ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Solution to the monomorphism restriction/implicit parameter problem
I wrote: Exactly the same rule should apply to implicit parameters. In the case of implicit parameters, safety is ensured if in every use of the bound variable, its implicit parameter refers to the same explicit binding of that parameter. For example, the expression let g = ?x in (g,g) should be accepted provided there is an enclosing binding of ?x, because in both uses of g the implicit parameter ?x refers to that same binding. I think what I wrote above is misleading. The explicit or enclosing binding need not be local, or even in a known location, as long as the compiler can prove that there's only one of them. And this is always possible in the case of non-local bindings. E.g.: f () = let g = ?x in (g,g) Each time f is invoked it will be passed exactly one implicit ?x. The compiler has no idea where that value was explicitly bound, but it can still prove that the two uses of g always refer to the same ?x. -- Ben ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Calling Haskell from Java
Calling Haskell from java was supposed to be supported by a tool called lambada, but all I can seen to find of that on the net is a paper. Does anyone have any pointers to more information/implementation. I specifically want to call Java-Haskell and not the other way around. thanks in advance Immanuel *** It makes me uncomfortable to see An English spinster of the middle class Describe the amorous effects of `brass', Reveal so frankly and with such sobriety The economic basis of society. W.H. Auden -- Immanuel Litzroth Software Development Engineer Enfocus Software Kleindokkaai 3-5 B-9000 Gent Belgium Voice: +32 9 269 23 90 Fax : +32 9 269 16 91 Email: [EMAIL PROTECTED] web : www.enfocus.be *** ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: literate scripts.
Immanuel Litzroth [EMAIL PROTECTED] writes: thanks for your code. Perhaps I was not completely clear in my question: I specifically want to know if unliterating should include lexing so that it recognizes strings (comments) or if it can be a separate phase. The following compiles without problems in ghc. \begin{code} main :: IO () main = putStr \end{code} \begin{code} \end{code} Ghc should not accept this code, because, no matter how the unliterating is achieved, it is illegal for a literal string to contain a literal newline character. (You must use '\n' for the character, and/or string-gaps if your intention is to make the layout more readable.) The report says Program code ends just before a subsequent line that begins \end{code} (ignoring string literals, of course). Certainly if the unliteration spec in the Haskell 1.2 Report is still valid (?) I believe the intention is that all unliteration is done in a line-by-line manner before any interpretation of the code text. Therefore, the unliteration engine does not need to lex the program code at all. Regards, Malcolm ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: Solution to the monomorphism restriction/implicit parameter problem
I wrote: My solution *is* the Right Thing. :-) What I meant is: it always preserves the validity of inlining, it always preserves sharing, and it rejects otherwise-correct programs only in situations which are (I expect) uncommon in practice. -- Ben ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
ANNOUNCE: Alex version 2.0
I am pleased to announce version 2.0 of Alex, the lexical analyser generator for Haskell. Based on Chris Dornan's original version of Alex, this new version contains some significant changes: - A revised syntax, more closely matching that of lex and Happy. - A rewritten back-end, producing smaller, faster, lexers. - A more flexible programmer interface, allowing simple tokenisers to be produced with very little code, and allowing monads to be threaded through the lexer. Read the release notes for the full story: http://www.haskell.org/alex/doc/html/about.html#RELNOTES This version has been tested on GHC: I have a development version of GHC using an Alex lexer, which beats the orignal hand-optimised lexer. Distributions can be obtained from Alex's new home: http://www.haskell.org/alex/ Alex is now distributed under a BSD-style license. Share and enjoy, Simon Marlow: [EMAIL PROTECTED] Chris Dornan: [EMAIL PROTECTED] Isaac Jones: [EMAIL PROTECTED] ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Calling Haskell from Java
Is it fine if the interface uses JNI? The jvm-bridge is an excellent tool if you can use JNI, but I don't know of anything that compiles Haskell to java bytecode. There was a post a few years ago about an experimental Java backend for GHC, but I haven't heard anything since, and the -J switch doesn't do anything in a recent GHC. The Mandarin people had a version of GHC back when they were targeting Java, but they've moved to .NET. Does anyone know of a project (or a CVS tag) for something that can compile Haskell to java bytecode? The jvm-bridge project includes tools for generating a Haskell interface to a java class, another for generating a monad that wraps the JVM initialization your program needs, using typeclasses to model the class hierearch and convert parameters. There is a function that will dynamically define a class with Haskell methods. I don't know how much support jvm-bridge provides if you want to define a class in Haskell and package it so you can use it from a normal java program. You would need to declare a class in java with native methods, and compile the haskell into a suitable library providing the native implementation. I don't remember any tools for doing this. I might have simply forgotten or overlooked a nice interface, or you might need to write the JNI code. If you are determined to go this way you could at least use the JNI binding JVM provides. Rather than doing that, it's probably simpler for your program to start in Haskell, even if all it does is define a class and invoke your main class (passing a factory object). I assume your haskell with need to call java at some point, if only to unpack a collection, so I'll pass along two things that confused me for a while. One thing to remember is that methods are defined in the class module for the first class that defined them. If you want to use a method that a class inherited from an ancestor you need to create and import the class module for that ancestor. The method will have a name like method_ancestor_args, but it calls the correct overridden method on whatever object you pass in a this (first argument). The other thing (this is more a Haskell issue) is that if you are writing a GUI program the main (Haskell) thread has to survive until the program is supposed to end, and it needs to be inside the let java threads run combinator. (sorry, I forgot the name and I'm away from my home machine). What are you trying to do? I'm thinking about porting a web testing application from python to haskell for parser combinators and monads (I'm using objects with a run method to control execution and thread through some state), but I don't know of any alternative to the HttpUnit library for testing webpages with javascript. I just need to call a bit of java in the middle of a Haskell program Tell us how your project works out. Brandon On 12 Aug 2003, Immanuel Litzroth wrote: Calling Haskell from java was supposed to be supported by a tool called lambada, but all I can seen to find of that on the net is a paper. Does anyone have any pointers to more information/implementation. I specifically want to call Java-Haskell and not the other way around. thanks in advance Immanuel *** It makes me uncomfortable to see An English spinster of the middle class Describe the amorous effects of `brass', Reveal so frankly and with such sobriety The economic basis of society. W.H. Auden -- Immanuel Litzroth Software Development Engineer Enfocus Software Kleindokkaai 3-5 B-9000 Gent Belgium Voice: +32 9 269 23 90 Fax : +32 9 269 16 91 Email: [EMAIL PROTECTED] web : www.enfocus.be *** ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: Help with Exceptions on I/O
You don't really need to change the buffering mode. stdout is line buffered by default, so you just need to make sure a newline is printed after your message. putStrLn adds a newline after the string it prints, or you could use \n in the string literal. Try this: main = do --lots of code goes here, --with a catch handler if you want it putStrLn Press ENTER to exit -- with Ln getLine return () On Tue, 12 Aug 2003, Hal Daume wrote: you can write this a bit more simply as: main = do (do do-the-major stuff here putStr File created...) `catch` (\_ - show the error) getLine-- look ma, no - return () now, your problem is almost certainly with buffering. in the main do, put hSetBuffering stdout NoBuffering hSetBuffering stdin NoBuffering you'll need to import System.IO to get these. -- Hal Daume III | [EMAIL PROTECTED] Arrest this man, he talks in maths. | www.isi.edu/~hdaume -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alexandre Weffort Thenorio Sent: Tuesday, August 12, 2003 4:17 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Help with Exceptions on I/O I have a program which creates textfiles out of other files. Since the program is runned from windows I output some text strings (Like File created succefully) and I need to stop the program before it quits so that the user can read the line outputted to know what went on and then he can press ENTER to quit the program. I managed to do this fine if no error occurs but when a error occurs I am having problems. The code goes like that main :: IO() main =catch (do Do all the needed stuff here putStr File created Successfully. Press RETURN to quit dummy - getLine --Halts the program so the user can read the above line) putStr Exiting now... --needed since I can't finish a do function with the dummy- getLine line) (\_ - do putStr \nFile not found. Press RETURN (ENTER) to quit. dumb - getLine putStr \nExiting...) So when the program runs, if the input file is found the program writes successfull creation of file but if the file doesn't exist, after the user gives the input filename and press enter, the program creates a new line and Halts (Probably because of the getLine function) without writing out anything, then when the user press ENTER again it writes the line at the first putStr (File not...), then writes the next putStr line under it (Exiting...) and exits. I don't know why it doesn't wirte the first line, halts and then when user press enter it writes the second and quits. Can anybody help me as I am not very familiar with exception and catches. Another question I have is: Is there any other function rather than getLine that halts a program and continues when a user press any key (Instead of ENTER) and besides this is an ugly code since getLine wasn't made for that but I couldn't find anything else myself. Thank you in advance. Best Regards Alex ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: Help with Exceptions on I/O
you can write this a bit more simply as: main = do (do do-the-major stuff here putStr File created...) `catch` (\_ - show the error) getLine-- look ma, no - return () now, your problem is almost certainly with buffering. in the main do, put hSetBuffering stdout NoBuffering hSetBuffering stdin NoBuffering you'll need to import System.IO to get these. -- Hal Daume III | [EMAIL PROTECTED] Arrest this man, he talks in maths. | www.isi.edu/~hdaume -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alexandre Weffort Thenorio Sent: Tuesday, August 12, 2003 4:17 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Help with Exceptions on I/O I have a program which creates textfiles out of other files. Since the program is runned from windows I output some text strings (Like File created succefully) and I need to stop the program before it quits so that the user can read the line outputted to know what went on and then he can press ENTER to quit the program. I managed to do this fine if no error occurs but when a error occurs I am having problems. The code goes like that main :: IO() main =catch (do Do all the needed stuff here putStr File created Successfully. Press RETURN to quit dummy - getLine --Halts the program so the user can read the above line) putStr Exiting now... --needed since I can't finish a do function with the dummy- getLine line) (\_ - do putStr \nFile not found. Press RETURN (ENTER) to quit. dumb - getLine putStr \nExiting...) So when the program runs, if the input file is found the program writes successfull creation of file but if the file doesn't exist, after the user gives the input filename and press enter, the program creates a new line and Halts (Probably because of the getLine function) without writing out anything, then when the user press ENTER again it writes the line at the first putStr (File not...), then writes the next putStr line under it (Exiting...) and exits. I don't know why it doesn't wirte the first line, halts and then when user press enter it writes the second and quits. Can anybody help me as I am not very familiar with exception and catches. Another question I have is: Is there any other function rather than getLine that halts a program and continues when a user press any key (Instead of ENTER) and besides this is an ugly code since getLine wasn't made for that but I couldn't find anything else myself. Thank you in advance. Best Regards Alex ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Implicit parameters, second draft
In article [EMAIL PROTECTED], Ben Rudiak-Gould [EMAIL PROTECTED] wrote: The proposed notation seems to be almost the same as the existing field-label notation semantically as well as syntactically, which suggests that it wouldn't be a destabilizing addition. (See section 2.5.) Might these be unified in any useful way? -- Ashley Yakeley, Seattle WA ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Haskell and algebra
Hi all, I am trying to understand the algebraic laws and operators behind a functional expression. So, for example, I can understand that the standard length function is a catamorphism, (| [_0, succ . \pi_2] |) where _0 is a constant function, . is the function composition, \pi_2 is a projection, and [] is a coproduct. Obviously, the type is 1 + A x A* - Int ([A] - Int in haskell). But, what about the actions? Behind these we have monads like algebraic structures. So, in the next expression f = g where we suppose that there is a T monad (endofunctor) involved, we can assume that f : a - T b, g : b - T c and g* : T b - T c. therefore f = g \equiv g* . f in the Kleisli Star context. Is this right? If it is so, can I combine g*.f with a fork for example? gustavo ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
ICFP 2003 / PLI 2003 -- final call for participation
The following message is a courtesy copy of an article that has been posted to comp.lang.scheme,comp.lang.scheme.scsh,comp.lang.dylan,comp.lang.functional,comp.lang.lisp,comp.lang.lisp.franz,comp.lang.lisp.mcl,comp.lang.lisp.x,comp.lang.apl,comp.lang.clos as well. ICFP 2003, the International Conference on Functional Programming, will be happening two weeks from now, 8/25-27. If you are contemplating registering for the conference, note that on-line/remote registration closes on Friday (8/15) -- although walk-in/on-site registration will be available up to and through the conference. I append the programme of talks to this message. For more information, see the conference web page http://www.cc.gatech.edu/~shivers/icfp03/schedule.html -Olin Shivers --- ICFP 2003 program - http://www.cc.gatech.edu/icfp03/schedule.html http://www.cc.gatech.edu/icfp03/schedule.txt Affiliated with PLI 2003 August 25-29, 2003 Uppsala, Sweden === Monday 25 August 2003 Invited talk: 9:00-10:00 Conservation of information: Applications in functional, reversible, and quantum computing Thomas Knight, Jr. (MIT Artificial Intelligence Laboratory) Session I: 10:30-12:30 -- Scripting the type-inference process Bastiaan Heeren, Jurriaan Hage, Doaitse Swierstra (Universiteit Utrecht) Discriminative sum types locate the source of type errors Matthias Neubauer, Peter Thiemann (Universität Freiburg) MLF: Raising ML to the power of System F Didier Le Botlan, Didier Rémy (INRIA Rocquencourt) An extension of HM(X) with bounded existential and universal data-types Vincent Simonet (INRIA Rocquencourt) Session II: 2:15-3:45 - CDuce: an XML-centric general-purpose language Véronique Benzaken (LRI, Université Paris Sud, Orsay), Giuseppe Castagna (CNRS, LIENS, École Normale Supérieure), Alain Frisch (LIENS, École Normale Supérieure, Paris) Compiling regular patterns Michael Levin (University of Pennsylvania) Software is discrete mathematics Rex Page (University of Oklahoma) Session III: 4:15-6:00 -- Global abstraction-safe marshalling with hash types James Leifer (INRIA Rocquencourt), Gilles Peskine(INRIA Rocquencourt), Peter Sewell (University of Cambridge), Keith Wansbrough (University of Cambridge) Dynamic rebinding for marshalling and update, with destruct-time lambda Gavin Bierman (University of Cambridge), Michael Hicks (University of Maryland, College Park), Peter Sewell (University of Cambridge), Gareth Stoyle (University of Cambridge), Keith Wansbrough (University of Cambridge) Iterative-free program analysis Mizuhito Ogawa (Japan Advanced Institute of Science and Technology), Zhenjiang Hu (University of Tokyo), Isao Sasano (Japan Advanced Institute of Technology and Science) Report on ICFP 2003 2004 Olin Shivers Kathleen Fisher === Tuesday 26 August 2003 Invited talk: 9:00-10:00 From Hilbert space to Dilbert space: Context semantics as a language for games and flow analysis Harry Mairson (Brandeis University) Session IV: 10:30-12:30 --- A theory of aspects David Walker (Princeton University), Steve Zdancewic (University of Pennsylvania), Jay Ligatti (Princeton University) Dependency-style Generic Haskell Andres Löh, Dave Clarke, Johan Jeuring (Universiteit Utrecht) Functional automatic differentiation with Dirac impulses Henrik Nilsson (Yale University) A user-centred approach to functions in Excel Simon Peyton Jones (Microsoft Research), Alan Blackwell (University of Cambridge), Margaret Burnett (Oregon State University) Session V: 2:15-3:45 A sound and complete axiomatization of delimited continuations Yukiyoshi Kameyama (University of Tsukuba), Masahito Hasegawa (Kyoto University) Call-by-value is dual to call-by-name Philip Wadler (Avaya Labs) Disjunctive normal forms and local exceptions Emmanuel Beffara (CRNS, Université Paris 7), Vincent Danos (CRNS, Université Paris 7) Session VI: 4:15-6:00 - An effective theory of type refinements Yitzhak Mandelbaum (Princeton University), David Walker (Princeton University), Robert Harper (Carnegie Mellon University) A static type system for JVM access control Tomoyuki Higuchi, Atsushi Ohori (Japan Advanced Institute of Science and Technology) Parsing polish, step by step (functional pearl) John Hughes (Chalmers University), Doaitse Swierstra (Universiteit Utrecht) Programming contest awards presentation John Hughes et
HI TypeCast
Hi there! Iam new to the list so feel free to shout at me when i do wrong! :) Software-designer from sweden, likes fast bikes and metal, thats me, and hi to you all! Yeah ok to the problem, i have this stupid code, [c | (c,i) - l] Where (c,i) are a tuple from a (Char,Int) and l is a [(Char,Int)] So far everthings nice but i would like to cast the c to a Sting and add : in front, So if i fry with a list like [('d',3)('f',3)] I end up with fg but i want it to look like :f :g piece of cake, huh? Give me a hit or a webpage to read more from...? How do you TypeCast in haskell? Cheers! //FRedde ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Haskell and algebra
Gustavo Villavicencio wrote: Frank Atanassow said: What do you mean by a fork? So, the question is, if i have f : A - T B and g : A - T C where T is a monad, i.e. an endofunctor, can i combine f and g as f,g : A - T (BxC) knowing that T involves side effects? I guess you are asking: if category C has finite products, and T is a strong monad on C, does the Kleisli category have finite products? The answer, I imagine, is not in general, but yes if the monad is commutative. pair :: (a - m b) - (a - m c) - (a - m (b,c)) pair f g a = do b - f a c - g a return (b, c) You need to pick an order for the first two actions. I haven't done the proof, though. Regards, Frank ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Type class problem
To try some of the examples from paper Recursion Schemes from Comonads, I wanted to define instances of Show and Observable for types defined as the fixed point of a functor. I defined type recursion and naturals as newtype Mu f = In {unIn :: f (Mu f)} data N f = S f | Z type Nat = Mu N An application of Mu should be showable if the functor maps showable types to showable types, so the most natural way to define the instance seemed to be instance (Show a = Show (f a)) = Show (Mu f) where show (In x) = show x Of course that constraint didn't work, so I made a class PShow with a method that witnessed the constraint class PShow f where pshow :: (Show a) = f a - String Now I could define a generic show instance for Mu, and got a Show instance for Nat by defing a PShow instance for N instance (PShow f) = Show (Mu f) where show (In x) = pshow x instance PShow N where pshow Z = Z pshow (S k) = S +show K show (In (S (In (S (In Z) - S S Z This works fine, but you need to be able to use the method of PClass in the definition of Class (Mu f). I couldn't figure out how to do the same thing with Observable (the use of the class methods is a few layers away from the public interface). I tried to define a set of mutaully recursive definitions instance (Observable (f (Mu f))) = Observable (Mu f) where observer (In x) = send In (return In x) instance (Observable a) = Observable (N a) where observer Z = send Z (return Z) observer (S x) = send S (return S x) unfortunately, the class constraint solver doesn't doesn't like this. I get an error message like Constraint Stack Overflow: Observable (N (Mu N)) Observable (Mu N) Observable (N (Mu N)) Observable (Mu N) ... I expected that that constraint solver would realize it could construct a dictionary transformer with a type like Observer Nat - Observer Nat and take the fixed point to get an instance for Nat. I haven't looked at the implementation, but it seems like it would be easy to add the constraint we are trying to derive to the list of assumptions when trying to construct all the anteceedents of an instance declaration. Can anyone tell me how to 1) get around this 2) modify GHC to handle this :) Brandon ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Calling Haskell from Java
In article [EMAIL PROTECTED], Immanuel Litzroth [EMAIL PROTECTED] wrote: Calling Haskell from java was supposed to be supported by a tool called lambada, but all I can seen to find of that on the net is a paper. Lambada is available from Sigbjorn Finne's web-page: http://galois.com/~sof/lambada-0-1.zip -- Ashley Yakeley, Seattle WA ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Haskell and algebra
Frank Atanassow wrote: Gustavo Villavicencio wrote: Hi all, I am trying to understand the algebraic laws and operators behind a functional expression... f = g \equiv g* . f in the Kleisli Star context. Is this right? Yep. Oops, or rather, not quite. m = g means g* m The Kleisli composition (-)* . (-) is sometimes written as (@@): (@@) :: (Monad m) = (b - m c) - (a - m b) - (a - m c) (f @@ g) x = let m = f x in m = g Regards, Frank ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Haskell and algebra
The Kleisli composition (-)* . (-) is sometimes written as (@@): (@@) :: (Monad m) = (b - m c) - (a - m b) - (a - m c) (f @@ g) x = let m = f x in m = g Man, I can't get anything right today. I meant: (g @@ f) x = let m = f x in m = g Apologies for the flooding. Regards, Frank ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: HI TypeCast
hello, Fredrik Petersson wrote: Hi there! Iam new to the list so feel free to shout at me when i do wrong! :) Software-designer from sweden, likes fast bikes and metal, thats me, and hi to you all! welcome Yeah ok to the problem, i have this stupid code, [c | (c,i) - l] Where (c,i) are a tuple from a (Char,Int) and l is a [(Char,Int)] So far everthings nice but i would like to cast the c to a Sting and add : in front, So if i fry with a list like [('d',3)('f',3)] I end up with fg but i want it to look like :f :g piece of cake, huh? Give me a hit or a webpage to read more from...? How do you TypeCast in haskell? no type casting in haskell. and we think of that as a feature, not a bug :-) having said that, you can write functions that convert values of one type into values of another. for example: toString :: Char - String toString c = [c] in Haskell the type String is the same as [Char], i.e. a string is a list of characters. another useful predefined function is: concat :: [[a]] - [a] that given a list of lists will produce a flattened list that contains all the elements, e.g. concat [[1,2],[3,4]] = [1,2,3,4]. in particular when you take 'a' above to be Char you get: concat :: [String] - String which takes a list of strings and gives you back a single string containing all the input strings. now you can achieve what you wanted as: concat [ : ++ toString c ++ | (c,i) - l ] ++ joins two lists into a single list. there are a lot of useful functions in the Prelude. hope this helped. by the way a better list to post questions when you are stuck with a program is probably [EMAIL PROTECTED], but people will usually reply on either list. bye iavor -- == | Iavor S. Diatchki, Ph.D. student | | Department of Computer Science and Engineering | | School of OGI at OHSU | | http://www.cse.ogi.edu/~diatchki | == ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Help with Exceptions on I/O
I have a program which creates textfiles out of other files. Since theprogram is runned from windows I output some text strings (Like "Filecreated succefully") and I need to stop the program before it quits so thatthe user can read the line outputted to know what went on and then he canpress ENTER to quit the program.I managed to do this fine if no error occurs but when a error occurs I amhaving problems.The code goes like thatmain :: IO()main =catch (do Do all the needed stuff here putStr "File created Successfully. Press RETURN toquit" dummy - getLine --Halts the program so the user canread the above line) putStr "Exiting now..." --needed since I can't finish ado function with the "dummy- getLine" line) (\_ - do putStr "\nFile notfound. Press RETURN (ENTER) to quit." dumb - getLine putStr "\nExiting...")So when the program runs, if the input file is found the program writessuccessfull creation of file but if the file doesn't exist, after the usergives the input filename and press enter, the program creates a new line andHalts (Probably because of the getLine function) without writing outanything, then when the user press ENTER again it writes the line at thefirst putStr (File not...), then writes the next putStr line under it(Exiting...) and exits. I don't know why it doesn't wirte the first line,halts and then when user press enter it writes the second and quits.Can anybody help me as I am not very familiar with exception and catches.Another question I have is: Is there any other function rather than getLinethat halts a program and continues when a user press any key (Instead ofENTER) and besides this is an ugly code since getLine wasn't made for thatbut I couldn't find anything else myself.Thank you in advance.Best RegardsAlex
Help with Exceptions on I/O
I have a program which creates textfiles out of other files. Since the program is runned from windows I output some text strings (Like File created succefully) and I need to stop the program before it quits so that the user can read the line outputted to know what went on and then he can press ENTER to quit the program. I managed to do this fine if no error occurs but when a error occurs I am having problems. The code goes like that main :: IO() main =catch (do Do all the needed stuff here putStr File created Successfully. Press RETURN to quit dummy - getLine --Halts the program so the user can read the above line) putStr Exiting now... --needed since I can't finish a do function with the dummy- getLine line) (\_ - do putStr \nFile not found. Press RETURN (ENTER) to quit. dumb - getLine putStr \nExiting...) So when the program runs, if the input file is found the program writes successfull creation of file but if the file doesn't exist, after the user gives the input filename and press enter, the program creates a new line and Halts (Probably because of the getLine function) without writing out anything, then when the user press ENTER again it writes the line at the first putStr (File not...), then writes the next putStr line under it (Exiting...) and exits. I don't know why it doesn't wirte the first line, halts and then when user press enter it writes the second and quits. Can anybody help me as I am not very familiar with exception and catches. Another question I have is: Is there any other function rather than getLine that halts a program and continues when a user press any key (Instead of ENTER) and besides this is an ugly code since getLine wasn't made for that but I couldn't find anything else myself. Thank you in advance. Best Regards Alex ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: haskell newbie seeking for advice
Jose A.Ortega Ruiz wrote: as stated in the subject, i'm a newcomer to haskell programming: i've read some tutorials and (portions of) a couple of books and am really fascinated with the language. but my haskell coding experience is limited to toy programs and short exercises. so i decided to try my hand at a small project to really learn haskell and the functional programming mindset[1], and i would appreciate to hear your opinions and comments on some issues before i start coding: - build toolchain. i'm used to the autoconfig/automake/make tools for C/C++ projects, and to ant for Java stuff. what do haskellers use? my initial thought was using a plain Makefile with ghc, but there is also hmake and maybe other tools i am missing. what would you use? [2] There's also ghc --make. -- Glynn Clements [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Yet Another Monad Tutorial
On Wed, 13 Aug 2003 13:26:34 +0200 blaat blaat [EMAIL PROTECTED] wrote: I have a long reply, perhaps I'll post it later. Here's a more pragmatic short one. What did we lose? Well, introspection comes to mind. A monad is strange in the sense that, actually, there does not seem to be any reason to compute its value since we cannot possibly get anything out of it. In case of IO, only the haskell interpreter can. And, introspection is a nice thing to have, especially for compiler writers. Although I think the benefits in Haskell would be limited, an application might be that I could write my own promotion functions on my own programs. Lot's of issues with this paragraph, but here are the questions. What do you mean by promotion function? How would you write it in your hypothetical Haskell? How is it related to IO? How do monads and/or the IO monad in particular cause problems? Why couldn't the same be done using monads or why would it be significantly harder if it can be done? Think of the following though experiment. What if I would have a function unparse:IO a-String which gives the textual representation of the specification of the object of type IO a? Clearly, IO is not a monad anymore. Moreover, I don't think it would break the purity of Haskell. And surely, in case of the IO monad, we can think of better manners to break a program down. Keith has already pointed out the flagrant error here; which I also point out in my long reply. But again, the questions... What is unparse supposed to return? What does it have to do with IO in particular, i.e. why do I want to unparse IO computations especially? Why can't it be done with (or over) the current IO monad? What other ways do you want to breakdown a program, still resulting in understandable behavior, but can't because of the IO monad? Hmm, I am rambling. The point is, I think there is no reason to discard all alternatives to monads; I believe that central in the IO-issue is not the fact that we are using monads for IO - but that we can purely create impure programs which do the IO for us ;-), and that those do not have to be of the monadic kind. I have comments for these too, but I'll keep this short. Basically, I don't really see how what you want has all that much to do with IO in general, and I don't see monads get in the way. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Editor in Linux for Hint/Helium
Tim Stitt wrote: I'm using the Helium interpreter/compiler with the Hint interface within Linux. Unfortunately, I want an editor that allows me to jump to the row/column of the source when I receive an error. Does anyone know of a good editor in Linux to do this or the commands for Emacs etc. that can be used from within Hint to achieve it? Emacs and XEmacs allow you to go to a specified line using +number, e.g. xemacs +20 foo.txt loads foo.txt and positions the cursor on line 20. The same syntax works with emacsclient (Emacs) and gnuclient (XEmacs), which load a file into an existing XEmacs process, i.e. gnuclient +20 foo.txt Emacs requires the server-start command (e.g. in ~/.emacs) before emacsclient can connect; similarly XEmacs requires gnuserv-start. -- Glynn Clements [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: idiom for producing comma-seperated lists?
Ketil Z. Malde wrote: Antony Courtney [EMAIL PROTECTED] writes: -- Example: format a list of strings, using a comma as a seperator: mkSepStr :: [String] - String mkSepStr xs = foldrs (\x s - x ++ , ++ s) xs t0 = mkSepStr [] -- == t1 = mkSepStr [hello]-- == hello t2 = mkSepStr [10,20,30] -- == 10, 20, 30 What do the rest of you do to solve this particular problem? Uh, concat and intersperse? Yep, that'll do the trick. Thanks for all the lightnin-fast responses. Appologies for overlooking this! -antony -- Antony Courtney Grad. Student, Dept. of Computer Science, Yale University [EMAIL PROTECTED] http://www.apocalypse.org/pub/u/antony ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Another typing question
On Tuesday 05 August 2003 15:23, Wolfgang Jeltsch wrote: There probably are ways to achieve this with Haskell's type system. The exact solution depends on what exactly you want. For just distinguishing between lists of different lengths you could use tuples like (a,a) (list of length 2) (a,a,a) (list of length 3) etc. What would be the advantage to using standard lists? In both cases I'd need explicit length checks everywhere. A better solution might be: data EmptyList element = EmptyList data TrueList list element = TrueList element (list element) A list of four Ints for example would be represented by a value of type TrueList (TrueList (TrueList (TrueList EmptyList))) Int. Isn't that just the Haskell list type by another name? You could define different types for different natural numbers: data Zero = Zero data Succ number = Succ number and do simple arithmetic with them at the type level: class Sum a b c | (a, b) - c instance Sum 0 a a instance Sum a b c = Sum (Succ a) b (Succ c) That looks interesting, I need to look into multiple parameter classes... At the moment, I cannot think of a way of defining a list type which is parameterized by such natural types. What I mean is having a type List :: * - * - * where for our above example of a list of four Ints we would have the type List (Succ (Succ (Succ (Succ Zero Int That's what I would like... What I can think of, is an association between our above list types (EmptyList and TrueList) and our natural number types by a multi-parameter class: class HasLength list length | list - length instance HasLength EmptyList Zero instance HasLength list length = HasLength (TrueList list) (Succ length) Again those multi-parameter classes... and off I go to the Haskell Web site ;-) Thanks for your comments! Konrad. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [newbie] UTF-8
Dnia pon 11. sierpnia 2003 00:49, Wolfgang Jeltsch napisa: The main problem is that you need binary I/O. Haskell 98 only provides text I/O. You don't need binary I/O for UTF-8 now; because implementations use ISO-8859-1, UTF-8 octets can be faked as characters by (chr . fromIntegral). The other point with text I/O is that under Windows the EOF character ^Z is treated specially and a conversion between Windows EOLs (^M^J) and Haskell EOLs (^J) takes place. UTF-8 preserves ASCII and doesn't use ASCII bytes for non-ASCII characters, so the situation is the same as in other encodings and text mode is usually fine. It would not be OK for UTF-16. -- __( Marcin Kowalczyk \__/ [EMAIL PROTECTED] ^^ http://qrnik.knm.org.pl/~qrczak/ ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
On Thu, 14 Aug 2003, Wolfgang Jeltsch wrote: On Thursday, 2003-08-14, 17:05, CEST, Kevin S. Millikin wrote: On Wednesday, August 13, 2003 11:20 PM, Tn X-10n [SMTP:[EMAIL PROTECTED] wrote: is it possible to convert IO Bool to Bool? Sure. Which Bool do you want? True? toTrue :: IO Bool - Bool toTrue x = True Or False? toFalse :: IO Bool - Bool toFalse x = False There's also boolFromIO :: IO Bool - Bool boolFromIO = boolFromIO if you want to be even less useful :) I wouldn't call these *conversion* functions because they don't look at their argument. Maybe that's not what you had in mind. Surely not. Wolfgang I'm surprise nobody has mentioned unsafePerformIO (:: IO a - a). As the name suggests, it isn't referentially transparent. Are you sure you need a function of type IO Bool - Bool? What are you trying to do? Brandon ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: idiom for producing comma-seperated lists?
Antony Courtney [EMAIL PROTECTED] writes: -- Example: format a list of strings, using a comma as a seperator: mkSepStr :: [String] - String mkSepStr xs = foldrs (\x s - x ++ , ++ s) xs t0 = mkSepStr [] -- == t1 = mkSepStr [hello]-- == hello t2 = mkSepStr [10,20,30] -- == 10, 20, 30 What do the rest of you do to solve this particular problem? Uh, concat and intersperse? Prelude concat $ List.intersperse , $ [] Prelude concat $ List.intersperse , $ [hello] hello Prelude concat $ List.intersperse , $ [10,20,30] 10, 20, 30 -kzm -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: .. Drowning in stateful, side-effect riddled, spaghetti code? We have the answer. fdps[]c.
Hey there! Stateful side-effect-laden spaghetti programming sucks, and so does the cost.. feel like your [sic] getting ripped off? ... We tear up your code and give you and your colleagues a fresh start .. - Save you a lot of money by eliminating side-effects - Develop new code in substantially reduced time - Stop customers/managers calling you on the phone about late delivery - Avoid code maintenance debt ... and more! Why keep dealing with the stress, and headaches, of mainstream programming styles? Combine pure and lazy functional programming and get on with your life today!! Come here and take a look at how we can help. http:///www.haskell.org -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 12 August 2003 08:47 To: [EMAIL PROTECTED] Subject: .. Drowning in debt? We have the answer. fdps[]c. Hey There! Debt sucks, and so do the repayments.. feel like your getting ripped off? .. We tear up your debt and give you and your family a fresh start .. - Save you a lot of money by eliminating late fees - Settle your accounts for a substantially reduced amount - Stop creditors calling you on the phone - Avoid bankruptcy ... and more! Why keep dealing with the stress, and headaches? Combine your debt into a low interest repayment and get on with your life today!! Come here and take a look at how we can help. http://[EMAIL PROTECTED]/index.php?N=g * The information in this email and in any attachments is confidential and intended solely for the attention and use of the named addressee(s). This information may be subject to legal professional or other privilege or may otherwise be protected by work product immunity or other legal rules. It must not be disclosed to any person without our authority. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it. * ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: Database interface
[EMAIL PROTECTED] wrote: If I may interject, that's precisely how a Scheme DB interface is designed. The main function is a left-fold. Not quite though: it provides for a premature termination: A major procedure: DB1:fold-left PROC INITIAL-SEED QUERY-OBJECT Premature termination sounds like a useful property. I can see two ways this could be done: keep the previous signature, and use an exception to exit early, or add a boolean return value like the scheme version: doquery :: Process - String - (a - b - IO (b,Bool)) - b - IO b Any opinions on which alternative wouuld be preferable? Tim ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[String]-[[Bool]] 2
[String] contains = ["1 0 0","1 0 0","0 1 0"] this [String] is read from a file. the file shows only: i convert it by using Lines. but i stuck wif the output. 1 0 0 1 0 0 1 0 1 if 1 then False 0 then True the expected result show be [[False,True,True],[False,True,True],[True,False,True]] My code is as followed... readF :: String - IO () readF fname = do x - (readFile fname) putStr (show(conv(words x))) i can't use lines here because change only accepts "0" or "1". but my file contains spaces. change :: String - Bool change "1" = True change "0" = False conv :: [String] - [Bool]==unable to declare [[Bool]] conv fname = [(change x)| x - (fname)] Get free gift vouchers every week with MSN Premium Vouchers ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Another typing question
On Tuesday, 2003-08-05, 15:22, CEST, Nick Name wrote: [...] Is there any way to parametrize a type by a value, rather than another type? What I would like to do is to define list of length 3 and list of length 4 as separate parametrization of the same type, such that I could write functions that accept lists (under my new typename) of any length as long as parameters have the same length. The goal is to remove the need for runtime checks all over the code. This is called dependent types and is not a feature of haskell (nor of any language that I know); there was cayenne (try a google search) but I don't believe it is still mantained. Well, there are, e.g., Ada and C++ which allow types to be parametrized by values. The point is that they obviously still use runtime checks, it's just that you don't have to code these checks explicitely. BTW, why is there no general interest for such a thing as dependent types? What negative consequences does their implementation have? I think, sometimes they could be quite handy. V. W. ;-) ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: Yet Another Monad Tutorial
Alistair, Hhhmmm. That is an interesting issue, and I am unsure how to treat it in the tutorial. I did attempt to explain the ability of the monad to isolate impure computations, but I think I need to make a better explanation of what an action is and how it is used. As for the question of whether using a monad in this way casts Haskell out of the ranks of the functionally pure, I don't know. This feels to me like a debate over personal interpretation, with decent arguments on both sides. I think the most accurate thing to say is that it enables Haskell to incorporate non-pure features without destroying the purity of the core of the language. Any suggestions for how best to present this issue to a reader who may be new to the world of FP? Should we mention it at all? Thanks, Jeff Alistair Bayley wrote: Thanks. Quite comprehensive. Peter Van Roy (the Mozart/Oz guy) said this on the PragProg list, and I didn't have the knowledge to respond. It's a point you might want to address, perhaps in this section?: http://www.nomaware.com/monads/html/laws.html#nowayout [Discussion of whether I/O monad makes Haskell impure] -- Jeff Newbern [EMAIL PROTECTED] Nomaware, Inc. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Yet Another Monad Tutorial
To many questions, not enough mail. First, thanks for all your replies. Second, I stand totally corrected on the fact that we cannot break down monads. Functions of type m a-b are called impure, see also unsafePerformIO. I am questioning (a) the exact relation between monads, monadic IO, IO in general and (b) whether the impure restriction is actually a warranted restriction, which relates to, what I find, strange evaluation behavior of the IO monad. What is the difference between putStr a, (putStr a, putStr a), putStr (putStr a), putStr (show (putStr a))? At the moment objects of type IO a _only_ get evaluted when they are the _sole_ result of a Haskell program. What kind of strange dichotomy is that? Is not the _only_ interpretation of this dichotomy that objects of type IO describe impure programs (composed of actions which are only evaluated when...)? And, if so, why can't we decompose these programs (before they get evaluated)? And, if so, is not the only relation between a monad and doing functional IO that there is a monadic manner to construct descriptions of impure programs? If so, are there also non-monadic ways which might be equally interesting? As stated by Keith, deriving show for IO is possible. In such a setting putStr (putStr a) I imagine returns putStr \a\, which I find far more orthogonal than what we have now. (Have to find the reference still). Does this boil down to an impure or a pure decomposition? From: Derek Elkins [EMAIL PROTECTED] To: blaat blaat [EMAIL PROTECTED], [EMAIL PROTECTED] pragmatic short one. What did we lose? Well, introspection comes to mind. A monad is strange in the sense that, actually, there does not seem to be any reason to compute its value since we cannot possibly get anything out of it. In case of IO, only the haskell interpreter can. And, introspection is a nice thing to have, especially for compiler writers. Although I think the benefits in Haskell would be limited, an application might be that I could write my own promotion functions on my own programs. Lot's of issues with this paragraph, but here are the questions. What do you mean by promotion function? Example of promotion: map f . map g = map (f . g) A promotion function would transform objects of type IO a into objects of type IO a while performing promotions. How would you write it in your hypothetical Haskell? How is it related to IO? How do monads and/or the IO monad in particular cause problems? Why couldn't the same be done using monads or why would it be significantly harder if it can be done? In a monadic approach, I imagine functions like unbind which now would break purity. [..] I believe that central in the IO-issue is not the fact that we are using monads for IO - but that we can purely create impure programs which do the IO for us ;-), and that those do not have to be of the monadic kind. I still stand here (but am totally willing to be corrected on this account too). Hmpf, maybe someone more enlightened should write a paper on it. Cheers, l4t3r _ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Yet Another Monad Tutorial
Peter G. Hancock wrote: Jeff Newbern wrote (on Tue, 12 Aug 2003 at 17:20): ? The functions exported from the IO module do not perform I/O themselves. They return I/O actions, which describe an I/O operation to be performed. The I/O actions are combined within the IO monad (in a purely functional manner) to create more complex I/O actions, resulting in the final I/O action that is the main value of the program. The result of the Haskell compiler is an executable function incorporating the main I/O action. Executing the program applies this ultimate I/O action to the outside world to produce a new state of the world. That seems to me the wrong thing to say. There is no application. Whether or not the word is put in quotes, it is something involving a function and an argument. An IO action is not a function. So then, in your view, what *is* an IO action? One conceptual model is that an IO action with type (IO a) denotes a function of type World - (World,a). Given that model, applying an IO action to the external world seems like a perfectly reasonable account of executing such an action. -antony -- Antony Courtney Grad. Student, Dept. of Computer Science, Yale University [EMAIL PROTECTED] http://www.apocalypse.org/pub/u/antony ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
AW: Yet Another Monad Tutorial
The overall message I have taken from your post is that I need to be more precise to convey the correct information and avoid confusion (or worse, misinformation). As I understood it, the tutorial should be instructive. So I would not try to be more precise at the beginning, because too much detail would lead to confusion for a beginner. Start with something like I'm now telling you some lies, which make it easier to grasp the idea of the monad, but further down the road, I'll reexplain some concepts and be more precise there. This was done by Don Knuth for the Typesetting-Books and it worked very well (for me). I hope this is a sensible idea. Markus -- Markus Schnell Infineon Technologies AG, CPR ET Tel +49 (89) 234-20875 ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: Database interface
I'll probably generalise the query function to do a fold, rathen than always accumulate a list: doquery :: Process - String - (a - b - IO b) - b - IO b If I may interject, that's precisely how a Scheme DB interface is designed. The main function is a left-fold. Not quite though: it provides for a premature termination: A major procedure: DB1:fold-left PROC INITIAL-SEED QUERY-OBJECT A QUERY-OBJECT (which in this implementation is a list of fragments that make a SQL statement, in the reverse order -- without the terminating semi-colon) is submitted to the database, using the default database connection. PROC is a procedure: SEED COL COL ... The procedure PROC takes 1+n arguments where n is the number of columns in the the table returned by the query. The procedure PROC must return two values: CONTINUE? NEW-SEED The query is executed, and the PROC is applied to each returned row in order. The first invocation of PROC receives INITIAL-SEED as its first argument. Each following invocation of PROC receives as the first argument the NEW-SEED result of the previous invocation of PROC. The CONTINUE? result of PROC is an early termination flag. If that flag is returned as #f, any further applications of PROC are skipped and DB1:fold-left finishes. The function DB1:fold-left returns NEW-SEED produced by the last invocation of PROC. If the query yielded no rows, DB1:fold-left returns the INITIAL-SEED. Thus DB1:fold-left is identical to the left fold over a sequence, modulo the early termination. There are a few minor variants of the above procedure, optimized for common particular cases: a query that is expected to return at most one row, and a query that expects to return at most one row with exactly one column. The latter query has the same interface as a lookup in a finite map. The QUERY-OBJECT is of coursed not built by hand. There is a domain-specific language (which greatly resembles the source language and makes some use of quasi-quotation) whose result is a query object. Therefore, I can write both the query and the handlers of the query result using the same syntax. The premature termination is important. Database connections and cursors are too precious resources to leave them for the garbage collector to finalize. More discussion and pointers can be found at http://srfi.schemers.org/srfi-44/mail-archive/msg00023.html The interface has been used in an industrial application. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Yet Another Monad Tutorial
I suspect that tutorials should at some point mention some definitions of monads, monoids et al --- since this is where the power (sorry, QA) comes from. I was reading an overview-for-non-specialists of category theory earlier today, and was surprised by the familiarity of much of it - based on the little Haskell I'd learned. What it didn't have, and what I'd still like to read, is an overview-for-non-specialists of monads and monoids, as this was one bit of the mathematical terminology used by Haskell that was rather opaque to me - I think of a monad as a) a sort of a self-contained something-or-other in Liebniz's philosophy, and b) a scary baddy in the ABC Warriors comic strip published by 2000AD (I'm not making this up...). Dominic ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [String] - [[Bool]]
i am new wif haskell, i would like to know how can i get a list of string and convert it to a list of a list of bool [String]- [[Bool]] for example a [String] [0 1 0 1 0 1,0 0 0 0 0 0 ,1 0 0 0 1 0] it return true if 0 and false if 1. the [String] is read from a file. map (\x - map (==0) x) $ map words [0 1 0 1 0 1,0 0 0 0 0 0 ,1 0 0 0 1 0] -- Yoshinori Tahara [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
haskell newbie seeking for advice
hi all, as stated in the subject, i'm a newcomer to haskell programming: i've read some tutorials and (portions of) a couple of books and am really fascinated with the language. but my haskell coding experience is limited to toy programs and short exercises. so i decided to try my hand at a small project to really learn haskell and the functional programming mindset[1], and i would appreciate to hear your opinions and comments on some issues before i start coding: - build toolchain. i'm used to the autoconfig/automake/make tools for C/C++ projects, and to ant for Java stuff. what do haskellers use? my initial thought was using a plain Makefile with ghc, but there is also hmake and maybe other tools i am missing. what would you use? [2] - graphics toolkit. one of my programs will be a GUI. there seems to be a lot of choice here: gtk2hs looks nice (as used in hircules) and fudgets seems to have a pretty interesting and well-documented architecture (which covers also client/server programming: i'll be using a client/server architecture too) but its widgets are uglier and look alien in current linux desktops. i'd like to have a fudgets-gtk framework of sorts :) and then, there is htoolkit, Object I/O and whatnot... any recommendations? - TCP/IP stuff. i will have a client/server architecture with TCP/IP as the transport protocol. other than fudgets, i'm not aware of any haskell framework for IPC: am i missing something? - XML. i'll be handling XML documents, and HaXml seems to me an excellent candidate to cover this area, but, of course, i'm very interested in hearing of alternatives... thanks a lot for your help! cheers, jao Footnotes: [1] if that matters, the project will consist on a set of utilities for handling a document metadata database, based upon the OMF standard. [2] my project will consist of several executables, sharing a set of common libraries and, therefore, i plan to use (if possible) a non-flat directory layout. -- Come to think of it, there are already a million monkeys on a million typewriters, and Usenet is NOTHING like Shakespeare. - Blair Houghton. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Yet Another Monad Tutorial
Peter, Thank you for criticism. This is exactly the kind of feedback I need. The overall message I have taken from your post is that I need to be more precise to convey the correct information and avoid confusion (or worse, misinformation). I should have said that a function which performs a computation in the I/O monad must have IO as the outermost constructor in its return type. I think that is more precise (and correct :-). As for the later text concerning application of the top-level I/O action, I will need to think for a while to see how I can word this more clearly. If you (or anyone else) have ideas, I'd like to hear them. Thanks again, Jeff On Tue, 2003-08-12 at 18:24, Peter G. Hancock wrote: Jeff Newbern wrote (on Tue, 12 Aug 2003 at 17:20): (proposed revisions) In the section No Way Out: -- The IO monad is a familiar example of a one-way monad in Haskell. Because you can't escape from the IO monad, it is impossible to write a function that does a computation in the IO monad but returns a non-monadic value. I wouldn't say that, as it is inaccurate. Of course you can return a value of _some_ monadic type eg. (Maybe ...). Not only are functions of the type IO a - a impossible to create, You can quite easily write a function of type IO (IO a) - IO a, which is a special case of that type. but any function whose result type does not contain the IO type constructor is guaranteed not to use the IO monad. That's rather vague: what does it mean for a function to use a monad? Other monads, such as List and Maybe, do allow values out of the monad. So it is possible to write non-monadic functions that internally do computations in those monads. The one-way nature of the IO monad also has consequences when combining monads, a topic that is discussed in part III. -- In summary, I've only a vague idea of what you are trying to say. If you can't reformulate it more precisely, don't add the above stuff. and a little farther down: -- Some people argue that using monads to introduce non-pure features into Haskell disqualifies it from claiming to be a pure functional language. This subtle question not particularly relevant to the practical programmer is revisited in the context of the I/O monad later in the tutorial. -- That's fair enough. I don't think the question is so much subtle as religious, as we might expect from the terminology of purity. Later, in the section on the I/O monad: -- In Haskell, the top-level main function must have type IO (), so that programs are typically structured at the top level as an imperative-style sequence of I/O actions and calls to functional-style code. Revisiting the debate about the purity of Haskell (in a functional sense), it is important to note that the IO monad only simulates imperative-style I/O. That (about simulation) seems weak. A simulation isn't a vague syntactic resemblance. The functions exported from the IO module do not perform I/O themselves. They return I/O actions, which describe an I/O operation to be performed. The I/O actions are combined within the IO monad (in a purely functional manner) to create more complex I/O actions, resulting in the final I/O action that is the main value of the program. The result of the Haskell compiler is an executable function incorporating the main I/O action. Executing the program applies this ultimate I/O action to the outside world to produce a new state of the world. That seems to me the wrong thing to say. There is no application. Whether or not the word is put in quotes, it is something involving a function and an argument. An IO action is not a function. This occurs only once per execution of the program, and since the state of the world changes for each execution, the issue of purity is neatly side-stepped. -- By the program, I think you mean the IO action. I think it is right to speak of the action as something that is executed. Execution may involve (side-effect free) calculation; but execution is something essentially different from calculation, not an impure form of it. I'm sorry to sound negative -- it's just that you invited criticism. Your pages seem generally of a very high quality to me. Sorry not to be more constructive too. Peter Hancock -- Jeff Newbern [EMAIL PROTECTED] Nomaware, Inc. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Another typing question
On Tuesday, 2003-08-05, 15:22, CEST, Nick Name wrote: snip This is called dependent types and is not a feature of haskell (nor of any language that I know); there was cayenne (try a google search) but I don't believe it is still mantained. snip BTW, why is there no general interest for such a thing as dependent types? What negative consequences does their implementation have? It depends on whether you just want to write functions to take in values of such types, or whether you want to write functions to return values of such types. Doing the former uses dependant products, which would require a significant extension to GHC's guts, but not (AIUI) inherently unpleasant. Doing the latter (AIUI) essentially requires dependant sums. Basically, a family of types A_i parameterized by a value i :: I is written, for long-honored traditional reasons too complex to get into here, Sigma i::I.A_i. Now, if you have such dependant sums, there's a bad interaction with polymorphism: either you must have a type alpha which cannot appear in a family of types A_i in a dependant sum, or, for any function f :: alpha - alpha, there exists a type beta such that f cannot be aplied at either beta or Sigma i::Int.beta. Clear? The alternative, btw., is to have both dependant sums and an undecidable type-checking problem. I think, sometimes they could be quite handy. Sure. Sarcastic comment censored. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
On Thursday 14 August 2003 06:20, Tn X-10n wrote: htmldiv style='background-color:'DIV PBRhai guys/Pis it possible to convert IO Bool to Bool?/DIV/divbr clear=allhrGet 10mb of e-mail space with a href=http://g.msn.com/8HMTENSG/2737??PS=;MSN Hotmail Extra Storage/a at only S$36 per year including GST/html It makes no sense to convert an IO Bool to a Bool. If something has type IO Bool that means it is an action which will get a Bool from the outside world. It cannot be converted into a Bool. If you want to use the action to get a Bool from the outside world you should invoke the action in somewhere in the IO part of your code, like this.. do ... boolVal - ioBoolAction ... Regards -- Adrian Hey ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Fwd: Re: Yet Another Monad Tutorial
From: Derek Elkins [EMAIL PROTECTED] blaat blaat [EMAIL PROTECTED] wrote: [...] However, given that observation, the fact that IO is a monad I find to be a _rather arbitrary design decision_; why not define a small term language which may be passed to the OS? That would be confusing to use or restrictive (unless done exceedingly well perhaps), it would be awkward to define, and it would pretty much require arbitrary design decisions (what should be included in this language? what are it's semantics? etc). Why not have (some limited) introspection on programs which we build? It would be round-about in both implementation and use to do this. Nevertheless, you can easily view the IO monad as an imperative language -embedded- in Haskell. Even when writing mostly imperative code Haskell gives you much more flexibility and protection than many imperative languages, especially the more popular ones. [...] Are we missing out on usefull stuff? No, but if we were, it'd be trivial to test/get it with an appropriate top-level runTheProgram IO computation definable in Haskell today. Trivial to test I fully agree with; however, to the missing out on usefull stuff I am not convinced. Please allow me to continue my trolling. To use the IO monad for impure calculations is, of course, a design decision. It is arbitrary to the point that I have the freedom not to agree with it; but hey, even I know the thing works ;-). The key point to my email was that doing impure IO possibly has little to do with a monadic style of programming but with the fact that we can functionally construct a description of an impure program which is evaluated _only_ when delivered as a sole result of a Haskell computation. I find that somewhat odd; but not to the point I cannot live with it ;-) About the indirectness issue. The benefit of choosing a monad is clear - the evaluation/rewrite of an action corresponds directly with an impure subroutine call. Moreover, the action can be discarded and, as you pointed out, the description of these impure subroutine calls are trivially embedded directly into Haskell - giving typesafety as a reward. It is both effective and efficient. Great Hail to the monad! Hmmm, uhm, but let's think further... What did we lose? Well, introspection comes to mind. A monad is strange in the sense that, actually, there does not seem to be any reason to compute its value since we cannot possibly get anything out of it. In case of IO, only the haskell interpreter can. And, introspection is a nice thing to have, especially for compiler writers. Although I think the benefits in Haskell would be limited, an application might be that I could write my own promotion functions on my own programs. Think of the following though experiment. What if I would have a function unparse:IO a-String which gives the textual representation of the specification of the object of type IO a? Clearly, IO is not a monad anymore. Moreover, I don't think it would break the purity of Haskell. And surely, in case of the IO monad, we can think of better manners to break a program down. Hmm, I am rambling. The point is, I think there is no reason to discard all alternatives to monads; I believe that central in the IO-issue is not the fact that we are using monads for IO - but that we can purely create impure programs which do the IO for us ;-), and that those do not have to be of the monadic kind (with all respect to the baffling ingenuity of the invention). Cheers, l4t3r _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Outlook
hey there, i thought you'd like to check this out You really owe it to yourself and your family to take a look, With the money you save, put it towards a new car! --- http://btrack.iwon.com/r.pl?redir=http://[EMAIL PROTECTED]/index.asp?RefID=198478 --- for no more http://[EMAIL PROTECTED]/auto/index.htm ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Yet Another Monad Tutorial
Hello, I have put up all-in-one archives of the tutorial for people who prefer to read it offline. http://www.nomaware.com/monads/monad_tutorial.tgz and http://www.nomaware.com/monads/monad_tutorial.zip Thanks, Jeff Newbern [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Database interface
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I still want to use HaskellDB (or at least the relational calculus part of it), so I was thinking of splitting it into two pieces: a library that submits SQL queries and returns the results (database interface), and a library that constructs queries with the relational calculus and generates SQL from them. Obviously the database interface must be written for each DBMS product, while the relational calculus library ought to be independent of DBMS (although it might be wise to have SQL compatibility flags for the SQL it generates. For example: Oracle 8 (what I'm using now) only supports SQL-92). Ideally, we would have the following. 1/ A high level combinator library for relational calculus built on, 2/ A standard low-level Haskell API i.e. functions like Connection - String - ( a - b - IO b) - IO b 3/ Database specific bindings. The problem is that projections and cartesian products generate new types, at least in the way it was done in HaskellDB. The form the calculus takes would need to be substantially reworked. Tom -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/O6DBYha8TWXIQwoRAmkCAKCwZkNpU3TjX5bj7rOZHx5DXRjPhwCgihnY sAWwEKX+5hZ1Tiu4wfSGo7Y= =ALnJ -END PGP SIGNATURE- ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
On Thursday, 2003-08-14, 17:05, CEST, Kevin S. Millikin wrote: On Wednesday, August 13, 2003 11:20 PM, Tn X-10n [SMTP:[EMAIL PROTECTED] wrote: is it possible to convert IO Bool to Bool? Sure. Which Bool do you want? True? toTrue :: IO Bool - Bool toTrue x = True Or False? toFalse :: IO Bool - Bool toFalse x = False I wouldn't call these *conversion* functions because they don't look at their argument. Maybe that's not what you had in mind. Surely not. Wolfgang ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Yet Another Monad Tutorial
On Tue, Aug 12, 2003 at 03:04:39PM -0400, Antony Courtney wrote: So then, in your view, what *is* an IO action? One conceptual model is that an IO action with type (IO a) denotes a function of type World - (World,a). But the IO monad is not a state monad, because other agents may change the state of the world while a Haskell program is running. It's more accurate to say that the program returns an action to be executed by the environment: data IO a = Return a | Invoke (SysCall (IO a)) data SysCall r = GetChar (Char - r) | PutChar Char r | ... In addition to the usual arguments, the system call is given a return continuation to enter on completion. (This was the model of interactive I/O used by Moggi in An Abstract View of Programming Languages, and is also used by Fudgets.) Of course the interpretation the environment places on GetChar, etc is outside of the functional world. That simple model omits exceptions. One way of adding them is data IO a = Return a | Error IOError | Invoke (SysCall (IO a)) (IOError - IO a) ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: IO Bool - Bool
On Wednesday, August 13, 2003 11:20 PM, Tn X-10n [SMTP:[EMAIL PROTECTED] wrote: is it possible to convert IO Bool to Bool? Sure. Which Bool do you want? True? toTrue :: IO Bool - Bool toTrue x = True Or False? toFalse :: IO Bool - Bool toFalse x = False Maybe that's not what you had in mind. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: Yet Another Monad Tutorial
From: Wolfgang Jeltsch [mailto:[EMAIL PROTECTED] For example, the function readFile is pure. For a specific string s the expression readFile s always yields the same result: an I/O action which searches for a file named s, reads its content and takes this content as the result of the *action* (not the expression). What about getChar? This is a function which takes no arguments, yet returns a (potentially) different value each time. I know, I know: it returns an IO action which reads a single char from the terminal and returns it. Is the IO monad the only one (currently) in which you would say that it returns an action, which is then executed by the runtime system? I would have thought that monads that are not involved in IO (e.g. State) would be pure in the sense that Van Roy was thinking. You wouldn't need to describe functions in them as returning an action. * The information in this email and in any attachments is confidential and intended solely for the attention and use of the named addressee(s). This information may be subject to legal professional or other privilege or may otherwise be protected by work product immunity or other legal rules. It must not be disclosed to any person without our authority. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it. * ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
PBRhai guys/Pis it possible to convert IO Bool to Bool? No, it's not... and for good reason! See the discussion at http://www.haskell.org/hawiki/ThatAnnoyingIoType and http://www.haskell.org/hawiki/UsingIo In general, the HaWiki has answers to lots of newbie questions like this - you might find it useful to peruse (although you should certainly continue to ask questions here too - we're a pretty friendly bunch!). Best wishes, --KW 8-) -- Keith Wansbrough [EMAIL PROTECTED] http://www.cl.cam.ac.uk/users/kw217/ University of Cambridge Computer Laboratory. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe