Skip to content

Instantly share code, notes, and snippets.

@mightybyte
Last active November 13, 2015 18:45
Show Gist options
  • Save mightybyte/ae26c9b9d7bef0419b0f to your computer and use it in GitHub Desktop.
Save mightybyte/ae26c9b9d7bef0419b0f to your computer and use it in GitHub Desktop.
Get all of a function's arguments and return value
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