module FFICXX.Generate.Util.HaskellSrcExts where

import Data.List (foldl')
import Data.Maybe (maybeToList)
import Language.Haskell.Exts
  ( Alt (..),
    Asst (TypeA),
    Binds,
    Bracket (TypeBracket),
    CallConv (CCall),
    ClassDecl (ClsDecl),
    ConDecl
      ( ConDecl,
        RecDecl
      ),
    Context
      ( CxEmpty,
        CxTuple
      ),
    DataOrNew
      ( DataType,
        NewType
      ),
    Decl
      ( ClassDecl,
        DataDecl,
        ForImp,
        FunBind,
        InstDecl,
        PatBind,
        TypeSig
      ),
    DeclHead
      ( DHApp,
        DHead
      ),
    Deriving (..),
    EWildcard (..),
    Exp
      ( App,
        BracketExp,
        Con,
        If,
        InfixApp,
        Lit,
        Var
      ),
    ExportSpec
      ( EAbs,
        EModuleContents,
        EThingWith,
        EVar
      ),
    ExportSpecList (..),
    FieldDecl,
    ImportDecl (..),
    ImportSpec (IVar),
    ImportSpecList (..),
    InstDecl
      ( InsDecl,
        InsType
      ),
    InstHead
      ( IHApp,
        IHCon
      ),
    InstRule (IRule),
    Literal,
    Match (..),
    Module (..),
    ModuleHead (..),
    ModuleName (..),
    ModulePragma (LanguagePragma),
    Name
      ( Ident,
        Symbol
      ),
    Namespace (NoNamespace),
    Pat
      ( PVar,
        PatTypeSig
      ),
    QName (UnQual),
    QOp (QVarOp),
    QualConDecl (..),
    Rhs (UnGuardedRhs),
    Safety (PlayInterruptible),
    Splice (ParenSplice),
    Stmt
      ( Generator,
        Qualifier
      ),
    TyVarBind (UnkindedVar),
    Type
      ( TyApp,
        TyCon,
        TyForall,
        TyFun,
        TyList,
        TyParen,
        TySplice,
        TyVar
      ),
    app,
    unit_tycon,
  )
import Language.Haskell.Exts.Syntax (CName)

unqual :: String -> QName ()
unqual :: String -> QName ()
unqual = () -> Name () -> QName ()
forall l. l -> Name l -> QName l
UnQual () (Name () -> QName ()) -> (String -> Name ()) -> String -> QName ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> String -> Name ()
forall l. l -> String -> Name l
Ident ()

tycon :: String -> Type ()
tycon :: String -> Type ()
tycon = () -> QName () -> Type ()
forall l. l -> QName l -> Type l
TyCon () (QName () -> Type ()) -> (String -> QName ()) -> String -> Type ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> QName ()
unqual

tyapp :: Type () -> Type () -> Type ()
tyapp :: Type () -> Type () -> Type ()
tyapp = () -> Type () -> Type () -> Type ()
forall l. l -> Type l -> Type l -> Type l
TyApp ()

infixl 2 `tyapp`

tyfun :: Type () -> Type () -> Type ()
tyfun :: Type () -> Type () -> Type ()
tyfun = () -> Type () -> Type () -> Type ()
forall l. l -> Type l -> Type l -> Type l
TyFun ()

infixr 2 `tyfun`

tylist :: Type () -> Type ()
tylist :: Type () -> Type ()
tylist = () -> Type () -> Type ()
forall l. l -> Type l -> Type l
TyList ()

unit_tycon :: Type ()
unit_tycon :: Type ()
unit_tycon = () -> Type ()
forall l. l -> Type l
Language.Haskell.Exts.unit_tycon ()

conDecl :: String -> [Type ()] -> ConDecl ()
conDecl :: String -> [Type ()] -> ConDecl ()
conDecl String
n [Type ()]
ys = () -> Name () -> [Type ()] -> ConDecl ()
forall l. l -> Name l -> [Type l] -> ConDecl l
ConDecl () (() -> String -> Name ()
forall l. l -> String -> Name l
Ident () String
n) [Type ()]
ys

qualConDecl ::
  Maybe [TyVarBind ()] ->
  Maybe (Context ()) ->
  ConDecl () ->
  QualConDecl ()
qualConDecl :: Maybe [TyVarBind ()]
-> Maybe (Context ()) -> ConDecl () -> QualConDecl ()
qualConDecl = ()
-> Maybe [TyVarBind ()]
-> Maybe (Context ())
-> ConDecl ()
-> QualConDecl ()
forall l.
l
-> Maybe [TyVarBind l]
-> Maybe (Context l)
-> ConDecl l
-> QualConDecl l
QualConDecl ()

recDecl :: String -> [FieldDecl ()] -> ConDecl ()
recDecl :: String -> [FieldDecl ()] -> ConDecl ()
recDecl String
n [FieldDecl ()]
rs = () -> Name () -> [FieldDecl ()] -> ConDecl ()
forall l. l -> Name l -> [FieldDecl l] -> ConDecl l
RecDecl () (() -> String -> Name ()
forall l. l -> String -> Name l
Ident () String
n) [FieldDecl ()]
rs

app' :: String -> String -> Exp ()
app' :: String -> String -> Exp ()
app' String
x String
y = () -> Exp () -> Exp () -> Exp ()
forall l. l -> Exp l -> Exp l -> Exp l
App () (String -> Exp ()
mkVar String
x) (String -> Exp ()
mkVar String
y)

lit :: Literal () -> Exp ()
lit :: Literal () -> Exp ()
lit = () -> Literal () -> Exp ()
forall l. l -> Literal l -> Exp l
Lit ()

mkVar :: String -> Exp ()
mkVar :: String -> Exp ()
mkVar = () -> QName () -> Exp ()
forall l. l -> QName l -> Exp l
Var () (QName () -> Exp ()) -> (String -> QName ()) -> String -> Exp ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> QName ()
unqual

con :: String -> Exp ()
con :: String -> Exp ()
con = () -> QName () -> Exp ()
forall l. l -> QName l -> Exp l
Con () (QName () -> Exp ()) -> (String -> QName ()) -> String -> Exp ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> QName ()
unqual

mkTVar :: String -> Type ()
mkTVar :: String -> Type ()
mkTVar = () -> Name () -> Type ()
forall l. l -> Name l -> Type l
TyVar () (Name () -> Type ()) -> (String -> Name ()) -> String -> Type ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> String -> Name ()
forall l. l -> String -> Name l
Ident ()

mkPVar :: String -> Pat ()
mkPVar :: String -> Pat ()
mkPVar = () -> Name () -> Pat ()
forall l. l -> Name l -> Pat l
PVar () (Name () -> Pat ()) -> (String -> Name ()) -> String -> Pat ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> String -> Name ()
forall l. l -> String -> Name l
Ident ()

mkIVar :: String -> ImportSpec ()
mkIVar :: String -> ImportSpec ()
mkIVar = () -> Name () -> ImportSpec ()
forall l. l -> Name l -> ImportSpec l
IVar () (Name () -> ImportSpec ())
-> (String -> Name ()) -> String -> ImportSpec ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> String -> Name ()
forall l. l -> String -> Name l
Ident ()

mkPVarSig :: String -> Type () -> Pat ()
mkPVarSig :: String -> Type () -> Pat ()
mkPVarSig String
n Type ()
typ = () -> Pat () -> Type () -> Pat ()
forall l. l -> Pat l -> Type l -> Pat l
PatTypeSig () (String -> Pat ()
mkPVar String
n) Type ()
typ

pbind :: Pat () -> Exp () -> Maybe (Binds ()) -> Decl ()
pbind :: Pat () -> Exp () -> Maybe (Binds ()) -> Decl ()
pbind Pat ()
pat Exp ()
e = () -> Pat () -> Rhs () -> Maybe (Binds ()) -> Decl ()
forall l. l -> Pat l -> Rhs l -> Maybe (Binds l) -> Decl l
PatBind () Pat ()
pat (() -> Exp () -> Rhs ()
forall l. l -> Exp l -> Rhs l
UnGuardedRhs () Exp ()
e)

pbind_ :: Pat () -> Exp () -> Decl ()
pbind_ :: Pat () -> Exp () -> Decl ()
pbind_ Pat ()
p Exp ()
e = Pat () -> Exp () -> Maybe (Binds ()) -> Decl ()
pbind Pat ()
p Exp ()
e Maybe (Binds ())
forall a. Maybe a
Nothing

mkTBind :: String -> TyVarBind ()
mkTBind :: String -> TyVarBind ()
mkTBind = () -> Name () -> TyVarBind ()
forall l. l -> Name l -> TyVarBind l
UnkindedVar () (Name () -> TyVarBind ())
-> (String -> Name ()) -> String -> TyVarBind ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> String -> Name ()
forall l. l -> String -> Name l
Ident ()

mkBind1 :: String -> [Pat ()] -> Exp () -> Maybe (Binds ()) -> Decl ()
mkBind1 :: String -> [Pat ()] -> Exp () -> Maybe (Binds ()) -> Decl ()
mkBind1 String
n [Pat ()]
pat Exp ()
rhs Maybe (Binds ())
mbinds =
  () -> [Match ()] -> Decl ()
forall l. l -> [Match l] -> Decl l
FunBind () [() -> Name () -> [Pat ()] -> Rhs () -> Maybe (Binds ()) -> Match ()
forall l.
l -> Name l -> [Pat l] -> Rhs l -> Maybe (Binds l) -> Match l
Match () (() -> String -> Name ()
forall l. l -> String -> Name l
Ident () String
n) [Pat ()]
pat (() -> Exp () -> Rhs ()
forall l. l -> Exp l -> Rhs l
UnGuardedRhs () Exp ()
rhs) Maybe (Binds ())
mbinds]

mkFun :: String -> Type () -> [Pat ()] -> Exp () -> Maybe (Binds ()) -> [Decl ()]
mkFun :: String
-> Type () -> [Pat ()] -> Exp () -> Maybe (Binds ()) -> [Decl ()]
mkFun String
fname Type ()
typ [Pat ()]
pats Exp ()
rhs Maybe (Binds ())
mbinds = [String -> Type () -> Decl ()
mkFunSig String
fname Type ()
typ, String -> [Pat ()] -> Exp () -> Maybe (Binds ()) -> Decl ()
mkBind1 String
fname [Pat ()]
pats Exp ()
rhs Maybe (Binds ())
mbinds]

mkFunSig :: String -> Type () -> Decl ()
mkFunSig :: String -> Type () -> Decl ()
mkFunSig String
fname Type ()
typ = () -> [Name ()] -> Type () -> Decl ()
forall l. l -> [Name l] -> Type l -> Decl l
TypeSig () [() -> String -> Name ()
forall l. l -> String -> Name l
Ident () String
fname] Type ()
typ

mkClass :: Context () -> String -> [TyVarBind ()] -> [ClassDecl ()] -> Decl ()
mkClass :: Context () -> String -> [TyVarBind ()] -> [ClassDecl ()] -> Decl ()
mkClass Context ()
ctxt String
n [TyVarBind ()]
tbinds [ClassDecl ()]
cdecls = ()
-> Maybe (Context ())
-> DeclHead ()
-> [FunDep ()]
-> Maybe [ClassDecl ()]
-> Decl ()
forall l.
l
-> Maybe (Context l)
-> DeclHead l
-> [FunDep l]
-> Maybe [ClassDecl l]
-> Decl l
ClassDecl () (Context () -> Maybe (Context ())
forall a. a -> Maybe a
Just Context ()
ctxt) (String -> [TyVarBind ()] -> DeclHead ()
mkDeclHead String
n [TyVarBind ()]
tbinds) [] ([ClassDecl ()] -> Maybe [ClassDecl ()]
forall a. a -> Maybe a
Just [ClassDecl ()]
cdecls)

dhead :: String -> DeclHead ()
dhead :: String -> DeclHead ()
dhead String
n = () -> Name () -> DeclHead ()
forall l. l -> Name l -> DeclHead l
DHead () (() -> String -> Name ()
forall l. l -> String -> Name l
Ident () String
n)

mkDeclHead :: String -> [TyVarBind ()] -> DeclHead ()
mkDeclHead :: String -> [TyVarBind ()] -> DeclHead ()
mkDeclHead String
n [TyVarBind ()]
tbinds = (DeclHead () -> TyVarBind () -> DeclHead ())
-> DeclHead () -> [TyVarBind ()] -> DeclHead ()
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (() -> DeclHead () -> TyVarBind () -> DeclHead ()
forall l. l -> DeclHead l -> TyVarBind l -> DeclHead l
DHApp ()) (String -> DeclHead ()
dhead String
n) [TyVarBind ()]
tbinds

mkInstance :: Context () -> String -> [Type ()] -> [InstDecl ()] -> Decl ()
mkInstance :: Context () -> String -> [Type ()] -> [InstDecl ()] -> Decl ()
mkInstance Context ()
ctxt String
n [Type ()]
typs [InstDecl ()]
idecls = ()
-> Maybe (Overlap ())
-> InstRule ()
-> Maybe [InstDecl ()]
-> Decl ()
forall l.
l
-> Maybe (Overlap l) -> InstRule l -> Maybe [InstDecl l] -> Decl l
InstDecl () Maybe (Overlap ())
forall a. Maybe a
Nothing InstRule ()
instrule ([InstDecl ()] -> Maybe [InstDecl ()]
forall a. a -> Maybe a
Just [InstDecl ()]
idecls)
  where
    instrule :: InstRule ()
instrule = ()
-> Maybe [TyVarBind ()]
-> Maybe (Context ())
-> InstHead ()
-> InstRule ()
forall l.
l
-> Maybe [TyVarBind l]
-> Maybe (Context l)
-> InstHead l
-> InstRule l
IRule () Maybe [TyVarBind ()]
forall a. Maybe a
Nothing (Context () -> Maybe (Context ())
forall a. a -> Maybe a
Just Context ()
ctxt) InstHead ()
insthead
    insthead :: InstHead ()
insthead = (InstHead () -> Type () -> InstHead ())
-> InstHead () -> [Type ()] -> InstHead ()
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' InstHead () -> Type () -> InstHead ()
f (() -> QName () -> InstHead ()
forall l. l -> QName l -> InstHead l
IHCon () (String -> QName ()
unqual String
n)) [Type ()]
typs
      where
        f :: InstHead () -> Type () -> InstHead ()
f InstHead ()
acc Type ()
x = () -> InstHead () -> Type () -> InstHead ()
forall l. l -> InstHead l -> Type l -> InstHead l
IHApp () InstHead ()
acc (Type () -> Type ()
tyParen Type ()
x)

mkData :: String -> [TyVarBind ()] -> [QualConDecl ()] -> Maybe (Deriving ()) -> Decl ()
mkData :: String
-> [TyVarBind ()]
-> [QualConDecl ()]
-> Maybe (Deriving ())
-> Decl ()
mkData String
n [TyVarBind ()]
tbinds [QualConDecl ()]
qdecls Maybe (Deriving ())
mderiv = ()
-> DataOrNew ()
-> Maybe (Context ())
-> DeclHead ()
-> [QualConDecl ()]
-> [Deriving ()]
-> Decl ()
forall l.
l
-> DataOrNew l
-> Maybe (Context l)
-> DeclHead l
-> [QualConDecl l]
-> [Deriving l]
-> Decl l
DataDecl () (() -> DataOrNew ()
forall l. l -> DataOrNew l
DataType ()) Maybe (Context ())
forall a. Maybe a
Nothing DeclHead ()
declhead [QualConDecl ()]
qdecls (Maybe (Deriving ()) -> [Deriving ()]
forall a. Maybe a -> [a]
maybeToList Maybe (Deriving ())
mderiv)
  where
    declhead :: DeclHead ()
declhead = String -> [TyVarBind ()] -> DeclHead ()
mkDeclHead String
n [TyVarBind ()]
tbinds

mkNewtype :: String -> [TyVarBind ()] -> [QualConDecl ()] -> Maybe (Deriving ()) -> Decl ()
mkNewtype :: String
-> [TyVarBind ()]
-> [QualConDecl ()]
-> Maybe (Deriving ())
-> Decl ()
mkNewtype String
n [TyVarBind ()]
tbinds [QualConDecl ()]
qdecls Maybe (Deriving ())
mderiv = ()
-> DataOrNew ()
-> Maybe (Context ())
-> DeclHead ()
-> [QualConDecl ()]
-> [Deriving ()]
-> Decl ()
forall l.
l
-> DataOrNew l
-> Maybe (Context l)
-> DeclHead l
-> [QualConDecl l]
-> [Deriving l]
-> Decl l
DataDecl () (() -> DataOrNew ()
forall l. l -> DataOrNew l
NewType ()) Maybe (Context ())
forall a. Maybe a
Nothing DeclHead ()
declhead [QualConDecl ()]
qdecls (Maybe (Deriving ()) -> [Deriving ()]
forall a. Maybe a -> [a]
maybeToList Maybe (Deriving ())
mderiv)
  where
    declhead :: DeclHead ()
declhead = String -> [TyVarBind ()] -> DeclHead ()
mkDeclHead String
n [TyVarBind ()]
tbinds

mkForImpCcall :: String -> String -> Type () -> Decl ()
mkForImpCcall :: String -> String -> Type () -> Decl ()
mkForImpCcall String
quote String
n Type ()
typ = ()
-> CallConv ()
-> Maybe (Safety ())
-> Maybe String
-> Name ()
-> Type ()
-> Decl ()
forall l.
l
-> CallConv l
-> Maybe (Safety l)
-> Maybe String
-> Name l
-> Type l
-> Decl l
ForImp () (() -> CallConv ()
forall l. l -> CallConv l
CCall ()) (Safety () -> Maybe (Safety ())
forall a. a -> Maybe a
Just (() -> Safety ()
forall l. l -> Safety l
PlayInterruptible ())) (String -> Maybe String
forall a. a -> Maybe a
Just String
quote) (() -> String -> Name ()
forall l. l -> String -> Name l
Ident () String
n) Type ()
typ

mkModule :: String -> [ModulePragma ()] -> [ImportDecl ()] -> [Decl ()] -> Module ()
mkModule :: String
-> [ModulePragma ()] -> [ImportDecl ()] -> [Decl ()] -> Module ()
mkModule String
n [ModulePragma ()]
pragmas [ImportDecl ()]
idecls [Decl ()]
decls = ()
-> Maybe (ModuleHead ())
-> [ModulePragma ()]
-> [ImportDecl ()]
-> [Decl ()]
-> Module ()
forall l.
l
-> Maybe (ModuleHead l)
-> [ModulePragma l]
-> [ImportDecl l]
-> [Decl l]
-> Module l
Module () (ModuleHead () -> Maybe (ModuleHead ())
forall a. a -> Maybe a
Just ModuleHead ()
mhead) [ModulePragma ()]
pragmas [ImportDecl ()]
idecls [Decl ()]
decls
  where
    mhead :: ModuleHead ()
mhead = ()
-> ModuleName ()
-> Maybe (WarningText ())
-> Maybe (ExportSpecList ())
-> ModuleHead ()
forall l.
l
-> ModuleName l
-> Maybe (WarningText l)
-> Maybe (ExportSpecList l)
-> ModuleHead l
ModuleHead () (() -> String -> ModuleName ()
forall l. l -> String -> ModuleName l
ModuleName () String
n) Maybe (WarningText ())
forall a. Maybe a
Nothing Maybe (ExportSpecList ())
forall a. Maybe a
Nothing

mkModuleE :: String -> [ModulePragma ()] -> [ExportSpec ()] -> [ImportDecl ()] -> [Decl ()] -> Module ()
mkModuleE :: String
-> [ModulePragma ()]
-> [ExportSpec ()]
-> [ImportDecl ()]
-> [Decl ()]
-> Module ()
mkModuleE String
n [ModulePragma ()]
pragmas [ExportSpec ()]
exps [ImportDecl ()]
idecls [Decl ()]
decls = ()
-> Maybe (ModuleHead ())
-> [ModulePragma ()]
-> [ImportDecl ()]
-> [Decl ()]
-> Module ()
forall l.
l
-> Maybe (ModuleHead l)
-> [ModulePragma l]
-> [ImportDecl l]
-> [Decl l]
-> Module l
Module () (ModuleHead () -> Maybe (ModuleHead ())
forall a. a -> Maybe a
Just ModuleHead ()
mhead) [ModulePragma ()]
pragmas [ImportDecl ()]
idecls [Decl ()]
decls
  where
    mhead :: ModuleHead ()
mhead = ()
-> ModuleName ()
-> Maybe (WarningText ())
-> Maybe (ExportSpecList ())
-> ModuleHead ()
forall l.
l
-> ModuleName l
-> Maybe (WarningText l)
-> Maybe (ExportSpecList l)
-> ModuleHead l
ModuleHead () (() -> String -> ModuleName ()
forall l. l -> String -> ModuleName l
ModuleName () String
n) Maybe (WarningText ())
forall a. Maybe a
Nothing (ExportSpecList () -> Maybe (ExportSpecList ())
forall a. a -> Maybe a
Just ExportSpecList ()
eslist)
    eslist :: ExportSpecList ()
eslist = () -> [ExportSpec ()] -> ExportSpecList ()
forall l. l -> [ExportSpec l] -> ExportSpecList l
ExportSpecList () [ExportSpec ()]
exps

mkImport :: String -> ImportDecl ()
mkImport :: String -> ImportDecl ()
mkImport String
m = ()
-> ModuleName ()
-> Bool
-> Bool
-> Bool
-> Maybe String
-> Maybe (ModuleName ())
-> Maybe (ImportSpecList ())
-> ImportDecl ()
forall l.
l
-> ModuleName l
-> Bool
-> Bool
-> Bool
-> Maybe String
-> Maybe (ModuleName l)
-> Maybe (ImportSpecList l)
-> ImportDecl l
ImportDecl () (() -> String -> ModuleName ()
forall l. l -> String -> ModuleName l
ModuleName () String
m) Bool
False Bool
False Bool
False Maybe String
forall a. Maybe a
Nothing Maybe (ModuleName ())
forall a. Maybe a
Nothing Maybe (ImportSpecList ())
forall a. Maybe a
Nothing

mkImportExp :: String -> [String] -> ImportDecl ()
mkImportExp :: String -> [String] -> ImportDecl ()
mkImportExp String
m [String]
lst =
  ()
-> ModuleName ()
-> Bool
-> Bool
-> Bool
-> Maybe String
-> Maybe (ModuleName ())
-> Maybe (ImportSpecList ())
-> ImportDecl ()
forall l.
l
-> ModuleName l
-> Bool
-> Bool
-> Bool
-> Maybe String
-> Maybe (ModuleName l)
-> Maybe (ImportSpecList l)
-> ImportDecl l
ImportDecl () (() -> String -> ModuleName ()
forall l. l -> String -> ModuleName l
ModuleName () String
m) Bool
False Bool
False Bool
False Maybe String
forall a. Maybe a
Nothing Maybe (ModuleName ())
forall a. Maybe a
Nothing (ImportSpecList () -> Maybe (ImportSpecList ())
forall a. a -> Maybe a
Just ImportSpecList ()
islist)
  where
    islist :: ImportSpecList ()
islist = () -> Bool -> [ImportSpec ()] -> ImportSpecList ()
forall l. l -> Bool -> [ImportSpec l] -> ImportSpecList l
ImportSpecList () Bool
False ((String -> ImportSpec ()) -> [String] -> [ImportSpec ()]
forall a b. (a -> b) -> [a] -> [b]
map String -> ImportSpec ()
mkIVar [String]
lst)

mkImportSrc :: String -> ImportDecl ()
mkImportSrc :: String -> ImportDecl ()
mkImportSrc String
m = ()
-> ModuleName ()
-> Bool
-> Bool
-> Bool
-> Maybe String
-> Maybe (ModuleName ())
-> Maybe (ImportSpecList ())
-> ImportDecl ()
forall l.
l
-> ModuleName l
-> Bool
-> Bool
-> Bool
-> Maybe String
-> Maybe (ModuleName l)
-> Maybe (ImportSpecList l)
-> ImportDecl l
ImportDecl () (() -> String -> ModuleName ()
forall l. l -> String -> ModuleName l
ModuleName () String
m) Bool
False Bool
True Bool
False Maybe String
forall a. Maybe a
Nothing Maybe (ModuleName ())
forall a. Maybe a
Nothing Maybe (ImportSpecList ())
forall a. Maybe a
Nothing

lang :: [String] -> ModulePragma ()
lang :: [String] -> ModulePragma ()
lang [String]
ns = () -> [Name ()] -> ModulePragma ()
forall l. l -> [Name l] -> ModulePragma l
LanguagePragma () ((String -> Name ()) -> [String] -> [Name ()]
forall a b. (a -> b) -> [a] -> [b]
map (() -> String -> Name ()
forall l. l -> String -> Name l
Ident ()) [String]
ns)

dot :: Exp () -> Exp () -> Exp ()
Exp ()
x dot :: Exp () -> Exp () -> Exp ()
`dot` Exp ()
y = Exp ()
x Exp () -> Exp () -> Exp ()
`app` String -> Exp ()
mkVar String
"." Exp () -> Exp () -> Exp ()
`app` Exp ()
y

tyForall ::
  Maybe [TyVarBind ()] ->
  Maybe (Context ()) ->
  Type () ->
  Type ()
tyForall :: Maybe [TyVarBind ()] -> Maybe (Context ()) -> Type () -> Type ()
tyForall = ()
-> Maybe [TyVarBind ()] -> Maybe (Context ()) -> Type () -> Type ()
forall l.
l -> Maybe [TyVarBind l] -> Maybe (Context l) -> Type l -> Type l
TyForall ()

tyParen :: Type () -> Type ()
tyParen :: Type () -> Type ()
tyParen = () -> Type () -> Type ()
forall l. l -> Type l -> Type l
TyParen ()

tyPtr :: Type ()
tyPtr :: Type ()
tyPtr = String -> Type ()
tycon String
"Ptr"

tyForeignPtr :: Type ()
tyForeignPtr :: Type ()
tyForeignPtr = String -> Type ()
tycon String
"ForeignPtr"

classA :: QName () -> [Type ()] -> Asst ()
classA :: QName () -> [Type ()] -> Asst ()
classA QName ()
n = () -> Type () -> Asst ()
forall l. l -> Type l -> Asst l
TypeA () (Type () -> Asst ())
-> ([Type ()] -> Type ()) -> [Type ()] -> Asst ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Type () -> Type () -> Type ()) -> Type () -> [Type ()] -> Type ()
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Type () -> Type () -> Type ()
tyapp (() -> QName () -> Type ()
forall l. l -> QName l -> Type l
TyCon () QName ()
n)

