File: BangPatterns.hs

package info (click to toggle)
haskell-src-exts 1.23.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,852 kB
  • sloc: haskell: 13,707; makefile: 12
file content (8 lines) | stat: -rw-r--r-- 288 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
{-# LANGUAGE BangPatterns #-}
module BangPatterns where

firstnonspace :: Ptr Word8 -> Int -> Int -> IO Int
firstnonspace !ptr !n !m
    | n >= m    = return n
    | otherwise = do w <- peekElemOff ptr n
                     if isSpaceWord8 w then firstnonspace ptr (n+1) m else return n