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

Jeff Polakow jeff.polakow at db.com
Wed Mar 12 15:59:36 EDT 2008


Hello,

> >    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] 
> 
It might be hard, or even impossible, to get Data.Typeable and 
Data.Generics to play with each other. There seems to be no good way of 
converting a Data.Typeable.TypeRep to a Data.Generics.Basics.DataType.

Another option might be to use Language.Haskell.Parser and 
Language.Haskell.Syntax, but I have little experience with this and am not 
sure if you'll be able to do what you want.

-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/9c8cc54a/attachment.htm


More information about the Haskell-Cafe mailing list