[Haskell-cafe] A model theory question

Patrick Browne patrick.browne at dit.ie
Tue Sep 28 06:03:15 EDT 2010

Alexander Solla wrote:
> Doing similar constructions with type classes is possible.  I think you
> might have to use witness types (or even a nice functorial wrapper
> around your target value in the original algebra, or both) to do
> generalizations of type classes.  For example:
> class Uneditable obj where
>       a :: a -> obj
>       b :: b -> obj
> class Refactored obj witness where
>       a' :: Maybe (a -> obj)
>       b' :: Maybe (a -> obj)
> data EmptyFilter -- I think the name of the extension needed for this is
> 'EmptyDataDecls'
> data NoA
> data NoB
> instance Uneditable obj => Refactored obj EmptyFilter where a' = Just a;
> b' = Just b
> instance Uneditable obj => Refactored obj NoA where a' = Nothing; b' =
> Just b
Thank you for your excellent explanation and example. Due to my lack of
knowledge, I do not fully understand what is going in the example.

I had a look at the types of a and a’.
*Main> :t a
a :: forall a obj. (Uneditable obj) => a -> obj
*Main> :t a'
a' :: forall witness a obj. (Refactored obj witness) => Maybe (a -> obj)

Could you explain the example a little more.

Apologies for my slowness.

This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie

More information about the Haskell-Cafe mailing list