Is ApplicativeDo with irrefutable pattern matches a performance pitfall?
It is common to write code like data FileHierarchy = FileHierarchy { .. } -- only one constructor getUserAttributes :: IO (String, [Permission]) getCurrentDirectoryInfo :: IO FileHierarchy countUserWritableFiles :: IO Int countUserWritableFiles = do (name, permissions) <- getUserAttributes FileHierarchy{directoryName=dirName, directoryContents=dirConts} <- getCurrentDirectoryInfo return $ length [{- Those of `dirConts` that user `name` is allowed to write with the `permissions` -}] Observe that none of the matched variables are used in a subsequent IO action, so this can be written with only A
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.