import Data.Char (digitToInt)

productFold :: Num a => Int -> [a] -> [a]
productFold _ [] = []
productFold n all@(_:xs) = 
  if length partialList == n
    then product partialList : (productFold n xs) 
    else []
  where partialList = take n all

main = do
  str <- readFile "number.txt"
  let number = map digitToInt $ concat $ lines str
  print $ maximum $ productFold 5 number

import Data.Char (digitToInt)

takeOrNone :: Int -> [a] -> [a]
takeOrNone n xs =
  if length taken == n
    then taken
    else []
  where taken = take n xs

productFold :: Num a => Int -> [a] -> [a]
productFold _ [] = []
productFold n all@(_:xs) = 
  let partialList = takeOrNone n all
  in  product partialList : (productFold n xs)

main = do
  str <- readFile "number.txt"
  let number = map digitToInt $ concat $ lines str
  print $ maximum $ productFold 5 number

Move take part of solution into seperate function to clean up code
Move take part of solution into seperate function to clean up code
