{-# LANGUAGE DeriveGeneric     #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}

{- |
Module      : Language.Egison.IExpr
Licence     : MIT

This module defines internal representation of Egison language.
-}

module Language.Egison.IExpr
  ( ITopExpr (..)
  , IExpr (..)
  , IPattern (..)
  , ILoopRange (..)
  , IBindingExpr
  , IMatchClause
  , IPatternDef
  , IPrimitiveDataPattern
  , Var (..)
  , stringToVar
  , extractNameFromVar
  , Index (..)
  , extractSupOrSubIndex
  , extractIndex
  , makeIApply
  -- Re-export from AST
  , ConstantExpr (..)
  , PMMode (..)
  , PrimitivePatPattern (..)
  , PDPatternBase (..)
  ) where

import           Data.Hashable
import           GHC.Generics        (Generic)

import           Language.Egison.AST (ConstantExpr (..), PDPatternBase (..), PMMode (..), PrimitivePatPattern (..))

data ITopExpr
  = IDefine Var IExpr
  | ITest IExpr
  | IExecute IExpr
  | ILoadFile String
  | ILoad String
  deriving Int -> ITopExpr -> ShowS
[ITopExpr] -> ShowS
ITopExpr -> String
(Int -> ITopExpr -> ShowS)
-> (ITopExpr -> String) -> ([ITopExpr] -> ShowS) -> Show ITopExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ITopExpr] -> ShowS
$cshowList :: [ITopExpr] -> ShowS
show :: ITopExpr -> String
$cshow :: ITopExpr -> String
showsPrec :: Int -> ITopExpr -> ShowS
$cshowsPrec :: Int -> ITopExpr -> ShowS
Show

data IExpr
  = IConstantExpr ConstantExpr
  | IVarExpr String
  | IIndexedExpr Bool IExpr [Index IExpr]
  | ISubrefsExpr Bool IExpr IExpr
  | ISuprefsExpr Bool IExpr IExpr
  | IUserrefsExpr Bool IExpr IExpr
  | IInductiveDataExpr String [IExpr]
  | ITupleExpr [IExpr]
  | ICollectionExpr [IExpr]
  | IConsExpr IExpr IExpr
  | IJoinExpr IExpr IExpr
  | IHashExpr [(IExpr, IExpr)]
  | IVectorExpr [IExpr]
  | ILambdaExpr (Maybe Var) [Var] IExpr
  | IMemoizedLambdaExpr [String] IExpr
  | ICambdaExpr String IExpr
  | IPatternFunctionExpr [String] IPattern
  | IIfExpr IExpr IExpr IExpr
  | ILetRecExpr [IBindingExpr] IExpr
  | ILetExpr [IBindingExpr] IExpr
  | IWithSymbolsExpr [String] IExpr
  | IMatchExpr PMMode IExpr IExpr [IMatchClause]
  | IMatchAllExpr PMMode IExpr IExpr [IMatchClause]
  | IMatcherExpr [IPatternDef]
  | IQuoteExpr IExpr
  | IQuoteSymbolExpr IExpr
  | IWedgeApplyExpr IExpr [IExpr]
  | IDoExpr [IBindingExpr] IExpr
  | ISeqExpr IExpr IExpr
  | IApplyExpr IExpr [IExpr]
  | ICApplyExpr IExpr IExpr
  | IGenerateTensorExpr IExpr IExpr
  | ITensorExpr IExpr IExpr
  | ITensorContractExpr IExpr
  | ITensorMapExpr IExpr IExpr
  | ITensorMap2Expr IExpr IExpr IExpr
  | ITransposeExpr IExpr IExpr
  | IFlipIndicesExpr IExpr
  | IFunctionExpr [String]
  deriving Int -> IExpr -> ShowS
[IExpr] -> ShowS
IExpr -> String
(Int -> IExpr -> ShowS)
-> (IExpr -> String) -> ([IExpr] -> ShowS) -> Show IExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IExpr] -> ShowS
$cshowList :: [IExpr] -> ShowS
show :: IExpr -> String
$cshow :: IExpr -> String
showsPrec :: Int -> IExpr -> ShowS
$cshowsPrec :: Int -> IExpr -> ShowS
Show

type IBindingExpr = (IPrimitiveDataPattern, IExpr)
type IMatchClause = (IPattern, IExpr)
type IPatternDef  = (PrimitivePatPattern, IExpr, [(IPrimitiveDataPattern, IExpr)])
type IPrimitiveDataPattern = PDPatternBase Var

data IPattern
  = IWildCard
  | IPatVar String
  | IValuePat IExpr
  | IPredPat IExpr
  | IIndexedPat IPattern [IExpr]
  | ILetPat [IBindingExpr] IPattern
  | INotPat IPattern
  | IAndPat IPattern IPattern
  | IOrPat IPattern IPattern
  | IForallPat IPattern IPattern
  | ITuplePat [IPattern]
  | IInductivePat String [IPattern]
  | ILoopPat String ILoopRange IPattern IPattern
  | IContPat
  | IPApplyPat IExpr [IPattern]
  | IVarPat String
  | IInductiveOrPApplyPat String [IPattern]
  | ISeqNilPat
  | ISeqConsPat IPattern IPattern
  | ILaterPatVar
  -- For symbolic computing
  | IDApplyPat IPattern [IPattern]
  deriving Int -> IPattern -> ShowS
[IPattern] -> ShowS
IPattern -> String
(Int -> IPattern -> ShowS)
-> (IPattern -> String) -> ([IPattern] -> ShowS) -> Show IPattern
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IPattern] -> ShowS
$cshowList :: [IPattern] -> ShowS
show :: IPattern -> String
$cshow :: IPattern -> String
showsPrec :: Int -> IPattern -> ShowS
$cshowsPrec :: Int -> IPattern -> ShowS
Show

data ILoopRange = ILoopRange IExpr IExpr IPattern
  deriving Int -> ILoopRange -> ShowS
[ILoopRange] -> ShowS
ILoopRange -> String
(Int -> ILoopRange -> ShowS)
-> (ILoopRange -> String)
-> ([ILoopRange] -> ShowS)
-> Show ILoopRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ILoopRange] -> ShowS
$cshowList :: [ILoopRange] -> ShowS
show :: ILoopRange -> String
$cshow :: ILoopRange -> String
showsPrec :: Int -> ILoopRange -> ShowS
$cshowsPrec :: Int -> ILoopRange -> ShowS
Show

data Index a
  = Sub a
  | Sup a
  | MultiSub a Integer a
  | MultiSup a Integer a
  | SupSub a
  | User a
  | DF Integer Integer
  deriving (Int -> Index a -> ShowS
[Index a] -> ShowS
Index a -> String
(Int -> Index a -> ShowS)
-> (Index a -> String) -> ([Index a] -> ShowS) -> Show (Index a)
forall a. Show a => Int -> Index a -> ShowS
forall a. Show a => [Index a] -> ShowS
forall a. Show a => Index a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Index a] -> ShowS
$cshowList :: forall a. Show a => [Index a] -> ShowS
show :: Index a -> String
$cshow :: forall a. Show a => Index a -> String
showsPrec :: Int -> Index a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Index a -> ShowS
Show, Index a -> Index a -> Bool
(Index a -> Index a -> Bool)
-> (Index a -> Index a -> Bool) -> Eq (Index a)
forall a. Eq a => Index a -> Index a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Index a -> Index a -> Bool
$c/= :: forall a. Eq a => Index a -> Index a -> Bool
== :: Index a -> Index a -> Bool
$c== :: forall a. Eq a => Index a -> Index a -> Bool
Eq, a -> Index b -> Index a
(a -> b) -> Index a -> Index b
(forall a b. (a -> b) -> Index a -> Index b)
-> (forall a b. a -> Index b -> Index a) -> Functor Index
forall a b. a -> Index b -> Index a
forall a b. (a -> b) -> Index a -> Index b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Index b -> Index a
$c<$ :: forall a b. a -> Index b -> Index a
fmap :: (a -> b) -> Index a -> Index b
$cfmap :: forall a b. (a -> b) -> Index a -> Index b
Functor, Index a -> Bool
(a -> m) -> Index a -> m
(a -> b -> b) -> b -> Index a -> b
(forall m. Monoid m => Index m -> m)
-> (forall m a. Monoid m => (a -> m) -> Index a -> m)
-> (forall m a. Monoid m => (a -> m) -> Index a -> m)
-> (forall a b. (a -> b -> b) -> b -> Index a -> b)
-> (forall a b. (a -> b -> b) -> b -> Index a -> b)
-> (forall b a. (b -> a -> b) -> b -> Index a -> b)
-> (forall b a. (b -> a -> b) -> b -> Index a -> b)
-> (forall a. (a -> a -> a) -> Index a -> a)
-> (forall a. (a -> a -> a) -> Index a -> a)
-> (forall a. Index a -> [a])
-> (forall a. Index a -> Bool)
-> (forall a. Index a -> Int)
-> (forall a. Eq a => a -> Index a -> Bool)
-> (forall a. Ord a => Index a -> a)
-> (forall a. Ord a => Index a -> a)
-> (forall a. Num a => Index a -> a)
-> (forall a. Num a => Index a -> a)
-> Foldable Index
forall a. Eq a => a -> Index a -> Bool
forall a. Num a => Index a -> a
forall a. Ord a => Index a -> a
forall m. Monoid m => Index m -> m
forall a. Index a -> Bool
forall a. Index a -> Int
forall a. Index a -> [a]
forall a. (a -> a -> a) -> Index a -> a
forall m a. Monoid m => (a -> m) -> Index a -> m
forall b a. (b -> a -> b) -> b -> Index a -> b
forall a b. (a -> b -> b) -> b -> Index a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Index a -> a
$cproduct :: forall a. Num a => Index a -> a
sum :: Index a -> a
$csum :: forall a. Num a => Index a -> a
minimum :: Index a -> a
$cminimum :: forall a. Ord a => Index a -> a
maximum :: Index a -> a
$cmaximum :: forall a. Ord a => Index a -> a
elem :: a -> Index a -> Bool
$celem :: forall a. Eq a => a -> Index a -> Bool
length :: Index a -> Int
$clength :: forall a. Index a -> Int
null :: Index a -> Bool
$cnull :: forall a. Index a -> Bool
toList :: Index a -> [a]
$ctoList :: forall a. Index a -> [a]
foldl1 :: (a -> a -> a) -> Index a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Index a -> a
foldr1 :: (a -> a -> a) -> Index a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Index a -> a
foldl' :: (b -> a -> b) -> b -> Index a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Index a -> b
foldl :: (b -> a -> b) -> b -> Index a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Index a -> b
foldr' :: (a -> b -> b) -> b -> Index a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Index a -> b
foldr :: (a -> b -> b) -> b -> Index a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Index a -> b
foldMap' :: (a -> m) -> Index a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Index a -> m
foldMap :: (a -> m) -> Index a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Index a -> m
fold :: Index m -> m
$cfold :: forall m. Monoid m => Index m -> m
Foldable, (forall x. Index a -> Rep (Index a) x)
-> (forall x. Rep (Index a) x -> Index a) -> Generic (Index a)
forall x. Rep (Index a) x -> Index a
forall x. Index a -> Rep (Index a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Index a) x -> Index a
forall a x. Index a -> Rep (Index a) x
$cto :: forall a x. Rep (Index a) x -> Index a
$cfrom :: forall a x. Index a -> Rep (Index a) x
Generic, Functor Index
Foldable Index
Functor Index
-> Foldable Index
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Index a -> f (Index b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Index (f a) -> f (Index a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Index a -> m (Index b))
-> (forall (m :: * -> *) a. Monad m => Index (m a) -> m (Index a))
-> Traversable Index
(a -> f b) -> Index a -> f (Index b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Index (m a) -> m (Index a)
forall (f :: * -> *) a. Applicative f => Index (f a) -> f (Index a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Index a -> m (Index b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Index a -> f (Index b)
sequence :: Index (m a) -> m (Index a)
$csequence :: forall (m :: * -> *) a. Monad m => Index (m a) -> m (Index a)
mapM :: (a -> m b) -> Index a -> m (Index b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Index a -> m (Index b)
sequenceA :: Index (f a) -> f (Index a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Index (f a) -> f (Index a)
traverse :: (a -> f b) -> Index a -> f (Index b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Index a -> f (Index b)
$cp2Traversable :: Foldable Index
$cp1Traversable :: Functor Index
Traversable)

extractSupOrSubIndex :: Index a -> Maybe a
extractSupOrSubIndex :: Index a -> Maybe a
extractSupOrSubIndex (Sub a
x)    = a -> Maybe a
forall a. a -> Maybe a
Just a
x
extractSupOrSubIndex (Sup a
x)    = a -> Maybe a
forall a. a -> Maybe a
Just a
x
extractSupOrSubIndex (SupSub a
x) = a -> Maybe a
forall a. a -> Maybe a
Just a
x
extractSupOrSubIndex Index a
_          = Maybe a
forall a. Maybe a
Nothing

extractIndex :: Index a -> a
extractIndex :: Index a -> a
extractIndex (Sub a
x)    = a
x
extractIndex (Sup a
x)    = a
x
extractIndex (SupSub a
x) = a
x
extractIndex (User a
x)   = a
x
extractIndex DF{}       = a
forall a. HasCallStack => a
undefined

data Var = Var String [Index (Maybe Var)]
  deriving ((forall x. Var -> Rep Var x)
-> (forall x. Rep Var x -> Var) -> Generic Var
forall x. Rep Var x -> Var
forall x. Var -> Rep Var x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Var x -> Var
$cfrom :: forall x. Var -> Rep Var x
Generic, Int -> Var -> ShowS
[Var] -> ShowS
Var -> String
(Int -> Var -> ShowS)
-> (Var -> String) -> ([Var] -> ShowS) -> Show Var
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Var] -> ShowS
$cshowList :: [Var] -> ShowS
show :: Var -> String
$cshow :: Var -> String
showsPrec :: Int -> Var -> ShowS
$cshowsPrec :: Int -> Var -> ShowS
Show)

-- for eq and hashable
data Var' = Var' String [Index ()]
  deriving (Var' -> Var' -> Bool
(Var' -> Var' -> Bool) -> (Var' -> Var' -> Bool) -> Eq Var'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Var' -> Var' -> Bool
$c/= :: Var' -> Var' -> Bool
== :: Var' -> Var' -> Bool
$c== :: Var' -> Var' -> Bool
Eq, (forall x. Var' -> Rep Var' x)
-> (forall x. Rep Var' x -> Var') -> Generic Var'
forall x. Rep Var' x -> Var'
forall x. Var' -> Rep Var' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Var' x -> Var'
$cfrom :: forall x. Var' -> Rep Var' x
Generic, Int -> Var' -> ShowS
[Var'] -> ShowS
Var' -> String
(Int -> Var' -> ShowS)
-> (Var' -> String) -> ([Var'] -> ShowS) -> Show Var'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Var'] -> ShowS
$cshowList :: [Var'] -> ShowS
show :: Var' -> String
$cshow :: Var' -> String
showsPrec :: Int -> Var' -> ShowS
$cshowsPrec :: Int -> Var' -> ShowS
Show)

instance Eq Var where
  Var String
name (MultiSup Maybe Var
_ Integer
_ Maybe Var
_:[Index (Maybe Var)]
_) == :: Var -> Var -> Bool
== Var String
name' [Index (Maybe Var)]
is' = String -> [Index (Maybe Var)] -> Var
Var String
name [] Var -> Var -> Bool
forall a. Eq a => a -> a -> Bool
== String -> [Index (Maybe Var)] -> Var
Var String
name' [Index (Maybe Var)]
is'
  Var String
name (MultiSub Maybe Var
_ Integer
_ Maybe Var
_:[Index (Maybe Var)]
_) == Var String
name' [Index (Maybe Var)]
is' = String -> [Index (Maybe Var)] -> Var
Var String
name [] Var -> Var -> Bool
forall a. Eq a => a -> a -> Bool
== String -> [Index (Maybe Var)] -> Var
Var String
name' [Index (Maybe Var)]
is'
  Var String
name [Index (Maybe Var)]
is == Var String
name' (MultiSup Maybe Var
_ Integer
_ Maybe Var
_:[Index (Maybe Var)]
_)  = String -> [Index (Maybe Var)] -> Var
Var String
name [Index (Maybe Var)]
is Var -> Var -> Bool
forall a. Eq a => a -> a -> Bool
== String -> [Index (Maybe Var)] -> Var
Var String
name' []
  Var String
name [Index (Maybe Var)]
is == Var String
name' (MultiSub Maybe Var
_ Integer
_ Maybe Var
_:[Index (Maybe Var)]
_)  = String -> [Index (Maybe Var)] -> Var
Var String
name [Index (Maybe Var)]
is Var -> Var -> Bool
forall a. Eq a => a -> a -> Bool
== String -> [Index (Maybe Var)] -> Var
Var String
name' []
  Var String
name [Index (Maybe Var)]
is == Var String
name' [Index (Maybe Var)]
is'                 = String -> [Index ()] -> Var'
Var' String
name ((Index (Maybe Var) -> Index ())
-> [Index (Maybe Var)] -> [Index ()]
forall a b. (a -> b) -> [a] -> [b]
map ((Maybe Var -> ()) -> Index (Maybe Var) -> Index ()
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe Var
_ -> ())) [Index (Maybe Var)]
is) Var' -> Var' -> Bool
forall a. Eq a => a -> a -> Bool
== String -> [Index ()] -> Var'
Var' String
name' ((Index (Maybe Var) -> Index ())
-> [Index (Maybe Var)] -> [Index ()]
forall a b. (a -> b) -> [a] -> [b]
map ((Maybe Var -> ()) -> Index (Maybe Var) -> Index ()
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe Var
_ -> ())) [Index (Maybe Var)]
is')

instance Hashable a => Hashable (Index a)
instance Hashable Var'
instance Hashable Var where
  hashWithSalt :: Int -> Var -> Int
hashWithSalt Int
salt (Var String
name (MultiSup Maybe Var
_ Integer
_ Maybe Var
_:[Index (Maybe Var)]
_)) = Int -> Var' -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt (String -> [Index ()] -> Var'
Var' String
name [])
  hashWithSalt Int
salt (Var String
name (MultiSub Maybe Var
_ Integer
_ Maybe Var
_:[Index (Maybe Var)]
_)) = Int -> Var' -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt (String -> [Index ()] -> Var'
Var' String
name [])
  hashWithSalt Int
salt (Var String
name [Index (Maybe Var)]
is) = Int -> Var' -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt (String -> [Index ()] -> Var'
Var' String
name ((Index (Maybe Var) -> Index ())
-> [Index (Maybe Var)] -> [Index ()]
forall a b. (a -> b) -> [a] -> [b]
map ((Maybe Var -> ()) -> Index (Maybe Var) -> Index ()
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe Var
_ -> ())) [Index (Maybe Var)]
is))

stringToVar :: String -> Var
stringToVar :: String -> Var
stringToVar String
name = String -> [Index (Maybe Var)] -> Var
Var String
name []

extractNameFromVar :: Var -> String
extractNameFromVar :: Var -> String
extractNameFromVar (Var String
name [Index (Maybe Var)]
_) = String
name

makeIApply :: String -> [IExpr] -> IExpr
makeIApply :: String -> [IExpr] -> IExpr
makeIApply String
func [IExpr]
args = IExpr -> [IExpr] -> IExpr
IApplyExpr (String -> IExpr
IVarExpr String
func) [IExpr]
args

instance {-# OVERLAPPING #-} Show (Index String) where
  show :: Index String -> String
show (Sup String
s)    = String
"~" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
  show (Sub String
s)    = String
"_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
  show (SupSub String
s) = String
"~_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
  show (User String
s)   = String
"|" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
  show (DF Integer
_ Integer
_)   = String
""