|
Hello,
I 'm developing a new language in haskell and I need someone to help me. Anyone would like to help? _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
Is the language secret? because I'm sure lots of people would like to help on this mailing list, but you'd need to tell us what help you need first :)
On Sun, Oct 3, 2010 at 8:38 PM, Eduardo Ribeiro <[hidden email]> wrote: Hello, _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
No, it is not secret. I'm having trouble to define functions. Take a look at my code(please be gentle)hai1.hs
|
|
c8h10n4o2 wrote:
> No, it is not secret. I'm having trouble to define functions. Take a look > at my code(please be gentle) > http://haskell.1045720.n5.nabble.com/file/n3100036/hai1.hs hai1.hs Can you explain in a few words what the Func constructor should represent why it has three arguments? I ask because I am not sure whether it represents function definition or function call. Maybe yuou can give a small example for a function definition as well as a function application (call) in your Hai language. Cheers Ben _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
The problem is there. A function in Hai would be function-name, arg1,argn=body.
Func stores function name,arguments and body as Strings(I was thinking to put Func String String String). The parser func that I wrote so far try to parse a function definition, not a function call. But when I try to store the function on my Map I get a error with somthing called 'functional dependencies'(which I don't know what is). |
|
c8h10n4o2 wrote:
> The problem is there. A function in Hai would be function-name, > arg1,argn=body. > Func stores function name,arguments and body as Strings(I was thinking to > put Func String String String). > The parser func that I wrote so far try to parse a function definition, > not a function call. > But when I try to store the function on my Map I get a error with somthing > called 'functional dependencies'(which I don't know what is). You mean: hai1.hs:41:6: Couldn't match expected type `Hai' against inferred type `[Hai]' Expected type: Map.Map Hai Hai Inferred type: Map.Map [Hai] Hai When using functional dependencies to combine MonadState (Map.Map [Hai] Hai) m, arising from a use of `get' at hai1.hs:52:17-19 MonadState (Map.Map Hai Hai) m, arising from a use of `get' at hai1.hs:47:16-18 When generalising the type(s) for `w' The type checker tells you that you are using the same Map with different key types: at 52:17-19 the key has type [Hai], whereas at 47:16-18 it has type Hai. The latter is in your Func case: e <-return $ Map.insert (a :[b]) c d where you use a :[b] which is the same as [a,b] for the key. Everywhere else, the key has type Hai. This in itself is questionable: do you really want to use arbitrary expressions as keys? Usually one would have a Map String Hai representing a map from variable (or function) names to expressions. For functions you then want data Hai = ... | Func [String] Hai | ... so that Func args body represents the (anonymous) function with the formal arguments args and the resulting expression body . The function gets a name by inserting it into the variable map. This means that a definition function-name,arg1,...,argn=body actually defines a variable named "function-name" which, when it gets looked up in the environment, yields the value Func [arg1,...,argn] body . Cheers Ben _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
Ben Franksen wrote:
> The type checker tells you that you are using the same Map with different > key types: at 52:17-19 the key has type [Hai], whereas at 47:16-18 it has > type Hai. > > The latter is in your Func case: s/latter/former/ _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
And why
b <- between (char ',') (char '=') (sepBy alphaNum (char ',') ) does not return [String] ? |
|
On 4 October 2010 23:10, c8h10n4o2 <[hidden email]> wrote:
sepBy :: Parser a -> Parser sep -> Parser [a]
sepBy alphaNum sepP :: Parser [Char] or Parser String but not Parser [String]
between :: Parser open -> Parser close -> Parser a -> Parser a between openP closeP (sepBy alphaNum sepP) :: Parser String
Hope this helps, Ozgur
_______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
I read the parsec documentation and saw my mistake.
By the way, there is a parser that returns [String] for my case? |
|
On 4 October 2010 23:54, c8h10n4o2 <[hidden email]> wrote:
If you are trying to parse strings (of alphaNum's) separated by commas, you can use "many alphaNum" (or "many1 alphaNum" depending on what you want) instead of simply using alphaNum. The type of the complete parser will then be Parser [String].
alphaNum :: Parser Char
alphaNums :: Parser String alphaNums = many alphaNum
alphaNums1 :: Parser String alphaNums1 = many1 alphaNum
Ozgur _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
| Powered by Nabble | Edit this page |
