"John Ky" <newho...@gmail.com> writes:

> Hi,
>
> Possibly a silly question but is it possible to have a function that has a
> different return type based on it's first argument?

Are you sure that's what you really want?

> For instance
>
> data Person = Person { name :: String, ... }
> data Business = Business { business_number :: Int, ...}

data Entity = Person {...} | Business {...}

> key person = name person
> key business = business_number business

data Key = PersonKey String | BusinessKey Int

It seems likely that you are at least sometimes going to
want to pass the result of key to some other function.

...?

-- 
Jón Fairbairn                                 jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2008-04-26)

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to