[Haskell-cafe] Re: Re: Reflective capabilities of Haskell (cont'd)

Jeff Polakow jeff.polakow at db.com
Wed Mar 12 15:06:29 EDT 2008


Hello,

> Thanks a lot, this helps a bit, but access to function bodies is exactly
> what I need. Or being more precise, I need the functionality of ghci's
> command ':t'. So functions that behave as follows, where everything is
> of course meta-represented in some way as ADT:
> 
>    Prelude Data.Typeable> typeOf  (\a -> (Just (a:"")))
>    (\a -> (Just (a:""))) :: Char -> Maybe [Char]
> 
>    Prelude Data.Typeable> getDomain $ typeOf (\a -> (Just (a:"")))
>    [Char]
> 
>    Prelude Data.Typeable>getCodomain $ typeOf (\a -> (Just (a:"")))
>    (Maybe [Char])
> 
Data.Typeable should allow for all of the previous.

>    Prelude Data.Typeable>getTypeConstructors (Maybe [Char])
>    [ (Just) :: [Char] -> Maybe [Char]
>    , (Nothing) :: Maybe [Char]
>    ]
> 
>    Prelude Data.Typeable>getTypeConstructors [Char]
>    [ (:) :: Char -> [Char] -> [Char]
>    , ([]) :: [Char]
>    ]
> 
Data.Generics allows you to do this (to a certain extent), i.e. there is a 
function 

    dataTypeConstrs :: DataType -> [Constr]

-Jeff


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080312/2df39a1e/attachment.htm


More information about the Haskell-Cafe mailing list