Maybe Monad
type Transaction = [Char] -- or String
type Account = [Char] -- or String-- helper functions for finding transactions/accounts that may fail
findTransaction :: Transaction -> Maybe Transaction
findOriginAccount :: Transaction -> Maybe Account
findDestinationAccount :: Transaction -> Maybe Account
findAccounts :: Transaction -> Maybe (Account, Account)
findAccounts t =
case findTransaction t of
Nothing -> Nothing
Just t ->
case findOriginAccount t of
Nothing -> Nothing
Just originAcc ->
case findDestinationAccount t of
Nothing -> Nothing
Just destinationAcc ->
Just (originAcc, destinationAcc)Last updated