mkTTName :: FC -> Name -> PTerm
mkTTName fc n =
    let mkList fc []     = PRef fc [] (sNS (sUN "Nil") ["List", "Prelude"])
        mkList fc (x:xs) = PApp fc (PRef fc [] (sNS (sUN "::") ["List", "Prelude"]))
                                   [ pexp (stringC x)
                                   , pexp (mkList fc xs)]
        stringC = PConstant fc . Str . str
        intC = PConstant fc . I
        reflm n = sNS (sUN n) ["Reflection", "Language"]
    in case n of
         UN nm     -> PApp fc (PRef fc [] (reflm "UN")) [ pexp (stringC nm)]
         NS nm ns  -> PApp fc (PRef fc [] (reflm "NS")) [ pexp (mkTTName fc nm)
                                                        , pexp (mkList fc ns)]
         MN i nm   -> PApp fc (PRef fc [] (reflm "MN")) [ pexp (intC i)
                                                        , pexp (stringC nm)]
         _ -> error "Invalid name from user syntax for DSL name"
mkTTName :: FC -> Name -> PTerm
mkTTName fc n =
    let mkList fc []     = PRef fc [] (sNS (sUN "Nil") ["List", "Prelude"])
        mkList fc (x:xs) = PApp fc (PRef fc [] (sNS (sUN "::") ["List", "Prelude"]))
                                   [ pexp (stringC x)
                                   , pexp (mkList fc xs)]
        stringC = PConstant fc . Str . str
        intC = PConstant fc . I
        reflm n = sNS (sUN n) ["Reflection", "Language"]
    in case n of
         UN nm     -> PApp fc (PRef fc [] (reflm "UN")) [ pexp (stringC nm)]
         NS nm ns  -> PApp fc (PRef fc [] (reflm "NS")) [ pexp (mkTTName fc nm)
                                                        , pexp (mkList fc ns)]
         MN i nm   -> PApp fc (PRef fc [] (reflm "MN")) [ pexp (intC i)
                                                        , pexp (stringC nm)]
         _ -> error "Invalid name from user syntax for DSL name"
mkTTName fc n =
    let mkList fc []     = PRef fc [] (sNS (sUN "Nil") ["List", "Prelude"])
        mkList fc (x:xs) = PApp fc (PRef fc [] (sNS (sUN "::") ["List", "Prelude"]))
                                   [ pexp (stringC x)
                                   , pexp (mkList fc xs)]
        stringC = PConstant fc . Str . str
        intC = PConstant fc . I
        reflm n = sNS (sUN n) ["Reflection", "Language"]
    in case n of
         UN nm     -> PApp fc (PRef fc [] (reflm "UN")) [ pexp (stringC nm)]
         NS nm ns  -> PApp fc (PRef fc [] (reflm "NS")) [ pexp (mkTTName fc nm)
                                                        , pexp (mkList fc ns)]
         MN i nm   -> PApp fc (PRef fc [] (reflm "MN")) [ pexp (intC i)
                                                        , pexp (stringC nm)]
         _ -> error "Invalid name from user syntax for DSL name"