Re: Getting the constructor from flat curry

From: hema kumar <hemasid_at_gmail.com>
Date: Wed, 07 Jul 2010 14:56:40 -0700

Hi Gustavo,

Thanks for replying.

The program you edited does not do the task i require. For me Bintree.curry
is a separate program and in the future i need to write a program which
could give me the constructor from a file which I plan to dynamically
provide.

If you can please tell me what is the error in the program Sebastian mailed.
Do not get why it is giving the error i mailed in my last mail.

error corresponding to constructorNames.

Prelude> :l flatConstrs.curry
Parsing 'flatConstrs.curry'...
generating flatConstrs.fcy ...
cymake:
"flatConstrs.curry", line 4.2: Unexpected token identifier
`constructorNames'
ERROR occurred during parsing!
Prelude>

Thanks and Regards
Hema



On Tue, Jul 6, 2010 at 8:27 AM, Gustavo Arroyo Delgado
<garroyo_at_dsic.upv.es>wrote:

> hola a todos!
>
> I made a little change in Sebastian program:
>
> Prelude> :l BinTree
> Parsing 'BinTree.curry'...
> skipping BinTree.curry ...
> BinTree> :show
>
> import FlatCurry
> import FlatCurryGoodies
>
>
> data BinTree a = Leaf | Branch a (BinTree a) (BinTree a)
>
> getNames p = do progFlat <- readFlatCurry p
> let cN = constructorNames progFlat
> putStrLn (show cN)
>
>
> constructorNames :: Prog -> [QName]
> constructorNames prog = [ name | typ <- progTypes prog, name <- consNames
> typ ]
> where
> consNames typ = [ consName cons | not (isTypeSyn typ), cons <-
> typeConsDecls typ ]
> BinTree> getNames "BinTree"
> [("BinTree","Leaf"),("BinTree","Branch")]
> BinTree>
>
>
> I'm using "BinTree" file as program as well as getName's argument...
>
>
>
> hasta luego...
>
>
>
> Quoting hema kumar <hemasid_at_gmail.com>:
>
> Hi Sebastian,
>> Thanks for the effort for explaining me regarding the program. Really
>> appreciate your help
>>
>> But, I m still getting the same error corresponding to constructorNames.
>>
>> Prelude> :l flatConstrs.curry
>> Parsing 'flatConstrs.curry'...
>> generating flatConstrs.fcy ...
>> cymake:
>> "flatConstrs.curry", line 4.2: Unexpected token identifier
>> `constructorNames'
>> ERROR occurred during parsing!
>> Prelude>
>>
>> Please help.
>> Thanks
>> Hema
>>
>>
>> On Fri, Jul 2, 2010 at 1:28 AM, Sebastian Fischer <
>> sebf_at_informatik.uni-kiel.de> wrote:
>>
>> Hi Hema,
>>>
>>>
>>> On Jul 1, 2010, at 11:58 PM, hema kumar wrote:
>>>
>>> I m trying to catch a constructor of a small program given below named
>>>
>>>> BinTree.curry
>>>>
>>>> data BinTree a = Leaf | Branch a (BinTree a) (BinTree a)
>>>>
>>>> The constructors will be Branch and Leaf.
>>>>
>>>>
>>>> I tried to execute the program you gave in your last mail:
>>>> [...]
>>>>
>>>> I m getting an error corresponding to constructorNames. It seems to me
>>>> that its a user defined fuction.
>>>>
>>>>
>>> Which error do you get? Did you load the program which contains
>>> `constuctorNames` into PAKCS?
>>>
>>>
>>> Please tell me how should I go about it further. Do i have to specify the
>>>
>>>> file name as BinTree.fcy or BinTree.curry??
>>>>
>>>>
>>> The module FlatCurry contains a function `readFlatCurry :: String -> IO
>>> Prog` that takes a module name (without suffix) and returns the
>>> corresponding FlatCurry program. You can test my program as follows:
>>>
>>> # cat BinTree.curry
>>>
>>> data BinTree a = Leaf | Branch a (BinTree a) (BinTree a)
>>>
>>> # cat flatConstrs.curry
>>>
>>> import FlatCurry
>>> import FlatCurryGoodies
>>>
>>> constructorNames :: Prog -> [QName]
>>> constructorNames prog =
>>> [ name | typ <- progTypes prog, name <- consNames typ ]
>>> where
>>> consNames typ =
>>> [ consName cons | not (isTypeSyn typ), cons <- typeConsDecls typ ]
>>>
>>> # pakcs
>>> [...]
>>> Prelude> :l flatConstrs.curry
>>> [...]
>>> flatConstrs> readFlatCurry "BinTree" >>= print . constructorNames
>>> [("BinTree","Leaf"),("BinTree","Branch")]
>>>
>>> hope that helps,
>>>
>>> Sebastian
>>>
>>> --
>>> Underestimating the novelty of the future is a time-honored tradition.
>>> (D.G.)
>>>
>>>
>>>
>>>
>>>
>>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>



_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Do Jul 08 2010 - 09:20:30 CEST

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:10 CEST