que desea implementar el stripPrefixBy
siguiente función:clasificados Superior y impredicativas tipos
-- psuedo code signature
stripPrefixBy :: forall a. [forall b. a -> Maybe b] -> [a] -> Maybe [a]
stripPrefixBy [] xs = Just xs
stripPrefixBy _ [] = Nothing
stripPrefixBy (p:ps) (x:xs) = case p x of
Just _ -> stripPrefixBy ps xs
Nothing -> Nothing
res :: Maybe String
res = stripPrefixBy [const (Just 0), Just] "abc"
wantThisToBeTrue :: Bool
wantThisToBeTrue = case res of
Just "c" -> True
_ -> False
He intentado usar ImpredicativeTypes
y RankNTypes
pero sin suerte. ¿Cómo puedo implementar stripPrefixBy
con el tipo que quiero que tenga?
q Relacionados/a: http://stackoverflow.com/questions/19982295/practical-implications-of-runst-vs-unsafeperformio – crockeea