         8 read trim-string oct> >>devminor
         155 read-c-string >>prefix ;
 
-: checksum-header ( seq -- n )
-    148 cut-slice 8 tail-slice [ sum ] bi@ + 256 + ;
+TYPED: checksum-header ( seq: byte-array -- n )
+    148 cut-slice 8 tail-slice [ 0 [ + ] reduce ] bi@ + 256 + >fixnum ;
 
 : read-data-blocks ( tar-header -- )
     dup size>> 0 > [

: trim-string ( seq -- newseq ) [ "\0 " member? ] trim ;

: read-c-string ( n -- str/f )
    read [ zero? ] trim-tail [ f ] when-empty >string ;

: read-tar-header ( -- obj )
    \ tar-header new

USING: accessors byte-arrays combinators io io.backend
io.directories io.encodings.binary io.files io.files.links
io.pathnames io.streams.byte-array io.streams.string kernel
math math.parser namespaces sequences strings summary
typed ;
IN: tar

CONSTANT: zero-checksum 256
