[Haskell-cafe] Re: a simple question about types

2010-11-19 Thread JerzM
Thank you for these excellent explanations. Best regards, Jerz -- View this message in context: http://haskell.1045720.n5.nabble.com/a-simple-question-about-types-tp3269519p3272344.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com

[Haskell-cafe] Re: a simple question about types

2010-11-18 Thread Jon Fairbairn
Daniel Fischer daniel.is.fisc...@web.de writes: On Wednesday 17 November 2010 19:09:16, Jerzy M wrote: Hallo, let me take this simple function: (2*). If I check its type :t (2*) I'll obtain (2*) :: (Num a) = a - a But now it suffices to write g = (2*) and check :t g to obtain g

[Haskell-cafe] a simple question about types

2010-11-17 Thread Jerzy M
Hallo, let me take this simple function: (2*). If I check its type :t (2*) I'll obtain (2*) :: (Num a) = a - a But now it suffices to write g = (2*) and check :t g to obtain g :: Integer - Integer One more combination, now I write h x = (2*) x and check once more :t h to get h :: (Num a) = a - a

Re: [Haskell-cafe] a simple question about types

2010-11-17 Thread Alexander Solla
On Nov 17, 2010, at 10:09 AM, Jerzy M wrote: So my question is: why (in this second example) Integer is inferred? What makes a difference? I think there are two things going on. First, the monomorphism restriction is causing the types to be different. I'm not sure why Integer -

Re: [Haskell-cafe] a simple question about types

2010-11-17 Thread Daniel Fischer
On Wednesday 17 November 2010 19:09:16, Jerzy M wrote: Hallo, let me take this simple function: (2*). If I check its type :t (2*) I'll obtain (2*) :: (Num a) = a - a But now it suffices to write g = (2*) and check :t g to obtain g :: Integer - Integer One more combination, now I

Re: [Haskell-cafe] a simple question about types

2010-11-17 Thread Ryan Ingram
Now of course, the followup question is what the heck is a monomorphism restriction and why would I want it? Here is a simple example: expensiveComputation :: Num a = a - a expensiveComputation x = ... something that takes a long time to compute ... ghci :t (expensiveComputation 2 *)

Re: [Haskell-cafe] a simple question about types

2010-11-17 Thread Daniel Fischer
On Wednesday 17 November 2010 20:19:17, Ryan Ingram wrote: Now of course, the followup question is what the heck is a monomorphism restriction and why would I want it? Here is a simple example: snip But if you give g the more general type signature, the expensiveComputation has to get run

Re: [Haskell-cafe] Simple question about the function composition operator

2010-09-25 Thread wren ng thornton
On 9/24/10 5:35 AM, Axel Benz wrote: Can anybody explain why this happens and how I can compose f and g? Hint: It works fine if f is defined as an unary function. As already mentioned: (g . f) x y = (\z- g (f z)) x y = g (f x) y In order to get it to work you need to say that you want to

[Haskell-cafe] Simple question about the function composition operator

2010-09-24 Thread Axel Benz
Hello, this is maybe a simple question: cbinary :: a - b - (a - b - b) - (b - c) - c -- Version 1 works: cbinary x y f g = g (f x y) -- Version 2 should be exactly the same according -- to my understanding of the . operator definition, -- but fails with: -- Occurs check

Re: [Haskell-cafe] Simple question about the function composition operator

