summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_compile/T10602b.hs
blob: f90ad0a783194df0e0b7fa825c146271502c357d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE NoImplicitPrelude #-}
module T10602b (splitAt, map, foldr) where

import GHC.Classes
import GHC.Types
import GHC.Num
import GHC.Base

splitAt                :: Int -> [a] -> ([a],[a])
splitAt n ls
  | n <= 0 = ([], ls)
  | otherwise          = splitAt' n ls
    where
        splitAt' :: Int -> [a] -> ([a], [a])
        splitAt' _  []     = ([], [])
        splitAt' 1  (x:xs) = ([x], xs)
        splitAt' m  (x:xs) = (x:xs', xs'')
          where
            (xs', xs'') = splitAt' (m - 1) xs