Re: [Haskell-cafe] What is the difference between runhaskell and compile?
Sorry for the wrong information. I made a mistake when did the test. After more testing, I think it is a bug of ghc 7.4.1. Until now, I cannot find a way to make ghc 7.4.1 compiled binary work. On Mon, May 28, 2012 at 11:01 AM, Magicloud Magiclouds wrote: > Alright, with another box of different version of ghc and things. I > finally got the cause. > Or may I say as simple as Ozgun said, ghc 7.4.1 defaultly uses > optimization. ghc-7.4.1 -O0 works. ghc-7.2.2 also works. > > Thank you all. > > On Sun, May 27, 2012 at 7:07 PM, Chris Dornan wrote: >> By configuration of the OpenLDAP client library I mean mostly so that SSL >> connections will work, but this is all system-level configuration. >> >> That GHC establishes connections in interactive mode for you indicates that >> the problem is not with the LDAP systems, but that something peculiar is >> going wrong with your GHC installation. >> >> Do you have only the one GHC installation on the system; is there any chance >> that ghc and ghci could be selecting different installations? >> >> Is it easy for you to try connecting with GHC-7.0.4? It would be worth a try >> if you can -- it might be a 7.4.1 oddity but it looks as if it could be some >> kind of GHC mis-installation. >> >> (If trying this with GHC-7.0.4 would be bothersome I would be interested to >> hear more; which O/S are you using?) >> >> Chris >> >> -Original Message- >> From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com] >> Sent: 27 May 2012 10:12 >> To: Chris Dornan >> Cc: Brandon Allbery; Haskell-Cafe >> Subject: Re: [Haskell-cafe] What is the difference between runhaskell and >> compile? >> >> Hi, >> Sorry for the delayed reply. I am using ghc 7.4.1 and LDAP 0.6.6. >> When you said "configuration of the OpenLDAP client library", may I have >> more information? Since ldap-utils and other client (php, perl, >> etc) do not have any problem. This might be the only clue to me. >> >> On Fri, May 25, 2012 at 4:43 PM, Chris Dornan wrote: >>> I have been using LDAP with GHC without a problem – I get this error >>> often but the problems have been with the configuration of the >>> OpenLDAP client library or the OpenLDAP server. >>> >>> >>> >>> We are all taking about LDAP-0.6.6? Which version of GHC are we >>> talking about? (I don’t think I have tested this on GHC-7.4.1, and >>> maybe the others haven’t either.) >>> >>> >>> >>> Chris >>> >>> >>> >>> >>> >>> From: haskell-cafe-boun...@haskell.org >>> [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Brandon Allbery >>> Sent: 25 May 2012 04:21 >>> To: Magicloud Magiclouds >>> Cc: Haskell-Cafe >>> Subject: Re: [Haskell-cafe] What is the difference between runhaskell >>> and compile? >>> >>> >>> >>> On Thu, May 24, 2012 at 11:05 PM, Magicloud Magiclouds >>> wrote: >>> >>> Hi there, >>> The code could not be simpler. Just ldapInit, ldapSimpleBind. >>> I just found that the code works with ghci, too. So to sum up, >>> ghci/runhaskell works, ghc not. >>> >>> >>> >>> A possibility that occurs to me: does it by any chance work with ghc >>> -threaded? Perhaps the issue relates to the different behavior of the >>> threaded runtime (which is used automatically by ghci/runghc). >>> >>> >>> >>> -- >>> brandon s allbery >>> allber...@gmail.com wandering unix systems administrator (available) >>> (412) 475-9364 vm/sms >> >> >> >> -- >> 竹密岂妨流水过 >> 山高哪阻野云飞 >> >> And for G+, please use magiclouds#gmail.com. >> > > > > -- > 竹密岂妨流水过 > 山高哪阻野云飞 > > And for G+, please use magiclouds#gmail.com. -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building pattern and trying monads
* L Corbijn [2012-05-27 14:21:39+0200] > The solution I've in mind depends on the stack being pure. When the > monad stack is pure a rule can be applied, returning a maybe value (or > having a MaybeT wrapper) and when returning Nothing (failed rule) > reverting the stack to it's point before applying the rule. > > As I'm not quite sure about the design (nor good at software design) > I've some questions about this approach. > 1. Is there a better approach then using a state monad for building > the 'products'? If you need to interleave building your "products" and analyzing them, State seems a reasonable choice here. > 2. My solution with saving/reverting monad-stacks seems quite a > hassle/hack, so is it a good approach or is there something better? You can use a backtracking monad here ([] or Logic). The key thing is to put the backtracking monad in the bottom of your stack (everything above it will be restored on mzero). On the other hand, if you want some "global" effects that should not be restored, you can put corresponding monads below LogicT in the stack. Example: > observe $ flip runStateT 10 $ (put 0 >> mzero) <|> modify (+3) ((),13) Note that "put 0" had no effect here, because it was followed by mzero. -- Roman I. Cheplyaka :: http://ro-che.info/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A functional programming solution for Mr and Mrs Hollingberry
On Sun, May 27, 2012 at 7:07 PM, Richard O'Keefe wrote: > > On 26/05/2012, at 4:16 AM, David Turner wrote: > > > > I don't. I think the trouble is that classes don't add value in > exercises of this size. > > This was the key point, I think. > In this example, there wasn't any significant behaviour that could be moved > to superclasses. For that matter, whether a supplier is plain, preferred, > or problematic is, one hopes, not a *permanent* property of a supplier. > > Sometimes higher-order functions can substitute for classes. Functors can always substitute for OO classes. A class system is a functor from the set of objects to a set of methods, mediated by inheritance, or things like message-passing, duck typing, prototyping, etc. Functions with the type Foo -> Foo can be easily used to implement a prototype based dispatch mechanism. Indeed, this is a common Haskell pattern. Define: -- Library code: defaultFoo :: Foo defaultFoo = Foo { bar = ..., baz = ... } -- Client code myFoo = defaultFoo { bar = myBar } Things can get as complicated as you would like, up to and including inheritance, by using functors other than ((->) a) The defining characteristic of OO is that objects are stateful, but self-contained entities. How methods are defined and dispatched vary wildly across OO languages. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is the difference between runhaskell and compile?
Alright, with another box of different version of ghc and things. I finally got the cause. Or may I say as simple as Ozgun said, ghc 7.4.1 defaultly uses optimization. ghc-7.4.1 -O0 works. ghc-7.2.2 also works. Thank you all. On Sun, May 27, 2012 at 7:07 PM, Chris Dornan wrote: > By configuration of the OpenLDAP client library I mean mostly so that SSL > connections will work, but this is all system-level configuration. > > That GHC establishes connections in interactive mode for you indicates that > the problem is not with the LDAP systems, but that something peculiar is > going wrong with your GHC installation. > > Do you have only the one GHC installation on the system; is there any chance > that ghc and ghci could be selecting different installations? > > Is it easy for you to try connecting with GHC-7.0.4? It would be worth a try > if you can -- it might be a 7.4.1 oddity but it looks as if it could be some > kind of GHC mis-installation. > > (If trying this with GHC-7.0.4 would be bothersome I would be interested to > hear more; which O/S are you using?) > > Chris > > -Original Message- > From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com] > Sent: 27 May 2012 10:12 > To: Chris Dornan > Cc: Brandon Allbery; Haskell-Cafe > Subject: Re: [Haskell-cafe] What is the difference between runhaskell and > compile? > > Hi, > Sorry for the delayed reply. I am using ghc 7.4.1 and LDAP 0.6.6. > When you said "configuration of the OpenLDAP client library", may I have > more information? Since ldap-utils and other client (php, perl, > etc) do not have any problem. This might be the only clue to me. > > On Fri, May 25, 2012 at 4:43 PM, Chris Dornan wrote: >> I have been using LDAP with GHC without a problem – I get this error >> often but the problems have been with the configuration of the >> OpenLDAP client library or the OpenLDAP server. >> >> >> >> We are all taking about LDAP-0.6.6? Which version of GHC are we >> talking about? (I don’t think I have tested this on GHC-7.4.1, and >> maybe the others haven’t either.) >> >> >> >> Chris >> >> >> >> >> >> From: haskell-cafe-boun...@haskell.org >> [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Brandon Allbery >> Sent: 25 May 2012 04:21 >> To: Magicloud Magiclouds >> Cc: Haskell-Cafe >> Subject: Re: [Haskell-cafe] What is the difference between runhaskell >> and compile? >> >> >> >> On Thu, May 24, 2012 at 11:05 PM, Magicloud Magiclouds >> wrote: >> >> Hi there, >> The code could not be simpler. Just ldapInit, ldapSimpleBind. >> I just found that the code works with ghci, too. So to sum up, >> ghci/runhaskell works, ghc not. >> >> >> >> A possibility that occurs to me: does it by any chance work with ghc >> -threaded? Perhaps the issue relates to the different behavior of the >> threaded runtime (which is used automatically by ghci/runghc). >> >> >> >> -- >> brandon s allbery >> allber...@gmail.com wandering unix systems administrator (available) >> (412) 475-9364 vm/sms > > > > -- > 竹密岂妨流水过 > 山高哪阻野云飞 > > And for G+, please use magiclouds#gmail.com. > -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A functional programming solution for Mr and Mrs Hollingberry
On 26/05/2012, at 4:16 AM, David Turner wrote: > > I don't. I think the trouble is that classes don't add value in exercises of > this size. This was the key point, I think. In this example, there wasn't any significant behaviour that could be moved to superclasses. For that matter, whether a supplier is plain, preferred, or problematic is, one hopes, not a *permanent* property of a supplier. Sometimes higher-order functions can substitute for classes. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building pattern and trying monads
On 5/27/12 8:21 AM, L Corbijn wrote: > 2. My solution with saving/reverting monad-stacks seems quite a > hassle/hack, so is it a good approach or is there something better? One good solution for backtracking is to use logict[1]. I've used it with various state-like monads and it works well (e.g., the IntBindingT monad in unification-fd[2]). [1] http://hackage.haskell.org/package/logict http://okmij.org/ftp/papers/LogicT.pdf [2] http://hackage.haskell.org/package/unification-fd http://hackage.haskell.org/packages/archive/unification-fd/0.7.0/doc/html/Control-Unification-IntVar.html -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Finding the average in constant space
Hi Chris, On 05/27/2012 10:04 AM, Chris Wong wrote: I just came up with a way of executing multiple folds in a single pass. In short, we can write code like this: average = foldLeft $ (/)<$> sumF<*> lengthF and it will only traverse the input list once. The code is at: https://gist.github.com/2802644 My question is: has anyone done this already? If not, I might release this on Hackage -- it seems quite useful. This is (a special case of) the main point in the design of iteratees. See e.g. the definition of the 'Iteratee' type in the enumeratee library. - Looks pretty much like your 'Fold' type with an additional state (done or not yet done). Also, the pipe package seems to provide something similar. -- Steffen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building pattern and trying monads
It's common to use a writer monad possibly stacked with other monads (e.g. a state monad for fresh variable names) for code generation that approximates "macro expansion" - i.e. one call in Haskell maps to one-or-more lines of code in the output language, no global transformations are permitted. If you want transformations, then it is likely you will need to model the syntax of the output language or an intermediate language to have something concrete to transform. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is the difference between runhaskell and compile?
Maybe try with "ghc --make -O0". Afaik, ghci and runhaskell don't do any optimization, which could be the difference. On May 27, 2012, at 5:12 PM, Magicloud Magiclouds wrote: > Hi, > Sorry for the delayed reply. I am using ghc 7.4.1 and LDAP 0.6.6. > When you said "configuration of the OpenLDAP client library", may I > have more information? Since ldap-utils and other client (php, perl, > etc) do not have any problem. This might be the only clue to me. > > On Fri, May 25, 2012 at 4:43 PM, Chris Dornan wrote: >> I have been using LDAP with GHC without a problem – I get this error often >> but the problems have been with the configuration of the OpenLDAP client >> library or the OpenLDAP server. >> >> >> >> We are all taking about LDAP-0.6.6? Which version of GHC are we talking >> about? (I don’t think I have tested this on GHC-7.4.1, and maybe the others >> haven’t either.) >> >> >> >> Chris >> >> >> >> >> >> From: haskell-cafe-boun...@haskell.org >> [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Brandon Allbery >> Sent: 25 May 2012 04:21 >> To: Magicloud Magiclouds >> Cc: Haskell-Cafe >> Subject: Re: [Haskell-cafe] What is the difference between runhaskell and >> compile? >> >> >> >> On Thu, May 24, 2012 at 11:05 PM, Magicloud Magiclouds >> wrote: >> >> Hi there, >> The code could not be simpler. Just ldapInit, ldapSimpleBind. >> I just found that the code works with ghci, too. So to sum up, >> ghci/runhaskell works, ghc not. >> >> >> >> A possibility that occurs to me: does it by any chance work with ghc >> -threaded? Perhaps the issue relates to the different behavior of the >> threaded runtime (which is used automatically by ghci/runghc). >> >> >> >> -- >> brandon s allbery allber...@gmail.com >> wandering unix systems administrator (available) (412) 475-9364 vm/sms > > > > -- > 竹密岂妨流水过 > 山高哪阻野云飞 > > And for G+, please use magiclouds#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
[Haskell-cafe] Building pattern and trying monads
Hello cafe, I'm working on a project where the main goal of the program is building some complex output (e.g. a Haskell function, module, etc.). In this process there is almost always some partially finished product on which to work. Currently I'm modelling this with a wrapper around StateT containing the partial product but I'm having some doubts about this approach. On one of the projects there is some rule-based transformation which needs to be done. The problem is with the matching and applying the rules. The matches need to retrieve information from the monads in the stack, and the application of a rule changes values in the stack. However when a match fails the stack should be left *untouched* and another rule should be tried. The solution I've in mind depends on the stack being pure. When the monad stack is pure a rule can be applied, returning a maybe value (or having a MaybeT wrapper) and when returning Nothing (failed rule) reverting the stack to it's point before applying the rule. As I'm not quite sure about the design (nor good at software design) I've some questions about this approach. 1. Is there a better approach then using a state monad for building the 'products'? 2. My solution with saving/reverting monad-stacks seems quite a hassle/hack, so is it a good approach or is there something better? Thanks in advance, Lars ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Finding the average in constant space
There are a few blog posts by Conal Elliott and Max Rabkin (I think) reifying folds as a data type to get more "composition" and thus fold different functions at the same time. Search for "beautiful folding" with the above authors names. Personally I didn't find the examples significantly more "beautiful" that using regular composition in a normal fold - only that that the helper functions to manage pairs aren't in the standard library. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is the difference between runhaskell and compile?
By configuration of the OpenLDAP client library I mean mostly so that SSL connections will work, but this is all system-level configuration. That GHC establishes connections in interactive mode for you indicates that the problem is not with the LDAP systems, but that something peculiar is going wrong with your GHC installation. Do you have only the one GHC installation on the system; is there any chance that ghc and ghci could be selecting different installations? Is it easy for you to try connecting with GHC-7.0.4? It would be worth a try if you can -- it might be a 7.4.1 oddity but it looks as if it could be some kind of GHC mis-installation. (If trying this with GHC-7.0.4 would be bothersome I would be interested to hear more; which O/S are you using?) Chris -Original Message- From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com] Sent: 27 May 2012 10:12 To: Chris Dornan Cc: Brandon Allbery; Haskell-Cafe Subject: Re: [Haskell-cafe] What is the difference between runhaskell and compile? Hi, Sorry for the delayed reply. I am using ghc 7.4.1 and LDAP 0.6.6. When you said "configuration of the OpenLDAP client library", may I have more information? Since ldap-utils and other client (php, perl, etc) do not have any problem. This might be the only clue to me. On Fri, May 25, 2012 at 4:43 PM, Chris Dornan wrote: > I have been using LDAP with GHC without a problem – I get this error > often but the problems have been with the configuration of the > OpenLDAP client library or the OpenLDAP server. > > > > We are all taking about LDAP-0.6.6? Which version of GHC are we > talking about? (I don’t think I have tested this on GHC-7.4.1, and > maybe the others haven’t either.) > > > > Chris > > > > > > From: haskell-cafe-boun...@haskell.org > [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Brandon Allbery > Sent: 25 May 2012 04:21 > To: Magicloud Magiclouds > Cc: Haskell-Cafe > Subject: Re: [Haskell-cafe] What is the difference between runhaskell > and compile? > > > > On Thu, May 24, 2012 at 11:05 PM, Magicloud Magiclouds > wrote: > > Hi there, > The code could not be simpler. Just ldapInit, ldapSimpleBind. > I just found that the code works with ghci, too. So to sum up, > ghci/runhaskell works, ghc not. > > > > A possibility that occurs to me: does it by any chance work with ghc > -threaded? Perhaps the issue relates to the different behavior of the > threaded runtime (which is used automatically by ghci/runghc). > > > > -- > brandon s allbery > allber...@gmail.com wandering unix systems administrator (available) > (412) 475-9364 vm/sms -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Record syntax, reopening a can of worms.
I enclosed a source file that shows the use of a GADT in that case. 2012/5/27 > Somehow I don't understand you. > Could you please fill out your example into a working bit of code? > > Thank you, > > Timothy > > > -- Původní zpráva -- > Od: Yves Parès > > Datum: 27. 5. 2012 > Předmět: Re: [Haskell-cafe] Record syntax, reopening a can of worms. > > > case myData of > > myA@A{} -> fooForA's myA > > myB@B{} -> fooForB's myB > > I think this would typecheck if you used GADTs. > Actually what you'd want is to use the record syntax with GADTs (there are > to add the extra type safety you want), however both are not compatible. > > data ALike > data BLike > > data MyData x where > A :: Int -> Int -> MyData ALike > B :: Int -> MyData BLike > > a (A x _) = x > b (A _ x) = x > c (B x) = x > -- GHC may require you to write the type signatures for those three > functions. > Le 27 mai 2012 10:52, a écrit : > > Your Maybe example is very contrived. The place where I ran into this was > much less contrived I think. > > I have an editor for a visual programming language. That looks like this: > > https://github.com/timthelion/gridhaskell-haskarrow/wiki > > I'm using a modified version of the Document-View model for application > design. The commands in the language are defined in the Cell data type: > > > https://github.com/timthelion/gridhaskell-haskarrow/blob/master/Cell.lhs > > > Some Cell types, like Jump, have a long crooked line comming out of them > called a Path. This line is held in the path :: Maybe Path feild. > > > When I'm drawing the Cell tree, I have a function that extracts these > Paths. > https://github.com/timthelion/gridhaskell-haskarrow/blob/master/ArrowDrawing.lhs#L75 > > > It used to be, that more types of Cell than just the Jump Cell had a path. > > > As I removed these Paths from the Cell datatype, my line drawing function > started crashing, whenever it encountered those Cell types. By having > chosen to use the short hand record selector syntax rather than the long > hand place value syntax, I caused a runtime error in my code. > > > I could of course have written the same function like this: > > > where path_points = > > > > case > > case cell of > > > > Types of cells which have paths: > > > Cell.Jump _ path-> Just path > > > > _ -> Nothing of > > Just path -> maybe [] (\p -> [Path.point p]) (Cell.path cell) > > > > Nothing -> [] > > > Record selection is a more convenient syntax. It *could* be usefull for > making more maintainable code(the reason why I choose it). The method I > have chosen *would* be more maintainable in the case I want to add another > feild to Jump. In that case I would not have to re-write the path_points > function. Sadly, due to GHC's unnessesary and complete inability to do > type safety checking, what should have been a convenient tool, has become > an unnessecary source of runtime errors! > > > How would I use your syntax in functions that want to pattern match > against both A and B? I tried this without success: > > >data ALike > >data BLike > > >data MyData t = A {a::Int, > > b::Int} | > > B {c::Int} > > >mkA x y = A x y :: MyData ALike > >mkB x = B x :: MyData BLike > > altRecordSyntaxes.lhs:15:18: > Couldn't match type `BLike' with `ALike' > Expected type: MyData ALike > Actual type: MyData t > In the first argument of `g', namely `myA' > In the expression: g myA > > >foo :: MyData t -> Int > > >foo myA@A{} = g myA > > > where > > > g :: MyData ALike -> Int > > > g myA' = a myA' > > >foo myB@B{} = g myB > > > where > > > g :: MyData BLike -> Int > > > g myB' = c myB' > > >main :: IO () > > >main = do > > > print $ foo $ mkA 1 3 > > > This also doesn't work: > > >foo :: MyData t -> Int > > >foo myData = > > > case myData of > > > myA@A{} -> fooForA's myA > > > myB@B{} -> fooForB's myB > > > where > > > fooForA's :: MyData ALike -> Int > > > fooForA's myA' = a myA' > > > fooForB's :: MyData BLike -> Int > > > fooForB's myB' = a myB' > > >main :: IO () > > >main = do > > > print $ foo $ mkA 1 3 > > My solution looks very clean(except for that nasty looking data > declaration) and has the same advantages. Really, the current record > syntax is just flawed :D > > >data MyData = A A' | B B' > > >data A' = A'{a::Int, > > b::Int} > >data B' = B'{c::Int} > > >foo :: MyData -> Int > >foo (A myA) = a myA > >foo (B myB) = c myB > > >main :: IO () > >main = print $ foo (A (A' 1 2)) > > Timothy > > -- Původní zpráva -- > Od: John Meacham > Datum: 27. 5. 2012 > Předmět: Re: [Haskell-cafe] Record syntax, reopening a can of worms. > > Is it any more ridiculous than > > > f x@Nothing {} = fromJust x > > main = print (f Nothing) > > crashing at run time? That is what you are expressing with your first > one. This issue is completely unrelated to the named field syntax, > they behave exac
Re: [Haskell-cafe] Problem with packet documentation generated by cabal on windows 7
Chrome works well. The "file://" portion at the beginning has got to do with windows namespace [1] and browser conventions. On 26 May 2012 02:40, Antoine Latter wrote: > Also 'cabal' doesn't track executables, only libraries. It does update your cabal package binaries, if the package generates one, though. -- 1. http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx Regards, Paulo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Record syntax, reopening a can of worms.
Somehow I don't understand you. Could you please fill out your example into a working bit of code? Thank you, Timothy -- Původní zpráva -- Od: Yves Parès Datum: 27. 5. 2012 Předmět: Re: [Haskell-cafe] Record syntax, reopening a can of worms. " > case myData of > myA@A{} -> fooForA's myA > myB@B{} -> fooForB's myB I think this would typecheck if you used GADTs. Actually what you'd want is to use the record syntax with GADTs (there are to add the extra type safety you want), however both are not compatible. data ALike data BLike data MyData x where A :: Int -> Int -> MyData ALike B :: Int -> MyData BLike a (A x _) = x b (A _ x) = x c (B x) = x -- GHC may require you to write the type signatures for those three functions. Le 27 mai 2012 10:52, mailto:timothyho...@seznam.cz) > a écrit : " Your Maybe example is very contrived. The place where I ran into this was much less contrived I think. I have an editor for a visual programming language. That looks like this: https://github.com/timthelion/gridhaskell-haskarrow/wiki (https://github.com/timthelion/gridhaskell-haskarrow/wiki) I'm using a modified version of the Document-View model for application design. The commands in the language are defined in the Cell data type: https://github.com/timthelion/gridhaskell-haskarrow/blob/master/Cell.lhs (https://github.com/timthelion/gridhaskell-haskarrow/blob/master/Cell.lhs) Some Cell types, like Jump, have a long crooked line comming out of them called a Path. This line is held in the path :: Maybe Path feild. When I'm drawing the Cell tree, I have a function that extracts these Paths. https://github.com/timthelion/gridhaskell-haskarrow/blob/master/ ArrowDrawing.lhs#L75 (https://github.com/timthelion/gridhaskell-haskarrow/blob/master/ArrowDrawing.lhs#L75) It used to be, that more types of Cell than just the Jump Cell had a path. As I removed these Paths from the Cell datatype, my line drawing function started crashing, whenever it encountered those Cell types. By having chosen to use the short hand record selector syntax rather than the long hand place value syntax, I caused a runtime error in my code. I could of course have written the same function like this: > where path_points = > case> case cell of Types of cells which have paths:> Cell.Jump _ path -> Just path > _ -> Nothing of> Just path -> maybe [] (\p -> [Path.point p]) (Cell.path cell) > Nothing -> [] Record selection is a more convenient syntax. It *could* be usefull for making more maintainable code(the reason why I choose it). The method I have chosen *would* be more maintainable in the case I want to add another feild to Jump. In that case I would not have to re-write the path_points function. Sadly, due to GHC's unnessesary and complete inability to do type safety checking, what should have been a convenient tool, has become an unnessecary source of runtime errors! How would I use your syntax in functions that want to pattern match against both A and B? I tried this without success: >data ALike >data BLike >data MyData t = A {a::Int, > b::Int} | > B {c::Int} >mkA x y = A x y :: MyData ALike >mkB x = B x :: MyData BLike altRecordSyntaxes.lhs:15:18: Couldn't match type `BLike' with `ALike' Expected type: MyData ALike Actual type: MyData t In the first argument of `g', namely `myA' In the expression: g myA >foo :: MyData t -> Int >foo myA@A{} = g myA > where > g :: MyData ALike -> Int > g myA' = a myA' >foo myB@B{} = g myB > where > g :: MyData BLike -> Int > g myB' = c myB' >main :: IO () >main = do > print $ foo $ mkA 1 3 This also doesn't work: >foo :: MyData t -> Int >foo myData = > case myData of > myA@A{} -> fooForA's myA > myB@B{} -> fooForB's myB > where > fooForA's :: MyData ALike -> Int > fooForA's myA' = a myA' > fooForB's :: MyData BLike -> Int > fooForB's myB' = a myB' >main :: IO () >main = do > print $ foo $ mkA 1 3 My solution looks very clean(except for that nasty looking data declaration) and has the same advantages. Really, the current record syntax is just flawed :D >data MyData = A A' | B B' >data A' = A'{a::Int, > b::Int} >data B' = B'{c::Int} >foo :: MyData -> Int >foo (A myA) = a myA >foo (B myB) = c myB >main :: IO () >main = print $ foo (A (A' 1 2)) Timothy -- Původní zpráva -- Od: John Meacham mailto:j...@repetae.net)> Datum: 27. 5. 2012 Předmět: Re: [Haskell-cafe] Record syntax, reopening a can of worms. "Is it any more ridiculous than > f x@Nothing {} = fromJust x > main = print (f Nothing) crashing at run time? That is what you are expressing with your first one. This issue is completely unrelated to the named field syntax, they behave exactly like data types with non-named fields. However, you can achieve something like what you wa
Re: [Haskell-cafe] Record syntax, reopening a can of worms.
> case myData of > myA@A{} -> fooForA's myA > myB@B{} -> fooForB's myB I think this would typecheck if you used GADTs. Actually what you'd want is to use the record syntax with GADTs (there are to add the extra type safety you want), however both are not compatible. data ALike data BLike data MyData x where A :: Int -> Int -> MyData ALike B :: Int -> MyData BLike a (A x _) = x b (A _ x) = x c (B x) = x -- GHC may require you to write the type signatures for those three functions. Le 27 mai 2012 10:52, a écrit : > Your Maybe example is very contrived. The place where I ran into this was > much less contrived I think. > > I have an editor for a visual programming language. That looks like this: > > https://github.com/timthelion/gridhaskell-haskarrow/wiki > > I'm using a modified version of the Document-View model for application > design. The commands in the language are defined in the Cell data type: > > > https://github.com/timthelion/gridhaskell-haskarrow/blob/master/Cell.lhs > > > Some Cell types, like Jump, have a long crooked line comming out of them > called a Path. This line is held in the path :: Maybe Path feild. > > > When I'm drawing the Cell tree, I have a function that extracts these > Paths. > https://github.com/timthelion/gridhaskell-haskarrow/blob/master/ArrowDrawing.lhs#L75 > > > It used to be, that more types of Cell than just the Jump Cell had a path. > > > As I removed these Paths from the Cell datatype, my line drawing function > started crashing, whenever it encountered those Cell types. By having > chosen to use the short hand record selector syntax rather than the long > hand place value syntax, I caused a runtime error in my code. > > > I could of course have written the same function like this: > > > where path_points = > > case > > case cell of > > Types of cells which have paths: > > > Cell.Jump _ path-> Just path > > _ -> Nothing of > > Just path -> maybe [] (\p -> [Path.point p]) (Cell.path cell) > > Nothing -> [] > > > Record selection is a more convenient syntax. It *could* be usefull for > making more maintainable code(the reason why I choose it). The method I > have chosen *would* be more maintainable in the case I want to add another > feild to Jump. In that case I would not have to re-write the path_points > function. Sadly, due to GHC's unnessesary and complete inability to do > type safety checking, what should have been a convenient tool, has become > an unnessecary source of runtime errors! > > > How would I use your syntax in functions that want to pattern match > against both A and B? I tried this without success: > > >data ALike > >data BLike > > >data MyData t = A {a::Int, > > b::Int} | > > B {c::Int} > > >mkA x y = A x y :: MyData ALike > >mkB x = B x :: MyData BLike > > altRecordSyntaxes.lhs:15:18: > Couldn't match type `BLike' with `ALike' > Expected type: MyData ALike > Actual type: MyData t > In the first argument of `g', namely `myA' > In the expression: g myA > > >foo :: MyData t -> Int > > >foo myA@A{} = g myA > > > where > > > g :: MyData ALike -> Int > > > g myA' = a myA' > > >foo myB@B{} = g myB > > > where > > > g :: MyData BLike -> Int > > > g myB' = c myB' > > >main :: IO () > > >main = do > > > print $ foo $ mkA 1 3 > > > This also doesn't work: > > >foo :: MyData t -> Int > > >foo myData = > > > case myData of > > > myA@A{} -> fooForA's myA > > > myB@B{} -> fooForB's myB > > > where > > > fooForA's :: MyData ALike -> Int > > > fooForA's myA' = a myA' > > > fooForB's :: MyData BLike -> Int > > > fooForB's myB' = a myB' > > >main :: IO () > > >main = do > > > print $ foo $ mkA 1 3 > > My solution looks very clean(except for that nasty looking data > declaration) and has the same advantages. Really, the current record > syntax is just flawed :D > > >data MyData = A A' | B B' > > >data A' = A'{a::Int, > > b::Int} > >data B' = B'{c::Int} > > >foo :: MyData -> Int > >foo (A myA) = a myA > >foo (B myB) = c myB > > >main :: IO () > >main = print $ foo (A (A' 1 2)) > > Timothy > > -- Původní zpráva -- > Od: John Meacham > Datum: 27. 5. 2012 > Předmět: Re: [Haskell-cafe] Record syntax, reopening a can of worms. > > Is it any more ridiculous than > > > f x@Nothing {} = fromJust x > > main = print (f Nothing) > > crashing at run time? That is what you are expressing with your first > one. This issue is completely unrelated to the named field syntax, > they behave exactly like data types with non-named fields. > > However, you can achieve something like what you want with phantom types. > > > data ALike > > data BLike > > >data MyData t = A {a::Int, > > b::Int} | > > B {c::Int} > > > mkA x y = A x y :: MyData ALike > > mkB x = B x :: MyData BLike > > then you can write functions of > 'MyData ALike' to indicate it will only have 'A' as a constructor > 'MyData BLike' to indicate it wil
Re: [Haskell-cafe] What is the difference between runhaskell and compile?
Hi, Sorry for the delayed reply. I am using ghc 7.4.1 and LDAP 0.6.6. When you said "configuration of the OpenLDAP client library", may I have more information? Since ldap-utils and other client (php, perl, etc) do not have any problem. This might be the only clue to me. On Fri, May 25, 2012 at 4:43 PM, Chris Dornan wrote: > I have been using LDAP with GHC without a problem – I get this error often > but the problems have been with the configuration of the OpenLDAP client > library or the OpenLDAP server. > > > > We are all taking about LDAP-0.6.6? Which version of GHC are we talking > about? (I don’t think I have tested this on GHC-7.4.1, and maybe the others > haven’t either.) > > > > Chris > > > > > > From: haskell-cafe-boun...@haskell.org > [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Brandon Allbery > Sent: 25 May 2012 04:21 > To: Magicloud Magiclouds > Cc: Haskell-Cafe > Subject: Re: [Haskell-cafe] What is the difference between runhaskell and > compile? > > > > On Thu, May 24, 2012 at 11:05 PM, Magicloud Magiclouds > wrote: > > Hi there, > The code could not be simpler. Just ldapInit, ldapSimpleBind. > I just found that the code works with ghci, too. So to sum up, > ghci/runhaskell works, ghc not. > > > > A possibility that occurs to me: does it by any chance work with ghc > -threaded? Perhaps the issue relates to the different behavior of the > threaded runtime (which is used automatically by ghci/runghc). > > > > -- > brandon s allbery allber...@gmail.com > wandering unix systems administrator (available) (412) 475-9364 vm/sms -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A functional programming solution for Mr and Mrs Hollingberry
Andreas Pauley writes: > Do you know of an exercise where classes would add value? Something > fairly small, roughly similar in size to this exercise. AFAICR, the motivating example for OO (in Simula) was simulating an environment where different entities interact - I think the case was queues in a post office, where object represents the door, customers, tellers, etc. Perhaps something along those lines? -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Record syntax, reopening a can of worms.
Your Maybe example is very contrived. The place where I ran into this was much less contrived I think. I have an editor for a visual programming language. That looks like this: https://github.com/timthelion/gridhaskell-haskarrow/wiki I'm using a modified version of the Document-View model for application design. The commands in the language are defined in the Cell data type: https://github.com/timthelion/gridhaskell-haskarrow/blob/master/Cell.lhs Some Cell types, like Jump, have a long crooked line comming out of them called a Path. This line is held in the path :: Maybe Path feild. When I'm drawing the Cell tree, I have a function that extracts these Paths. https://github.com/timthelion/gridhaskell-haskarrow/blob/master/ ArrowDrawing.lhs#L75 It used to be, that more types of Cell than just the Jump Cell had a path. As I removed these Paths from the Cell datatype, my line drawing function started crashing, whenever it encountered those Cell types. By having chosen to use the short hand record selector syntax rather than the long hand place value syntax, I caused a runtime error in my code. I could of course have written the same function like this: > where path_points = > case> case cell ofTypes of cells which have paths:> Cell.Jump _ path-> Just path> _ -> Nothing of> Just path -> maybe [] (\p -> [Path.point p]) (Cell.path cell)> Nothing -> [] Record selection is a more convenient syntax. It *could* be usefull for making more maintainable code(the reason why I choose it). The method I have chosen *would* be more maintainable in the case I want to add another feild to Jump. In that case I would not have to re-write the path_points function. Sadly, due to GHC's unnessesary and complete inability to do type safety checking, what should have been a convenient tool, has become an unnessecary source of runtime errors! How would I use your syntax in functions that want to pattern match against both A and B? I tried this without success: >data ALike >data BLike >data MyData t = A {a::Int, > b::Int} | > B {c::Int} >mkA x y = A x y :: MyData ALike >mkB x = B x :: MyData BLike altRecordSyntaxes.lhs:15:18: Couldn't match type `BLike' with `ALike' Expected type: MyData ALike Actual type: MyData t In the first argument of `g', namely `myA' In the expression: g myA >foo :: MyData t -> Int >foo myA@A{} = g myA > where > g :: MyData ALike -> Int > g myA' = a myA' >foo myB@B{} = g myB > where > g :: MyData BLike -> Int > g myB' = c myB' >main :: IO () >main = do > print $ foo $ mkA 1 3 This also doesn't work: >foo :: MyData t -> Int >foo myData = > case myData of > myA@A{} -> fooForA's myA > myB@B{} -> fooForB's myB > where > fooForA's :: MyData ALike -> Int > fooForA's myA' = a myA' > fooForB's :: MyData BLike -> Int > fooForB's myB' = a myB' >main :: IO () >main = do > print $ foo $ mkA 1 3 My solution looks very clean(except for that nasty looking data declaration) and has the same advantages. Really, the current record syntax is just flawed :D >data MyData = A A' | B B' >data A' = A'{a::Int, > b::Int} >data B' = B'{c::Int} >foo :: MyData -> Int >foo (A myA) = a myA >foo (B myB) = c myB >main :: IO () >main = print $ foo (A (A' 1 2)) Timothy -- Původní zpráva -- Od: John Meacham Datum: 27. 5. 2012 Předmět: Re: [Haskell-cafe] Record syntax, reopening a can of worms. "Is it any more ridiculous than > f x@Nothing {} = fromJust x > main = print (f Nothing) crashing at run time? That is what you are expressing with your first one. This issue is completely unrelated to the named field syntax, they behave exactly like data types with non-named fields. However, you can achieve something like what you want with phantom types. > data ALike > data BLike >data MyData t = A {a::Int, > b::Int} | > B {c::Int} > mkA x y = A x y :: MyData ALike > mkB x = B x :: MyData BLike then you can write functions of 'MyData ALike' to indicate it will only have 'A' as a constructor 'MyData BLike' to indicate it will only have 'B' and 'forall t . MyData t' for functions that can take a general MyData that can have either. John"___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Finding the average in constant space
A lot of people have done this :) eg from me: google up a fairly recent thread from me about processing streams and perhaps the keyword "timeplot" (writing from a dying phone, can't do myself) 27.05.2012, в 12:04, Chris Wong написал(а): > Hello all > > I just came up with a way of executing multiple folds in a single > pass. In short, we can write code like this: > > average = foldLeft $ (/) <$> sumF <*> lengthF > > and it will only traverse the input list once. > > The code is at: https://gist.github.com/2802644 > > My question is: has anyone done this already? If not, I might release > this on Hackage -- it seems quite useful. > > Chris > > ___ > 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] Finding the average in constant space
Hello all I just came up with a way of executing multiple folds in a single pass. In short, we can write code like this: average = foldLeft $ (/) <$> sumF <*> lengthF and it will only traverse the input list once. The code is at: https://gist.github.com/2802644 My question is: has anyone done this already? If not, I might release this on Hackage -- it seems quite useful. Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe