1-- SPDX-FileCopyrightText: 2025 Sören Tempel <soeren+git@soeren-tempel.net>2--3-- SPDX-License-Identifier: GPL-3.0-only45module Language.QBE.Backend6 ( SolverError (..),7 prefixLength,8 )9where1011import Control.Exception (Exception)1213data SolverError14 = UnknownResult15 deriving (Show)1617instance Exception SolverError1819------------------------------------------------------------------------2021-- | Determine the length of the common prefix of two lists.22prefixLength :: (Eq a) => [a] -> [a] -> Int23prefixLength = prefixLength' 024 where25 prefixLength' :: (Eq a) => Int -> [a] -> [a] -> Int26 prefixLength' n [] _ = n27 prefixLength' n _ [] = n28 prefixLength' n (x : xs) (y : ys)29 | x == y = prefixLength' (n + 1) xs ys30 | otherwise = n