cxEmpty :: Context ()
cxEmpty :: Context ()
cxEmpty = () -> Context ()
forall l. l -> Context l
CxEmpty ()

cxTuple :: [Asst ()] -> Context ()
cxTuple :: [Asst ()] -> Context ()
cxTuple = () -> [Asst ()] -> Context ()
forall l. l -> [Asst l] -> Context l
CxTuple ()

tySplice :: Splice () -> Type ()
tySplice :: Splice () -> Type ()
tySplice = () -> Splice () -> Type ()
forall l. l -> Splice l -> Type l
TySplice ()

parenSplice :: Exp () -> Splice ()
parenSplice :: Exp () -> Splice ()
parenSplice = () -> Exp () -> Splice ()
forall l. l -> Exp l -> Splice l
ParenSplice ()

bracketExp :: Bracket () -> Exp ()
bracketExp :: Bracket () -> Exp ()
bracketExp = () -> Bracket () -> Exp ()
forall l. l -> Bracket l -> Exp l
BracketExp ()

typeBracket :: Type () -> Bracket ()
typeBracket :: Type () -> Bracket ()
typeBracket = () -> Type () -> Bracket ()
forall l. l -> Type l -> Bracket l
TypeBracket ()

mkDeriving :: [InstRule ()] -> Deriving ()
mkDeriving :: [InstRule ()] -> Deriving ()
mkDeriving = () -> Maybe (DerivStrategy ()) -> [InstRule ()] -> Deriving ()
forall l.
l -> Maybe (DerivStrategy l) -> [InstRule l] -> Deriving l
Deriving () Maybe (DerivStrategy ())
forall a. Maybe a
Nothing

irule ::
  Maybe [TyVarBind ()] ->
  Maybe (Context ()) ->
  InstHead () ->
  InstRule ()
irule :: Maybe [TyVarBind ()]
-> Maybe (Context ()) -> InstHead () -> InstRule ()
irule = ()
-> Maybe [TyVarBind ()]
-> Maybe (Context ())
-> InstHead ()
-> InstRule ()
forall l.
l
-> Maybe [TyVarBind l]
-> Maybe (Context l)
-> InstHead l
-> InstRule l
IRule ()

ihcon :: QName () -> InstHead ()
ihcon :: QName () -> InstHead ()
ihcon = () -> QName () -> InstHead ()
forall l. l -> QName l -> InstHead l
IHCon ()

evar :: QName () -> ExportSpec ()
evar :: QName () -> ExportSpec ()
evar = () -> QName () -> ExportSpec ()
forall l. l -> QName l -> ExportSpec l
EVar ()

eabs :: Namespace () -> QName () -> ExportSpec ()
eabs :: Namespace () -> QName () -> ExportSpec ()
eabs = () -> Namespace () -> QName () -> ExportSpec ()
forall l. l -> Namespace l -> QName l -> ExportSpec l
EAbs ()

ethingwith ::
  EWildcard () ->
  QName () ->
  [Language.Haskell.Exts.Syntax.CName ()] ->
  ExportSpec ()
