On Sun, Dec 4, 2011 at 3:53 AM, Scott Lawrence <[email protected]> wrote:
> type AList = [Event]
> type BList = [Event]
> type CList = [Event]
>
> myMapish :: AList -> AList
> mySelect :: AList -> (Event -> Bool) -> BList
> myOtherSelect :: BList -> CList
A suggestion:
data Exists f = forall a. Exists f a
data List a = List [Event] -- your list type
myMapish :: List a -> List a
myDoSomething :: List a -> (List a, List a)
myPair :: (Event -> Event -> Event) -> List a -> List a -> List a
mySelect :: List a -> Exists List
So the "anonymous, unique type" would be enclosed on the existential.
Its real type doesn't really matter, it may be always (), but code
that uses mySelect can't use this fact. It's not able to do even
something simple like
let Exists b = mySelect a
Exists c = mySelect a
in myPair f b c
even though we know that in this case this is valid =). But you can always make
unsafeCastList :: List a -> List b
unsafeCastList (List a) = List a
Cheers,
--
Felipe.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe