Christoph Bauer | 2 Jul 10:00 2005
Picon

New-bee question about seq in Parsec.Pos

Hi,

I try to understand, how Parsec works. In Pos.hs I found
these definition of SourcePos:

data SourcePos      = SourcePos SourceName !Line !Column
		     deriving (Eq,Ord)

My poor haskell knowledge says me, that Line and Column is
always strict. So, what does the following function?

forcePos :: SourcePos -> SourcePos      
forcePos pos <at> (SourcePos name line column)
    = seq line (seq column (pos))

thanks for an enlightenment,
Christoph Bauer

--

-- 
let () = let rec f a w i j = Printf.printf "%.20f\r" a; let a1 = a *. i /. j in
if w then f a1 false (i +. 2.0) j else f a1 true i (j +. 2.0) in f 2.0 false 2.0 1.0
Ketil Malde | 4 Jul 11:08 2005
Picon
Picon

Re: New-bee question about seq in Parsec.Pos

Christoph Bauer <ich <at> christoph-bauer.net> writes:

> data SourcePos      = SourcePos SourceName !Line !Column
> 		     deriving (Eq,Ord)

> My poor haskell knowledge says me, that Line and Column is
> always strict. 

Yes.

> So, what does the following function?

> forcePos :: SourcePos -> SourcePos      
> forcePos pos <at> (SourcePos name line column) = seq line (seq column (pos))

AFAICT, nothing.  My guess would be that it's an oversight (for
instance, it could be a remnant from a prevoius version where the data
type was non-strict).  Is 'forcePos' used much in the code?

-k
--

-- 
If I haven't seen further, it is by standing in the footprints of giants

Gmane