Hi Zsolt, fs :: (((a, a) -> a) -> t) -> (t, t) fs g = (g fst, g snd) examples = (fs fmap, fs liftA, fs liftM, fs id, fs ($(1,"2")), fs ((,)id), fs (:[]), fs repeat)
No instance for (Num [Char]) arising from the literal `1' at M.hs:6:54 Possible fix: add an instance declaration for (Num [Char]) In the expression: 1 In the second argument of `($)', namely `(1, "2")' In the first argument of `fs', namely `($ (1, "2"))' Anyways, this signature is not what intended. I want it to work for all tuples, regardless of their element types. Thanks Vladimir On 6/7/09, Zsolt Dollenstein <zsol.z...@gmail.com> wrote: > On Sun, Jun 7, 2009 at 9:17 AM, Vladimir > Reshetnikov<v.reshetni...@gmail.com> wrote: >> Hi Zsolt, >> >> It does not compiles with GHC without type annotations. > > It does with mine: The Glorious Glasgow Haskell Compilation System, version > 6.10.2 > > Anyway, try this: fs :: (((a, a) -> a) -> t) -> (t, t) > >> >> Thanks, >> Vladimir >> >> On 6/7/09, Zsolt Dollenstein <zsol.z...@gmail.com> wrote: >>> Hi Vladimir, >>> >>> On Sun, Jun 7, 2009 at 12:06 AM, Vladimir >>> Reshetnikov<v.reshetni...@gmail.com> wrote: >>>> Hi, >>>> >>>> I have the following code: >>>> >>>> -------------------------------------------------------------------------------- >>>> fs g = (g fst, g snd) >>>> examples = (fs fmap, fs liftA, fs liftM, fs id, fs ($(1,"2")), fs >>>> ((,)id), fs (:[]), fs repeat) >>>> -------------------------------------------------------------------------------- >>>> >>>> The idea is that fs accepts a polymorphic function as its argument. >>>> What type signature can I specify for f in order to compile this code? >>> >>> Have you tried putting the above into ghci for example, then asking for >>> ":t >>> fs"? >>> Or am I misunderstanding your point? >>> >>> Cheers, >>> Zsolt >>> >>>> If it is not possible in Haskell, is there another language with >>>> static typing which allows this? >>>> >>>> Thanks, >>>> Vladimir >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >> > > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe