Hi Chris, Maybe this package (from Edward Kmett, surprisingly) could help: http://hackage.haskell.org/package/constraints-0.3.3/docs/Data-Constraint.html? Considering it kind of reifies the type class constraints, I'm wondering whether you could use this to carry the constraints along the value you're storing? I haven't given it a lot of thoughts for now, but maybe you can get something decent working with this?
On Fri, Oct 4, 2013 at 12:41 PM, Heinrich Apfelmus < apfel...@quantentunnel.de> wrote: > Christopher Done wrote: > >> On 4 October 2013 10:56, Heinrich Apfelmus <apfel...@quantentunnel.de> >> wrote: >> >>> In particular, the Locker stores arbitrary values like Dynamic , >>> except >>> that values are extracted and removed with the help of a Key . This gets >>> rid of the Typeable constraint. >>> >> >> lock :: Key a -> a -> Locker >> >> I can't pass anything with class constraints to that. >> > > I don't know what "something with a class constraint" means. But I guess > you want to pass a value with a *polymorphic* type? This is no problem, but > requires impredicative polymorphism: > > a = (forall b. Show b => b -> IO ()) > > lock :: Key (forall b. Show b => b -> IO ()) > -> (forall b. Show b => b -> IO ()) > -> Locker > > Unfortunately, GHC's support for that is a little shaky, but a solution > that always works is to put it in a new data type. > > data Dummy = Dummy { unDummy :: forall b. Show b => b -> IO () } > > lock :: Key Dummy -> Dummy -> Locker > > > It seems to me that your problem decomposes into two problems: > > 1. A heterogenous store for values of different types. > 2. Values with polymorphic instead of monomorphic types. > > Solution for problem 1 are usually restricted to monomorphic types, but > you can work around it. > > > > Best regards, > Heinrich Apfelmus > > -- > http://apfelmus.nfshost.com > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe<http://www.haskell.org/mailman/listinfo/haskell-cafe> > -- Alp Mestanogullari
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe