{-# htermination (takeWhile :: (a -> MyBool) -> (List a) -> (List a)) #-} import qualified Prelude data MyBool = MyTrue | MyFalse data List a = Cons a (List a) | Nil otherwise :: MyBool; otherwise = MyTrue; takeWhile0 p x xs MyTrue = Nil; takeWhile1 p x xs MyTrue = Cons x (takeWhile p xs); takeWhile1 p x xs MyFalse = takeWhile0 p x xs otherwise; takeWhile2 p (Cons x xs) = takeWhile1 p x xs (p x); takeWhile3 p Nil = Nil; takeWhile3 vx vy = takeWhile2 vx vy; takeWhile :: (a -> MyBool) -> (List a) -> (List a); takeWhile p Nil = takeWhile3 p Nil; takeWhile p (Cons x xs) = takeWhile2 p (Cons x xs);