ethingwith :: EWildcard () -> QName () -> [CName ()] -> ExportSpec ()
ethingwith = () -> EWildcard () -> QName () -> [CName ()] -> ExportSpec ()
forall l. l -> EWildcard l -> QName l -> [CName l] -> ExportSpec l
EThingWith ()

ethingall :: QName () -> ExportSpec ()
ethingall :: QName () -> ExportSpec ()
ethingall QName ()
q = EWildcard () -> QName () -> [CName ()] -> ExportSpec ()
ethingwith (() -> Int -> EWildcard ()
forall l. l -> Int -> EWildcard l
EWildcard () Int
0) QName ()
q []

emodule :: String -> ExportSpec ()
emodule :: String -> ExportSpec ()
emodule String
nm = () -> ModuleName () -> ExportSpec ()
forall l. l -> ModuleName l -> ExportSpec l
EModuleContents () (() -> String -> ModuleName ()
forall l. l -> String -> ModuleName l
ModuleName () String
nm)

nonamespace :: Namespace ()
nonamespace :: Namespace ()
nonamespace = () -> Namespace ()
forall l. l -> Namespace l
NoNamespace ()

insType :: Type () -> Type () -> InstDecl ()
insType :: Type () -> Type () -> InstDecl ()
insType = () -> Type () -> Type () -> InstDecl ()
forall l. l -> Type l -> Type l -> InstDecl l
InsType ()

insDecl :: Decl () -> InstDecl ()
insDecl :: Decl () -> InstDecl ()
insDecl = () -> Decl () -> InstDecl ()
forall l. l -> Decl l -> InstDecl l
InsDecl ()

generator :: Pat () -> Exp () -> Stmt ()
generator :: Pat () -> Exp () -> Stmt ()
generator = () -> Pat () -> Exp () -> Stmt ()
forall l. l -> Pat l -> Exp l -> Stmt l
Generator ()

qualifier :: Exp () -> Stmt ()
qualifier :: Exp () -> Stmt ()
qualifier = () -> Exp () -> Stmt ()
forall l. l -> Exp l -> Stmt l
Qualifier ()

clsDecl :: Decl () -> ClassDecl ()
clsDecl :: Decl () -> ClassDecl ()
clsDecl = () -> Decl () -> ClassDecl ()
forall l. l -> Decl l -> ClassDecl l
ClsDecl ()

unkindedVar :: Name () -> TyVarBind ()
unkindedVar :: Name () -> TyVarBind ()
unkindedVar = () -> Name () -> TyVarBind ()
forall l. l -> Name l -> TyVarBind l
UnkindedVar ()

op :: String -> QOp ()
op :: String -> QOp ()
op = () -> QName () -> QOp ()
forall l. l -> QName l -> QOp l
QVarOp () (QName () -> QOp ()) -> (String -> QName ()) -> String -> QOp ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Name () -> QName ()
forall l. l -> Name l -> QName l
UnQual () (Name () -> QName ()) -> (String -> Name ()) -> String -> QName ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> String -> Name ()
forall l. l -> String -> Name l
Symbol ()

inapp :: Exp () -> QOp () -> Exp () -> Exp ()
inapp :: Exp () -> QOp () -> Exp () -> Exp ()
inapp = () -> Exp () -> QOp () -> Exp () -> Exp ()
forall l. l -> Exp l -> QOp l -> Exp l -> Exp l
InfixApp ()

if_ :: Exp () -> Exp () -> Exp () -> Exp ()
if_ :: Exp () -> Exp () -> Exp () -> Exp ()
if_ = () -> Exp () -> Exp () -> Exp () -> Exp ()
forall l. l -> Exp l -> Exp l -> Exp l -> Exp l
If ()

urhs :: Exp () -> Rhs ()
urhs :: Exp () -> Rhs ()
urhs = () -> Exp () -> Rhs ()
forall l. l -> Exp l -> Rhs l
UnGuardedRhs ()

-- | case pattern match p -> e
match :: Pat () -> Exp () -> Alt ()
match :: Pat () -> Exp () -> Alt ()
match Pat ()
p Exp ()
e = () -> Pat () -> Rhs () -> Maybe (Binds ()) -> Alt ()
forall l. l -> Pat l -> Rhs l -> Maybe (Binds l) -> Alt l
Alt () Pat ()
p (Exp () -> Rhs ()
urhs Exp ()
e) Maybe (Binds ())
forall a. Maybe a
Nothing