# Installing fxp with SML working versions

Kevin S. Millikin has documented the changes needed in fxp's sources in order to use it with the SML working version 110.43.

1. Download fxp-1.4.6;
2. Unpack the sources, and change to the fxp directory:

        gunzip -c fxp-1.4.6.tar.gz | tar xf -
        cd fxp-1.4.6

3. You need to do some modifications in the fxp's sources in order to account for the changes in the SML working version. For fxp 1.4.6 put the following patch working.diff in the fxp-1.4.6 directory and type:

           patch -p1 < working.diff

   Alternatively you can perform them by hand as it follows:
   1. Since the SML/NJ compilation manager (CM) is changed in the working version, it is necessary to specifically note the dependency on the SML Basis library (which is SML's standard libarary). Add the following line

              $/basis.cm

      to the end of all the necessary CM files. Those files are

          src/fxlib.cm
          src/Apps/Canon/canon.cm
          src/Apps/Copy/copy.cm
          src/Apps/Esis/esis.cm
          src/Apps/Null/null.cm
          src/Apps/Viz/viz.cm

   2. The signatures for Arrays and Vectors in the Basis library have changed, as of version 110.43. Functions in the `Vector` and `Array` structure which previously operated over slices now use the `VectorSlice` or `ArraySlice` structures. This necessitates a whole host of changes.
      1. In file `src/Util/utilString.sml`, line 233, change

                         Vector.foldri (fn (_,x,yet) => sep::X2String x::yet) [post] (vec,1,NONE))

         to

                          VectorSlice.foldri
                              (fn (_,x,yet) => sep::X2String x::yet)
                              [post]
                              (VectorSlice.slice (vec,1,NONE)))

      2. In file `src/Unicode/Chars/uniChar.sml`, line 111, change

                                 val cs1 = Vector.foldri
                                    (fn (_,c,cs) => c::cs) nil (vec,0,SOME (maxlen div 2))
                                 val cs2 = Vector.foldri
                                    (fn (_,c,cs) => c::cs) nil (vec,len-3-maxlen div 2,NONE)

         to

                                 val cs1 = VectorSlice.foldri
                                    (fn (_,c,cs) => c::cs)
                                    nil
                                    (VectorSlice.slice (vec,0,SOME (maxlen div 2)))
                                 val cs2 = VectorSlice.foldri
                                    (fn (_,c,cs) => c::cs)
                                    nil
                                    (VectorSlice.slice (vec,len-3-maxlen div 2,NONE))

      3. In file `src/Unicode/Chars/charClasses.sml`, line 94, change

                   fun finalize arr = Array.extract(arr,0,NONE)

         to

                   fun finalize arr = Array.vector arr

      4. In file `src\Unicode\Uri\uriEncode.sml`, line 76, change

                         nil (cv,0,NONE)

         to

                         nil cv

         and on line 88, make the same change.
      5. In file `src\Util\SymDict\dict.sml`, line 233, change

                         Array.appi addTo (oldTab,0,NONE)

         to

                         Array.appi addTo oldTab

         and on line 319, change

                       Array.appi
                       (fn (n,(key,value)) =>
                        print ("  "^Int.toString n^": "^Key.toString key^" = "^X2String value^"\n"))
                       (!tab,0,SOME (!count)))

         to

                       ArraySlice.appi
                       (fn (n,(key,value)) =>
                        print ("  "^Int.toString n^": "^Key.toString key^" = "^X2String value^"\n"))
                       (ArraySlice.slice(!tab,0,SOME (!count))))

      6. In file `src\Util\SymDict\symbolTable.sml`, line 222, change

                         val _ = Array.appi addToNew (!tab,0,NONE)

         to

                         val _ = Array.appi addToNew (!tab)

         and on line 303, change

                      Array.extract(!tab,0,SOME(!count))

         to

                      ArraySlice.vector(ArraySlice.slice(!tab,0,SOME(!count)))

         an on line 310, change

                       Array.appi
                       (fn (n,key) =>
                        print ("  "^Int.toString n^": "^Key.toString key^"\n"))
                       (!tab,0,SOME (!count)))

         to

                       ArraySlice.appi
                       (fn (n,key) =>
                        print ("  "^Int.toString n^": "^Key.toString key^"\n"))
                       (ArraySlice.slice(!tab,0,SOME (!count))))

      7. In file `src\Parser\Dfa\dfaString.sml`, line 71, change

                             (tab,0,NONE))

         to

                             tab)

         and on line 77, change

                         nil (tab,0,NONE))

         to

                         nil tab)

      8. In file `src\Parser\Params\dtd.sml`, line 293, change

                         val _ = Vector.appi
                            (fn (_,(name,lit,cs))
                             => (setGenEnt dtd (GenEnt2Index dtd name,(GE_INTERN(lit,cs),false))))
                            (predefined,1,NONE)

         to

                         val _ = VectorSlice.appi
                            (fn (_,(name,lit,cs))
                             => (setGenEnt dtd (GenEnt2Index dtd name,(GE_INTERN(lit,cs),false))))
                            (VectorSlice.slice (predefined,1,NONE))

      9. In file `src\Parser\Dtd\dtdAttributes.sml`, line 68, change

                      in Vector.tabulate(26,fn i => Array.extract (Array.sub(arr,i),0,NONE))

         to

                      in Vector.tabulate(26,fn i => Array.vector (Array.sub(arr,i)))

      10. In file `src\Util\intSets.sml`, line 53, change

                       in Vector.extract (vec,0,SOME max)

          to

                       in VectorSlice.vector(VectorSlice.slice (vec,0,SOME max))

          and line 52 from

                          (fn (i,w,max) => if w=0wx0 then i else max) 0 (vec,0,NONE)

          to

                          (fn (i,w,max) => if w=0wx0 then i else max) 0 vec

          and line 91 from

                             then Vector.mapi (fn (i,x) => if i=idx then x||mask else x) (vec,0,NONE)

          to

                             then Vector.mapi (fn (i,x) => if i=idx then x||mask else x) vec

          and line 104 from

                                             (fn (i,x) => if i=idx then x && mask else x) (vec,0,NONE)

          to

                                             (fn (i,x) => if i=idx then x && mask else x) vec

      11. In file `src\Parser\Dfa\dfaUtil.sml`, change line 127 from

                          (lo,hi,Array.extract (tab,0,NONE),fin)

          to

                          (lo,hi,Array.vector tab,fin)

      12. In file `src\Parser\Dfa\dfaPassTwo.sml`, change line 75 from

                       in Array.extract (table,0,NONE)

          to

                       in Array.vector table

      13. In file `src\Parser\Parse\parseContent.sml`, line 590, change

                                hookData(a,((!pos0,getPos q),Array.extract(dataBuffer,0,SOME i),false))

          to

                                hookData(a,((!pos0,getPos q),
                                            ArraySlice.vector(ArraySlice.slice(dataBuffer,0,SOME i)),
                                            false))

      14. In file `src\Apps\Copy\copyEncode.sml`, line 129, change

                          val f2 = Vector.foldli putOne f1 (cv,0,NONE)

          to

                          val f2 = Vector.foldli putOne f1 cv

4. Follow the installation instructions for fxp starting with step 3.