Last active
November 13, 2015 18:45
-
-
Save mightybyte/ae26c9b9d7bef0419b0f to your computer and use it in GitHub Desktop.
Get all of a function's arguments and return value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getArgs :: Type -> [Type] | |
getArgs (ForallT _ _ t) = getArgs t | |
getArgs (SigT t _) = getArgs t | |
getArgs (AppT (AppT ArrowT a) b) = a : getArgs b | |
getArgs b = [b] | |
-- Possible lens version | |
prismCase [ _ForallT . _3 :-> getArgs, _SigT . _1 :-> getArgs, _AppAppArrow :-> \(a,b) -> a : getArgs b, id :-> \b -> [b] ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment