 : make-8-bit ( word byte>ch ch>byte -- )
     [ 8-bit construct-boa ] 2curry dupd curry define ;
 
-: define-8-bit-encoding ( name path -- )
+: define-8-bit-encoding ( name stream -- )
     >r in get create r> parse-file make-8-bit ;
 
 PRIVATE>
 
 [
     "io.encodings.8-bit" in [
-        mappings [ full-path define-8-bit-encoding ] assoc-each
+        mappings [ encoding-file define-8-bit-encoding ] assoc-each
     ] with-variable
 ] with-compilation-unit

    { "mac-roman" "ROMAN" }
} ;

: full-path ( file-name -- path )
    "extra/io/encodings/8-bit/" ".TXT"
    swapd 3append resource-path ;

: tail-if ( seq n -- newseq )
    2dup swap length <= [ tail ] [ drop ] if ;

: ch>byte ( assoc -- newassoc )
    [ swap ] assoc-map >hashtable ;

: parse-file ( path -- byte>ch ch>byte )
    lines process-contents
    [ byte>ch ] [ ch>byte ] bi ;

TUPLE: 8-bit name decode encode ;
