Re: [Haskell-cafe] Parsec error message not making any sense
Hi Roman, I'm using parsec-3.1.3 I put the code in a gist here - sorry about that. https://gist.github.com/dargosch/5955045 Fredrik On Tue, Jul 9, 2013 at 12:08 AM, Roman Cheplyaka r...@ro-che.info wrote: Hi Fredrik, First, do you use the latest parsec version (3.1.3)? If not, can you try the same with 3.1.3? Second, please upload your code to hpaste.org or a similar service and give us the link. It's not much fun to extract code from an html email. Roman * Fredrik Karlsson dargo...@gmail.com [2013-07-08 23:54:17+0200] Dear list, I have a Parsec parser that fails and gives the following error message: *Main parseFromFile textgridfile testFile Left /Users/frkkan96/Documents/src/ume/umecore/testing/testdata/testdata.TextGrid (line 35, column 5): unexpected t expecting intervals [ Now, this is perfectly understandable, but line 35, col 5 in the file being parsed looks like the supplies image - there is no 't' there. Any ideas on what is going on? The parser I am using is: data VariableLine = VariableLine String String deriving Show data TierType = IntervalTier | PointTier deriving Show data Tier = Tier String deriving Show data LabelFile = LabelFile Double Double deriving Show data Label = Label String TierType Double Double String deriving Show haskelldef = makeTokenParser haskellDef textgridfile :: Parser (LabelFile, [[Label]]) textgridfile = do h - header ll - many1 tier return $ (h,ll) header :: Parser LabelFile header = do string headTS1 start - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string xmax = end - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string tiers? exists \n string size = integer haskelldef string item []: whiteSpace haskelldef return $ LabelFile start end tier :: Parser [Label] tier = do whiteSpace haskelldef string item [ integer haskelldef string ]: whiteSpace haskelldef try (string class = \IntervalTier\) | string class = \TextTier\ whiteSpace haskelldef string name = char '' name - many quotedChar char '' ? quote at end of cell whiteSpace haskelldef string xmin = try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) whiteSpace haskelldef string xmax = try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string intervals: size = | string points: size = integer haskelldef whiteSpace haskelldef labelList - many1 (interval name) return $ labelList interval :: String - Parser Label interval tierName = do whiteSpace haskelldef string intervals [ integer haskelldef string ]: whiteSpace haskelldef string xmin = start - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) whiteSpace haskelldef string xmax = end - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) whiteSpace haskelldef string text = char '' text - many quotedChar char '' ? quote at end of cell return $ Label tierName IntervalTier start end text which fails on the attached input file. I can't see how 't' is found?? What am I doing wrong? /Fredrik -- Life is like a trumpet - if you don't put anything into it, you don't get anything out of it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Life is like a trumpet - if you don't put anything into it, you don't get anything out of it. testdata.TextGrid Description: Binary data ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Linux users needed for OpenGL extensions survey
On Mon, Jul 08, 2013 at 09:55:08PM -0700, Kirill Zaborsky wrote: Brian, I think it would be better to provide your email in the thread. E.g. from http://www.haskell.org/pipermail/haskell-cafe/2013-July/109061.html I can only reply to the maillist. I'm answering now through Google Groups hope it will get to you. Brian's email address is at the top of that page. Just replace at with @. Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Ajhc Haskell Compiler 0.8.0.7 Release
I'd be very interested in a pic32 port. On Mon, Jul 8, 2013 at 7:24 PM, Tommy Thorn tt1...@yahoo.com wrote: On Jul 6, 2013, at 03:07 , Kiwamu Okabe kiw...@debian.or.jp wrote: Umm... Is your question Is Ajhc's goal that build the compiler for Android? If so, the answer is No. The Ajhc's goal is that find the compiler to rewrite the NetBSD kernel with Haskell. But you can do support Android. I think porting (A)jhc's RTS to Android NDK is as easy as to Cortex-M4. Similarly, I might look into a PIC32 port (= MIPS 4K). I don't expect any problems. I presume nobody have started on this yet. Tommy ___ 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] ANNOUNCE: Ajhc Haskell Compiler 0.8.0.7 Release
Hi Jeremy. On Tue, Jul 9, 2013 at 3:30 AM, Jeremy Shaw jer...@n-heptane.com wrote: Any plans on supporting the popular Raspberry Pi platform? I poked at the source code a bit, but I didn't even know where to begin. I think you can do it already, if you have cross GCC for Raspberry Pi. http://ajhc.metasepi.org/manual.html#crosscompilation Best regards, -- Kiwamu Okabe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsec error message not making any sense
Please check your code. I had two problems with it: mixed tabs and spaces, and undefined 'quotedChar'. After defining quotedChar = anyChar, I get a different error message from yours: *Main parseFromFile textgridfile testdata.TextGrid Left testdata.TextGrid (line 137, column 1): unexpected end of input expecting quote at end of cell Roman * Fredrik Karlsson dargo...@gmail.com [2013-07-09 08:07:24+0200] Hi Roman, I'm using parsec-3.1.3 I put the code in a gist here - sorry about that. https://gist.github.com/dargosch/5955045 Fredrik On Tue, Jul 9, 2013 at 12:08 AM, Roman Cheplyaka r...@ro-che.info wrote: Hi Fredrik, First, do you use the latest parsec version (3.1.3)? If not, can you try the same with 3.1.3? Second, please upload your code to hpaste.org or a similar service and give us the link. It's not much fun to extract code from an html email. Roman * Fredrik Karlsson dargo...@gmail.com [2013-07-08 23:54:17+0200] Dear list, I have a Parsec parser that fails and gives the following error message: *Main parseFromFile textgridfile testFile Left /Users/frkkan96/Documents/src/ume/umecore/testing/testdata/testdata.TextGrid (line 35, column 5): unexpected t expecting intervals [ Now, this is perfectly understandable, but line 35, col 5 in the file being parsed looks like the supplies image - there is no 't' there. Any ideas on what is going on? The parser I am using is: data VariableLine = VariableLine String String deriving Show data TierType = IntervalTier | PointTier deriving Show data Tier = Tier String deriving Show data LabelFile = LabelFile Double Double deriving Show data Label = Label String TierType Double Double String deriving Show haskelldef = makeTokenParser haskellDef textgridfile :: Parser (LabelFile, [[Label]]) textgridfile = do h - header ll - many1 tier return $ (h,ll) header :: Parser LabelFile header = do string headTS1 start - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string xmax = end - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string tiers? exists \n string size = integer haskelldef string item []: whiteSpace haskelldef return $ LabelFile start end tier :: Parser [Label] tier = do whiteSpace haskelldef string item [ integer haskelldef string ]: whiteSpace haskelldef try (string class = \IntervalTier\) | string class = \TextTier\ whiteSpace haskelldef string name = char '' name - many quotedChar char '' ? quote at end of cell whiteSpace haskelldef string xmin = try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) whiteSpace haskelldef string xmax = try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string intervals: size = | string points: size = integer haskelldef whiteSpace haskelldef labelList - many1 (interval name) return $ labelList interval :: String - Parser Label interval tierName = do whiteSpace haskelldef string intervals [ integer haskelldef string ]: whiteSpace haskelldef string xmin = start - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) whiteSpace haskelldef string xmax = end - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) whiteSpace haskelldef string text = char '' text - many quotedChar char '' ? quote at end of cell return $ Label tierName IntervalTier start end text which fails on the attached input file. I can't see how 't' is found?? What am I doing wrong? /Fredrik -- Life is like a trumpet - if you don't put anything into it, you don't get anything out of it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Life is like a trumpet - if you don't put anything into it, you don't get anything out of it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC trac
The registration page reappeared. There's also a Reset Password page. But none of them woks correctly. They return the following error: Trac detected an internal error: IOError: [Errno 2] No such file or directory: u'/srv/trac/ghc/trac.htpasswd' On Mon, Jul 8, 2013 at 4:28 AM, Marios Titas redneb8...@gmail.com wrote: I just noticed that the GHC trac was moved to http://ghc.haskell.org/trac/ghc/ and I cannot login with my old credentials. Were the old accounts transferred to the new trac? Also, the registration page [1] does not work. [1] http://ghc.haskell.org/trac/ghc/register ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Understanding version differences
Hi,The code [1] below compiles and runs with GHCi version 7.0.4.I get one warning and an error message with GHCi version 7.6.1.1) Warning -XDatatypeContexts is deprecated. Unless there are propagation effects, this is well explained.2) foom-1.hs:65:15: `quality' is applied to too many type arguments In the type `quality entity - agent - IO Observation' In the class declaration for `OBSERVERS'Failed, modules loaded: none.I do not understand the error message from 7.6.1. I am not too interested actually fixing it, I just want to understand it.Thanks,Pat[1]The code is from: A Functional Ontology of Observation and Measurement Werner Kuhn{-# LANGUAGE DatatypeContexts,MultiParamTypeClasses #-}module ENDURANTS whereimport System.Timetype Id = Stringtype Position = Integertype Moisture = Floattype Celsius = Stringtype Heat = Float data WeatherStation = WeatherStation Id Position deriving Showdata Value = Boolean Bool | Count Int | Measure Float | Category String deriving Showdata Observation = Observation Value Position ClockTime deriving Showdata AmountOfAir = AmountOfAir Heat Moisture deriving ShowmuensterAir = AmountOfAir 10.0 70.0class ENDURANTS endurant where -- must add instances all down the hierarchy for each instanceinstance ENDURANTS WeatherStation whereinstance ENDURANTS AmountOfAir whereclass ENDURANTS physicalEndurant = PHYSICAL_ENDURANTS physicalEndurant whereinstance PHYSICAL_ENDURANTS WeatherStation whereinstance PHYSICAL_ENDURANTS AmountOfAir whereclass PHYSICAL_ENDURANTS amountOfMatter = AMOUNTS_OF_MATTER amountOfMatter whereinstance AMOUNTS_OF_MATTER WeatherStation whereclass PHYSICAL_ENDURANTS physicalObject = PHYSICAL_OBJECTS physicalObject whereinstance PHYSICAL_OBJECTS WeatherStation whereclass PHYSICAL_OBJECTS apo = APOS apo where getPosition :: apo - Positioninstance APOS WeatherStation where getPosition (WeatherStation iD pos) = pos + 10 -- a data type declaration and data type constructor.data PHYSICAL_ENDURANTS physicalEndurant = Temperature physicalEndurant = Temperature physicalEndurant deriving Show-- Qualities the class of all quality types (= properties) is a constructor class-- its constructors can be applied to endurants, perdurants, qualities or abstractsclass QUALITIES quality entity instance QUALITIES Temperature AmountOfAirclass (APOS agent, QUALITIES quality entity) = OBSERVERS agent quality entity where observe :: quality entity - agent - IO Observation express :: quality entity - agent - Value observe quale agent = do clockTime - getClockTime return (Observation (express quale agent) (getPosition agent) clockTime)instance OBSERVERS WeatherStation Temperature AmountOfAir where express (Temperature (AmountOfAir heat moisture)) weatherStation = Measure heat {--- running the followingexpress (Temperature (AmountOfAir 40 20)) (WeatherStation rr 6)-- GivesMeasure 40.0 Measure 40.0-- We can get the type: Value :t express (Temperature (AmountOfAir 40 20)) (WeatherStation rr 6)-} Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a bheith slán. http://www.dit.ie This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Probabilistic functional programming with Baysig/BayesHive
Dear cafe, I would like to announce that the Baysig programming language and the BayesHive analytics environment (http://bayeshive.com) are now available for beta testers. Baysig is a new probabilistic, functional and typed programming language that attempts to realise the vision of fully Bayesian computing. That is, in Baysig almost all the work in data processing consists of building a probabilistic model of the incoming data. Almost everything else -- optimal decisions, categorisation, measuring hidden parameters or states, forecasting, testing hypothesis -- becomes trivial. This paradigm can in principle be applied to a large number of domains, although for the moment we are focusing on models that are based on continuous parameters. It will therefore be of interest to users of statistics and dynamical systems models, including in finance, physics and life sciences. To analyse data in Baysig, you write a program in the random-number supply monad that generates simulated data. A special construct, estimate, then applies Bayes' theorem to this program and returns the probability distribution of the model parameters given observed data. The estimate procedure is difficult to implement in Haskell or similar languages, which encouraged us to develop a new language. However, in many respects Baysig should feel like Haskell, and we hope that Baysig will encourage the Haskell community to experiment with statistical modelling. We have built a web-based environment to help users, including those with little-to-no programming experience, use Baysig, at bayeshive.com. This web application allows you to upload data from spreadsheets or timeseries, and to build statistical models with a point-and-click web interface which ends up generating Baysig code. Code and the results of running it are collected in shareable and editable literate programming documents. We would appreciate any feedback from the Haskell community before releasing our platform to unsuspecting statisticians and researchers. Almost everything is written in Haskell, including the Baysig compiler. The BayesHive website is written using Yesod, with which we are mostly happy. We also use the Stan package (mc-stan.org), and the web front-end is written using AngularJS. For the moment the Baysig language is only available through the BayesHive web interface, but that will change. If you want to run Baysig on your own computer, please send me an email at t...@openbrain.org. Finally, both the BayesHive web application and the Baysig language implementation are still prototypes and very much work-in-progress. We promise to work hard at fixing the bugs you find! Links: BayesHive, including a few videos: http://bayeshive.com Baysig quick tour (QuickBAYSIG): http://bayeshive.com/helppage/Baysig%20quick%20tour:%20fundamentals More documentation: http://bayeshive.com/help Regards, Tom Nielsen OpenBrain Ltd. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Probabilistic functional programming with Baysig/BayesHive
Le 09/07/2013 13:53, Tom Nielsen a écrit : Almost everything else -- optimal decisions, categorisation, (...) -- becomes trivial. Optimal decisions trivial? Interesting... And not so frequent... Jerzy Karczmarczuk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Harder Question - Chapter 4 - 4.12 - haskell the craft of functional programming - Second Edition
Manoel Menezes manoel.menezes...@gmail.com writes: Hi everybody! I am trying to solve the question for a long time: [4.12 Harder] Find out the maximum number of pieces we can get by making a given number of flat (that is planar) cuts through a solid block. It is not the same answer as we calculated for straight-line cuts of a flat piece of paper. I find out that this function has the following results: f 0 = 1 f 1 = 2 f 2 = 4 f 3 = 8 That is, from 0 to 3, the flat cuts all the pieces in two other pieces, so the number of pieces is doubled. But, starting from f 4, the flat can not cuts all the pieces, in case of f 4, the flat can cut 6 out of the 8 pieces, resulting in 12 pieces plus 2 pieces 2 = 14 pieces. It can cut 7, so it is 2*7+1. Forget about block borders and suppose you have n-1 planes and add a new place. It will cut each n-1 planes. Now look at this new plane with intersection lines (n-1 ones) in it. Each region in plane adds one new 3D piece, so F(0) = 1; F(n) = F(n-1) + P(n-1), where P(n) is max number of pieces slicing plane with n cuts. Spoiler: cake numbers -- lelf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ERP/CRM solution with Haskell ?
Hello all, I don't know if it's the good mailing list to post, if not my apologize for that. I am actually looking for an ERP/CRM solution. Is there a solution (like dolibarr or openerp), but in Haskell to do that ? Thank you Loïc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Understanding version differences
The compiler defaults the kind of 'quality' (i.e. the first argument of QUALITIES) to *, not being able to infer it from the class definition itself (and other definitions that it references). Since you want it to have kind * - *, you should enable KindSignatures and add an annotation, or otherwise disambiguate the kind. This behaviour follows the Haskell Report. The change from previous versions of GHC is documented here: http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/release-7-4-1.html#id3015054 Roman * Patrick Browne patrick.bro...@dit.ie [2013-07-09 12:45:19+0100] Hi, The code [1] below compiles and runs with GHCi version 7.0.4. I get one warning and an error message with GHCi version 7.6.1. 1) Warning -XDatatypeContexts is deprecated. Unless there are propagation effects, this is well explained. 2) foom-1.hs:65:15: `quality' is applied to too many type arguments In the type `quality entity - agent - IO Observation' In the class declaration for `OBSERVERS' Failed, modules loaded: none. I do not understand the error message from 7.6.1. I am not too interested actually fixing it, I just want to understand it. Thanks, Pat [1]The code is from: A Functional Ontology of Observation and Measurement Werner Kuhn {-# LANGUAGE DatatypeContexts,MultiParamTypeClasses #-} module ENDURANTS where import System.Time type Id = String type Position = Integer type Moisture = Float type Celsius = String type Heat = Float data WeatherStation = WeatherStation Id Position deriving Show data Value = Boolean Bool | Count Int | Measure Float | Category String deriving Show data Observation = Observation Value Position ClockTime deriving Show data AmountOfAir = AmountOfAir Heat Moisture deriving Show muensterAir = AmountOfAir 10.0 70.0 class ENDURANTS endurant where -- must add instances all down the hierarchy for each instance instance ENDURANTS WeatherStation where instance ENDURANTS AmountOfAir where class ENDURANTS physicalEndurant = PHYSICAL_ENDURANTS physicalEndurant where instance PHYSICAL_ENDURANTS WeatherStation where instance PHYSICAL_ENDURANTS AmountOfAir where class PHYSICAL_ENDURANTS amountOfMatter = AMOUNTS_OF_MATTER amountOfMatter where instance AMOUNTS_OF_MATTER WeatherStation where class PHYSICAL_ENDURANTS physicalObject = PHYSICAL_OBJECTS physicalObject where instance PHYSICAL_OBJECTS WeatherStation where class PHYSICAL_OBJECTS apo = APOS apo where getPosition :: apo - Position instance APOS WeatherStation where getPosition (WeatherStation iD pos) = pos + 10 -- a data type declaration and data type constructor. data PHYSICAL_ENDURANTS physicalEndurant = Temperature physicalEndurant = Temperature physicalEndurant deriving Show -- Qualities the class of all quality types (= properties) is a constructor class -- its constructors can be applied to endurants, perdurants, qualities or abstracts class QUALITIES quality entity instance QUALITIES Temperature AmountOfAir class (APOS agent, QUALITIES quality entity) = OBSERVERS agent quality entity where observe :: quality entity - agent - IO Observation express :: quality entity - agent - Value observe quale agent = do clockTime - getClockTime return (Observation (express quale agent) (getPosition agent) clockTime) instance OBSERVERS WeatherStation Temperature AmountOfAir where express (Temperature (AmountOfAir heat moisture)) weatherStation = Measure heat {- -- running the following express (Temperature (AmountOfAir 40 20)) (WeatherStation rr 6) -- Gives Measure 40.0 Measure 40.0 -- We can get the type: Value :t express (Temperature (AmountOfAir 40 20)) (WeatherStation rr 6) -} Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a bheith slán. [1]http://www.dit.ie This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. [2]http://www.dit.ie References 1. http://www.dit.ie/ 2. http://www.dit.ie/ ___ 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] GHC bug? Let with guards loops
Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 = Just 1 in x works returns 1, loops loops. If x is unused on the rhs, the non-termination disappears. works' = let Just x | x 0 = Just 1 in 42 Is this intended by the Haskell semantics or is this a bug? I would have assumed that non-recursive let and single-branch case are interchangeable, but apparently, not... Cheers, Andreas -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC bug? Let with guards loops
The definition Just x | x 0 = Just 1 is recursive. It conditionally defines Just x as Just 1 when x 0 (and as bottom otherwise). So it must know the result before it can test the guard, but it cannot know the result until the guard is tested. Consider an augmented definition: Just x | x 0 = Just 1 | x = 0 = Just 0 What is x? On Tue, Jul 9, 2013 at 10:42 AM, Andreas Abel andreas.a...@ifi.lmu.dewrote: Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 = Just 1 in x works returns 1, loops loops. If x is unused on the rhs, the non-termination disappears. works' = let Just x | x 0 = Just 1 in 42 Is this intended by the Haskell semantics or is this a bug? I would have assumed that non-recursive let and single-branch case are interchangeable, but apparently, not... Cheers, Andreas -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~**abel/ http://www2.tcs.ifi.lmu.de/~abel/ __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://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] Open Source project suitable for 2-3 persons this fall?
On Thu, Jul 04, 2013 at 05:26:59PM +0200, Anders Bech Mellson wrote: Is there any project that needs working this fall which could be used as a university project? I am in the university (M.Sc. in software development), so I am mainly looking for project ideas (preferably concrete ones). We are 2-3 students that have ~10 hours pr week for 3 months to work on a project. Is there a listing somewhere with project ideas for contributing to the Haskell community? I am a bit late, but there are quite a few things that could be done for the diagrams project [1]. Some project ideas are at [2], and more can be found on the bug tracker [3]. [1] http://projects.haskell.org/diagrams/ [2] http://www.haskell.org/haskellwiki/Diagrams/Projects [3] https://github.com/diagrams/diagrams-lib/issues?state=open -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC bug? Let with guards loops
As Dan said, this behaviour is correct. The confusing thing here is that in case expressions guards are attached to the patterns (i.e. to the lhs), while in let expressions they are attached to the rhs. So, despite the common Just x | x 0 part, your examples mean rather different things. Here's the translation of 'loops' according to the Report: loops = let Just x = case () of () | x 0 - Just 1 in x Here it's obvious that 'x' is used in the rhs of its own definition. Roman * Andreas Abel andreas.a...@ifi.lmu.de [2013-07-09 16:42:00+0200] Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 = Just 1 in x works returns 1, loops loops. If x is unused on the rhs, the non-termination disappears. works' = let Just x | x 0 = Just 1 in 42 Is this intended by the Haskell semantics or is this a bug? I would have assumed that non-recursive let and single-branch case are interchangeable, but apparently, not... Cheers, Andreas -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ 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] Boulder Haskell Programmers, Next Meeting July 17
The Boulder Haskell Programmer Group is getting together on July 17 at 6:30pm. All experience levels are welcome. Agenda: * 6:30--7:00: Social/beer time. * 7:00--7:30: What do we want from this group? * 7:30--8:30: Introduction to Haskell Types. * 8:30--9:00: Whatever! http://www.meetup.com/Boulder-Haskell-Programmers/events/125427022/ -- Peter Jones, Founder, Devalot.com Defending the honor of good code ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC bug? Let with guards loops
Thanks, Dan and Roman, for the explanation. So I have to delete the explanation non-recursive let = single-branch case from my brain. I thought the guards in a let are assertations, but in fact it is more like an if. Ok. But then I do not see why the pattern variables are in scope in the guards in let p | g = e The variables in p are only bound to their values (given by e) if the guard g evaluates to True. But how can g evaluate if it has yet unbound variables? How can ever a pattern variable of p be *needed* to compute the value of the guard? My conjecture is that it cannot, so it does not make sense to consider variables of g bound by p. Maybe you can cook up some counterexample. I think the pattern variables of p should not be in scope in g, and shadowing free variables of g by pattern variables of p should be forbidden. Cheers, Andreas On 09.07.2013 17:05, Dan Doel wrote: The definition Just x | x 0 = Just 1 is recursive. It conditionally defines Just x as Just 1 when x 0 (and as bottom otherwise). So it must know the result before it can test the guard, but it cannot know the result until the guard is tested. Consider an augmented definition: Just x | x 0 = Just 1 | x = 0 = Just 0 What is x? On 09.07.2013 17:49, Roman Cheplyaka wrote: As Dan said, this behaviour is correct. The confusing thing here is that in case expressions guards are attached to the patterns (i.e. to the lhs), while in let expressions they are attached to the rhs. So, despite the common Just x | x 0 part, your examples mean rather different things. Here's the translation of 'loops' according to the Report: loops = let Just x = case () of () | x 0 - Just 1 in x Here it's obvious that 'x' is used in the rhs of its own definition. Roman * Andreas Abel andreas.a...@ifi.lmu.de [2013-07-09 16:42:00+0200] Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 = Just 1 in x works returns 1, loops loops. If x is unused on the rhs, the non-termination disappears. works' = let Just x | x 0 = Just 1 in 42 Is this intended by the Haskell semantics or is this a bug? I would have assumed that non-recursive let and single-branch case are interchangeable, but apparently, not... Cheers, Andreas -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC bug? Let with guards loops
Well, you could use p's type for something. let x | foo (undefined `asTypeOf` x) = 3 foo _ = True in x Arguably not very useful. It seems to me that the most compelling rationale is being consistent with the cases where, instead of being a data type, p is a function. Even so most of the time you won't be recursing on the guard. But, since you could use something from the where clause on the guard, and we certainly won't be restricting recursing on the where clause, it also seems compelling to allow recursion on the guard. My 2 centavos, =) On Tue, Jul 9, 2013 at 2:12 PM, Andreas Abel andreas.a...@ifi.lmu.de wrote: Thanks, Dan and Roman, for the explanation. So I have to delete the explanation non-recursive let = single-branch case from my brain. I thought the guards in a let are assertations, but in fact it is more like an if. Ok. But then I do not see why the pattern variables are in scope in the guards in let p | g = e The variables in p are only bound to their values (given by e) if the guard g evaluates to True. But how can g evaluate if it has yet unbound variables? How can ever a pattern variable of p be *needed* to compute the value of the guard? My conjecture is that it cannot, so it does not make sense to consider variables of g bound by p. Maybe you can cook up some counterexample. I think the pattern variables of p should not be in scope in g, and shadowing free variables of g by pattern variables of p should be forbidden. Cheers, Andreas On 09.07.2013 17:05, Dan Doel wrote: The definition Just x | x 0 = Just 1 is recursive. It conditionally defines Just x as Just 1 when x 0 (and as bottom otherwise). So it must know the result before it can test the guard, but it cannot know the result until the guard is tested. Consider an augmented definition: Just x | x 0 = Just 1 | x = 0 = Just 0 What is x? On 09.07.2013 17:49, Roman Cheplyaka wrote: As Dan said, this behaviour is correct. The confusing thing here is that in case expressions guards are attached to the patterns (i.e. to the lhs), while in let expressions they are attached to the rhs. So, despite the common Just x | x 0 part, your examples mean rather different things. Here's the translation of 'loops' according to the Report: loops = let Just x = case () of () | x 0 - Just 1 in x Here it's obvious that 'x' is used in the rhs of its own definition. Roman * Andreas Abel andreas.a...@ifi.lmu.de [2013-07-09 16:42:00+0200] Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 = Just 1 in x works returns 1, loops loops. If x is unused on the rhs, the non-termination disappears. works' = let Just x | x 0 = Just 1 in 42 Is this intended by the Haskell semantics or is this a bug? I would have assumed that non-recursive let and single-branch case are interchangeable, but apparently, not... Cheers, Andreas -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC bug? Let with guards loops
With pattern guards, it's difficult to say whether it is never 'useful' to have things like the following work: C x | C' y z - f x = ... But I'd also shy away from changing the behavior because it causes a lot of consistency issues. In let f vs1 | gs1 = es1 h vs2 | gs2 = es2 ... we have that f and h are in scope in both gs1 and gs2. Does it make sense to call f in gs1? It's easy to loop if you do. So should f not be in scope in gs1, but h is, and vice versa for gs2? But they're both in scope for es1 and es2? And if we leave the above alone, then what about the case where there are no vs? Is that different? Or is it only left-hand patterns that get this treatment? Also, it might have some weird consequences for moving code around. Like: let Just x | x 0 = Just 1 let Just x | y 0 = Just 1 y = x let Just x | b = Just 1 where b = x 0 let Just x | b = Just 1 b = x 0 These all behave the same way now. Which ones should change? If Haskell had a non-recursive let, that'd probably be a different story. But it doesn't. On Tue, Jul 9, 2013 at 1:12 PM, Andreas Abel andreas.a...@ifi.lmu.dewrote: Thanks, Dan and Roman, for the explanation. So I have to delete the explanation non-recursive let = single-branch case from my brain. I thought the guards in a let are assertations, but in fact it is more like an if. Ok. But then I do not see why the pattern variables are in scope in the guards in let p | g = e The variables in p are only bound to their values (given by e) if the guard g evaluates to True. But how can g evaluate if it has yet unbound variables? How can ever a pattern variable of p be *needed* to compute the value of the guard? My conjecture is that it cannot, so it does not make sense to consider variables of g bound by p. Maybe you can cook up some counterexample. I think the pattern variables of p should not be in scope in g, and shadowing free variables of g by pattern variables of p should be forbidden. Cheers, Andreas On 09.07.2013 17:05, Dan Doel wrote: The definition Just x | x 0 = Just 1 is recursive. It conditionally defines Just x as Just 1 when x 0 (and as bottom otherwise). So it must know the result before it can test the guard, but it cannot know the result until the guard is tested. Consider an augmented definition: Just x | x 0 = Just 1 | x = 0 = Just 0 What is x? On 09.07.2013 17:49, Roman Cheplyaka wrote: As Dan said, this behaviour is correct. The confusing thing here is that in case expressions guards are attached to the patterns (i.e. to the lhs), while in let expressions they are attached to the rhs. So, despite the common Just x | x 0 part, your examples mean rather different things. Here's the translation of 'loops' according to the Report: loops = let Just x = case () of () | x 0 - Just 1 in x Here it's obvious that 'x' is used in the rhs of its own definition. Roman * Andreas Abel andreas.a...@ifi.lmu.de [2013-07-09 16:42:00+0200] Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 = Just 1 in x works returns 1, loops loops. If x is unused on the rhs, the non-termination disappears. works' = let Just x | x 0 = Just 1 in 42 Is this intended by the Haskell semantics or is this a bug? I would have assumed that non-recursive let and single-branch case are interchangeable, but apparently, not... Cheers, Andreas -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~**abel/ http://www2.tcs.ifi.lmu.de/~abel/ __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~**abel/ http://www2.tcs.ifi.lmu.de/~abel/ __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://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] GHC bug? Let with guards loops
Hi Felipe, thanks for the centavos. So you mean that in let p | g = e where bs in ... the bindings bs should be in scope in g (and of course the variables of p are in scope in bs). Mmh, the bindings in bs that do not uses the pattern variables could be useful in g, but the other bindings will still lead to non-termination. Maybe such an analysis is too sophisticated. My lesson is to use case instead of let. Only that the let syntax is nicer and indentation-friendlier than case, so it would be preferable. The greater evil is that Haskell does not have a non-recursive let. This is source of many non-termination bugs, including this one here. let should be non-recursive by default, and for recursion we could have the good old let rec. Cheers, Andreas On 09.07.2013 19:23, Felipe Almeida Lessa wrote: Well, you could use p's type for something. let x | foo (undefined `asTypeOf` x) = 3 foo _ = True in x Arguably not very useful. It seems to me that the most compelling rationale is being consistent with the cases where, instead of being a data type, p is a function. Even so most of the time you won't be recursing on the guard. But, since you could use something from the where clause on the guard, and we certainly won't be restricting recursing on the where clause, it also seems compelling to allow recursion on the guard. My 2 centavos, =) On Tue, Jul 9, 2013 at 2:12 PM, Andreas Abel andreas.a...@ifi.lmu.de wrote: Thanks, Dan and Roman, for the explanation. So I have to delete the explanation non-recursive let = single-branch case from my brain. I thought the guards in a let are assertations, but in fact it is more like an if. Ok. But then I do not see why the pattern variables are in scope in the guards in let p | g = e The variables in p are only bound to their values (given by e) if the guard g evaluates to True. But how can g evaluate if it has yet unbound variables? How can ever a pattern variable of p be *needed* to compute the value of the guard? My conjecture is that it cannot, so it does not make sense to consider variables of g bound by p. Maybe you can cook up some counterexample. I think the pattern variables of p should not be in scope in g, and shadowing free variables of g by pattern variables of p should be forbidden. Cheers, Andreas On 09.07.2013 17:05, Dan Doel wrote: The definition Just x | x 0 = Just 1 is recursive. It conditionally defines Just x as Just 1 when x 0 (and as bottom otherwise). So it must know the result before it can test the guard, but it cannot know the result until the guard is tested. Consider an augmented definition: Just x | x 0 = Just 1 | x = 0 = Just 0 What is x? On 09.07.2013 17:49, Roman Cheplyaka wrote: As Dan said, this behaviour is correct. The confusing thing here is that in case expressions guards are attached to the patterns (i.e. to the lhs), while in let expressions they are attached to the rhs. So, despite the common Just x | x 0 part, your examples mean rather different things. Here's the translation of 'loops' according to the Report: loops = let Just x = case () of () | x 0 - Just 1 in x Here it's obvious that 'x' is used in the rhs of its own definition. Roman * Andreas Abel andreas.a...@ifi.lmu.de [2013-07-09 16:42:00+0200] Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 = Just 1 in x works returns 1, loops loops. If x is unused on the rhs, the non-termination disappears. works' = let Just x | x 0 = Just 1 in 42 Is this intended by the Haskell semantics or is this a bug? I would have assumed that non-recursive let and single-branch case are interchangeable, but apparently, not... -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Understanding version differences
Thanks to Roman and Eric for for their clear explanations.PatOn 09/07/13, Roman Cheplyaka r...@ro-che.info wrote:The compiler defaults the kind of 'quality' (i.e. the first argument ofQUALITIES) to *, not being able to infer it from the class definitionitself (and other definitions that it references).Since you want it to have kind * - *, you should enable KindSignaturesand add an annotation, or otherwise disambiguate the kind.This behaviour follows the Haskell Report. The change from previousversions of GHC is documented here:http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/release-7-4-1.html#id3015054Roman* Patrick Browne patrick.bro...@dit.ie [2013-07-09 12:45:19+0100] Hi, The code [1] below compiles and runs with GHCi version 7.0.4. I get one warning and an error message with GHCi version 7.6.1. 1) Warning -XDatatypeContexts is deprecated. Unless there are propagation effects, this is well explained. 2) foom-1.hs:65:15: `quality' is applied to too many type arguments In the type `quality entity - agent - IO Observation' In the class declaration for `OBSERVERS' Failed, modules loaded: none. I do not understand the error message from 7.6.1. I am not too interested actually fixing it, I just want to understand it. Thanks, Pat [1]The code is from: A Functional Ontology of Observation and Measurement Werner Kuhn {-# LANGUAGE DatatypeContexts,MultiParamTypeClasses #-} module ENDURANTS where import System.Time type Id = String type Position = Integer type Moisture = Float type Celsius = String type Heat = Float data WeatherStation = WeatherStation Id Position deriving Show data Value = Boolean Bool | Count Int | Measure Float | Category String deriving Show data Observation = Observation Value Position ClockTime deriving Show data AmountOfAir = AmountOfAir Heat Moisture deriving Show muensterAir = AmountOfAir 10.0 70.0 class ENDURANTS endurant where -- must add instances all down the hierarchy for each instance instance ENDURANTS WeatherStation where instance ENDURANTS AmountOfAir where class ENDURANTS physicalEndurant = PHYSICAL_ENDURANTS physicalEndurant where instance PHYSICAL_ENDURANTS WeatherStation where instance PHYSICAL_ENDURANTS AmountOfAir where class PHYSICAL_ENDURANTS amountOfMatter = AMOUNTS_OF_MATTER amountOfMatter where instance AMOUNTS_OF_MATTER WeatherStation where class PHYSICAL_ENDURANTS physicalObject = PHYSICAL_OBJECTS physicalObject where instance PHYSICAL_OBJECTS WeatherStation where class PHYSICAL_OBJECTS apo = APOS apo where getPosition :: apo - Position instance APOS WeatherStation where getPosition (WeatherStation iD pos) = pos + 10 -- a data type declaration and data type constructor. data PHYSICAL_ENDURANTS physicalEndurant = Temperature physicalEndurant = Temperature physicalEndurant deriving Show -- Qualities the class of all quality types (= properties) is a constructor class -- its constructors can be applied to endurants, perdurants, qualities or abstracts class QUALITIES quality entity instance QUALITIES Temperature AmountOfAir class (APOS agent, QUALITIES quality entity) = OBSERVERS agent quality entity where observe :: quality entity - agent - IO Observation express :: quality entity - agent - Value observe quale agent = do clockTime - getClockTime return (Observation (express quale agent) (getPosition agent) clockTime) instance OBSERVERS WeatherStation Temperature AmountOfAir where express (Temperature (AmountOfAir heat moisture)) weatherStation = Measure heat {- -- running the following express (Temperature (AmountOfAir 40 20)) (WeatherStation rr 6) -- Gives Measure 40.0 Measure 40.0 -- We can get the type: Value :t express (Temperature (AmountOfAir 40 20)) (WeatherStation rr 6) -} Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a bheith slán. [1]http://www.dit.ie This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. [2]http://www.dit.ie References 1. http://www.dit.ie/ 2. http://www.dit.ie/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a bheith slán. http://www.dit.ie This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie ___
Re: [Haskell-cafe] Optimization flag changing result of code execution
Same here, I used mwc-random to generate random strings. It works in ghci and when compiled with -O0, but with -O1 and -O2 I've been getting exclusively a's and b's. On Sun, 17 Mar 2013 18:48:06 +0500 Azeem -ul-Hasan aze...@live.com wrote: I am using GHC 7.6.1 mwc-random 0.12.0.1 vector 0.9.1 primitive 0.4.1 Azeem On 16.03.2013 13:31, Azeem -ul-Hasan wrote: Nope that isn't the case either. Even if I make use of defaultSeed through create the problem still remains. The problem seems to be in the generation of a vector of (a,a) i.e in the part V.generateM ((round $ p*(fromIntegral $ l*z)) `div` 2) (\i- R.uniformR ((0,0) , (l-1,l-1)) gen) in line 16. Thanks again. I've tried to run you program and I've got approximately same results regardless of optimization level. Which versions of GHC, mwc-random, vector and primitive do you use? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC bug? Let with guards loops
On 09.07.2013 19:56, Dan Doel wrote: With pattern guards, it's difficult to say whether it is never 'useful' to have things like the following work: C x | C' y z - f x = ... But I'd also shy away from changing the behavior because it causes a lot of consistency issues. In let f vs1 | gs1 = es1 h vs2 | gs2 = es2 ... we have that f and h are in scope in both gs1 and gs2. Does it make sense to call f in gs1? It's easy to loop if you do. So should f not be in scope in gs1, but h is, and vice versa for gs2? But they're both in scope for es1 and es2? If f and h are really mutually recursive, then they should not be in scope in gs1 and gs2. If the first thing you do in the body of f is calling f (which happens if f appears in gs1), then you are bound to loop. But of course, if vs are not just variables but patterns, then the first thing you do is matching, so using f in gs1 could be fine. I am getting on muddy grounds here, better retreat. I was thinking only of non-recursive let. In the report http://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-440003.12 it says that let p = e1 in e0= case e1 of ~p - e0 where no variable in p appears free in e1 but this applies only for patterns p without guards, and I would have expected to be true also for patterns with guards. And if we leave the above alone, then what about the case where there are no vs? Is that different? Or is it only left-hand patterns that get this treatment? Yes, it is only about the things defined by the let binding (in this case, f and g). The variables in vs1 are bound by calling f, but by f's body. Also, it might have some weird consequences for moving code around. Like: let Just x | x 0 = Just 1 Non-recursive. let Just x | y 0 = Just 1 y = x Recursive. let Just x | b = Just 1 where b = x 0 Recursive? let Just x | b = Just 1 b = x 0 Recursive. (Like 2.) These all behave the same way now. Which ones should change? Only the first one? Hard to tell. If Haskell had a non-recursive let, that'd probably be a different story. But it doesn't. Definitely agree. On Tue, Jul 9, 2013 at 1:12 PM, Andreas Abel andreas.a...@ifi.lmu.de mailto:andreas.a...@ifi.lmu.de wrote: Thanks, Dan and Roman, for the explanation. So I have to delete the explanation non-recursive let = single-branch case from my brain. I thought the guards in a let are assertations, but in fact it is more like an if. Ok. But then I do not see why the pattern variables are in scope in the guards in let p | g = e The variables in p are only bound to their values (given by e) if the guard g evaluates to True. But how can g evaluate if it has yet unbound variables? How can ever a pattern variable of p be *needed* to compute the value of the guard? My conjecture is that it cannot, so it does not make sense to consider variables of g bound by p. Maybe you can cook up some counterexample. I think the pattern variables of p should not be in scope in g, and shadowing free variables of g by pattern variables of p should be forbidden. Cheers, Andreas On 09.07.2013 17:05, Dan Doel wrote: The definition Just x | x 0 = Just 1 is recursive. It conditionally defines Just x as Just 1 when x 0 (and as bottom otherwise). So it must know the result before it can test the guard, but it cannot know the result until the guard is tested. Consider an augmented definition: Just x | x 0 = Just 1 | x = 0 = Just 0 What is x? On 09.07.2013 17:49, Roman Cheplyaka wrote: As Dan said, this behaviour is correct. The confusing thing here is that in case expressions guards are attached to the patterns (i.e. to the lhs), while in let expressions they are attached to the rhs. So, despite the common Just x | x 0 part, your examples mean rather different things. Here's the translation of 'loops' according to the Report: loops = let Just x = case () of () | x 0 - Just 1 in x Here it's obvious that 'x' is used in the rhs of its own definition. Roman * Andreas Abel andreas.a...@ifi.lmu.de mailto:andreas.a...@ifi.lmu.de [2013-07-09 16:42:00+0200] Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 =
Re: [Haskell-cafe] Possible extension to Haskell overloading behavior
On 08.07.2013 23:54, Chris Smith wrote: So I've been thinking about something, and I'm curious whether anyone (in particular, people involved with GHC) think this is a worthwhile idea. I'd like to implement an extension to GHC to offer a different behavior for literals with polymorphic types. The current behavior is something like: Probably RebidableSyntax[1] could work for you. From description it allows to change meaning of literals. [1] http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/syntax-extns.html#rebindable-syntax ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
On 09.07.2013 22:10, kudah wrote: Same here, I used mwc-random to generate random strings. It works in ghci and when compiled with -O0, but with -O1 and -O2 I've been getting exclusively a's and b's. It looks like MWC generates only 0 and 1 for some reason. I've tried to write simple test but everything works fine. Could you post test case and compiler/libraries/OS versions you use? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsec error message not making any sense
Hi, Sorry, that was a careless extraction of code - I should have made sure that it was complete. Please, have a look again. When downloading and running the gist ( https://gist.github.com/dargosch/5955045) , I still get the error: Main let testFile = /Users/frkkan96/Documents/src/ume/umecore/testing/testdata/testdata.TextGrid *Main parseFromFile textgridfile testFile Left /Users/frkkan96/Documents/src/ume/umecore/testing/testdata/testdata.TextGrid (line 35, column 5): unexpected t expecting intervals [ on the attached testfile. The tier parser works once, but then I get an error that I cant understand, given the input. How come the parser finds the unexpected t when the expected thing is what is in the input at that point? Thankful for any help I can get on this. On Tue, Jul 9, 2013 at 10:22 PM, Fredrik Karlsson dargo...@gmail.comwrote: Hi, Sorry, that was a careless extraction of code - I should have made sure that it was complete. Please, have a look again. When downloading and running the gist, I still get the error: Main let testFile = /Users/frkkan96/Documents/src/ume/umecore/testing/testdata/testdata.TextGrid *Main parseFromFile textgridfile testFile Left /Users/frkkan96/Documents/src/ume/umecore/testing/testdata/testdata.TextGrid (line 35, column 5): unexpected t expecting intervals [ on the attached testfile. The tier parser works once, but then I get an error that I cant understand, given the input. How come the parser finds the unexpected t when the expected thing is what is in the input at that point? Thankful for any help I can get on this. /Fredrik On Tue, Jul 9, 2013 at 9:37 AM, Roman Cheplyaka r...@ro-che.info wrote: Please check your code. I had two problems with it: mixed tabs and spaces, and undefined 'quotedChar'. After defining quotedChar = anyChar, I get a different error message from yours: *Main parseFromFile textgridfile testdata.TextGrid Left testdata.TextGrid (line 137, column 1): unexpected end of input expecting quote at end of cell Roman * Fredrik Karlsson dargo...@gmail.com [2013-07-09 08:07:24+0200] Hi Roman, I'm using parsec-3.1.3 I put the code in a gist here - sorry about that. https://gist.github.com/dargosch/5955045 Fredrik On Tue, Jul 9, 2013 at 12:08 AM, Roman Cheplyaka r...@ro-che.info wrote: Hi Fredrik, First, do you use the latest parsec version (3.1.3)? If not, can you try the same with 3.1.3? Second, please upload your code to hpaste.org or a similar service and give us the link. It's not much fun to extract code from an html email. Roman * Fredrik Karlsson dargo...@gmail.com [2013-07-08 23:54:17+0200] Dear list, I have a Parsec parser that fails and gives the following error message: *Main parseFromFile textgridfile testFile Left /Users/frkkan96/Documents/src/ume/umecore/testing/testdata/testdata.TextGrid (line 35, column 5): unexpected t expecting intervals [ Now, this is perfectly understandable, but line 35, col 5 in the file being parsed looks like the supplies image - there is no 't' there. Any ideas on what is going on? The parser I am using is: data VariableLine = VariableLine String String deriving Show data TierType = IntervalTier | PointTier deriving Show data Tier = Tier String deriving Show data LabelFile = LabelFile Double Double deriving Show data Label = Label String TierType Double Double String deriving Show haskelldef = makeTokenParser haskellDef textgridfile :: Parser (LabelFile, [[Label]]) textgridfile = do h - header ll - many1 tier return $ (h,ll) header :: Parser LabelFile header = do string headTS1 start - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string xmax = end - try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string tiers? exists \n string size = integer haskelldef string item []: whiteSpace haskelldef return $ LabelFile start end tier :: Parser [Label] tier = do whiteSpace haskelldef string item [ integer haskelldef string ]: whiteSpace haskelldef try (string class = \IntervalTier\) | string class = \TextTier\ whiteSpace haskelldef string name = char '' name - many quotedChar char '' ? quote at end of cell whiteSpace haskelldef string xmin = try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) whiteSpace haskelldef string xmax = try (float haskelldef) | (fmap fromInteger $ integer haskelldef ) string intervals: size = | string points: size = integer haskelldef whiteSpace haskelldef labelList - many1 (interval name) return $ labelList interval :: String - Parser Label interval tierName = do whiteSpace haskelldef string
Re: [Haskell-cafe] Possible extension to Haskell overloading behavior
Oh, yes. That looks great! Also seems to work with OverloadedStrings in the natural way in GHC 7.6, although that isn't documented. Now if only it didn't force NoImplicitPrelude, since I really want to -hide-package base and -package my-other-prelude. Even adding -XImplicitPrelude doesn't help. On Tue, Jul 9, 2013 at 11:46 AM, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 08.07.2013 23:54, Chris Smith wrote: So I've been thinking about something, and I'm curious whether anyone (in particular, people involved with GHC) think this is a worthwhile idea. I'd like to implement an extension to GHC to offer a different behavior for literals with polymorphic types. The current behavior is something like: Probably RebidableSyntax[1] could work for you. From description it allows to change meaning of literals. [1] http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/syntax-extns.html#rebindable-syntax ___ 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] Possible extension to Haskell overloading behavior
Oh, never mind. In this case, I guess I don't need an extension at all! On Tue, Jul 9, 2013 at 1:47 PM, Chris Smith cdsm...@gmail.com wrote: Oh, yes. That looks great! Also seems to work with OverloadedStrings in the natural way in GHC 7.6, although that isn't documented. Now if only it didn't force NoImplicitPrelude, since I really want to -hide-package base and -package my-other-prelude. Even adding -XImplicitPrelude doesn't help. On Tue, Jul 9, 2013 at 11:46 AM, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 08.07.2013 23:54, Chris Smith wrote: So I've been thinking about something, and I'm curious whether anyone (in particular, people involved with GHC) think this is a worthwhile idea. I'd like to implement an extension to GHC to offer a different behavior for literals with polymorphic types. The current behavior is something like: Probably RebidableSyntax[1] could work for you. From description it allows to change meaning of literals. [1] http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/syntax-extns.html#rebindable-syntax ___ 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] Possible extension to Haskell overloading behavior
Ugh... I take back the never mind. So if I replace Prelude with an alternate definition, but don't use RebindableSyntax, and then hide the base package, GHC still uses fromInteger and such from base even though it should be inaccessible. But if I do use RebindableSyntax, then the end-user has to add 'import Prelude' to the top of their code. Am I missing something? On Tue, Jul 9, 2013 at 1:51 PM, Chris Smith cdsm...@gmail.com wrote: Oh, never mind. In this case, I guess I don't need an extension at all! On Tue, Jul 9, 2013 at 1:47 PM, Chris Smith cdsm...@gmail.com wrote: Oh, yes. That looks great! Also seems to work with OverloadedStrings in the natural way in GHC 7.6, although that isn't documented. Now if only it didn't force NoImplicitPrelude, since I really want to -hide-package base and -package my-other-prelude. Even adding -XImplicitPrelude doesn't help. On Tue, Jul 9, 2013 at 11:46 AM, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 08.07.2013 23:54, Chris Smith wrote: So I've been thinking about something, and I'm curious whether anyone (in particular, people involved with GHC) think this is a worthwhile idea. I'd like to implement an extension to GHC to offer a different behavior for literals with polymorphic types. The current behavior is something like: Probably RebidableSyntax[1] could work for you. From description it allows to change meaning of literals. [1] http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/syntax-extns.html#rebindable-syntax ___ 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] Is the following implemented by a sparse matrix representation? type Graph n w = Array (n, n) (Maybe w)
type Graph n w = Array (n,n) (Maybe w) -- -- Regards, KC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
I've attached the script that I had trouble with. It tries to replicate one directory structure in another directory, while replacing filenames and file contents with random data. When compiled with -O1 or -O2 resulting file and directory names are composed only of a's and b's, but file contents seem properly randomized. ghc-7.6.2, vector-0.10.0.1, primitive-0.5.0.1, mwc-random-0.12.0.1, Gentoo Linux i686 3.8.2-pf. On Tue, 09 Jul 2013 22:43:36 +0400 Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 09.07.2013 22:10, kudah wrote: Same here, I used mwc-random to generate random strings. It works in ghci and when compiled with -O0, but with -O1 and -O2 I've been getting exclusively a's and b's. It looks like MWC generates only 0 and 1 for some reason. I've tried to write simple test but everything works fine. Could you post test case and compiler/libraries/OS versions you use? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-imports #-} module Main where import Shelly import Filesystem.Path.CurrentOS (splitDirectories, encodeString, decodeString) import qualified Filesystem as F import qualified Data.Text as T import qualified Data.ByteString as B import Control.Monad.IO.Class import System.Random.MWC import Control.Monad.Primitive import Control.Monad import Control.Applicative import Prelude hiding (FilePath) import Data.String import System.Environment rands :: (PrimMonad m, Variate a) = Gen (PrimState m) - Int - m [a] rands gen i = replicateM i (uniform gen) randRs :: (PrimMonad m, Variate a) = Gen (PrimState m) - Int - (a, a) - m [a] randRs gen i z = replicateM i (uniformR z gen) lastElemLength :: FilePath - Int lastElemLength fd = case splitDirectories fd of [] - error $ Empty filepath ++ show fd g - T.length $ toTextIgnore $ last g randName :: Gen (PrimState IO) - Int - IO FilePath randName gen l = decodeString . map toEnum $ randRs gen l (fromEnum 'a', fromEnum 'z') main :: IO () main = do g - getArgs case g of [inDir, outDir] - withSystemRandom . asGenIO $ \gen - do shellyNoDir $ do escaping False $ do -- verbosely $ do out - absPath (decodeString outDir) in' - absPath (decodeString inDir) descent gen out in' _ - putStrLn Specify input directory and output directory descent :: Gen (PrimState IO) - FilePath - FilePath - Sh () descent gen outDir fd = do isDir - test_d fd if isDir then do n - liftIO $ randName gen $ lastElemLength fd let newDir = outDir / n mkdir_p newDir chdir fd $ do filesOrDirs - ls . mapM_ (descent gen newDir) filesOrDirs else do file - absPath fd liftIO $ do size - F.getSize file newFname - randName gen $ lastElemLength file bs - B.pack $ rands gen (fromInteger size) B.writeFile (encodeString $ outDir / newFname) bs ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Possible extension to Haskell overloading behavior
On 10.07.2013 01:13, Chris Smith wrote: Ugh... I take back the never mind. So if I replace Prelude with an alternate definition, but don't use RebindableSyntax, and then hide the base package, GHC still uses fromInteger and such from base even though it should be inaccessible. But if I do use RebindableSyntax, then the end-user has to add 'import Prelude' to the top of their code. Am I missing something? If base is hidden GHCi refuses to start becaus it can't import Prelude (with -XNoImplicitPrelude it starts just fine). According to documentation GHC will use whatever fromInteger is in scope. But I never used extension in such way. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
On 10.07.2013 01:38, kudah wrote: I've attached the script that I had trouble with. It tries to replicate one directory structure in another directory, while replacing filenames and file contents with random data. When compiled with -O1 or -O2 resulting file and directory names are composed only of a's and b's, but file contents seem properly randomized. No luck. On my computer script works correctly with and without optimizations. My best guess that uniformR is problematic. Does (\g - randName g 20) = create show different behavior with and without optimizations? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: MFlow 3.0
The third version of MFlow is out. http://hackage.haskell.org/package/MFlow MFlow is an all-heterodox web application framework, but very haskellish. Now MFlow support restful URLs. It is the first stateful web framework to my knowledge that supports it. The type safe routes are implicitly expressed as normal monadic code within a navigation monad. The application look as a normal imperative console application, but the navigation monad goes back and forth to match the path of the URL. The user has control of the state, that can roll-back or not when the navigation goes back depending on the application needs. The state is in the form of normal Haskell variables In a monadic computation, with the weird addition of backtracking. The menu of the application below is implemented as an imperative-like syntax, but the application navigate forward and backward to synchronize with the requests of the web browser: http://mflowdemo.herokuapp.com/ This version support in-page flows. What is that? look at this example: http://mflowdemo.herokuapp.com/noscript/fviewmonad These flows are implemented as formlets with a monad instance, and callbacks which change the look. I call them widgets: http://haskell-web.blogspot.com.es/2013/06/the-promising-land-of-monadic-formlets.html Each page may have many of these active widgets, each one running their own flow. These widgets refresh themselves trough Ajax if they are enclosed in the primitive autoRefresh. If there is no Ajax or JavaScript available, they gracefully degrade by refreshing the entire page: http://mflowdemo.herokuapp.com/noscript/combination http://haskell-web.blogspot.com.es/2013/06/and-finally-widget-auto-refreshing.html The page flows and the multiflow idea was inspired in Seasidehttp://www.seaside.st/, a great Smalltalk web framework and adapted to the pure recursive nature of Haskell and the formlets. It also support some JQuery widgets integrated: modal and not modal dialogs, datePicker and other active widgets that handle other widgets. It also support the older features: persistent state, WAI, blaze-html and others integration, server process timeouts, Ajax, requirements, content management, caching of widget rendering and all the other previous stuff. I wish to thank some people for their feedback. Specially Adrian May for his feedback and interest -- Alberto. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Possible extension to Haskell overloading behavior
This is working now. Trying to use -XRebindableSyntax with -XImplicitPrelude seems to not work (Prelude is still not loaded) when the exposed Prelude is from base, but it works fine when the Prelude is from a different package. Counterintuitive, but it does everything I need it to. Thanks for the suggestion! On Jul 9, 2013 4:20 PM, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 10.07.2013 01:13, Chris Smith wrote: Ugh... I take back the never mind. So if I replace Prelude with an alternate definition, but don't use RebindableSyntax, and then hide the base package, GHC still uses fromInteger and such from base even though it should be inaccessible. But if I do use RebindableSyntax, then the end-user has to add 'import Prelude' to the top of their code. Am I missing something? If base is hidden GHCi refuses to start becaus it can't import Prelude (with -XNoImplicitPrelude it starts just fine). According to documentation GHC will use whatever fromInteger is in scope. But I never used extension in such way. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe