
I'm a beginner, I'd like someone to help me understand a few lines of code My questions are: 1) Maybe String is an application of the constructor Maybe to the type String. What does it mean? Is there anything equivalent in the C language? 2) Is this a function with three arguments? type T = [Char] type P = (Char, Maybe String) type Delta = ((Maybe Char, Char), Maybe String) fromGtoM :: T -> [P] -> [Delta] 3) is this a usage of the above mentioned function? fromGtoM t p = terminalRules ++ varRules I dont'see why the function has three arguments but then only two are used t p. 4) what does ++ mean ? Sorry, for posting too many questions. Thanks in advance. -- moowoo9@fastmail.fm -- http://www.fastmail.fm - Access your email from home and the web

You really, really need to read a basic tutorial. You are not going
to get anywhere in haskell trying to be spoonfed like this.
1) There might be nothing, or their might be a string. No, not really.
2) No.
3) Yes. You will find out within the first five paragraphs of any
haskell tutorial.
4) String concatenation. You will learn how to look up functions in
said tutorial.
On Sat, Jul 2, 2011 at 12:47 PM,
I'm a beginner, I'd like someone to help me understand a few lines of code My questions are: 1) Maybe String is an application of the constructor Maybe to the type String. What does it mean? Is there anything equivalent in the C language? 2) Is this a function with three arguments? type T = [Char] type P = (Char, Maybe String) type Delta = ((Maybe Char, Char), Maybe String) fromGtoM :: T -> [P] -> [Delta] 3) is this a usage of the above mentioned function? fromGtoM t p = terminalRules ++ varRules I dont'see why the function has three arguments but then only two are used t p. 4) what does ++ mean ?
Sorry, for posting too many questions. Thanks in advance. --
moowoo9@fastmail.fm
-- http://www.fastmail.fm - Access your email from home and the web
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 07/02/2011 12:47 PM, moowoo9@fastmail.fm wrote:
I'm a beginner, I'd like someone to help me understand a few lines of code My questions are: 1) Maybe String is an application of the constructor Maybe to the type String. What does it mean? Is there anything equivalent in the C language?
"Maybe" is the Haskell way to represent a value that might be Nothing (you can think of Nothing as analogous to C's null). A value of type (Maybe String) might be a String, or it might be Nothing. You usually use pattern matching to determine which one you're dealing with before you try to do anything with the value. In C, this would be something like checking whether a string pointer is null before you try to print it. Homework: http://learnyouahaskell.com/making-our-own-types-and-typeclasses (I recommend the whole book if you have time. A hard copy is available on Amazon.)
2) Is this a function with three arguments? *type T = [Char]* *type P = (Char, Maybe String)* *type Delta = ((Maybe Char, Char), Maybe String)* *fromGtoM :: T -> [P] -> [Delta]*
The type signature of this function shows both the arguments and its return value. To learn more, you should read, http://learnyouahaskell.com/higher-order-functions but basically, you can think of the last value in the type signature (e.g. [Delta], here) as the return value. The rest are arguments.
3) is this a usage of the above mentioned function? *fromGtoM t p = terminalRules ++ varRules*
We don't have enough information, but it doesn't look right.
I dont'see why the function has three arguments but then only two are used t p. 4) what does *++* mean ?
The "++" function just concatenates two lists. Strings are lists, so you might call it string concatenation too depending on the context.

On 7/2/11, moowoo9@fastmail.fm
4) what does ++ mean ?
When you want to know what a function does, a good place to look is http://www.haskell.org/hoogle/ Tom
participants (4)
-
David McBride
-
Michael Orlitzky
-
moowoo9@fastmail.fm
-
Tom Murphy