platformFromTriple :: String -> Maybe Platform
platformFromTriple triple =
  fmap fst (listToMaybe $ Parse.readP_to_S parseTriple triple)
  where parseWord = Parse.munch1 (\c -> Char.isAlphaNum c || c == '_')
        parseTriple = do
          arch <- fmap (classifyArch Strict) parseWord
          _ <- Parse.char '-'
          _ <- parseWord -- Skip vendor
          _ <- Parse.char '-'
          os <- fmap (classifyOS Compat) ident -- OS may have hyphens, like
                                               -- 'nto-qnx'
          return $ Platform arch os
platformFromTriple :: String -> Maybe Platform
platformFromTriple triple =
  fmap fst (listToMaybe $ Parse.readP_to_S parseTriple triple)
  where parseWord = Parse.munch1 (\c -> Char.isAlphaNum c || c == '_')
        parseTriple = do
          arch <- fmap (classifyArch Strict) parseWord
          _ <- Parse.char '-'
          _ <- parseWord -- Skip vendor
          _ <- Parse.char '-'
          os <- fmap (classifyOS Compat) ident -- OS may have hyphens, like
                                               -- 'nto-qnx'
          return $ Platform arch os
platformFromTriple triple =
  fmap fst (listToMaybe $ Parse.readP_to_S parseTriple triple)
  where parseWord = Parse.munch1 (\c -> Char.isAlphaNum c || c == '_')
        parseTriple = do
          arch <- fmap (classifyArch Strict) parseWord
          _ <- Parse.char '-'
          _ <- parseWord -- Skip vendor
          _ <- Parse.char '-'
          os <- fmap (classifyOS Compat) ident -- OS may have hyphens, like
                                               -- 'nto-qnx'
          return $ Platform arch os