2010-09-24 Thread Miguel Mitrofanov
(g . f) x y = (\z - g (f z)) x y = g (f x) y, and you need g (f x y), which is definitely not the same thing. 24.09.2010 13:35, Axel Benz пишет: Hello, this is maybe a simple question: cbinary :: a - b - (a - b - b) - (b - c) - c -- Version 1 works: cbinary x y f g = g (f x y

[Haskell-cafe] Simple question about processing XML with HaXml

2008-06-25 Thread Dominic Espinosa
Hello, I'm trying to learn how to use HaXml, but I'm having trouble getting off the ground. I can see from the documentation how to process XML using the combinators and processXmlWith, but processXmlWith seems to hide the actual process of reading and parsing the XML. Suppose that processXmlWith

[Haskell-cafe] Hoogle search scope question -- was: [HXT] Simple question

2007-12-22 Thread Steve Lihn
I have a hoogle question. While I was reading the HXT discussion (below), I tried to search runX and readString in Hoogle (since I am new to HXT and Arrows). But neither search yielded any result and I had to use google to find the Haskell docs. So I am wondering what is the scope of Hoogle that

Re: [Haskell-cafe] Hoogle search scope question -- was: [HXT] Simple question

2007-12-22 Thread Neil Mitchell
Hi I have a hoogle question. While I was reading the HXT discussion (below), I tried to search runX and readString in Hoogle (since I am new to HXT and Arrows). But neither search yielded any result and I had to use google to find the Haskell docs. So I am wondering what is the scope of

Re: [Haskell-cafe] [HXT] Simple question

2007-12-20 Thread Uwe Schmidt
Hi Fernand, Everything works fine except for the fact that all the nodes « this /this » (that is, a space (an XML text node whose contents are a single space character) within a this element node) get transformed to a « this/ » element I can't really reproduce this: A simple ghci session

Re: [Haskell-cafe] [HXT] Simple question

2007-12-20 Thread Miguel Mitrofanov
I can't really reproduce this: A simple ghci session gives the following: --- [EMAIL PROTECTED]:~/haskell/hxt/curr/examples/arrows/HelloWorld ghci HelloWorld.hs GHCi, version 6.8.1: http://www.haskell.org/ghc/ :? for help Loading package base ... linking

Re: [Haskell-cafe] [HXT] Simple question

2007-12-20 Thread Uwe Schmidt
Hi Miguel, Hmmm, with 'readString ... this /this' everything works fine, but with 'readString ... itemsthis /this/items' it doesn't. Seems to be a bug in HXT. I don't see the bug: -- *Main runX $ ( readString [(a_validate,v_0)] itemsthis /this/items

Re: [Haskell-cafe] [HXT] Simple question

2007-12-20 Thread Fernand
Prelude Text.XML.HXT.Arrow runX $ ( readString [(a_validate,v_0)] xy /y/x setTraceLevel 4 traceDoc doc after reading s etTraceLevel 0 writeDocumentToString [(a_indent, v_1)]) -- (1) doc after reading x y/ /x content of: xy /y/x = ---XTag / | source=\xy

Re: [Haskell-cafe] [HXT] Simple question

2007-12-20 Thread Uwe Schmidt
Hi Miguel, Try xy /y/x and a_indent writing option. yes, with the indent option set, whitespace becomes insignificant and will change during formating, and so the contents of the inner element reduces to empty Turn of the indentation and you get the result you want. Cheers, Uwe -- Web:

[Haskell-cafe] [HXT] Simple question

2007-12-19 Thread Fernand
Hi, I'm using HXT (7.4) with GHC to make some XML transformations (BTW, congratulations to the maintainers of that package for their impressive work). Everything works fine except for the fact that all the nodes « this /this » (that is, a space (an XML text node whose contents are a single

Re: [Haskell-cafe] [HXT] Simple question

2007-12-19 Thread Fernand
Miguel Mitrofanov a écrit : Seems rather strange for me, I've just installed HXT and got this: Prelude Text.XML.HXT.Arrow runX $ readString [(a_validate,0)] this /this writeDocumentToString [] [?xml version=\1.0\ encoding=\UTF-8\?\nthis /this] Everything works fine except for the fact

Re: [Haskell-cafe] [HXT] Simple question

2007-12-19 Thread Miguel Mitrofanov
Hmmm, with 'readString ... this /this' everything works fine, but with 'readString ... itemsthis /this/items' it doesn't. Seems to be a bug in HXT. But if I try the same with my XML file, my empty nodes are folded. I suppose this comes from the Ctrl-M at the end of the lines. See the

Re: [Haskell-cafe] Hi I need help for very simple question!

2007-03-02 Thread Bryan Donlan
Taillefer, Troy (EXP) wrote: Hi there 1. First of all never forget your base case for exiting your recursion 2. you need to break up the problem like so import Char -- get the first word word :: String - String word [] = [] word ( x : x1 : xs ) | isSpace x = [] | isSpace x1 =

[Haskell-cafe] pls fast help me with this simple question

2006-03-26 Thread iliali16
with the variable value updated. setVal :: Store - (Variable, Data) - Store -- View this message in context: http://www.nabble.com/pls-fast-help-me-with-this-simple-question-t1345292.html#a3598605 Sent from the Haskell - Haskell-Cafe forum at Nabble.com. ___ Haskell

Re: [Haskell-cafe] pls fast help me with this simple question

2006-03-26 Thread Sebastian Sylvan
On 3/26/06, iliali16 [EMAIL PROTECTED] wrote: type Data = Integer type Variable = String type Store = [(Variable, Data)] Store = [(,0)] emptystore :: Store emptystore = [(,0)] getVal :: Store - Variable - Data thats my code i just have to continue and get the value of a variable from

simple question

2005-04-02 Thread Peter Hercek
What is $ function good for? ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Re: simple question

2005-04-02 Thread Benjamin Franksen
On Saturday 02 April 2005 22:29, Peter Hercek wrote: What is $ function good for? Mostly for avoiding parentheses. $ is right associative and has lowest precedence, whereas normal application is left associative and binds most tightly: f $ g $ h x === f ( g ( h x ) ) There are more

Re: simple question

2005-04-02 Thread Dean Herington
At 10:56 PM +0200 4/2/05, Benjamin Franksen wrote: On Saturday 02 April 2005 22:29, Peter Hercek wrote: What is $ function good for? Mostly for avoiding parentheses. $ is right associative and has lowest precedence, whereas normal application is left associative and binds most tightly: f $ g $

Re: [Haskell-cafe] A simple question

2004-11-03 Thread Henning Thielemann
On Tue, 2 Nov 2004, Marc Charpentier wrote: Doing some calculations in ghci, I encountered a difficulty which I cannot resolve. Here's a distilled version, prepared for the command line: let i = 2 in (-1)^i/(2^(10*i)) * (-2^5/(4*i+1)) Monomorphism was the short answer, the long

Re: Fwd: [Haskell-cafe] A simple question

2004-11-03 Thread Henning Thielemann
On Wed, 3 Nov 2004, Marc Charpentier wrote: Thank you all for the friendly and helpful explanations - and for your patience. The solution to my problem is finally f :: Double - Double f i = (-1)**i/(2**(10*i)) * (-2^5/(4*i+1)-1/(4*i+3)+2^8/(10*i+1)

Re: [Haskell-cafe] A simple question

2004-11-02 Thread Tomasz Zielonka
On Tue, Nov 02, 2004 at 09:53:28PM +0100, Marc Charpentier wrote: Good evening, Doing some calculations in ghci, I encountered a difficulty which I cannot resolve. Here's a distilled version, prepared for the command line: let i = 2 in (-1)^i/(2^(10*i)) * (-2^5/(4*i+1))

[Haskell] Simple question about IO in hugs and ghc

2004-09-26 Thread Vivian McPhail
Hi, When I run my main function I get an error: The prompt does not wait for user input and thus my parser fails with an empty head. Is there a switch to not echo to the console? Is this the problem? It happens in both Hugs and GHC main :: IO ()main = do putStr "sentence? " input -

Very simple question

2003-02-11 Thread Jorge Adriano
On style, yes. A concrete example of what I asked before. The following doesn't type check for obvious reasons. In your opinion what is the most elegant way to fix it? Like I said, I'm starting to feel like defining my own operators is the way to go. On the other hand, this kind of situation

Simple Question Again

2002-05-17 Thread Jerry
Hi, I'm sorry to bother everyone again with this simple append' stuff -- below is my revised append' function 1) append' :: [[a]] - a - [[a]] 2) append' [] y = [[y]] 3) append' (x:xs) y = 4) case xs of [] - foldr (:) [y] x 5)(z:zs) - (init (x:xs)) ++ [(last xs)++[y]] -- to

