[Haskell-cafe] Upgrading Arch Linux Haskell Packages
Hi, Is there a way to manually upgrade Haskell packages in the aur repository of Arch Linux which were previously contributed automatically by arch-haskell? Or is there a batch upgrade planned for the near future? What is the mailing list for arch Best Regards, Cetin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [arch-haskell] Upgrading Arch Linux Haskell Packages
Even while having a break he's blazing fast with his replies! 2010/1/8 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Don Stewart d...@galois.com writes: There's a batch upgrade, I've just been travelling! Yeah, let Don have a break for once! Oh, since you're here Don, how do I do ... ? ;-) -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [ANN] text 0.7, fast Unicode text
http://corsis.sourceforge.net/img/csharp-6.png http://corsis.sourceforge.net/img/csharp-6.pngo__O!? 2009/12/16 Bryan O'Sullivan b...@serpentine.com On Tue, Dec 15, 2009 at 8:03 PM, Ashley Yakeley ash...@semantic.orgwrote: How do you pack Unicode codepoints into Word16? Do you use UTF-16? You don't get to find out as a user of the Text API, but yes. Supposing - s = \x010A60\x010A61 -- Old South Arabian script t = pack s Is (unpack t) the same as s? What is (length t)? Yes, and 2. Any other answer would clearly be wrong (I'm lookin' at you, Java and C#) :-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Plot data reconstruction reading pixel colors from image files
Hi, How can I open and read colors of specific pixels of an image file in Haskell? Which packages, functions do you recommend? You can have a look at the quoted conversation for an idea on what I would like to automate. Best Regards, Cetin Sert Hi dear *^o^*, Here are the points from Figure 37 [SEE ATTACHED PNG] Cisse Goni Kodougou Nouna normals log10s normals log10s normals log10s normals log10s 0.7998 0.5249 0.4248 0.375 0.412499964 0.4248 0.8501 1.575 1.5999 1.325 1.0498 6.30957344480193 3.3496543915782757 2.6607250597988084 2.371373705661655 2.5852348395621885 2.6607250597988084 7.07945784384138 37.583740428844415 39.81071705534971 21.134890398366466 11.220184543019629 -0.5625 -0.3252 0.162499964 0.3374 0.5 0.8501 1.48749998 2.1375 2.2625 1.875 1.0 0.27384196342643613 0.4731512589614803 1.4537843856076607 2.1752040340195222 3.1622776601683795 7.07945784384138 30.725573652674456 137.24609610075626 183.02061063110568 74.98942093324558 10.0 0.7251 0.34964 0.3374 0.5 0.625 0.63749997 0.76249997 1.2249 1.5125 1.2125 0.625 5.30882309884 2.2387211385683377 2.1752040340195222 3.1622776601683795 4.216965034285822 4.340102636447436 5.787619883491203 16.788040181225597 32.546178349804585 16.31172909227838 4.216965034285822 0.3374 0.137499973 0.375 0.6499 0.5747 0.47464 0.98749998 1.825 2.025 1.4749 0.76249997 2.1752040340195222 1.372460961007561 2.371373705661655 4.46683592150963 3.7583740428844394 2.9853826189179573 9.716279515771058 66.83439175686145 105.92537251772886 29.853826189179586 5.787619883491203 Top to Bottom in the table is Left to Right in the figure. Lots of love, CS ;-) P/S: Sorry it took a bit longer than expected but it was lots of fun! --- module Main where import Control.Monad f x = 3 - (x / 80) -- 80: number of pixels d x = x - 2 -- pixel offset cisse, goni, kodou, nouna :: [Double] cisse = [178,200,208,212,209,208,174,116,114,136,158] goni = [287,268,229,215,202,174,123,71 ,61 ,92 ,162] kodou = [184,214,215,202,192,191,181,144,121,145,192] nouna = [215,231,212,190,196,204,163,96 ,80 ,124,181] disp :: (String, [Double]) → IO () disp (town,pixels) = do putStrLn$ town putStrLn$ normals mapM_ print $ points putStrLn$ log10s mapM_ print $ log10s putStrLn$ --- where points = map (f . d) pixels log10s = map (10 **) points main :: IO () main = do mapM_ disp [(Cisse, cisse),(Goni, goni),(Kodougou, kodou),(Nouna, nouna)] Cisse normals 0.7998 0.5249 0.4248 0.375 0.412499964 0.4248 0.8501 1.575 1.5999 1.325 1.0498 log10s 6.30957344480193 3.3496543915782757 2.6607250597988084 2.371373705661655 2.5852348395621885 2.6607250597988084 7.07945784384138 37.583740428844415 39.81071705534971 21.134890398366466 11.220184543019629 --- Goni normals -0.5625 -0.3252 0.162499964 0.3374 0.5 0.8501 1.48749998 2.1375 2.2625 1.875 1.0 log10s 0.27384196342643613 0.4731512589614803 1.4537843856076607 2.1752040340195222 3.1622776601683795 7.07945784384138 30.725573652674456 137.24609610075626 183.02061063110568 74.98942093324558 10.0 --- Kodougou normals 0.7251 0.34964 0.3374 0.5 0.625 0.63749997 0.76249997 1.2249 1.5125 1.2125 0.625 log10s 5.30882309884 2.2387211385683377 2.1752040340195222 3.1622776601683795 4.216965034285822 4.340102636447436 5.787619883491203 16.788040181225597 32.546178349804585 16.31172909227838 4.216965034285822 --- Nouna normals 0.3374 0.137499973 0.375 0.6499 0.5747 0.47464 0.98749998 1.825 2.025 1.4749 0.76249997 log10s 2.1752040340195222 1.372460961007561 2.371373705661655 4.46683592150963 3.7583740428844394 2.9853826189179573 9.716279515771058 66.83439175686145 105.92537251772886 29.853826189179586 5.787619883491203 --- attachment: fig37-points.png___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Flow Graphs for Language-independent Code Representation
Hi *^o^*, I'm working on a source code transformation project for numerical automatic differentiation for Fortran and C. I would love to know the best Haskell way/package available today to represent procedural (non-OO) code in a language-independent manner. Any tips or resource, paper references are most welcome! Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Happy GLR mode build failures
...@sweethome:~/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr$ find | grep -E y$ | xargs -n 1 echo happy -gcal happy -gcal ./packing/Expr.y happy -gcal ./highly-ambiguous/Expr.y happy -gcal ./expr-eval/Expr.y happy -gcal ./expr-monad/Expr.y happy -gcal ./nlp/English.y happy -gcal ./hidden-leftrec/Expr.y happy -gcal ./expr-tree/Expr.y happy -gcal ./bio-eg/Bio.y ce...@sweethome:~/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr$ find | grep -E y$ | xargs -n 1 happy -gcal reduce/reduce conflicts: 2 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 7 reduce/reduce conflicts: 1 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 9 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 9 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 2 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 4 reduce/reduce conflicts: 1 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 9 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) unused rules: 20 shift/reduce conflicts: 35 reduce/reduce conflicts: 68 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) Does anyone have solution for this? The irrefutable pattern failure issue is especially bothersome for me as I ran into it in a Fortran grammar I'm writing and got stuck. Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] System.Vacuum.Ubigraph
Hi, The package seems to have a connection problem on my machine. Prelude import System.Vacuum.Ubigraph Prelude System.Vacuum.Ubigraph view (0,1) Loading package syb ... linking ... done. Loading package base-3.0.3.1 ... linking ... done. Loading package parsec-2.1.0.1 ... linking ... done. Loading package network-2.2.1.3 ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.1 ... linking ... done. Loading package bytestring-0.9.1.4 ... linking ... done. Loading package old-locale-1.0.0.1 ... linking ... done. Loading package old-time-1.0.0.2 ... linking ... done. Loading package pretty-1.0.1.0 ... linking ... done. Loading package filepath-1.1.0.2 ... linking ... done. Loading package unix-2.3.2.0 ... linking ... done. Loading package directory-1.0.0.3 ... linking ... done. Loading package process-1.0.1.1 ... linking ... done. Loading package random-1.0.0.1 ... linking ... done. Loading package haskell98 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. Loading package time-1.1.3 ... linking ... done. Loading package vacuum-0.0.95 ... linking ... done. Loading package HTTP-4000.0.7 ... linking ... done. Loading package HaXml-1.13.3 ... linking ... done. Loading package dataenc-0.13.0.0 ... linking ... done. Loading package haxr-3000.2.1 ... linking ... done. Loading package vacuum-ubigraph-0.1.0.3 ... linking ... done. *** Exception: user error (Error calling ubigraph.clear: �: openFile: does not exist (No such file or directory)) In ubigraph.clear: �: openFile: the part between clear and openFile is not always the same character or sequence of characters! I guess it's a problem with Network.XmlRpc.Client but couldn't locate it. Anyone else that has (had) this problem? Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Generate Fortran 77 parser from a yacc grammar using Happy
I have stumbled upon the following F77 yacc grammar: http://yaxx.cvs.sourceforge.net/viewvc/yaxx/yaxx/fortran/fortran.y?revision=1.3view=markup . How can I make a Fortran 77 parser out of this file using Happyhttp://www.haskell.org/happy/ ? Why is there some C?/C++? code in that .y file? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: clock 0.1 released
clock http://hackage.haskell.org/package/clock is a library published under a BSD3 license that provides bindings to clock_gettime and clock_getres for monotonic, realtime, processtime and threadtime clocks from time.h http://www.opengroup.org/onlinepubs/007908799/xsh/time.h.html. It was implemented in response to a haskell-cafe discussion: http://www.mail-archive.com/haskell-cafe@haskell.org/msg51244.html Any suggestions for improvement, bug-fixes, joint-development offers are most welcome *^o^*!! Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] specialization in type classes
module IOStream where import System.IO import System.IO.Unsafe class Out a where out :: a → String instance Show a ⇒ Out a where out = show instance Out String where {-# SPECIALISE out :: String → String #-} out = id instance Out Char where {-# SPECIALISE out :: Char → String #-} out = \x → [x] infixl 0 , ≪ (≪), () :: Out a ⇒ IO Handle → a → IO Handle ()= (≪) h ≪ a = do s ← h hPutStr s $ out a return s cout, cin, cerr :: IO Handle cout = return stdout cin = return stdin cerr = return stderr endl :: String endl = \n --- ce...@unique:~/lab/c/linking/demo$ ghci -fglasgow-exts iostream.hs GHCi, version 6.10.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Ok, modules loaded: IOStream. Prelude IOStream cout 22 False 22False{handle: stdout} Prelude IOStream cout 22 False endl interactive:1:0: Overlapping instances for Out String arising from a use of `' at interactive:1:0-26 Matching instances: instance (Show a) = Out a -- Defined in IOStream instance Out String -- Defined in IOStream In the expression: cout 22 False endl In the definition of `it': it = cout 22 False endl oO how can I specialise a type class function? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: specialization in type classes
Now there's also a stackoverflow question for this: http://stackoverflow.com/questions/955711/specialization-in-type-classes-using-ghc Any help highly appreciated! 2009/6/5 Cetin Sert cetin.s...@gmail.com module IOStream where import System.IO import System.IO.Unsafe class Out a where out :: a → String instance Show a ⇒ Out a where out = show instance Out String where {-# SPECIALISE out :: String → String #-} out = id instance Out Char where {-# SPECIALISE out :: Char → String #-} out = \x → [x] infixl 0 , ≪ (≪), () :: Out a ⇒ IO Handle → a → IO Handle ()= (≪) h ≪ a = do s ← h hPutStr s $ out a return s cout, cin, cerr :: IO Handle cout = return stdout cin = return stdin cerr = return stderr endl :: String endl = \n --- ce...@unique:~/lab/c/linking/demo$ ghci -fglasgow-exts iostream.hs GHCi, version 6.10.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Ok, modules loaded: IOStream. Prelude IOStream cout 22 False 22False{handle: stdout} Prelude IOStream cout 22 False endl interactive:1:0: Overlapping instances for Out String arising from a use of `' at interactive:1:0-26 Matching instances: instance (Show a) = Out a -- Defined in IOStream instance Out String -- Defined in IOStream In the expression: cout 22 False endl In the definition of `it': it = cout 22 False endl oO how can I specialise a type class function? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Concurrent Haskell Actions with Timeout
Hi how could one implement a function in concurrent haskell that either returns 'a' successfully or due timeout 'b'? timed :: Int → IO a → b → IO (Either a b) timed max act def = do Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Concurrent Haskell Actions with Timeout
Thank you for your reply, I'd come up with the following: timed :: Int → IO a → b → IO (Either b a) timed max act def = do r ← new t ← forkIO $ do a ← act r ≔ Right a s ← forkIO $ do wait max e ← em r case e of True → do kill t r ≔ Left def False → return () takeMVar r - *Network.Port.Scan timed 500 (wait 5 return 0) 'x' Left 'x' *Network.Port.Scan timed 50 (wait 5 return 0) 'x' Right 0 - before reading your reply: timed timeout act fallback = do res - newEmptyMVar tid - forkIO $ act = writeMVar res threadDelay timeout stillRunning - isEmptyMVar res if stillRunning then killThread tid return fallback else takeMVar res - *Network.Port.Scan timed2 500 (wait 5 return 0) 'x' interactive:1:33: No instance for (Num Char) arising from the literal `0' at interactive:1:33 Possible fix: add an instance declaration for (Num Char) In the first argument of `return', namely `0' In the second argument of `()', namely `return 0' In the second argument of `timed2', namely `(wait 5 return 0)' Regards, Cetin Sert 2009/5/30 Sebastian Sylvan sebastian.syl...@gmail.com 2009/5/30 Cetin Sert cetin.s...@gmail.com Hi how could one implement a function in concurrent haskell that either returns 'a' successfully or due timeout 'b'? timed :: Int → IO a → b → IO (Either a b) timed max act def = do Something like (warning, untested code - no compiler atm). timed timeout act fallback = do res - newEmptyMVar tid - forkIO $ act = writeMVar res threadDelay timeout stillRunning - isEmptyMVar res if stillRunning then killThread tid return fallback else takeMVar res -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Concurrent Haskell Actions with Timeout
-__- hehe why did I not let Hayoo or Hoogle help me there *sigh* Thanks!! 2009/5/31 Sterling Clover s.clo...@gmail.com The proper way is just to wrap System.Timeout, which does some rather clever things with regards to exception semantics. The code for it is a joy to read, by the way. --S. On May 30, 2009, at 5:36 PM, Sebastian Sylvan wrote: On Sat, May 30, 2009 at 10:32 PM, Cetin Sert cetin.s...@gmail.com wrote: Thank you for your reply, I'd come up with the following: timed :: Int → IO a → b → IO (Either b a) timed max act def = do r ← new t ← forkIO $ do a ← act r ≔ Right a s ← forkIO $ do wait max e ← em r case e of True → do kill t r ≔ Left def False → return () takeMVar r - *Network.Port.Scan timed 500 (wait 5 return 0) 'x' Left 'x' *Network.Port.Scan timed 50 (wait 5 return 0) 'x' Right 0 - before reading your reply: timed timeout act fallback = do res - newEmptyMVar tid - forkIO $ act = writeMVar res threadDelay timeout stillRunning - isEmptyMVar res if stillRunning then killThread tid return fallback else takeMVar res - *Network.Port.Scan timed2 500 (wait 5 return 0) 'x' interactive:1:33: No instance for (Num Char) arising from the literal `0' at interactive:1:33 Possible fix: add an instance declaration for (Num Char) In the first argument of `return', namely `0' In the second argument of `()', namely `return 0' In the second argument of `timed2', namely `(wait 5 return 0)' Right, I forgot about the Either bit so you'd have to make sure the action's result and the default has the same type (or modify it to return an Either). -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Matrices
http://ccnmtl.columbia.edu/projects/qmss/the_chisquare_test/about_the_chisquare_test.html given two matrices, Prelude Data.Matrix.Dense Data.Vector.Dense m listMatrix (2,2) [46.0,37.0,71.0,83.0] Prelude Data.Matrix.Dense Data.Vector.Dense es listMatrix (2,2) [40.9746835443038,42.0253164556962,76.0253164556962,77.9746835443038] how can I flatten them to do: [ (o-e)^2 / e | o - m, e - es ] or use a function that will apply a given function to every corresponding elements of 2 or n matrices and create a result matrix? If I should use a different matrix type or library altogether, please specify which one and how ^__^ Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskell Logo Voting has started!
37Lenny222 Just noticed that this logo is way too similar to the logo of Techsmith: http://www.techsmith.com/ Regards, CS 2009/3/19 Eelco Lempsink ee...@lempsink.nl On 19 mrt 2009, at 11:39, Wolfgang Jeltsch wrote: Am Mittwoch, 18. März 2009 13:31 schrieben Sie: On Wed, Mar 18, 2009 at 04:36, Wolfgang Jeltsch wrote: Am Mittwoch, 18. März 2009 10:03 schrieb Benjamin L.Russell: Just go through the list, choose your top favorite, and assign rank 1 to it; Is rank 1 the best or the worst? The condorcet info page makes it clear that higher is better. http://www.cs.cornell.edu/w8/~andru/civs/rp.htmlhttp://www.cs.cornell.edu/w8/%7Eandru/civs/rp.html So assigning rank 1 to my favorite, as Benjamin suggested, might not be the best idea. :-( I hope, everyone who voted did it the right way. Rank 1 is the best. A 'higher' rank doesn't mean a 'higher' number. Also see this poll http://www.cs.cornell.edu/w8/~andru/cgi-perl/civs/http://www.cs.cornell.edu/w8/%7Eandru/cgi-perl/civs/ vote.pl?id=E_5820adef7d6e8733akey=51398305f80ae2cb -- Regards, Eelco Lempsink ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Class Instances
Thank you Benedikt! Thanks to your help I also figured out the way to do it using type families yesterday: class Pro p where type I p type O p re :: p → [I p → O p] instance Pro (b → c) where type I (b → c) = b type O (b → c) = c re = repeat instance Pro [b → c] where type I [b → c] = b type O [b → c] = c re = cycle broadcast :: Pro p ⇒ p → [I p] → [O p] ... Regards, Cetin 2009/2/13 Benedikt Huber benj...@gmx.net Cetin Sert schrieb: Thank you for your answer! This comes close to solving the problem but in the last line of the above I want to be able to say: either print $ broadcast id [1..10] or print $ broadcast [ (x +) | x ← [1..10] ] [1..10] both need to be possible*. So is there a way to make the FunList disappear completely? Hi Cetin, yes, if you're willing to use multi-parameter typeclasses: class Processor p b c | p - b c where ready :: p - [b - c] instance Processor (b - c) b c where ready = repeat instance Processor [b - c] b c where ready = id broadcast :: Processor p b c = p - [b] - [c] Maybe there are other possibilities as well. -- benedikt Regards, Cetin P.S.: * broadcast is a dummy function, I need this for tidying up the interface of a little experiment: http://corsis.blogspot.com/ 2009/2/13 Benedikt Huber benj...@gmx.net mailto:benj...@gmx.net Cetin Sert schrieb: Hi, class Processor a where ready :: (forall b c. a → [b → c]) instance Processor (b → c) where ready = repeat ... --- Why can I not declare the above instances and always get: Hi Cetin, in your class declaration you state that a (Processor T) provides a function ready :: T - [b - c] so ready (t::T) has type (forall b c. [b - c]), a list of functions from arbitrary types b to c. The error messages tell you that e.g. repeat (f :: t1 - t2) has type (t1-t2) - [t1-t2] and not the required type (t1-t2) - [a - b] With your declarations, head (ready negate) hi has to typecheck, that's probably not what you want. Is there a way around this? Maybe you meant class Processor a where ready :: a b c - [b - c] instance Processor (-) where ready = repeat newtype FunList b c = FunList [b-c] instance Processor FunList where ready (FunList fl) = fl I think the newtype FunList is neccessary here. benedikt message.hs:229:10: Couldn't match expected type `b' against inferred type `b1' `b' is a rigid type variable bound by the instance declaration at message.hs:228:20 `b1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:19 Expected type: b - c Inferred type: b1 - c1 In the expression: repeat In the definition of `ready': ready = repeat message.hs:229:10: Couldn't match expected type `c' against inferred type `c1' `c' is a rigid type variable bound by the instance declaration at message.hs:228:24 `c1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:21 Expected type: b - c Inferred type: b1 - c1 In the expression: repeat In the definition of `ready': ready = repeat message.hs:232:10: Couldn't match expected type `b1' against inferred type `b' `b1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:19 `b' is a rigid type variable bound by the instance declaration at message.hs:231:20 Expected type: [b1 - c] Inferred type: [b - c1] In the expression: id In the definition of `ready': ready = id message.hs:232:10: Couldn't match expected type `c1' against inferred type `c' `c1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:21 `c' is a rigid type variable bound by the instance declaration at message.hs:231:24 Expected type: [b - c1] Inferred type: [b1 - c] In the expression: id In the definition of `ready': ready = id Is there a way around this? Regards, CS ___ Haskell-Cafe mailing list Haskell
[Haskell-cafe] Class Instances
Hi, class Processor a where ready :: (forall b c. a → [b → c]) {- instance Processor (b → c) where ready = repeat instance Processor [b → c] where ready = id-} doSth :: (Show p, Processor p) ⇒ p → IO () doSth p = print p --- Why can I not declare the above instances and always get: message.hs:229:10: Couldn't match expected type `b' against inferred type `b1' `b' is a rigid type variable bound by the instance declaration at message.hs:228:20 `b1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:19 Expected type: b - c Inferred type: b1 - c1 In the expression: repeat In the definition of `ready': ready = repeat message.hs:229:10: Couldn't match expected type `c' against inferred type `c1' `c' is a rigid type variable bound by the instance declaration at message.hs:228:24 `c1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:21 Expected type: b - c Inferred type: b1 - c1 In the expression: repeat In the definition of `ready': ready = repeat message.hs:232:10: Couldn't match expected type `b1' against inferred type `b' `b1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:19 `b' is a rigid type variable bound by the instance declaration at message.hs:231:20 Expected type: [b1 - c] Inferred type: [b - c1] In the expression: id In the definition of `ready': ready = id message.hs:232:10: Couldn't match expected type `c1' against inferred type `c' `c1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:21 `c' is a rigid type variable bound by the instance declaration at message.hs:231:24 Expected type: [b - c1] Inferred type: [b1 - c] In the expression: id In the definition of `ready': ready = id Is there a way around this? Regards, CS ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Class Instances
module Main where import Control.Monad import Control.Concurrent class Processor p where ready :: p b c → [b → c] instance Processor (→) where ready = repeat --instance Processor [b → c] where --ready = id newtype FunList b c = FunList [b → c] instance Processor FunList where ready (FunList fl) = fl broadcast :: Processor p ⇒ p b c → [b] → [c] broadcast p bs = bcast ps bs [] where ps = ready p bcast [] _ cs = cs bcast _ [] cs = cs bcast ps bs cs = let (cp,nps) = rotate [] ps (cb,nbs) = rotate [] bs in bcast nps nbs (cp cb:cs) rotate :: [a] → [a] → (a,[a]) rotate os (x:[]) = (x,os) rotate os (x:xs) = (x,xs) main :: IO () main = do let pid = id let ppm = FunList [ (x +) | x ← [1..10] ] print $ broadcast ppm [1..10] -- Thank you for your answer! This comes close to solving the problem but in the last line of the above I want to be able to say: either print $ broadcast id [1..10] or print $ broadcast [ (x +) | x ← [1..10] ] [1..10] both need to be possible*. So is there a way to make the FunList disappear completely? Regards, Cetin P.S.: * broadcast is a dummy function, I need this for tidying up the interface of a little experiment: http://corsis.blogspot.com/ 2009/2/13 Benedikt Huber benj...@gmx.net Cetin Sert schrieb: Hi, class Processor a where ready :: (forall b c. a → [b → c]) instance Processor (b → c) where ready = repeat ... --- Why can I not declare the above instances and always get: Hi Cetin, in your class declaration you state that a (Processor T) provides a function ready :: T - [b - c] so ready (t::T) has type (forall b c. [b - c]), a list of functions from arbitrary types b to c. The error messages tell you that e.g. repeat (f :: t1 - t2) has type (t1-t2) - [t1-t2] and not the required type (t1-t2) - [a - b] With your declarations, head (ready negate) hi has to typecheck, that's probably not what you want. Is there a way around this? Maybe you meant class Processor a where ready :: a b c - [b - c] instance Processor (-) where ready = repeat newtype FunList b c = FunList [b-c] instance Processor FunList where ready (FunList fl) = fl I think the newtype FunList is neccessary here. benedikt message.hs:229:10: Couldn't match expected type `b' against inferred type `b1' `b' is a rigid type variable bound by the instance declaration at message.hs:228:20 `b1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:19 Expected type: b - c Inferred type: b1 - c1 In the expression: repeat In the definition of `ready': ready = repeat message.hs:229:10: Couldn't match expected type `c' against inferred type `c1' `c' is a rigid type variable bound by the instance declaration at message.hs:228:24 `c1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:21 Expected type: b - c Inferred type: b1 - c1 In the expression: repeat In the definition of `ready': ready = repeat message.hs:232:10: Couldn't match expected type `b1' against inferred type `b' `b1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:19 `b' is a rigid type variable bound by the instance declaration at message.hs:231:20 Expected type: [b1 - c] Inferred type: [b - c1] In the expression: id In the definition of `ready': ready = id message.hs:232:10: Couldn't match expected type `c1' against inferred type `c' `c1' is a rigid type variable bound by the type signature for `ready' at message.hs:226:21 `c' is a rigid type variable bound by the instance declaration at message.hs:231:24 Expected type: [b - c1] Inferred type: [b1 - c] In the expression: id In the definition of `ready': ready = id Is there a way around this? Regards, CS ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Computer time, independent of date
Don't know if it might help but: http://en.wikipedia.org/wiki/RDTSC cabal install rdtsc http://hackage.haskell.org/packages/archive/rdtsc/1.1.1/doc/html/System-CPUTime-Rdtsc.html Regards, CS 2009/1/9 Bulat Ziganshin bulat.zigans...@gmail.com Hello Mauricio, Friday, January 9, 2009, 4:01:18 PM, you wrote: computer has been turned on would do all I need. Or, maybe, how much has elapsed since the program started. i think you should look into system counters (if you on windows). for example, task managet in vista shows time since reboot, i think that in registry it should be available in previous windowses too. at the cpu level, there is cpu ticks counter, it should be readable via special libraries -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Computer time, independent of date
Here's a basic draft project for clock_gettime(CLOCK_MONOTONIC, ...) http://sert.homedns.org/hs/mnsec/ http://sert.homedns.org/hs/mnsec/dist/mnsec-1.0.0.tar.gz It could be extended to cover other clock types than just monotonic. Regards, CS 2009/1/9 John Goerzen jgoer...@complete.org Steve Schafer wrote: On Fri, 09 Jan 2009 11:01:18 -0200, you wrote: I'm writing a program that will read medical signs from many patients. It's important to have a precise measure of the time interval between some signs, and that can't depend on adjustments of time. (Supose my software is running midnight at the end of a year with leap seconds. I would get wrong time intervals.) If you really need that level of accuracy, there is nothing available on an off-the-shelf machine that will do the job. You need an independent timekeeping source of some kind, one that is not subject to the vagaries I'm not sure that the original question implied *that* level of need. Linux has High-Resolution Timers (HRTs) that may be appropriate. See the manpage for clock_gettime(), which defines these HRTs: CLOCK_REALTIME System-wide real-time clock. Setting this clock requires appropriate privi- leges. CLOCK_MONOTONIC Clock that cannot be set and represents monotonic time since some unspeci- fied starting point. CLOCK_PROCESS_CPUTIME_ID High-resolution per-process timer from the CPU. CLOCK_THREAD_CPUTIME_ID Thread-specific CPU-time clock. CLOCK_MONOTONIC, in particular, looks suitable. Using it could be a matter of just a few quick likes in FFI. I don't know if Windows has similar features. -- John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cabal, multi-file applications
Hi, I get the following error message: ce...@unique:~/lab/test/qths/hnm$ make configure runhaskell Setup.hs configure Configuring HNM-0.2... ce...@unique:~/lab/test/qths/hnm$ make build runhaskell Setup.hs build Preprocessing library HNM-0.2... Preprocessing executables for HNM-0.2... Building HNM-0.2... demo3.hs:4:7: Could not find module `HNM.WLAN': Use -v to see a list of the files searched for. make: *** [build] Error 1 when I try to build the following program: http://sert.homedns.org/hs/hnm/ http://sert.homedns.org/hs/hnm/hnm.cabal How can I tell in my cabal file that wlan.hs should be built first than settings.hs than demo3.hs? Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hackage, gtk2hs
Hi, A package I want to upload only builds with the unreleased gtk2hs version from the darcs repository and not the latest released version 0.9.13 or any lesser. But the repository version seems to not have changed, so if I say in my cabal file: gtk = 0.9.14 it does not even build with the gtk2hs version from the repos, on the other hand if I say: gtk = 0.9.13 people using 0.9.13 may be surprised to see the package does not build. What should I do o__O? Wait for the next gtk2hs release before releasing my package? Or is there a way to notify _potential users/those interested_ of the need to use the latest gtk2hs they can get from the darcs repos. Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] lengthOP rewrite rules
Hi, I tested the following, why does the rewrite rules not fire when using tuples also in testRewrite2, testRewriteReverse2? compiling: rm *.o; ghc -fglasgow-exts -ddump-simpl-stats -O9 --make rules.hs module Main where main :: IO () main = do print $ test0 print $ test2 0 print $ testRewrite 0 print $ testRewriteReverse 0 print $ testRewrite20 print $ testRewriteReverse2 0 test :: a → Bool test x = pi where f = replicate 2000 x i = repeat x pf = lenGT f 300 pi = lenGT i 300 test2 :: a → (Bool,Bool) test2 x = (pf,pi) where f = replicate 2000 x i = repeat x pf = lenGT f 300 pi = lenGT i 300 testRewrite :: a → Bool testRewrite x = pi where f = replicate 2000 x i = repeat x lf = length f li = length i pf = lf 300 pi = li 300 testRewriteReverse :: a → Bool testRewriteReverse x = pi where f = replicate 2000 x i = repeat x lf = length f li = length i pf = 300 = lf pi = 300 = li testRewrite2 :: a → (Bool,Bool) testRewrite2 x = (pf,pi) where f = replicate 2000 x i = repeat x lf = length f li = length i pf = lf 300 pi = li 300 testRewriteReverse2 :: a → (Bool,Bool) testRewriteReverse2 x = (pf,pi) where f = replicate 2000 x i = repeat x lf = length f li = length i pf = 300 = lf pi = 300 = li lengthOP :: (Num a, Ord a) ⇒ Bool → (a → a → Bool) → [b] → a → Bool lengthOP v (⊜) [] n = 0 ⊜ n lengthOP v (⊜) xxs n = co xxs 0 where co (_:xs) c | n c = co xs (c+1) | otherwise = v co [] c = c ⊜ n lenEQ = lengthOP False (==) lenLT = lengthOP False () lenLE = lengthOP False (=) lenGT = lengthOP True () lenGE = lengthOP True (=) {-# RULES -- | length lenEQ_LHS forall xs n. (length xs) == n = lenEQ xs n lenLT_LHS forall xs n. (length xs) n = lenLT xs n lenLE_LHS forall xs n. (length xs) = n = lenLE xs n lenGT_LHS forall xs n. (length xs) n = lenGT xs n lenGE_LHS forall xs n. (length xs) = n = lenGE xs n lenEQ_RHS forall xs n. n == (length xs) = lenEQ xs n lenLT_RHS forall xs n. n (length xs) = lenGE xs n lenLE_RHS forall xs n. n = (length xs) = lenGT xs n lenGT_RHS forall xs n. n (length xs) = lenLE xs n lenGE_RHS forall xs n. n = (length xs) = lenLT xs n #-} Best Regards, Cetin Sert 2008/12/18 Luke Palmer lrpal...@gmail.com This does not answer your question, but you can solve this problem without rewrite rules by having length return a lazy natural: data Nat = Zero | Succ Nat And defining lazy comparison operators on it. Of course you cannot replace usages of Prelude.length. But I am really not in favor of rules which change semantics, even if they only make things less strict. My argument is the following. I may come to rely on such nonstrictness as in: bad xs = (length xs 10, length xs 20) bad [1..] will return (True,True). However, if I do an obviously semantics-preserving refactor: bad xs = (l 10, l 20) where l = length xs My semantics are not preserved: bad [1..] = (_|_, _|_) (if/unless the compiler is clever, in which case my semantics depend on the compiler's cleverness which is even worse) Luke 2008/12/18 Cetin Sert cetin.s...@gmail.com Hi *^o^*, With the following rewrite rules: lengthOP :: (Num a, Ord a) ⇒ Bool → (a → a → Bool) → [b] → a → Bool lengthOP v (⊜) [] n = 0 ⊜ n lengthOP v (⊜) xxs n = co xxs 0 where co [] c = c ⊜ n co (_:xs) c | n c = co xs (c+1) | otherwise = v lenEQ = lengthOP False (==) lenLT = lengthOP False () lenLE = lengthOP False (=) lenGT = lengthOP True () lenGE = lengthOP True (=) {-# RULES -- | length lenEQ_LHS forall xs n. (length xs) == n = lenEQ xs n lenLT_LHS forall xs n. (length xs) n = lenLT xs n lenLE_LHS forall xs n. (length xs) = n = lenLE xs n lenGT_LHS forall xs n. (length xs) n = lenGT xs n lenGE_LHS forall xs n. (length xs) = n = lenGE xs n lenEQ_RHS forall xs n. n == (length xs) = lenEQ xs n lenLT_RHS forall xs n. n (length xs) = lenGE xs n lenLE_RHS forall xs n. n = (length xs) = lenGT xs n lenGT_RHS forall xs n. n (length xs) = lenLE xs n lenGE_RHS forall xs n. n = (length xs) = lenLT xs n -- | genericLength glenEQ_LHS forall xs n. (genericLength xs) == n = lenEQ xs n glenLT_LHS forall xs n. (genericLength xs) n = lenLT xs n glenLE_LHS forall xs n. (genericLength xs) = n = lenLE xs n glenGT_LHS forall xs n. (genericLength xs) n = lenGT xs n glenGE_LHS forall xs n. (genericLength xs) = n = lenGE xs n glenEQ_RHS forall xs n. n == (genericLength xs) = lenEQ xs n glenLT_RHS forall xs n. n (genericLength xs) = lenGE xs n glenLE_RHS forall xs n. n = (genericLength xs) = lenGT xs n glenGT_RHS forall xs n. n (genericLength xs) = lenLE xs n glenGE_RHS forall xs n. n = (genericLength xs) = lenLT
Re: [Haskell-cafe] lengthOP rewrite rules
oh, btw I am using GHC 6.10.1 (on Linux x86_64) 2008/12/18 Cetin Sert cetin.s...@gmail.com Hi, I tested the following, why does the rewrite rules not fire when using tuples also in testRewrite2, testRewriteReverse2? compiling: rm *.o; ghc -fglasgow-exts -ddump-simpl-stats -O9 --make rules.hs module Main where main :: IO () main = do print $ test0 print $ test2 0 print $ testRewrite 0 print $ testRewriteReverse 0 print $ testRewrite20 print $ testRewriteReverse2 0 test :: a → Bool test x = pi where f = replicate 2000 x i = repeat x pf = lenGT f 300 pi = lenGT i 300 test2 :: a → (Bool,Bool) test2 x = (pf,pi) where f = replicate 2000 x i = repeat x pf = lenGT f 300 pi = lenGT i 300 testRewrite :: a → Bool testRewrite x = pi where f = replicate 2000 x i = repeat x lf = length f li = length i pf = lf 300 pi = li 300 testRewriteReverse :: a → Bool testRewriteReverse x = pi where f = replicate 2000 x i = repeat x lf = length f li = length i pf = 300 = lf pi = 300 = li testRewrite2 :: a → (Bool,Bool) testRewrite2 x = (pf,pi) where f = replicate 2000 x i = repeat x lf = length f li = length i pf = lf 300 pi = li 300 testRewriteReverse2 :: a → (Bool,Bool) testRewriteReverse2 x = (pf,pi) where f = replicate 2000 x i = repeat x lf = length f li = length i pf = 300 = lf pi = 300 = li lengthOP :: (Num a, Ord a) ⇒ Bool → (a → a → Bool) → [b] → a → Bool lengthOP v (⊜) [] n = 0 ⊜ n lengthOP v (⊜) xxs n = co xxs 0 where co (_:xs) c | n c = co xs (c+1) | otherwise = v co [] c = c ⊜ n lenEQ = lengthOP False (==) lenLT = lengthOP False () lenLE = lengthOP False (=) lenGT = lengthOP True () lenGE = lengthOP True (=) {-# RULES -- | length lenEQ_LHS forall xs n. (length xs) == n = lenEQ xs n lenLT_LHS forall xs n. (length xs) n = lenLT xs n lenLE_LHS forall xs n. (length xs) = n = lenLE xs n lenGT_LHS forall xs n. (length xs) n = lenGT xs n lenGE_LHS forall xs n. (length xs) = n = lenGE xs n lenEQ_RHS forall xs n. n == (length xs) = lenEQ xs n lenLT_RHS forall xs n. n (length xs) = lenGE xs n lenLE_RHS forall xs n. n = (length xs) = lenGT xs n lenGT_RHS forall xs n. n (length xs) = lenLE xs n lenGE_RHS forall xs n. n = (length xs) = lenLT xs n #-} Best Regards, Cetin Sert 2008/12/18 Luke Palmer lrpal...@gmail.com This does not answer your question, but you can solve this problem without rewrite rules by having length return a lazy natural: data Nat = Zero | Succ Nat And defining lazy comparison operators on it. Of course you cannot replace usages of Prelude.length. But I am really not in favor of rules which change semantics, even if they only make things less strict. My argument is the following. I may come to rely on such nonstrictness as in: bad xs = (length xs 10, length xs 20) bad [1..] will return (True,True). However, if I do an obviously semantics-preserving refactor: bad xs = (l 10, l 20) where l = length xs My semantics are not preserved: bad [1..] = (_|_, _|_) (if/unless the compiler is clever, in which case my semantics depend on the compiler's cleverness which is even worse) Luke 2008/12/18 Cetin Sert cetin.s...@gmail.com Hi *^o^*, With the following rewrite rules: lengthOP :: (Num a, Ord a) ⇒ Bool → (a → a → Bool) → [b] → a → Bool lengthOP v (⊜) [] n = 0 ⊜ n lengthOP v (⊜) xxs n = co xxs 0 where co [] c = c ⊜ n co (_:xs) c | n c = co xs (c+1) | otherwise = v lenEQ = lengthOP False (==) lenLT = lengthOP False () lenLE = lengthOP False (=) lenGT = lengthOP True () lenGE = lengthOP True (=) {-# RULES -- | length lenEQ_LHS forall xs n. (length xs) == n = lenEQ xs n lenLT_LHS forall xs n. (length xs) n = lenLT xs n lenLE_LHS forall xs n. (length xs) = n = lenLE xs n lenGT_LHS forall xs n. (length xs) n = lenGT xs n lenGE_LHS forall xs n. (length xs) = n = lenGE xs n lenEQ_RHS forall xs n. n == (length xs) = lenEQ xs n lenLT_RHS forall xs n. n (length xs) = lenGE xs n lenLE_RHS forall xs n. n = (length xs) = lenGT xs n lenGT_RHS forall xs n. n (length xs) = lenLE xs n lenGE_RHS forall xs n. n = (length xs) = lenLT xs n -- | genericLength glenEQ_LHS forall xs n. (genericLength xs) == n = lenEQ xs n glenLT_LHS forall xs n. (genericLength xs) n = lenLT xs n glenLE_LHS forall xs n. (genericLength xs) = n = lenLE xs n glenGT_LHS forall xs n. (genericLength xs) n = lenGT xs n glenGE_LHS forall xs n. (genericLength xs) = n = lenGE xs n glenEQ_RHS forall xs n. n == (genericLength xs) = lenEQ xs n glenLT_RHS forall xs n. n (genericLength xs) = lenGE
[Haskell-cafe] lengthOP rewrite rules
Hi *^o^*, With the following rewrite rules: lengthOP :: (Num a, Ord a) ⇒ Bool → (a → a → Bool) → [b] → a → Bool lengthOP v (⊜) [] n = 0 ⊜ n lengthOP v (⊜) xxs n = co xxs 0 where co [] c = c ⊜ n co (_:xs) c | n c = co xs (c+1) | otherwise = v lenEQ = lengthOP False (==) lenLT = lengthOP False () lenLE = lengthOP False (=) lenGT = lengthOP True () lenGE = lengthOP True (=) {-# RULES -- | length lenEQ_LHS forall xs n. (length xs) == n = lenEQ xs n lenLT_LHS forall xs n. (length xs) n = lenLT xs n lenLE_LHS forall xs n. (length xs) = n = lenLE xs n lenGT_LHS forall xs n. (length xs) n = lenGT xs n lenGE_LHS forall xs n. (length xs) = n = lenGE xs n lenEQ_RHS forall xs n. n == (length xs) = lenEQ xs n lenLT_RHS forall xs n. n (length xs) = lenGE xs n lenLE_RHS forall xs n. n = (length xs) = lenGT xs n lenGT_RHS forall xs n. n (length xs) = lenLE xs n lenGE_RHS forall xs n. n = (length xs) = lenLT xs n -- | genericLength glenEQ_LHS forall xs n. (genericLength xs) == n = lenEQ xs n glenLT_LHS forall xs n. (genericLength xs) n = lenLT xs n glenLE_LHS forall xs n. (genericLength xs) = n = lenLE xs n glenGT_LHS forall xs n. (genericLength xs) n = lenGT xs n glenGE_LHS forall xs n. (genericLength xs) = n = lenGE xs n glenEQ_RHS forall xs n. n == (genericLength xs) = lenEQ xs n glenLT_RHS forall xs n. n (genericLength xs) = lenGE xs n glenLE_RHS forall xs n. n = (genericLength xs) = lenGT xs n glenGT_RHS forall xs n. n (genericLength xs) = lenLE xs n glenGE_RHS forall xs n. n = (genericLength xs) = lenLT xs n #-} 1) Is there a way to tell where 'length' is mentioned, what is meant is for example 'Prelude.length' or any length that works on lists? 2) How can I avoid the following error messages? module Main where import Data.List main :: IO Int print $ length (repeat 0) 200 print $ 200 length (repeat 0) print $ genericLength (repeat 0) 200 -- error print $ 200 genericLength (repeat 0) -- error return 0 : Could not deduce (Ord i) from the context (Eq i, Num i) arising from a use of `lenEQ' at Possible fix: add (Ord i) to the context of the RULE glenEQ_LHS In the expression: lenEQ xs n When checking the transformation rule glenEQ_LHS : Could not deduce (Ord a) from the context (Eq a, Num a) arising from a use of `lenEQ' at Possible fix: add (Ord a) to the context of the RULE glenEQ_RHS In the expression: lenEQ xs n When checking the transformation rule glenEQ_RHS 3) What speaks for/against broad usage of such rewrite rules involving list lengths? Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] gtk2hs question - derive SettingsWindow from Window
Hi all, For a network manager of sorts I'm working on, I want to derive a SettingsWindowClass from the WindowClass present in Gtk2Hs: I want (the) instance(s) of the SettingsWindowClass to have a field to store connection settings: 1) Is it safe to do it like this? class WindowClass self ⇒ SettingsWindowClass self where settingsWindowGetSettings :: self → IO [ConnectionSetting] settingsWindowSetSettings :: self → [ConnectionSetting] → IO () newtype SettingsWindow = SettingsWindow (Window,[ConnectionSetting]) mkSettingsWindow = SettingsWindow unSettingsWindow (SettingsWindow o) = o settingsWindowNew :: IO SettingsWindow settingsWindowNew = do win ← windowNew return $ mkSettingsWindow (win,[]) 2) Is this a common practice in gtk2hs usage? 3) And will GC properly free the memory allocated for the Window object? How is this ensured, do ForeignPtr's always call delete on the underlying C ptr when they get garbage collected? Best Regards, CS ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] wlan library
Hi *^o^*, I am writing a network manager http://sert.homedns.org/hnm/ as a replacement for some broken, already existing knetworkmanager for a friend's computer. I was looking for some haskell libraries that provide access to wlan cards but could not find any on hackage. Maybe I missed something. Currently my tool is using linux the commands: modprobe, ifconfig, iwconfig, iwlist, dhclient etc.. Can a library calling external stand-alone linux commands be considered good enough as is? Or should one definitely write a wrapper around a more low-level, stable, POSIX-compliant foreign library to access and configure, control WLAN cards? I'd love to hear your comments. Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] type error
Hi, Why does this not function? Prelude sequence [print 'a', print 2] 'a' 2 [(),()] *Prelude let myprint = print* *Prelude sequence [myprint 'a', myprint 2]* interactive:1:18: Couldn't match expected type `()' against inferred type `Char' In the first argument of `myprint', namely 'a' In the expression: myprint 'a' In the first argument of `sequence', namely `[myprint 'a', myprint 2]' Can providing some type annotations (interactively in ghci or in some .hs file) help solve the problem? Best Regards, CS ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ghci start-up banner
Hi all, after reading this announcement on the Galois blog: http://www.galois.com/blog/2008/11/13/tech-talk-mechanically-verified-lisp-interpreters/ I installed Hol4 to play around with it a little bit. I made 2 obvious observations ^_^: 1) It looks like the Hol4 system is just a ML module that gets loaded into the Moscow ML interpreter with the help of a script 2) it prints a custom banner after loading And now I have the following questions: == about proof assistants in general == 1) how many other proof assistants are built the same way as Hol4: as a module loaded into some interpreter? 2) is there a paper or even better a funny but detailed comparison of proof assistants? == about custom banners at module load time == 1) is there a way to do it in ghci? Regards, CS ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] view patterns
let has [] = False; has _ = True -- this one is ok let empty list = case has list of True - False; False - True -- the following is problematic let emp (has - True) = False; emp (has - False) = True interactive:1:4: Warning: Pattern match(es) are overlapped In the definition of `emp': emp ((has - True)) = ... emp ((has - False)) = ... Why do I get this error in ghc or when I try to compile a file with view patterns? (using -fglasgow-exts and -XViewPatterns, ghc 6.10.1) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] flipped IO sequence
warn :: String → IO Int warn = return 1 putStrLn-- causes an error -- = \msg → return 1 putStrLn msg -- works just fine -- = \msg → putStrLn msg return 1 -- works just fine () :: Monad m ⇒ m b → m a → m b b a = a = \_ → b Why do I get this compile-time error?? How can one define ? [EMAIL PROTECTED]:~/lab/test/qths/p ghc -fglasgow-exts -O2 -o d64x --make demo2.hs system.hs [1 of 2] Compiling Netman.System( system.hs, system.o ) system.hs:23:14: No instance for (Num (IO Int)) arising from the literal `1' at system.hs:23:14 Possible fix: add an instance declaration for (Num (IO Int)) In the first argument of `return', namely `1' In the first argument of `()', namely `return 1' In the expression: return 1 putStrLn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal upgrade
A reminder: When I wanted to upgrade to yi 0.4.6.2, I needed to download the new package list cabal update #download list of new packages cabal upgrade #make any upgrades Regards, CS 2008/9/26 Duncan Coutts [EMAIL PROTECTED] On Fri, 2008-09-26 at 10:49 +0200, Achim Schneider wrote: % cabal update Downloading package list from server 'http://hackage.haskell.org/packages/archive' % cabal install pureMD5 All requested packages already installed. Nothing to do. % cabal install pureMD5-0.2.4 Downloading 'pureMD5-0.2.4'... [...] The latest released cabal-install does what you want here. $ cabal install cabal-install Well, I might be spoiled by portage but shouldn't there be a thing like cabal upgrade pureMD5 That also works in the latest version. comparing, $ cabal install foo $ cabal upgrade foo both mean to get the latest 'foo'. The difference between install and upgrade is whether the dependencies are also upgraded or not. In Gentoo they call this 'deep' upgrades. and cabal upgrade --all We write that as just $ cabal upgrade Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Packages
A reminder: When I wanted to upgrade to yi 0.4.6.2, I needed to download the new package list first cabal update#download list of new packages cabal upgrade #install newer versions of all packages see cabal help upgrade for more, for upgrading a single package cabal upgrade yi Regards, CS 2008/9/23 Cetin Sert [EMAIL PROTECTED] Does that answer your query? Yep it does, ^__^ Thank you very much. Cetin 2008/9/23 Austin Seipp [EMAIL PROTECTED] Excerpts from Dougal Stanton's message of Tue Sep 23 06:09:58 -0500 2008: That should happen automatically with cabal-install if the version number in the .cabal file has changed. There doesn't seem to be a good way of forcing cabal-install to recreate a build (eg, if you want to rebuild/reinstall with profiling). I think you need to unregister the package manually first. :-( With cabal-install 0.5.2, you simply have to pass the '--reinstall' flag to the 'install' command and it will reconfigure, rebuild and reinstall the packages with whatever flags you specify. Austin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Hackage Build Failures
Hi, what is the best action to take if a package from hackage fails to build? Is there a recommended/established common way to deal with build failures/runtime bugs etc.? For example: [EMAIL PROTECTED]:~/Links/Elite/ac cabal install wired Resolving dependencies... Downloading Wired-0.1.1... Configuring Wired-0.1.1... Preprocessing library Wired-0.1.1... Building Wired-0.1.1... [ 1 of 21] Compiling Data.Hardware.Internal ( Data/Hardware/Internal.hs, dist/build/Data/Hardware/Internal.o ) Data/Hardware/Internal.hs:198:15: Ambiguous occurrence `' It could refer to either `Data.Hardware.Internal.', defined at Data/Hardware/Internal.hs:129:4 or `Test.QuickCheck.', imported from Test.QuickCheck at Data/Hardware/Internal.hs:11:0-21 cabal: Error: some packages failed to install: Wired-0.1.1 failed during the building phase. The exception was: exit: ExitFailure 1 Regards, CS ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Packages
Austin: Of course, if you are doing haskell development, the best possible way to go (IMO) full-blown cabal install since you will always get the most up-to-date code Let's say I go and compile a library from sources and install it through Cabal. How can I update the binary version of the library Cabal installed after recompiling the library using newer/modified sources? Cetin 2008/9/23 Wolfgang Jeltsch [EMAIL PROTECTED] Am Sonntag, 21. September 2008 09:44 schrieb Andrew Coppin: […] 2. If we already have a Cabal package, why do we also need seperate packages for Arch, Gentoo, Debian...? Isn't Cabal cross-platform? If I want to install gtk2hs on Debian, I'd like gtk (the C library) to be automatically installed. And I want Debian's gtk package because this is the one, other Debian-packaged software uses. And a Debian user installing an application written in Haskell wants to use the Debian package manager. […] Best wishes, Wolfgang ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Packages
Does that answer your query? Yep it does, ^__^ Thank you very much. Cetin 2008/9/23 Austin Seipp [EMAIL PROTECTED] Excerpts from Dougal Stanton's message of Tue Sep 23 06:09:58 -0500 2008: That should happen automatically with cabal-install if the version number in the .cabal file has changed. There doesn't seem to be a good way of forcing cabal-install to recreate a build (eg, if you want to rebuild/reinstall with profiling). I think you need to unregister the package manually first. :-( With cabal-install 0.5.2, you simply have to pass the '--reinstall' flag to the 'install' command and it will reconfigure, rebuild and reinstall the packages with whatever flags you specify. Austin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ask
Hi why do I get? [EMAIL PROTECTED]:~/lab/exp/1 ./eq 23 23 3 a = b = c = n1-0.8457820374040622n2-0.1542179625959377 when I run import System.IO main :: IO () main = do a ← ask a b ← ask b c ← ask c eval a b c ask v = do putStr (v ++ = ) readLn eval a b c = do case delta 0 of True → putStr neg False → putStr (n1 ++ show n1 ++ n2 ++ show n2) where delta = b*b - 4*c*a n o = (-b `o` sqrt(delta))/(2*a) n1= n (+) n2= n (-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] random colors, stack space overflow, mersenne and mersenne.pure64
Hi, The following piece of code runs just fine, if I say: instance Random RGB where random = color randomR = colorR instead of: instance Random RGB where random = color2 randomR = colorR When I use random = color2 I encounter a stack space overflow: [EMAIL PROTECTED]:~/lab/test/colors ./var2 +RTS -K3000 Stack space overflow: current size 3000 bytes. Use `+RTS -Ksize' to increase it. I think I'm doing something wrong with the definition of colorR. Can anyone explain me what's wrong? import GHC.Word import Data.Word import System.Random import System.Random.Mersenne.Pure64 type RGB = (Int,Int,Int) instance Bounded RGB where minBound = minRGB maxBound = maxRGB minRGB = (0 ,0 ,0 ) maxRGB = (255,255,255) instance Random RGB where random = color2 randomR = colorR color2 :: RandomGen g ⇒ g → (RGB,g) color2 = colorR (minRGB,maxRGB) color :: RandomGen g ⇒ g → (RGB,g) color s0 = ((r,g,b),s3) where (r,s1) = q s0 (g,s2) = q s1 (b,s3) = q s2 q = randomR (0,255) colorR :: RandomGen g ⇒ (RGB,RGB) → g → (RGB,g) colorR ((a,b,c),(x,y,z)) s0 = ((r,g,b),s3) where (r,s1) = q (a,x) s0 (g,s2) = q (b,y) s1 (b,s3) = q (c,z) s2 q = randomR main :: IO () main = do mt ← newPureMT let cs = randoms mt :: [RGB] print cs -- This one also just works fine: import Data.Word import System.Random.Mersenne type RGB = (Word8,Word8,Word8) instance MTRandom RGB where random m = do r ← random m :: IO Word8 g ← random m :: IO Word8 b ← random m :: IO Word8 return (r,g,b) main :: IO () main = do g ← newMTGen Nothing cs ← randoms g :: IO [RGB] print cs but I really need the range constraints colorR might provide me and would greatly appreciate any help to understand/solve the issue. Best Regards, Cetin P/s: uname -a Linux linux-d312 2.6.25.16-0.1-default #1 SMP 2008-08-21 00:34:25 +0200 x86_64 x86_64 x86_64 GNU/Linux ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] random colors, stack space overflow, mersenne and mersenne.pure64
Oh, hi *^o^* mersenne.pure64 http://sert.homedns.org/lab/colors/var2.hs mersenne http://sert.homedns.org/lab/colors/var.hs the problem seems to be with the definition of colorR in var2.hs CS 2008/9/13 Don Stewart [EMAIL PROTECTED] cetin.sert: random = color2 randomR = colorR color2 :: RandomGen g .$BM.(B g .$B*.(B (RGB,g) color2 = colorR (minRGB,maxRGB) color :: RandomGen g .$BM.(B g .$B*.(B (RGB,g) color s0 = ((r,g,b),s3) where ^^ There's some corruption in this text. Could you post the file somewhere? -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] random colors, stack space overflow, mersenne and mersenne.pure64
Oh, sorry... ^__^ ghc -fglasgow-exts -O2 --make var ghc -fglasgow-exts -O2 --make var2 I've not used pragmas in any source file o_O so far... should go fix that sometime. Thanks for reminding... Using ghc 6.8.3, mersenne-random-0.1.3 and mersenne-random-pure64-0.2.0.2. (Cause I could not find out how to check things out with darcs from hackage o__O google was not very helpful there so I used the latest tar packages.) @don: sorry I sent my reply twice only to you and then to the list and you... it's because of gmail... I'll be very careful not to repeat my mistake. 2008/9/13 Don Stewart [EMAIL PROTECTED] Oh, you've got unicode source. What's the flag to get this to actually compile? (Note to readers, using extensions , you should always include the LANGUAGE pragmas required to build the file when asking for help :) How are you compiling this? -- Don cetin.sert: Oh, hi *^o^* mersenne.pure64 [1]http://sert.homedns.org/lab/colors/var2.hs mersenne [2]http://sert.homedns.org/lab/colors/var.hs the problem seems to be with the definition of colorR in var2.hs CS 2008/9/13 Don Stewart [EMAIL PROTECTED] cetin.sert: random = color2 randomR = colorR color2 :: RandomGen g .$BM.(B g .$B*.(B (RGB,g) color2 = colorR (minRGB,maxRGB) color :: RandomGen g .$BM.(B g .$B*.(B (RGB,g) color s0 = ((r,g,b),s3) where ^^ There's some corruption in this text. Could you post the file somewhere? -- Don References Visible links 1. http://sert.homedns.org/lab/colors/var2.hs 2. http://sert.homedns.org/lab/colors/var.hs 3. mailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] random colors, stack space overflow, mersenne and mersenne.pure64
Oh thank you both *^o^*... now works like a charm again. Btw, Cetin, this is good practice, along with -funbox-strict-fields: data RGB = RGB !Int !Int !Int deriving Show Much better code than using a lazy triple. Where can I read more of such good practice? Looking forward to Real World Haskell to read lots of code, hope it'll help lots of people interested in learning haskell. (Will be released around Christmas here in Germany, I think.) CS 2008/9/13 Don Stewart [EMAIL PROTECTED] bertram.felgenhauer: Cetin Sert wrote: [snip] colorR :: RandomGen g ⇒ (RGB,RGB) → g → (RGB,g) colorR ((a,b,c),(x,y,z)) s0 = ((r,g,b),s3) where (r,s1) = q (a,x) s0 (g,s2) = q (b,y) s1 (b,s3) = q (c,z) s2 q = randomR Look closely at how you use the variable 'b'. :-) fast eyes. Btw, Cetin, this is good practice, along with -funbox-strict-fields: data RGB = RGB !Int !Int !Int deriving Show Much better code than using a lazy triple. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] random colors, stack space overflow, mersenne and mersenne.pure64
main :: IO () main = do as - getArgs mt - newPureMT let colors = randomRs (lo,hi) mt :: [RGB] print $ zip tx cs where lo = read $ as !! 0 hi = read $ as !! 1 tx =as !! 2 Why is as not visible in the where block? 2008/9/13 Brandon S. Allbery KF8NH [EMAIL PROTECTED] On 2008 Sep 12, at 21:57, Don Stewart wrote: cetin.sert: random = color2 randomR = colorR color2 :: RandomGen g .$BM.(B g .$B*.(B (RGB,g) color2 = colorR (minRGB,maxRGB) color :: RandomGen g .$BM.(B g .$B*.(B (RGB,g) color s0 = ((r,g,b),s3) where There's some corruption in this text. Could you post the file somewhere? It's not corrupt; he used UTF-8 symbols. It shows up properly in Mail.app but doesn't quote right (admittedly I force plaintext). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Hackage
Hi, Hackage seems to have been down for a few days now. When is it going to be back online? It is not possible to darcs-get any packages either. Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cgi liftM liftIO
Hi, Could someone please care to explain what I am doing wrong below in cgiMain2 and how can I fix it? ./Main.hs:25:15: No instance for (MonadCGI IO) arising from a use of `output' at ./Main.hs:25:15-20 Possible fix: add an instance declaration for (MonadCGI IO) In the first argument of `($)', namely `output' In the expression: output $ renderHtml $ page import fileForm In the definition of `upload': upload = output $ renderHtml $ page import fileForm ./Main.hs:57:29: Couldn't match expected type `CGI CGIResult' against inferred type `IO CGIResult' In the first argument of `handleErrors', namely `cgiMain2' In the second argument of `($)', namely `handleErrors cgiMain2' In the expression: runCGI $ handleErrors cgiMain2 import IO import Network.CGI import Text.XHtml import qualified Data.ByteString.Lazy as BS import Control.Monad (liftM) import Data.Maybe (fromJust) import Interact fileForm = form ! [method post, enctype multipart/form-data] [afile file, submit Upload] page t b = header thetitle t +++ body b cgiMain1 = do getInputFPS file ↠ λms → maybe upload contents ms ↠ return where upload = output $ renderHtml $ page import fileForm contents = outputFPS cgiMain2 = do getInputFPS file ↠ λms → maybe upload contents ms ↠ return where upload = output $ renderHtml $ page import fileForm contents = λs → do (i,o,h,_) ← runUnzip BS.hPutStr i s c ← BS.hGetContents o outputFPS c {- (i,o,h,_) ← runUnzip BS.hPutStr i s BS.hGetContents o ↠ outputFPS -} {- liftM :: (Monad m) = (a1 - r) - m a1 - m r liftIO :: (MonadIO m) = IO a - m a saveFile n = do cont - liftM fromJust $ getInputFPS file let f = uploadDir ++ / ++ basename n liftIO $ BS.writeFile f cont return $ paragraph (Saved as +++ anchor ! [href f] f +++ .) -} runUnzip = runInteractiveCommand unzip -l /dev/stdin main = runCGI $ handleErrors cgiMain2 Best Regards, Cetin Sert P/s: what are lifts o_O? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] automatically deriving Map and Filter on datatypes etc.
Hi ^_^, Let's say we have the following data type and functions: data Tab a = (:↺:) | a :↓: Tab a | Tab a :↙↘: (Tab a,Tab a) deriving (Eq, Show, Read) map f (:↺:) = (:↺:) map f (a :↓: t) = f a :↓: map f t map f (h :↙↘: (l,r)) = map f h :↙↘: (map f l, map f r) filter p (:↺:) = (:↺:) filter p (a :↓: t) | p a = filter p t | otherwise = a :↓: filter p t filter p (h :↙↘: (l,r)) = filter p h :↙↘: (filter p l, filter p r) is it possible to automatically derive map and filter? data Tab a = (:↺:) | a :↓: Tab a | Tab a :↙↘: (Tab a,Tab a) deriving (Eq, Show, Read, Map, Filter) If not, do you think it might be nice to have something like this in the future? Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Web server
Hi, What is the fastest way to set up a web server that can redirect requests to a haskell application and serve results returned by it? I need to demonstrate a simple visualization tool I have written for analytic tableaux on Monday and need something easy and simple. Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] lookup tables style guidelines
Dear Haskell Devs ^_^, 1) what is the most performant lookup table/hashtable/dictionary solution for Haskell? 1.1) should I use size-balanced binary trees for that or is there a more common way? 2) are there any established style guidelines for haskell code? Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] lookup tables style guidelines
Thanks Don... You are amazing... o_O always so quick with replies... I was using GraphViz to generate some directed graphs*, knowing what to use for a dict/map will help speed things up! Cetin * (for analytic tableaux in Okitsune+) + (need a better name, maybe I should ask Haskell-Cafe for one in the near future) 2008/4/23 Don Stewart [EMAIL PROTECTED]: cetin.sert: Dear Haskell Devs ^_^, 1) what is the most performant lookup table/hashtable/dictionary solution for Haskell? Data.IntMap is awfully good. 1.1) should I use size-balanced binary trees for that or is there a more common way? I would. Data.Map/Data.IntMap 2) are there any established style guidelines for haskell code? http://haskell.org/haskellwiki/Category:Style Or pick an author you like, and look at their code on hackage.haskell.org -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ghc
moving a binary compiled on a 32-bit machine running Linux to a 64-bit one, would that necessitate recompilation on the target machine or cross-compilation or can 64-bit Linux run 32-bit binaries? 2008/4/11 Jake Mcarthur [EMAIL PROTECTED]: On Apr 10, 2008, at 1:20 PM, Brent Yorgey wrote: This is true for any compiler that produces native binaries (as opposed to certain languages which require a virtual machine...) Unless, of course, it results in a dynamically linked binary, which I'm pretty sure GHC doesn't support at all anyway (unless that has changed?). — Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ghc
Hi, Is GHC required to be installed on the target OS I compile Haskell binaries for in order for these binaries to run? I need a quick answer on that! By the way there is no computer in the 4 or so networks I have online access to on which ghc is not installed, which might be a sign people like haskell here in Heidelberg/Mannheim, Germany. Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] getChar
Hi, is there a version of getChar that doesn't buffer keyboard input until enter is pressed? specialReadln :: IO String specialReadln = do c ← getChar if c == '#' then do return [] else do cs ← specialReadln return (c:cs) I want the input process to terminate when '#' or any other specific key has been pressed. Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] what is the fastest way to extract variables from a proposition?
-- proposition data Prp a = Var a | Not (Prp a) | Or (Prp a) (Prp a) | And (Prp a) (Prp a) | Imp (Prp a) (Prp a) | Xor (Prp a) (Prp a) | Eqv (Prp a) (Prp a) | Cns Bool deriving (Show, Eq) -- Here are to variable extraction methods -- variable extraction reference imp. -- Graham Hutton: Programming in Haskell, 107 vars_ :: Prp a → [a] vars_ (Cns _) = [] vars_ (Var x) = [x] vars_ (Not p) = vars_ p vars_ (Or p q) = vars_ p ++ vars_ q vars_ (And p q) = vars_ p ++ vars_ q vars_ (Imp p q) = vars_ p ++ vars_ q vars_ (Xor p q) = vars_ p ++ vars_ q vars_ (Eqv p q) = vars_ p ++ vars_ q -- variable extraction new * this is faster vars :: Prp a → [a] vars p = evs [p] where evs [] = [] evs (Cns _ :ps) = [] evs (Var x :ps) = x:evs ps evs (Not p :ps) = evs (p:ps) evs (Or p q:ps) = evs (p:q:ps) evs (And p q:ps) = evs (p:q:ps) evs (Imp p q:ps) = evs (p:q:ps) evs (Xor p q:ps) = evs (p:q:ps) evs (Eqv p q:ps) = evs (p:q:ps) -- for : Not (Imp (Or (Var 'p') (Var 'q')) (Var p)) -- vars_: ['p','q','p'] -- vars : ['p','q','p'] -- order and the fact that 'p' appears twice being irrelevant: -- is there an even faster way to do this? -- -- Cetin Sert -- www.corsis.de ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what is the fastest way to extract variables from a proposition?
plong 0 = Var 0 plong n | even n= Or (Var n) (plong (n-1)) | otherwise = And (Var n) (plong (n-1)) main = do print ((length ∘ vars) (plong 1000)) real0m3.290s user0m3.152s sys 0m0.020s main = do print ((length ∘ vars_) (plong 1000)) real0m3.732s user0m3.680s sys 0m0.024s -- vrsn=varsBromage main = do print ((length ∘ vrsn) (plong 1000)) real0m4.164s user0m4.128s sys 0m0.008s ghc -fglasgow-exts -O2 ghc 6.8.2 @Andrew: It is astonishing to see that your version actually performs the worst (at least on my machine). By looking at your code I had also thought that yours would be the fastest in terms of runtime performance, it was also exactly what I tried but failed to get to here on my own. Maybe future ghc versions will change this in favour of your version. I would like to have someone test it on another machine though: fetch: svn co https://okitsune.svn.sourceforge.net/svnroot/okitsune . build: ghc -fglasgow-exts -O2 Common.hs Propositions.hs Test.hs testS: time ./a.out sert testH: time ./a.out hutton testB: time ./a.out bromage Best regards, Cetin Sert. On 21/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: G'day all. Quoting Cetin Sert [EMAIL PROTECTED]: -- proposition data Prp a = Var a | Not (Prp a) | Or (Prp a) (Prp a) | And (Prp a) (Prp a) | Imp (Prp a) (Prp a) | Xor (Prp a) (Prp a) | Eqv (Prp a) (Prp a) | Cns Bool deriving (Show, Eq) This is probably the fastest: vars :: Prp a - [a] vars p = vars' p [] where vars' (Var a) = (a:) vars' (Not p) = vars' p vars' (Or l r) = vars' l . vars' r {- etc -} vars' (Cns _) = id Cheers, Andrew Bromage ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what is the fastest way to extract variables from a proposition?
[EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult sert 101 real0m1.384s user0m1.148s sys 0m0.112s [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult bromage 101 real0m2.240s user0m1.972s sys 0m0.176s [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult bromage 1001 real0m59.875s user0m58.080s sys 0m1.656s [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult sert 1001 real0m32.043s user0m30.930s sys 0m0.992s Hutton seems to fail miserably in both lengths here o_O I was not aware of the effect of structures on performance. Thanks for reminding me! Best Regards, Cetin Sert On 21/02/2008, Derek Elkins [EMAIL PROTECTED] wrote: On Thu, 2008-02-21 at 05:10 +0100, Cetin Sert wrote: plong 0 = Var 0 plong n | even n= Or (Var n) (plong (n-1)) | otherwise = And (Var n) (plong (n-1)) compare the times again but with plong as follows: plong 0 = Var 0 plong n | even n = Or (plong (n-1)) (Var n) | otherwise = And (plong (n-1)) (Var n) main = do print ((length ∘ vars) (plong 1000)) real0m3.290s user0m3.152s sys 0m0.020s main = do print ((length ∘ vars_) (plong 1000)) real0m3.732s user0m3.680s sys 0m0.024s -- vrsn=varsBromage main = do print ((length ∘ vrsn) (plong 1000)) real0m4.164s user0m4.128s sys 0m0.008s ghc -fglasgow-exts -O2 ghc 6.8.2 @Andrew: It is astonishing to see that your version actually performs the worst (at least on my machine). By looking at your code I had also thought that yours would be the fastest in terms of runtime performance, it was also exactly what I tried but failed to get to here on my own. Maybe future ghc versions will change this in favour of your version. I would like to have someone test it on another machine though: fetch: svn co https://okitsune.svn.sourceforge.net/svnroot/okitsune . build: ghc -fglasgow-exts -O2 Common.hs Propositions.hs Test.hs testS: time ./a.out sert testH: time ./a.out hutton testB: time ./a.out bromage Best regards, Cetin Sert. On 21/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: G'day all. Quoting Cetin Sert [EMAIL PROTECTED]: -- proposition data Prp a = Var a | Not (Prp a) | Or (Prp a) (Prp a) | And (Prp a) (Prp a) | Imp (Prp a) (Prp a) | Xor (Prp a) (Prp a) | Eqv (Prp a) (Prp a) | Cns Bool deriving (Show, Eq) This is probably the fastest: vars :: Prp a - [a] vars p = vars' p [] where vars' (Var a) = (a:) vars' (Not p) = vars' p vars' (Or l r) = vars' l . vars' r {- etc -} vars' (Cns _) = id Cheers, Andrew Bromage ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what is the fastest way to extract variables from a proposition?
I would expect my (well, I didn't invent it) to work better on something that didn't have this unique structure, such as: test 0 = Var 0 test n | even n= Or (Var n) (test (n-1)) | otherwise = And (test (n-1)) (Var n) for some reason this still does not perform as well as it should o__O I think function composition might somehow be the bottleneck behind this. --with plong 0 = Var 0 plong n | even n= Or (Var n) (plong (n-1)) | otherwise = And (plong (n-1)) (Var n) --and n = 100 [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult sert 101 real0m0.692s user0m0.624s sys 0m0.040s [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult sert 101 real0m0.696s user0m0.644s sys 0m0.036s [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult sert 101 real0m0.840s user0m0.744s sys 0m0.052s [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult bromage 101 real0m1.561s user0m1.360s sys 0m0.100s [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult bromage 101 real0m1.692s user0m1.392s sys 0m0.136s [EMAIL PROTECTED]:~/workspace/Haskell-1/bin$ time ./theResult bromage 101 real0m1.959s user0m1.580s sys 0m0.116s Best Regards, Cetin Sert On 21/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: G'day all. Quoting Cetin Sert [EMAIL PROTECTED]: It is astonishing to see that your version actually performs the worst (at least on my machine). On your example, I'm not surprised: plong 0 = Var 0 plong n | even n= Or (Var n) (plong (n-1)) | otherwise = And (Var n) (plong (n-1)) This is effectively a singly linked list. I would expect my (well, I didn't invent it) to work better on something that didn't have this unique structure, such as: test 0 = Var 0 test n | even n= Or (Var n) (test (n-1)) | otherwise = And (test (n-1)) (Var n) Cheers, Andrew Bromage ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Generic permutations
How can I make a generic permutations function? -- boolean permutations bpms :: Int → [[Bool]] bpms 0 = [[]] bpms n = map (False:) bss ++ map (True:) bss where bss = bpms (n - 1) -- generic permutations pms a :: Int → [[a]] Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Generic permutations
I have come up with this myself ^_^ mps :: [a] → [[a]] → [[a]] mps [] _ = [] mps _ [] = [] mps (x:xs) yss = map (x:) yss ++ mps xs yss pms :: [a] → Int → [[a]] pms [] _ = [[]] pms _ 0 = [[]] pms xxs n = mps xxs (pms (xxs) (n - 1)) -- now bpms can pointlessly be redefined as bpms = pms [False,True] On 26/01/2008, Cetin Sert [EMAIL PROTECTED] wrote: How can I make a generic permutations function? -- boolean permutations bpms :: Int → [[Bool]] bpms 0 = [[]] bpms n = map (False:) bss ++ map (True:) bss where bss = bpms (n - 1) -- generic permutations pms a :: Int → [[a]] Best Regards, Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Generic permutations
Thank you very much ^_^. What would be a mathematically correct and understandable name for what we call 'pms' here? And in what module do foldM, combine, replicate, rest, liftM and so on reside? How can I import them? o_O -- Cetin Sert On 26/01/2008, Ryan Ingram [EMAIL PROTECTED] wrote: When you say permuations, I think of reorderings of a list, for example: permutations [1,2,3] = [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] Here's an implementation: -- split [1,2,3] = [ --( 1, [2,3] ), --( 2, [1,3] ), --( 3, [1,2] ) ] split :: [a] - [(a, [a])] split [] = error split: empty list split [a] = [(a, [])] split (a:as) = (a, as) : map prefix (split as) where prefix (x, xs) = (x, a : xs) permutations :: [a] - [[a]] permutations [] = return [] permutations xs = do (first, rest) - split xs rest' - permutations rest return (first : rest') The problem you solved can be solved much more elegantly: pms : [a] - Int - [[a]] pms xs n = foldM combine [] (replicate n xs) where combine rest as = liftM (:rest) as or, for the unreadable version: pms xs n = foldM (map . flip (:)) [] $ replicate n xs (note that, in the list monad, liftM = map). -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Generic permutations with high performance
Hello again Ryan, I have found out where to import those stuff from and tested your more elegant suggestion and my original performance. -- print ((length ∘ pmsO [0,1]) 24) 9~ seconds -- print ((length ∘ pmsE [0,1]) 24) 23~ seconds -- print ((length ∘ pmsU [0,1]) 24) 23~ seconds -- O: original, E: elegant, U: unreadable I prefer performance over elegance (and for me using monads almost feels like adding an unnecessary dependency to the definition of pms. Though I know I may be dead wrong on that. I just don't quite understand monads yet.) I would love to have you and/or others suggest more performant versions of pms (and maybe also come up with a better name for it). mnt :: [a] → [[a]] → [[a]] mnt [] _ = [] mnt _ [] = [] mnt (x:xs) yss = map (x:) yss ++ mnt xs yss pms :: [a] → Int → [[a]] pms [] _ = [[]] pms _ 0 = [[]] pms xxs n = mnt xxs (pms xxs (n - 1)) I generalized 'pms' from the 'bools' function on page 108 of Programming in Haskell (Hutton, 2007) -- Cetin Sert On 26/01/2008, Ryan Ingram [EMAIL PROTECTED] wrote: When you say permuations, I think of reorderings of a list, for example: permutations [1,2,3] = [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] Here's an implementation: -- split [1,2,3] = [ --( 1, [2,3] ), --( 2, [1,3] ), --( 3, [1,2] ) ] split :: [a] - [(a, [a])] split [] = error split: empty list split [a] = [(a, [])] split (a:as) = (a, as) : map prefix (split as) where prefix (x, xs) = (x, a : xs) permutations :: [a] - [[a]] permutations [] = return [] permutations xs = do (first, rest) - split xs rest' - permutations rest return (first : rest') The problem you solved can be solved much more elegantly: pms : [a] - Int - [[a]] pms xs n = foldM combine [] (replicate n xs) where combine rest as = liftM (:rest) as or, for the unreadable version: pms xs n = foldM (map . flip (:)) [] $ replicate n xs (note that, in the list monad, liftM = map). -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Generic permutations
Hello again Ryan, I have found out where to import those stuff from and tested your more elegant suggestion and my original performance. -- print ((length ∘ pmsO [0,1]) 24) 9~ seconds -- print ((length ∘ pmsE [0,1]) 24) 23~ seconds -- print ((length ∘ pmsU [0,1]) 24) 23~ seconds -- O: original, E: elegant, U: unreadable I prefer performance over elegance (and for me using monads almost feels like adding an unnecessary dependency to the definition of pms. Though I know I may be dead wrong on that. I just don't quite understand monads yet.) I would love to have you and/or others suggest more performant versions of pms (and maybe also come up with a better name for it). mnt :: [a] → [[a]] → [[a]] mnt [] _ = [] mnt _ [] = [] mnt (x:xs) yss = map (x:) yss ++ mnt xs yss pms :: [a] → Int → [[a]] pms [] _ = [[]] pms _ 0 = [[]] pms xxs n = mnt xxs (pms xxs (n - 1)) I generalized 'pms' from the 'bools' function on page 108 of Programming in Haskell (Hutton, 2007) -- Cetin Sert On 26/01/2008, Cetin Sert [EMAIL PROTECTED] wrote: Thank you very much ^_^. What would be a mathematically correct and understandable name for what we call 'pms' here? And in what module do foldM, combine, replicate, rest, liftM and so on reside? How can I import them? o_O -- Cetin Sert On 26/01/2008, Ryan Ingram [EMAIL PROTECTED] wrote: When you say permuations, I think of reorderings of a list, for example: permutations [1,2,3] = [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] Here's an implementation: -- split [1,2,3] = [ --( 1, [2,3] ), --( 2, [1,3] ), --( 3, [1,2] ) ] split :: [a] - [(a, [a])] split [] = error split: empty list split [a] = [(a, [])] split (a:as) = (a, as) : map prefix (split as) where prefix (x, xs) = (x, a : xs) permutations :: [a] - [[a]] permutations [] = return [] permutations xs = do (first, rest) - split xs rest' - permutations rest return (first : rest') The problem you solved can be solved much more elegantly: pms : [a] - Int - [[a]] pms xs n = foldM combine [] (replicate n xs) where combine rest as = liftM (:rest) as or, for the unreadable version: pms xs n = foldM (map . flip (:)) [] $ replicate n xs (note that, in the list monad, liftM = map). -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Generic permutations
Thanks Jed, replicateM is almost as performant as pms on my pc (+ 2~ seconds). That's a killer suggestion... thank you very much ^_^ --Cetin Sert On 27/01/2008, Jed Brown [EMAIL PROTECTED] wrote: The problem you solved can be solved much more elegantly: pms : [a] - Int - [[a]] pms xs n = foldM combine [] (replicate n xs) where combine rest as = liftM (:rest) as or, for the unreadable version: pms xs n = foldM (map . flip (:)) [] $ replicate n xs or, if you don't mind getting the elements in a different order: replicateM 3 [True,False] Jed ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Yi and Data.ByteString
1) Can anyone tell me how I can build Yi or point me to a binary release of that editor? I tried to follow the instructions on http://www.nobugs.org/developer/yi/building.html but got a missing component error each time. 2) When if ever is Data.ByteString going to be the default string representation in GHC? I study computational linguistics and plan to switch to Haskell in the near future, that is once I get to grips with the language and the whole new thought model one has to develop as an imperative programmer. Best Regards, Cetin Sert www.corsis.de ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Yi and Data.ByteString
-- Yi that's the error message I got following the instructions on http://www.nobugs.org/developer/yi/building.html setup: At least the following dependencies are missing: fingertree -any make: *** [dist/setup-config] Error 1 Where can I get fingertree from? Do I need a specific version of this package? -- Data.ByteString Where can I read more about GHC options like -XOverloadedStrings or this :: ByteString type declaration? I did not know ByteString was less performant than a linked list of characters. It is used even in the language shootout benchmark programs. Cetin On 21/01/2008, pierre [EMAIL PROTECTED] wrote: Hello, On Mon, Jan 21, 2008 at 07:12:26PM +0100, Cetin Sert wrote: 2) When if ever is Data.ByteString going to be the default string representation in GHC? Why would you need such a thing? ByteStrings don't have any unicode support, and they can be quite slow for small strings. They are just a different tool for different task. But if you wish, you could use string literals as bytestrings with -XOverloadedStrings ghc (=6.8) flag Best Regards, Cetin Sert www.corsis.de -- pierre ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] non-alphabetical mathematical symbols as non-infix function names
(¬) :: Bool → Bool (¬) q = not q q = True ¬ q : parser error on input q ¬ : parser error (possibly incorrect indentation) (¬ q) : Couldn't match expected type `Bool - t' against inferred type `Bool' In the expression: (� True) In the definition of `it': it = (� True) * (q ¬) : False (Why) is it not possible to define a (non-infix) function whose name consists of a single non-alphabetical mathematical symbol? ¬ :: Bool → Bool -- parser error on input ** ¬ q = not q -- parser error on input ** Cetin Sert ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Reflection.Emit in Haskell
As a .NET (C#/F#) programmer learning Haskell, I would love to know the best online sources about run-time compilation etc. like Reflection.Emit in .NET. I am making heavy use of this .NET API to compile customized (regular-expressions-) FSAs at run-time and want to learn how I might achieve the same in Haskell. Book or online article references specific to this issue will be highly appreciated ^_^ Best Regards, Cetin Sert INF 521, 4-6-2 69120 Heidelberg Germany http://www.corsis.de ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL
I want to design a DSL in Haskell for propositional calculus. But instead of using natural language names for functions like or, and, implies etc. I want to use Unicode symbols as infix functions ¬, ˅, ˄, →, ↔ But I keep getting error messages from the GHC parser. Is there a way to make GHC parse my source files correctly? If it is not possible yet, please consider this as a “feature request”. Best Regards, Cetin Sert INF 521, 4-6-2 69120 Heidelberg Germany http://www.corsis.de ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL
Neither appending {-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-} at the beginning of a .hs source file in Visual Haskell nor setting the ghc options from the project properties seems to solve the problem. I keep getting Error 1 lexical error (UTF-8 decoding error) C:\Users\Sert\Lab\Haskell\HaskellApp1\HaskellApp1\src\Explogic.hs Line 25 Column 2 in the IDE. Maybe this is Visual Haskell-specific o_O!? -- not (¬) :: P a = a - Bool (¬) a | g a = False | otherwise = True Best Regards, Cetin Sert -Original Message- From: Don Stewart [mailto:[EMAIL PROTECTED] Sent: Mittwoch, 9. Januar 2008 18:24 To: Cetin Sert Cc: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL cetin.sert: I want to design a DSL in Haskell for propositional calculus. But instead of using natural language names for functions like or, and, implies etc. I want to use Unicode symbols as infix functions NOT, *, *, -, - But I keep getting error messages from the GHC parser. Is there a way to make GHC parse my source files correctly? If it is not possible yet, please consider this as a feature request. The survey of Haskell unicode support might have some advice, http://blog.kfish.org/2007/10/survey-haskell-unicode-support.html See also -XUnicodeSyntax for enabling unicode keywords for - - forall et al. This is turning into an FAQ, so clarifying the unicode support in the GHC user's guide would be a good result. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL
I'm making sure that my project files are all saved in UTF-8: I'm not newbie enough to miss something like that. I suspect something between Visual Studio and the background GHC instance that feeds it with syntax highlighting and environment information (like a list of functions that are accessible or inferred type infos etc..) might be causing a miscommunication with regards to the file encodings. I also tried writing -XUnicodeSyntax. I'll try to use some other editor and directly call the compiler to see if it works. Thanks for all your support ^_^ Best Regards, Cetin Sert http://www.corsis.de -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stefan O'Rear Sent: Mittwoch, 9. Januar 2008 23:49 To: Wolfgang Jeltsch Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL On Wed, Jan 09, 2008 at 10:23:05PM +0100, Wolfgang Jeltsch wrote: Am Mittwoch, 9. Januar 2008 18:34 schrieb Cetin Sert: Neither appending {-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-} First, I think, you have to use -XUnicodeSyntax (as Don said), and not -xunicodesyntax. Second, -XUnicodeSyntax only enables alternative notation for certain built-in syntax (as Don said). Unicode for operators is a different matter. I’d think, it should work out of the box and wonder a bit why it doesn’t. The give-away is that GHC gave a UTF-8 decoding error. This says that Cetin is using a different encoding, presumably (due to his mention of Visual Haskell, ergo Windows) UTF-16. Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Type Mismatch
Hi, I'm new to Haskell programming and have the following problem. - (|) f g = g f data Stream a where S :: (s - Step s a) - s - Stream a data Step s a = Done | Yield a s | Skip a s toStream :: [a] - Stream a toStream ax = S step ax where step [] = Done step (a:ax) = Yield a ax fromStream :: Stream a - [a] fromStream (S step s) = loop s where loop s = case step s of Done - [] Skip a s' - loop s' Yield a s' - a : loop s' filterStream :: (a - Bool) - Stream a - Stream a filterStream p (S step s) = S filter s where filter s = case step s of Done - Done Skip a s' - Skip a s' Yield a s' - if p a then Yield a s' else Skip a s' mapStream :: (a - b) - Stream a - Stream b mapStream f (S step s) = S map s where map s = case step s of Done - Done Skip a s' - Skip (f a) s' Yield a s' - Yield (f a) s' class Streamable a where to :: a - Stream a instance Streamable [a] where to = toStream -- ERROR: see below s f x = x | toStream | f | fromStream smap x = s (mapStream x) sfilter x = s (filterStream x) (%) a b = mod a b main = do print ([0..20] | sfilter (\x - x % 2 == 0)) - Error 1 Couldn't match expected type `a' (a rigid variable) against inferred type `[a]' `a' is bound by the instance declaration at C:\Users\Sert\Lab\Haskell\HaskellApp1\HaskellApp1\src/Main.hs:63:0 Expected type: [a] - Stream [a] Inferred type: [[a]] - Stream [a] In the expression: toStream In the definition of `to': to = toStream C:\Users\Sert\Lab\Haskell\HaskellApp1\HaskellApp1\src\Main.hs 64 8 How can I make the types match so that I can declare lists streamable? Is there something like in-place type annotations as in ML/OCaml/F#? Best Regards, Cetin Sert corsis.de/blog ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe