PolyTypeable jest analogiem Typeable dla typów polimorficznych. Ale to działa dość nieprzewidywalnie: kod źródłowypolyTypeOf jest tajemniczy
ghci> :t show
show :: Show a => a -> String
ghci> polyTypeOf show
a1 -> [Char]
ghci> :t fromEnum
fromEnum :: Enum a => a -> Int
ghci> polyTypeOf fromEnum
<interactive>:1:12:
Ambiguous type variable `a0' in the constraint:
(Enum a0) arising from a use of `fromEnum'
Probable fix: add a type signature that fixes these type variable(s)
In the first argument of `polyTypeOf', namely `fromEnum'
In the expression: polyTypeOf fromEnum
In an equation for `it': it = polyTypeOf fromEnum
Biblioteka jest dość trudne do zrozumienia, można wyjaśnić dlaczego polyTypeOf
zaakceptować pewien zbiór argumentów i nie akceptować innych, nawet bardzo podobne?
Dobry przykład. . – luqui
Dzięki, nie myślałem o tym, ponieważ 'polyTypeOf show' nie jest czymś domyślnym jak'() -> String'. – modular
I czy istnieje sposób na zrobienie 'polyTypeOf fromEnum' i podobnej pracy? może z ustawieniem 'default (...)' s? – Wizek