Re: Simple Question Again

2002-05-17 Thread Jay Cox
On Fri, 17 May 2002, Jerry wrote: Hi, I'm sorry to bother everyone again with this simple append' stuff -- now this is something I _really_ don't understand: -- x is of type [a], [y] is of type [a], and isn't foldr (:) [a] [a] -- perfectly valid?! :type foldr forall a b. (a - b - b) - b -

Simple Question

2002-05-16 Thread Jerry, JiJie
Hi, enlightenment much appreciated for my newbie question -- to achieve: append' [ [1, 2], [3, 4], [5] ] 6 - [ [1, 2], [3, 4], [5, 6] ] append' [ ['1', '2'], ['3'] ] '4' - [ ['1', '2'], ['3', '4'] ] append' [ [True], [True] ] False - [ [True], [True, False] ] so I (naively) write: 18) append'

Re: Simple Question

2002-05-16 Thread Ch. A. Herrmann
Hi, JiJie 20) append' x:xs y = [(init x:xs)] ++ [(tail xs)++[y]] function application (blank) binds stronger than :, thus you should write append' (x:xs) y = ... Cheers -- Christoph ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Simple Question Follow Up

2002-05-16 Thread Jerry, JiJie
* Ch. A. Herrmann [EMAIL PROTECTED] [020516 21:38]: Hi, JiJie 20) append' x:xs y = [(init x:xs)] ++ [(tail xs)++[y]] function application (blank) binds stronger than :, thus you should write append' (x:xs) y = ... -- so I added the parenthesis: 18) append' :: [[a]] - a -

Re: Simple Question Follow Up

2002-05-16 Thread Ch. A. Herrmann
To make it short: Main let append' xs y = init xs ++ [last xs ++ [y]] This works for the three given examples but maybe incorrect for the task you have in mind, e.g., if xs is empty. Main append' [ [1, 2], [3, 4], [5] ] 6 [[1,2],[3,4],[5,6]] Main append' [ ['1', '2'], ['3'] ] '4' [12,34] Main

simple question

2001-07-31 Thread Cagdas Ozgenc
Hi, I am trying to do some exercies in my Haskell book. I couldn't get my program to work correctly. type Database2 = [ (Person,[ Book ]) ] exampleBase2 :: Database2 exampleBase2 = [ (Alice, [ Tintin, Astrix ] ), (Anna, [ Little Woman ] ), (Rory, [ Tintin ] ) ] books2 :: Database2 -

Re: simple question

2001-07-31 Thread Tom Schrijvers
Cagdas Ozgenc wrote: books2 :: Database2 - Person - [Book] books2 db person = head [ snd tuple | tuple - db, fst tuple == person ] borrowers2 :: Database2 - Book - [Person] borrowers2 db book = [ person | (person, books) - db, book - books ] You can't pattern match against a variable

A simple question on Haskell style

1999-01-28 Thread Jose Emilio Labra Gayo
Suppose I define a new type class MyClass with some methods class MyClass a where -- Basic methods m :: Some type including a ... -- Derived Methods dm :: Some type including a dm = Definition of dm that depends on m ... However, I could

RE: A simple question on Haskell style

1999-01-28 Thread Simon Peyton-Jones
Is it better to type the derived methods inside the class definition or out? Are there any efficiency penalties in any of the styles? In Haskell98 Prelude there is a mixture of both styles, for example, () is defined inside the Monad class, but (=) is left out. Good question. The

Re: simple question

1997-07-03 Thread Simon L Peyton Jones
| Jin Yang [EMAIL PROTECTED] writes ... | | I wrote a translator in Haskell and it was compiled OK using an earlier ghc | version. Now the ghc at my department (Dept of Computing , Imperial) was | upgrated to ghc0.26 and all my code got a compiling error: |ld: Undefined symbol |