Re: Getting the constructor from flat curry

From: Gustavo Arroyo Delgado <garroyo_at_dsic.upv.es>
Date: Tue, 06 Jul 2010 17:27:46 +0200

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 Tue Jul 06 2010 - 17:29:48 CEST

This archive was generated by hypermail 2.3.0 : Mon Nov 18 2019 - 07:15:07 CET