[Haskell-cafe] Benchmark
Hi, exist some benchmark active to use in my libraries, i want test memory usage and performance? Cheers, André ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Benchmark
Hi Johan, i already try use Criterion but i couldn't install with cabal :S i get error: cabal install criterion Resolving dependencies... cabal: dependencies conflict: ghc-6.12.1 requires array ==0.3.0.1 however array-0.3.0.1 was excluded because ghc-6.12.1 requires array ==0.3.0.0 Anyone can help? No dia 3 de Novembro de 2010 16:33, Johan Tibell johan.tib...@gmail.comescreveu: Hi André, Have a look at the Criterion benchmarking package: http://hackage.haskell.org/package/criterion Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Convert Either to Tree - Occurs check
Tks for the answer, the data structure of Either is: data Either a b = Left a | Right b deriving (Eq, Ord, Read, Show) one example of what i want convert is: Left(Right(Left(Left( No dia 22 de Outubro de 2010 04:58, Dan Piponi dpip...@gmail.com escreveu: André Batista Martins asked: i want convert Either to a tree. Example: Either ( Either 1 2 ) ( Either 3 4) Branch ( Branch (Leafl 1) (Leafr2) ) ( Branch (Leafl 3) (Leafr4)) ) Before writing the function to convert your data structure, why not try writing down the precise type signature you expect it to have. In fact, before that, try writing down the precise type signature of the thing you call an Either. -- Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Convert Either to Tree - Occurs check
Tks for the answser, I need to continue a work that has already been developed. In this work i have Eithers and i want convert to another datatype with more information, because I want to generate Eithers, which will contain the information from the first but with positions exchanged. No dia 22 de Outubro de 2010 11:30, Neil Brown nc...@kent.ac.uk escreveu: On 22/10/10 09:23, André Batista Martins wrote: Tks for the answer, the data structure of Either is: data Either a b = Left a | Right b deriving (Eq, Ord, Read, Show) one example of what i want convert is: Left(Right(Left(Left( Hi, The problem here is that the type of Left () is: Either () a The type of Left (Left ()) is: Either (Either () a) b The type of Right (Left (Left ())) is: Either c (Either (Either () a) b) and finally, the type of Left (Right (Left (Left ( is: Either (Either c (Either (Either () a) b)) d That is, each level in the tree must have a different type. For this reason, you can't sensibly use Either for tree types of varying depth (a type-class would help, but I doubt it's what you want). A sensible type for a tree is the one you gave in your original post, TreeE. So why do you want to encode the tree with Either (not really possible) and then convert to your TreeE type? Why not just start out with the values in your tree type? Thanks, Neil. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Convert Either to Tree - Occurs check
hello, i want convert Either to a tree. Example: Either ( Either 1 2 ) ( Either 3 4) Branch ( Branch (Leafl 1) (Leafr2) ) ( Branch (Leafl 3) (Leafr4)) ) Code: data TreeE a b = Empty |Leafl a | Leafr b | Branch (TreeE a b ) (TreeE a b) deriving Show f3 (Right b) (Branch l r) =case( isRight(b) || isLeft(b) )of true - Branch l (f3 b r) false - Branch l (Leafl b) f3 (Left b) (Branch l r) = case( isRight(b) || isLeft(b) )of true - Branch (f3 b l) r false - Branch (Leafl b) r Error: Occurs check: cannot construct the infinite type: b = Either a b Expected type: Either a b - TreeE t t1 - TreeE t t1 Inferred type: Either a (Either a b) - TreeE t t1 - t2 In the second argument of `Branch', namely `(f3 b r)' In the expression: Branch l (f3 b r) I don't understand why this happen... Can anyone help me? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type
I thanks for the answers. On this paper, i found this example The student has accidental given the arguments of map in the wrong order. Again, the logged student programs show that this is indeed a common mistake. (1,8): Type error in application expression : map [1 .. 10] even term : map type : (a - b) - [a] - [b] does not match : [Int] - (Int - Bool) - c probable fix : re-order arguments The solution i think was in reordering of function arguments and the elements of a tuple, and the insertion or removal of function arguments. In general, this problem appears also in sequence of functions. So if we do the bridge between the functions, and that bridge was one function to re-order the elements of output to the correct input of next function. I think that work has been done, in helium compiler. But i can't identify the algorithm for this propose. How i can find the type of one function that i was done, on code, not on compiler? Cheers, André No dia 10 de Outubro de 2010 07:58, Gene A yumag...@gmail.com escreveu: 2010/10/9 André Batista Martins andre...@netcabo.pt Said: Might have not been clear, but i will try illustrate . f:: a- b - c - (b,(c,a)) f1 :: c - a - d - I think I would attack this with glue consisting of: comb f f1 a b c = arr (\(a,b,c) - f a b c) arr (\(b,(c,a))) -f1 c a) $ (a,b,c) and yes, have to agree that easier to roll your own if only a few functions are like this.. but should be able to parse the type signatures of the functions involved and write a program to automate this process.. using this format as a template.. Actually if you just set it to take all the variables prior to last (-) in sig you can put them put them together in an uncurried format.. for instance the a - b - c portion would become always \(a,b,c) - then the function so arr (\(a,b,c) - f a b c) then the term (output) would be the last term in this case (b,(c,a) add that with a - between to give that to first part of another lambda construction (\(c,a) - f1 c a) ... arrowizing the whole thing with arr (first lambda) arr (second lambda) $ and a tuple from all but the last variables in all cases of first function ... so for f it would be (a,b,c). if for some odd reason it was a single it would just become ((a)) an added parenthesis, which would not hurt a thing for the case where it was a sig like f :: a - b So for your case it becomes as shown above: comb f f1 a b c = arr (\(a,b,c) - f a b c) arr (\(b,(c,a))) -f1 c a) $ (a,b,c) and say for: f :: a - (b,c) f1:: b - d (\(a) - f a) (\(b,c) - f1 b) $ (a) - it just harmlessly adds the '( ' and ')' around the 'a' even though it doesn't need it as the only parameter prior to the last '-'. This is probably clear as mud, on first look, but I think a way forward in automating from this is possible.. I am sure of it.. but it would be at the source code level and a string parse and output from that .. cheers, gene ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type
Sorry, i don't refer the paper on other email. But the paper was Helium, for Learning Haskell No dia 10 de Outubro de 2010 12:22, André Batista Martins andre...@netcabo.pt escreveu: I thanks for the answers. On this paper, i found this example The student has accidental given the arguments of map in the wrong order. Again, the logged student programs show that this is indeed a common mistake. (1,8): Type error in application expression : map [1 .. 10] even term : map type : (a - b) - [a] - [b] does not match : [Int] - (Int - Bool) - c probable fix : re-order arguments The solution i think was in reordering of function arguments and the elements of a tuple, and the insertion or removal of function arguments. In general, this problem appears also in sequence of functions. So if we do the bridge between the functions, and that bridge was one function to re-order the elements of output to the correct input of next function. I think that work has been done, in helium compiler. But i can't identify the algorithm for this propose. How i can find the type of one function that i was done, on code, not on compiler? Cheers, André No dia 10 de Outubro de 2010 07:58, Gene A yumag...@gmail.com escreveu: 2010/10/9 André Batista Martins andre...@netcabo.pt Said: Might have not been clear, but i will try illustrate . f:: a- b - c - (b,(c,a)) f1 :: c - a - d - I think I would attack this with glue consisting of: comb f f1 a b c = arr (\(a,b,c) - f a b c) arr (\(b,(c,a))) -f1 c a) $ (a,b,c) and yes, have to agree that easier to roll your own if only a few functions are like this.. but should be able to parse the type signatures of the functions involved and write a program to automate this process.. using this format as a template.. Actually if you just set it to take all the variables prior to last (-) in sig you can put them put them together in an uncurried format.. for instance the a - b - c portion would become always \(a,b,c) - then the function so arr (\(a,b,c) - f a b c) then the term (output) would be the last term in this case (b,(c,a) add that with a - between to give that to first part of another lambda construction (\(c,a) - f1 c a) ... arrowizing the whole thing with arr (first lambda) arr (second lambda) $ and a tuple from all but the last variables in all cases of first function ... so for f it would be (a,b,c). if for some odd reason it was a single it would just become ((a)) an added parenthesis, which would not hurt a thing for the case where it was a sig like f :: a - b So for your case it becomes as shown above: comb f f1 a b c = arr (\(a,b,c) - f a b c) arr (\(b,(c,a))) -f1 c a) $ (a,b,c) and say for: f :: a - (b,c) f1:: b - d (\(a) - f a) (\(b,c) - f1 b) $ (a) - it just harmlessly adds the '( ' and ')' around the 'a' even though it doesn't need it as the only parameter prior to the last '-'. This is probably clear as mud, on first look, but I think a way forward in automating from this is possible.. I am sure of it.. but it would be at the source code level and a string parse and output from that .. cheers, gene ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re-order type
Hello, exists any algorithm to determine how terms can be changed to safisty the type of one function? example: f:: a- b - c - (b,c,a) f1 :: c - a - d In my first function f i want assign the output c and a for to input of function f1. I searched for any solution, but i didn't find any anything. One clue i have found is minimal edit distance algorithm for 2 strings. Perhaps if i convert de output type of f to one string, and de input of f1 to another string and then use this algorithm , i will get one dirty solution... I'm open to any sugestion. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Re-order type
Might have not been clear, but i will try illustrate . f:: a- b - c - (b,(c,a)) f1 :: c - a - d input type: A B C -- |f | | _ | output (B,(C,A)) CA -- |f1| | _ | output D If i want compose f and f1, i need to do a correct input to f1 from the output of f. So i want one function to convert the output of f to input off f!. In this case, we do f1 fst (snd (t,(t1,t2))) snd (snd (t,(t1,t2))) But i want do this automaticaly, for type of any two function. I search for the glue. I don't have any concern about what the function does, i only have interess on input and output types. Cheers, André No dia 9 de Outubro de 2010 22:38, André Batista Martins andre...@netcabo.pt escreveu: Hello, exists any algorithm to determine how terms can be changed to safisty the type of one function? example: f:: a- b - c - (b,c,a) f1 :: c - a - d In my first function f i want assign the output c and a for to input of function f1. I searched for any solution, but i didn't find any anything. One clue i have found is minimal edit distance algorithm for 2 strings. Perhaps if i convert de output type of f to one string, and de input of f1 to another string and then use this algorithm , i will get one dirty solution... I'm open to any sugestion. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe