2017-01-17 1 views

Antwort

1
null :: Foldable t => t a -> Bool 

Deshalb Vereinigung gibt

liftM null :: (Monad m, Foldable t) => m (t a) -> m Bool 

Dann liftM null id muss id, vereinigen die vom Typ ist b -> b, mit m (t a) wo m ist ein Monad und t ein Foldable ist. Zufällig ist der Typ ((->) r)defined as a Monad. Das bedeutet, dass der Typ id als m b geschrieben werden kann, wobei m((->) b) ist.

id :: b -> b 
id :: ((->) b) b -- this is the same as above 
-- m = ((->) b) 

Jetzt können b-t a spezialisiert, so dass wir den gewünschten Typ erhalten:

id :: ((->) (t a)) (t a) 
-- m = ((->) (t a)) 

Also zurück zu liftM null, haben wir:

liftM null :: Foldable t => ((->) (t a)) (t a) -> ((->) (t a)) Bool 

Oder, um es zu schreiben zurück in der üblichen Infix -> Formular,

liftM null :: Foldable t => (t a -> t a) -> t a -> Bool 

Der Rest ist klar - wir die obige Funktion id gelten

liftM null id :: Foldable t => t a -> Bool 
zu erhalten
Verwandte Themen