Re: [Haskell-cafe] Dynamic and equality

2013-07-21 Thread Alberto G. Corona
You can define: data EqDyn= forall a.(Typeable a, Eq a)= EqDyn a instance Eq EqDyn where (EqDyn x) == (EqDyn y)= typeOf x== typeOf y x== unsafeCoerce y unsafeCoerce is safe synce the expression assures that types are equal 2013/7/20 adam vogt vogt.a...@gmail.com On Sat, Jul 20, 2013 at

Re: [Haskell-cafe] Dynamic and equality

2013-07-20 Thread adam vogt
On Sat, Jul 20, 2013 at 12:31 AM, Carter Schonwald carter.schonw...@gmail.com wrote: the tricky part then is to add support for other types. another approach to existentially package type classes with the data type! eg data HasEq = forall a . HasEq ( Eq a = a) or its siblinng data HasEq a

Re: [Haskell-cafe] Dynamic and equality

2013-07-19 Thread adam vogt
On Fri, Jul 19, 2013 at 5:19 AM, Jose A. Lopes jabolo...@google.com wrote: Hello, How to define equality for Data.Dynamic ? Hi Jose, You could try casting the values to different types that do have an (==). You can treat the case where you have the types matching, but didn't list that type

Re: [Haskell-cafe] Dynamic and equality

2013-07-19 Thread Carter Schonwald
the tricky part then is to add support for other types. another approach to existentially package type classes with the data type! eg data HasEq = forall a . HasEq ( Eq a = a) or its siblinng data HasEq a = Haseq (Eq a = a ) note this requires more planning in how you structure your program,