    -- |
    -- Module      :  Cryptol.Parser.AST
    -- Copyright   :  (c) 2013-2016 Galois, Inc.
    -- License     :  BSD3
    -- Maintainer  :  cryptol@galois.com
    -- Stability   :  provisional
    -- Portability :  portable

    {-# LANGUAGE Safe #-}

    {-# LANGUAGE DeriveAnyClass #-}
    {-# LANGUAGE DeriveFoldable #-}
    {-# LANGUAGE DeriveTraversable #-}
    {-# LANGUAGE DeriveFunctor #-}
    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE PatternGuards #-}
    {-# LANGUAGE RecordWildCards #-}
    {-# LANGUAGE OverloadedStrings #-}
    module Cryptol.Parser.AST
      ( -- * Names
        Ident, mkIdent, mkInfix, isInfixIdent, nullIdent, identText
      , ModName, modRange
      , PName(..), getModName, getIdent, mkUnqual, mkQual
      , Named(..)
      , Pass(..)
      , Assoc(..)

        -- * Types
      , Schema(..)
      , TParam(..)
      , Kind(..)
      , Type(..)
      , Prop(..)
      , tsName
      , psName
      , tsFixity
      , psFixity

        -- * Declarations
      , Module(..)
      , Program(..)
      , TopDecl(..)
      , Decl(..)
      , Fixity(..), defaultFixity
      , FixityCmp(..), compareFixity
      , TySyn(..)
      , PropSyn(..)
      , Bind(..)
      , BindDef(..), LBindDef
      , Pragma(..)
      , ExportType(..)
      , TopLevel(..)
      , Import(..), ImportSpec(..)
      , Newtype(..)
      , PrimType(..)
      , ParameterType(..)
      , ParameterFun(..)

        -- * Interactive
      , ReplInput(..)

        -- * Expressions
      , Expr(..)
      , Literal(..), NumInfo(..)
      , Match(..)
      , Pattern(..)
      , Selector(..)
      , TypeInst(..)
      , UpdField(..)
      , UpdHow(..)

        -- * Positions
      , Located(..)
      , LPName, LString, LIdent
      , NoPos(..)

        -- * Pretty-printing
      , cppKind, ppSelector
      ) where

    import Cryptol.Parser.Fixity
    import Cryptol.Parser.Name
    import Cryptol.Parser.Position
    import Cryptol.Parser.Selector
    import Cryptol.Utils.Ident
    import Cryptol.Utils.PP

    import           Data.List(intersperse)
    import           Data.Bits(shiftR)
    import           Data.Maybe (catMaybes)
    import           Numeric(showIntAtBase)

    import GHC.Generics (Generic)
    import Control.DeepSeq

    import Prelude ()
    import Prelude.Compat

    -- AST -------------------------------------------------------------------------

    -- | A name with location information.
    type LPName    = Located PName

    -- | An identifier with location information.
    type LIdent    = Located Ident

    -- | A string with location information.
    type LString  = Located String

    newtype Program name = Program [TopDecl name]
                           deriving (Int -> Program name -> ShowS
    [Program name] -> ShowS
    Program name -> String
    (Int -> Program name -> ShowS)
    -> (Program name -> String)
    -> ([Program name] -> ShowS)
    -> Show (Program name)
    forall name. Show name => Int -> Program name -> ShowS
    forall name. Show name => [Program name] -> ShowS
    forall name. Show name => Program name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Program name] -> ShowS
    $cshowList :: forall name. Show name => [Program name] -> ShowS
    show :: Program name -> String
    $cshow :: forall name. Show name => Program name -> String
    showsPrec :: Int -> Program name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> Program name -> ShowS
    Show)

    -- | A parsed module.
    data Module name = Module
      { Module name -> Located ModName
    mName     :: Located ModName            -- ^ Name of the module
      , Module name -> Maybe (Located ModName)
    mInstance :: !(Maybe (Located ModName)) -- ^ Functor to instantiate
                                                -- (if this is a functor instnaces)
      , Module name -> [Located Import]
    mImports  :: [Located Import]           -- ^ Imports for the module
      , Module name -> [TopDecl name]
    mDecls    :: [TopDecl name]             -- ^ Declartions for the module
      } deriving (Int -> Module name -> ShowS
    [Module name] -> ShowS
    Module name -> String
    (Int -> Module name -> ShowS)
    -> (Module name -> String)
    -> ([Module name] -> ShowS)
    -> Show (Module name)
    forall name. Show name => Int -> Module name -> ShowS
    forall name. Show name => [Module name] -> ShowS
    forall name. Show name => Module name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Module name] -> ShowS
    $cshowList :: forall name. Show name => [Module name] -> ShowS
    show :: Module name -> String
    $cshow :: forall name. Show name => Module name -> String
    showsPrec :: Int -> Module name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> Module name -> ShowS
    Show, (forall x. Module name -> Rep (Module name) x)
    -> (forall x. Rep (Module name) x -> Module name)
    -> Generic (Module name)
    forall x. Rep (Module name) x -> Module name
    forall x. Module name -> Rep (Module name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (Module name) x -> Module name
    forall name x. Module name -> Rep (Module name) x
    $cto :: forall name x. Rep (Module name) x -> Module name
    $cfrom :: forall name x. Module name -> Rep (Module name) x
    Generic, Module name -> ()
    (Module name -> ()) -> NFData (Module name)
    forall name. NFData name => Module name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Module name -> ()
    $crnf :: forall name. NFData name => Module name -> ()
    NFData)

    modRange :: Module name -> Range
    modRange :: Module name -> Range
    modRange m :: Module name
    m = [Range] -> Range
    rCombs ([Range] -> Range) -> [Range] -> Range
    forall a b. (a -> b) -> a -> b
    $ [Maybe Range] -> [Range]
    forall a. [Maybe a] -> [a]
    catMaybes
        [ Located ModName -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Module name -> Located ModName
    forall name. Module name -> Located ModName
    mName Module name
    m)
        , [Located Import] -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Module name -> [Located Import]
    forall name. Module name -> [Located Import]
    mImports Module name
    m)
        , [TopDecl name] -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Module name -> [TopDecl name]
    forall name. Module name -> [TopDecl name]
    mDecls Module name
    m)
        , Range -> Maybe Range
    forall a. a -> Maybe a
    Just ($WRange :: Position -> Position -> String -> Range
    Range { from :: Position
    from = Position
    start, to :: Position
    to = Position
    start, source :: String
    source = "" })
        ]

    data TopDecl name =
        Decl (TopLevel (Decl name))
      | DPrimType (TopLevel (PrimType name))
      | TDNewtype (TopLevel (Newtype name)) -- ^ @newtype T as = t
      | Include (Located FilePath)          -- ^ @include File@
      | DParameterType (ParameterType name) -- ^ @parameter type T : #@
      | DParameterConstraint [Located (Prop name)]
                                            -- ^ @parameter type constraint (fin T)@
      | DParameterFun  (ParameterFun name)  -- ^ @parameter someVal : [256]@
                        deriving (Int -> TopDecl name -> ShowS
    [TopDecl name] -> ShowS
    TopDecl name -> String
    (Int -> TopDecl name -> ShowS)
    -> (TopDecl name -> String)
    -> ([TopDecl name] -> ShowS)
    -> Show (TopDecl name)
    forall name. Show name => Int -> TopDecl name -> ShowS
    forall name. Show name => [TopDecl name] -> ShowS
    forall name. Show name => TopDecl name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [TopDecl name] -> ShowS
    $cshowList :: forall name. Show name => [TopDecl name] -> ShowS
    show :: TopDecl name -> String
    $cshow :: forall name. Show name => TopDecl name -> String
    showsPrec :: Int -> TopDecl name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> TopDecl name -> ShowS
    Show, (forall x. TopDecl name -> Rep (TopDecl name) x)
    -> (forall x. Rep (TopDecl name) x -> TopDecl name)
    -> Generic (TopDecl name)
    forall x. Rep (TopDecl name) x -> TopDecl name
    forall x. TopDecl name -> Rep (TopDecl name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (TopDecl name) x -> TopDecl name
    forall name x. TopDecl name -> Rep (TopDecl name) x
    $cto :: forall name x. Rep (TopDecl name) x -> TopDecl name
    $cfrom :: forall name x. TopDecl name -> Rep (TopDecl name) x
    Generic, TopDecl name -> ()
    (TopDecl name -> ()) -> NFData (TopDecl name)
    forall name. NFData name => TopDecl name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: TopDecl name -> ()
    $crnf :: forall name. NFData name => TopDecl name -> ()
    NFData)

    data Decl name = DSignature [Located name] (Schema name)
                   | DFixity !Fixity [Located name]
                   | DPragma [Located name] Pragma
                   | DBind (Bind name)
                   | DPatBind (Pattern name) (Expr name)
                   | DType (TySyn name)
                   | DProp (PropSyn name)
                   | DLocated (Decl name) Range
                     deriving (Decl name -> Decl name -> Bool
    (Decl name -> Decl name -> Bool)
    -> (Decl name -> Decl name -> Bool) -> Eq (Decl name)
    forall name. Eq name => Decl name -> Decl name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Decl name -> Decl name -> Bool
    $c/= :: forall name. Eq name => Decl name -> Decl name -> Bool
    == :: Decl name -> Decl name -> Bool
    $c== :: forall name. Eq name => Decl name -> Decl name -> Bool
    Eq, Int -> Decl name -> ShowS
    [Decl name] -> ShowS
    Decl name -> String
    (Int -> Decl name -> ShowS)
    -> (Decl name -> String)
    -> ([Decl name] -> ShowS)
    -> Show (Decl name)
    forall name. Show name => Int -> Decl name -> ShowS
    forall name. Show name => [Decl name] -> ShowS
    forall name. Show name => Decl name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Decl name] -> ShowS
    $cshowList :: forall name. Show name => [Decl name] -> ShowS
    show :: Decl name -> String
    $cshow :: forall name. Show name => Decl name -> String
    showsPrec :: Int -> Decl name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> Decl name -> ShowS
    Show, (forall x. Decl name -> Rep (Decl name) x)
    -> (forall x. Rep (Decl name) x -> Decl name)
    -> Generic (Decl name)
    forall x. Rep (Decl name) x -> Decl name
    forall x. Decl name -> Rep (Decl name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (Decl name) x -> Decl name
    forall name x. Decl name -> Rep (Decl name) x
    $cto :: forall name x. Rep (Decl name) x -> Decl name
    $cfrom :: forall name x. Decl name -> Rep (Decl name) x
    Generic, Decl name -> ()
    (Decl name -> ()) -> NFData (Decl name)
    forall name. NFData name => Decl name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Decl name -> ()
    $crnf :: forall name. NFData name => Decl name -> ()
    NFData, a -> Decl b -> Decl a
    (a -> b) -> Decl a -> Decl b
    (forall a b. (a -> b) -> Decl a -> Decl b)
    -> (forall a b. a -> Decl b -> Decl a) -> Functor Decl
    forall a b. a -> Decl b -> Decl a
    forall a b. (a -> b) -> Decl a -> Decl b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Decl b -> Decl a
    $c<$ :: forall a b. a -> Decl b -> Decl a
    fmap :: (a -> b) -> Decl a -> Decl b
    $cfmap :: forall a b. (a -> b) -> Decl a -> Decl b
    Functor)

    -- | A type parameter
    data ParameterType name = ParameterType
      { ParameterType name -> Located name
    ptName    :: Located name     -- ^ name of type parameter
      , ParameterType name -> Kind
    ptKind    :: Kind             -- ^ kind of parameter
      , ParameterType name -> Maybe String
    ptDoc     :: Maybe String     -- ^ optional documentation
      , ParameterType name -> Maybe Fixity
    ptFixity  :: Maybe Fixity     -- ^ info for infix use
      , ParameterType name -> Int
    ptNumber  :: !Int             -- ^ number of the parameter
      } deriving (ParameterType name -> ParameterType name -> Bool
    (ParameterType name -> ParameterType name -> Bool)
    -> (ParameterType name -> ParameterType name -> Bool)
    -> Eq (ParameterType name)
    forall name.
    Eq name =>
    ParameterType name -> ParameterType name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: ParameterType name -> ParameterType name -> Bool
    $c/= :: forall name.
    Eq name =>
    ParameterType name -> ParameterType name -> Bool
    == :: ParameterType name -> ParameterType name -> Bool
    $c== :: forall name.
    Eq name =>
    ParameterType name -> ParameterType name -> Bool
    Eq,Int -> ParameterType name -> ShowS
    [ParameterType name] -> ShowS
    ParameterType name -> String
    (Int -> ParameterType name -> ShowS)
    -> (ParameterType name -> String)
    -> ([ParameterType name] -> ShowS)
    -> Show (ParameterType name)
    forall name. Show name => Int -> ParameterType name -> ShowS
    forall name. Show name => [ParameterType name] -> ShowS
    forall name. Show name => ParameterType name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [ParameterType name] -> ShowS
    $cshowList :: forall name. Show name => [ParameterType name] -> ShowS
    show :: ParameterType name -> String
    $cshow :: forall name. Show name => ParameterType name -> String
    showsPrec :: Int -> ParameterType name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> ParameterType name -> ShowS
    Show,(forall x. ParameterType name -> Rep (ParameterType name) x)
    -> (forall x. Rep (ParameterType name) x -> ParameterType name)
    -> Generic (ParameterType name)
    forall x. Rep (ParameterType name) x -> ParameterType name
    forall x. ParameterType name -> Rep (ParameterType name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (ParameterType name) x -> ParameterType name
    forall name x. ParameterType name -> Rep (ParameterType name) x
    $cto :: forall name x. Rep (ParameterType name) x -> ParameterType name
    $cfrom :: forall name x. ParameterType name -> Rep (ParameterType name) x
    Generic,ParameterType name -> ()
    (ParameterType name -> ()) -> NFData (ParameterType name)
    forall name. NFData name => ParameterType name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: ParameterType name -> ()
    $crnf :: forall name. NFData name => ParameterType name -> ()
    NFData)

    -- | A value parameter
    data ParameterFun name = ParameterFun
      { ParameterFun name -> Located name
    pfName   :: Located name      -- ^ name of value parameter
      , ParameterFun name -> Schema name
    pfSchema :: Schema name       -- ^ schema for parameter
      , ParameterFun name -> Maybe String
    pfDoc    :: Maybe String      -- ^ optional documentation
      , ParameterFun name -> Maybe Fixity
    pfFixity :: Maybe Fixity      -- ^ info for infix use
      } deriving (ParameterFun name -> ParameterFun name -> Bool
    (ParameterFun name -> ParameterFun name -> Bool)
    -> (ParameterFun name -> ParameterFun name -> Bool)
    -> Eq (ParameterFun name)
    forall name.
    Eq name =>
    ParameterFun name -> ParameterFun name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: ParameterFun name -> ParameterFun name -> Bool
    $c/= :: forall name.
    Eq name =>
    ParameterFun name -> ParameterFun name -> Bool
    == :: ParameterFun name -> ParameterFun name -> Bool
    $c== :: forall name.
    Eq name =>
    ParameterFun name -> ParameterFun name -> Bool
    Eq,Int -> ParameterFun name -> ShowS
    [ParameterFun name] -> ShowS
    ParameterFun name -> String
    (Int -> ParameterFun name -> ShowS)
    -> (ParameterFun name -> String)
    -> ([ParameterFun name] -> ShowS)
    -> Show (ParameterFun name)
    forall name. Show name => Int -> ParameterFun name -> ShowS
    forall name. Show name => [ParameterFun name] -> ShowS
    forall name. Show name => ParameterFun name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [ParameterFun name] -> ShowS
    $cshowList :: forall name. Show name => [ParameterFun name] -> ShowS
    show :: ParameterFun name -> String
    $cshow :: forall name. Show name => ParameterFun name -> String
    showsPrec :: Int -> ParameterFun name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> ParameterFun name -> ShowS
    Show,(forall x. ParameterFun name -> Rep (ParameterFun name) x)
    -> (forall x. Rep (ParameterFun name) x -> ParameterFun name)
    -> Generic (ParameterFun name)
    forall x. Rep (ParameterFun name) x -> ParameterFun name
    forall x. ParameterFun name -> Rep (ParameterFun name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (ParameterFun name) x -> ParameterFun name
    forall name x. ParameterFun name -> Rep (ParameterFun name) x
    $cto :: forall name x. Rep (ParameterFun name) x -> ParameterFun name
    $cfrom :: forall name x. ParameterFun name -> Rep (ParameterFun name) x
    Generic,ParameterFun name -> ()
    (ParameterFun name -> ()) -> NFData (ParameterFun name)
    forall name. NFData name => ParameterFun name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: ParameterFun name -> ()
    $crnf :: forall name. NFData name => ParameterFun name -> ()
    NFData)

    -- | An import declaration.
    data Import = Import { Import -> ModName
    iModule    :: !ModName
                         , Import -> Maybe ModName
    iAs        :: Maybe ModName
                         , Import -> Maybe ImportSpec
    iSpec      :: Maybe ImportSpec
                         } deriving (Import -> Import -> Bool
    (Import -> Import -> Bool)
    -> (Import -> Import -> Bool) -> Eq Import
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Import -> Import -> Bool
    $c/= :: Import -> Import -> Bool
    == :: Import -> Import -> Bool
    $c== :: Import -> Import -> Bool
    Eq, Int -> Import -> ShowS
    [Import] -> ShowS
    Import -> String
    (Int -> Import -> ShowS)
    -> (Import -> String) -> ([Import] -> ShowS) -> Show Import
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Import] -> ShowS
    $cshowList :: [Import] -> ShowS
    show :: Import -> String
    $cshow :: Import -> String
    showsPrec :: Int -> Import -> ShowS
    $cshowsPrec :: Int -> Import -> ShowS
    Show, (forall x. Import -> Rep Import x)
    -> (forall x. Rep Import x -> Import) -> Generic Import
    forall x. Rep Import x -> Import
    forall x. Import -> Rep Import x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep Import x -> Import
    $cfrom :: forall x. Import -> Rep Import x
    Generic, Import -> ()
    (Import -> ()) -> NFData Import
    forall a. (a -> ()) -> NFData a
    rnf :: Import -> ()
    $crnf :: Import -> ()
    NFData)

    -- | The list of names following an import.
    --
    -- INVARIANT: All of the 'Name' entries in the list are expected to be
    -- unqualified names; the 'QName' or 'NewName' constructors should not be
    -- present.
    data ImportSpec = Hiding [Ident]
                    | Only   [Ident]
                      deriving (ImportSpec -> ImportSpec -> Bool
    (ImportSpec -> ImportSpec -> Bool)
    -> (ImportSpec -> ImportSpec -> Bool) -> Eq ImportSpec
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: ImportSpec -> ImportSpec -> Bool
    $c/= :: ImportSpec -> ImportSpec -> Bool
    == :: ImportSpec -> ImportSpec -> Bool
    $c== :: ImportSpec -> ImportSpec -> Bool
    Eq, Int -> ImportSpec -> ShowS
    [ImportSpec] -> ShowS
    ImportSpec -> String
    (Int -> ImportSpec -> ShowS)
    -> (ImportSpec -> String)
    -> ([ImportSpec] -> ShowS)
    -> Show ImportSpec
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [ImportSpec] -> ShowS
    $cshowList :: [ImportSpec] -> ShowS
    show :: ImportSpec -> String
    $cshow :: ImportSpec -> String
    showsPrec :: Int -> ImportSpec -> ShowS
    $cshowsPrec :: Int -> ImportSpec -> ShowS
    Show, (forall x. ImportSpec -> Rep ImportSpec x)
    -> (forall x. Rep ImportSpec x -> ImportSpec) -> Generic ImportSpec
    forall x. Rep ImportSpec x -> ImportSpec
    forall x. ImportSpec -> Rep ImportSpec x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep ImportSpec x -> ImportSpec
    $cfrom :: forall x. ImportSpec -> Rep ImportSpec x
    Generic, ImportSpec -> ()
    (ImportSpec -> ()) -> NFData ImportSpec
    forall a. (a -> ()) -> NFData a
    rnf :: ImportSpec -> ()
    $crnf :: ImportSpec -> ()
    NFData)

    -- The 'Maybe Fixity' field is filled in by the NoPat pass.
    data TySyn n = TySyn (Located n) (Maybe Fixity) [TParam n] (Type n)
                    deriving (TySyn n -> TySyn n -> Bool
    (TySyn n -> TySyn n -> Bool)
    -> (TySyn n -> TySyn n -> Bool) -> Eq (TySyn n)
    forall n. Eq n => TySyn n -> TySyn n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: TySyn n -> TySyn n -> Bool
    $c/= :: forall n. Eq n => TySyn n -> TySyn n -> Bool
    == :: TySyn n -> TySyn n -> Bool
    $c== :: forall n. Eq n => TySyn n -> TySyn n -> Bool
    Eq, Int -> TySyn n -> ShowS
    [TySyn n] -> ShowS
    TySyn n -> String
    (Int -> TySyn n -> ShowS)
    -> (TySyn n -> String) -> ([TySyn n] -> ShowS) -> Show (TySyn n)
    forall n. Show n => Int -> TySyn n -> ShowS
    forall n. Show n => [TySyn n] -> ShowS
    forall n. Show n => TySyn n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [TySyn n] -> ShowS
    $cshowList :: forall n. Show n => [TySyn n] -> ShowS
    show :: TySyn n -> String
    $cshow :: forall n. Show n => TySyn n -> String
    showsPrec :: Int -> TySyn n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> TySyn n -> ShowS
    Show, (forall x. TySyn n -> Rep (TySyn n) x)
    -> (forall x. Rep (TySyn n) x -> TySyn n) -> Generic (TySyn n)
    forall x. Rep (TySyn n) x -> TySyn n
    forall x. TySyn n -> Rep (TySyn n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (TySyn n) x -> TySyn n
    forall n x. TySyn n -> Rep (TySyn n) x
    $cto :: forall n x. Rep (TySyn n) x -> TySyn n
    $cfrom :: forall n x. TySyn n -> Rep (TySyn n) x
    Generic, TySyn n -> ()
    (TySyn n -> ()) -> NFData (TySyn n)
    forall n. NFData n => TySyn n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: TySyn n -> ()
    $crnf :: forall n. NFData n => TySyn n -> ()
    NFData, a -> TySyn b -> TySyn a
    (a -> b) -> TySyn a -> TySyn b
    (forall a b. (a -> b) -> TySyn a -> TySyn b)
    -> (forall a b. a -> TySyn b -> TySyn a) -> Functor TySyn
    forall a b. a -> TySyn b -> TySyn a
    forall a b. (a -> b) -> TySyn a -> TySyn b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> TySyn b -> TySyn a
    $c<$ :: forall a b. a -> TySyn b -> TySyn a
    fmap :: (a -> b) -> TySyn a -> TySyn b
    $cfmap :: forall a b. (a -> b) -> TySyn a -> TySyn b
    Functor)

    -- The 'Maybe Fixity' field is filled in by the NoPat pass.
    data PropSyn n = PropSyn (Located n) (Maybe Fixity) [TParam n] [Prop n]
                     deriving (PropSyn n -> PropSyn n -> Bool
    (PropSyn n -> PropSyn n -> Bool)
    -> (PropSyn n -> PropSyn n -> Bool) -> Eq (PropSyn n)
    forall n. Eq n => PropSyn n -> PropSyn n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: PropSyn n -> PropSyn n -> Bool
    $c/= :: forall n. Eq n => PropSyn n -> PropSyn n -> Bool
    == :: PropSyn n -> PropSyn n -> Bool
    $c== :: forall n. Eq n => PropSyn n -> PropSyn n -> Bool
    Eq, Int -> PropSyn n -> ShowS
    [PropSyn n] -> ShowS
    PropSyn n -> String
    (Int -> PropSyn n -> ShowS)
    -> (PropSyn n -> String)
    -> ([PropSyn n] -> ShowS)
    -> Show (PropSyn n)
    forall n. Show n => Int -> PropSyn n -> ShowS
    forall n. Show n => [PropSyn n] -> ShowS
    forall n. Show n => PropSyn n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [PropSyn n] -> ShowS
    $cshowList :: forall n. Show n => [PropSyn n] -> ShowS
    show :: PropSyn n -> String
    $cshow :: forall n. Show n => PropSyn n -> String
    showsPrec :: Int -> PropSyn n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> PropSyn n -> ShowS
    Show, (forall x. PropSyn n -> Rep (PropSyn n) x)
    -> (forall x. Rep (PropSyn n) x -> PropSyn n)
    -> Generic (PropSyn n)
    forall x. Rep (PropSyn n) x -> PropSyn n
    forall x. PropSyn n -> Rep (PropSyn n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (PropSyn n) x -> PropSyn n
    forall n x. PropSyn n -> Rep (PropSyn n) x
    $cto :: forall n x. Rep (PropSyn n) x -> PropSyn n
    $cfrom :: forall n x. PropSyn n -> Rep (PropSyn n) x
    Generic, PropSyn n -> ()
    (PropSyn n -> ()) -> NFData (PropSyn n)
    forall n. NFData n => PropSyn n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: PropSyn n -> ()
    $crnf :: forall n. NFData n => PropSyn n -> ()
    NFData, a -> PropSyn b -> PropSyn a
    (a -> b) -> PropSyn a -> PropSyn b
    (forall a b. (a -> b) -> PropSyn a -> PropSyn b)
    -> (forall a b. a -> PropSyn b -> PropSyn a) -> Functor PropSyn
    forall a b. a -> PropSyn b -> PropSyn a
    forall a b. (a -> b) -> PropSyn a -> PropSyn b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> PropSyn b -> PropSyn a
    $c<$ :: forall a b. a -> PropSyn b -> PropSyn a
    fmap :: (a -> b) -> PropSyn a -> PropSyn b
    $cfmap :: forall a b. (a -> b) -> PropSyn a -> PropSyn b
    Functor)

    tsName :: TySyn name -> Located name
    tsName :: TySyn name -> Located name
    tsName (TySyn lqn :: Located name
    lqn _ _ _) = Located name
    lqn

    psName :: PropSyn name -> Located name
    psName :: PropSyn name -> Located name
    psName (PropSyn lqn :: Located name
    lqn _ _ _) = Located name
    lqn

    tsFixity :: TySyn name -> Maybe Fixity
    tsFixity :: TySyn name -> Maybe Fixity
    tsFixity (TySyn _ f :: Maybe Fixity
    f _ _) = Maybe Fixity
    f

    psFixity :: PropSyn name -> Maybe Fixity
    psFixity :: PropSyn name -> Maybe Fixity
    psFixity (PropSyn _ f :: Maybe Fixity
    f _ _) = Maybe Fixity
    f

    {- | Bindings.  Notes:

        * The parser does not associate type signatures and pragmas with
          their bindings: this is done in a separate pass, after de-sugaring
          pattern bindings.  In this way we can associate pragmas and type
          signatures with the variables defined by pattern bindings as well.

        * Currently, there is no surface syntax for defining monomorphic
          bindings (i.e., bindings that will not be automatically generalized
          by the type checker.  However, they are useful when de-sugaring
          patterns.
    -}
    data Bind name = Bind
      { Bind name -> Located name
    bName      :: Located name            -- ^ Defined thing
      , Bind name -> [Pattern name]
    bParams    :: [Pattern name]          -- ^ Parameters
      , Bind name -> Located (BindDef name)
    bDef       :: Located (BindDef name)  -- ^ Definition
      , Bind name -> Maybe (Schema name)
    bSignature :: Maybe (Schema name)     -- ^ Optional type sig
      , Bind name -> Bool
    bInfix     :: Bool                    -- ^ Infix operator?
      , Bind name -> Maybe Fixity
    bFixity    :: Maybe Fixity            -- ^ Optional fixity info
      , Bind name -> [Pragma]
    bPragmas   :: [Pragma]                -- ^ Optional pragmas
      , Bind name -> Bool
    bMono      :: Bool                    -- ^ Is this a monomorphic binding
      , Bind name -> Maybe String
    bDoc       :: Maybe String            -- ^ Optional doc string
      } deriving (Bind name -> Bind name -> Bool
    (Bind name -> Bind name -> Bool)
    -> (Bind name -> Bind name -> Bool) -> Eq (Bind name)
    forall name. Eq name => Bind name -> Bind name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Bind name -> Bind name -> Bool
    $c/= :: forall name. Eq name => Bind name -> Bind name -> Bool
    == :: Bind name -> Bind name -> Bool
    $c== :: forall name. Eq name => Bind name -> Bind name -> Bool
    Eq, (forall x. Bind name -> Rep (Bind name) x)
    -> (forall x. Rep (Bind name) x -> Bind name)
    -> Generic (Bind name)
    forall x. Rep (Bind name) x -> Bind name
    forall x. Bind name -> Rep (Bind name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (Bind name) x -> Bind name
    forall name x. Bind name -> Rep (Bind name) x
    $cto :: forall name x. Rep (Bind name) x -> Bind name
    $cfrom :: forall name x. Bind name -> Rep (Bind name) x
    Generic, Bind name -> ()
    (Bind name -> ()) -> NFData (Bind name)
    forall name. NFData name => Bind name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Bind name -> ()
    $crnf :: forall name. NFData name => Bind name -> ()
    NFData, a -> Bind b -> Bind a
    (a -> b) -> Bind a -> Bind b
    (forall a b. (a -> b) -> Bind a -> Bind b)
    -> (forall a b. a -> Bind b -> Bind a) -> Functor Bind
    forall a b. a -> Bind b -> Bind a
    forall a b. (a -> b) -> Bind a -> Bind b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Bind b -> Bind a
    $c<$ :: forall a b. a -> Bind b -> Bind a
    fmap :: (a -> b) -> Bind a -> Bind b
    $cfmap :: forall a b. (a -> b) -> Bind a -> Bind b
    Functor, Int -> Bind name -> ShowS
    [Bind name] -> ShowS
    Bind name -> String
    (Int -> Bind name -> ShowS)
    -> (Bind name -> String)
    -> ([Bind name] -> ShowS)
    -> Show (Bind name)
    forall name. Show name => Int -> Bind name -> ShowS
    forall name. Show name => [Bind name] -> ShowS
    forall name. Show name => Bind name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Bind name] -> ShowS
    $cshowList :: forall name. Show name => [Bind name] -> ShowS
    show :: Bind name -> String
    $cshow :: forall name. Show name => Bind name -> String
    showsPrec :: Int -> Bind name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> Bind name -> ShowS
    Show)

    type LBindDef = Located (BindDef PName)

    data BindDef name = DPrim
                      | DExpr (Expr name)
                        deriving (BindDef name -> BindDef name -> Bool
    (BindDef name -> BindDef name -> Bool)
    -> (BindDef name -> BindDef name -> Bool) -> Eq (BindDef name)
    forall name. Eq name => BindDef name -> BindDef name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: BindDef name -> BindDef name -> Bool
    $c/= :: forall name. Eq name => BindDef name -> BindDef name -> Bool
    == :: BindDef name -> BindDef name -> Bool
    $c== :: forall name. Eq name => BindDef name -> BindDef name -> Bool
    Eq, Int -> BindDef name -> ShowS
    [BindDef name] -> ShowS
    BindDef name -> String
    (Int -> BindDef name -> ShowS)
    -> (BindDef name -> String)
    -> ([BindDef name] -> ShowS)
    -> Show (BindDef name)
    forall name. Show name => Int -> BindDef name -> ShowS
    forall name. Show name => [BindDef name] -> ShowS
    forall name. Show name => BindDef name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [BindDef name] -> ShowS
    $cshowList :: forall name. Show name => [BindDef name] -> ShowS
    show :: BindDef name -> String
    $cshow :: forall name. Show name => BindDef name -> String
    showsPrec :: Int -> BindDef name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> BindDef name -> ShowS
    Show, (forall x. BindDef name -> Rep (BindDef name) x)
    -> (forall x. Rep (BindDef name) x -> BindDef name)
    -> Generic (BindDef name)
    forall x. Rep (BindDef name) x -> BindDef name
    forall x. BindDef name -> Rep (BindDef name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (BindDef name) x -> BindDef name
    forall name x. BindDef name -> Rep (BindDef name) x
    $cto :: forall name x. Rep (BindDef name) x -> BindDef name
    $cfrom :: forall name x. BindDef name -> Rep (BindDef name) x
    Generic, BindDef name -> ()
    (BindDef name -> ()) -> NFData (BindDef name)
    forall name. NFData name => BindDef name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: BindDef name -> ()
    $crnf :: forall name. NFData name => BindDef name -> ()
    NFData, a -> BindDef b -> BindDef a
    (a -> b) -> BindDef a -> BindDef b
    (forall a b. (a -> b) -> BindDef a -> BindDef b)
    -> (forall a b. a -> BindDef b -> BindDef a) -> Functor BindDef
    forall a b. a -> BindDef b -> BindDef a
    forall a b. (a -> b) -> BindDef a -> BindDef b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> BindDef b -> BindDef a
    $c<$ :: forall a b. a -> BindDef b -> BindDef a
    fmap :: (a -> b) -> BindDef a -> BindDef b
    $cfmap :: forall a b. (a -> b) -> BindDef a -> BindDef b
    Functor)

    data Pragma   = PragmaNote String
                  | PragmaProperty
                    deriving (Pragma -> Pragma -> Bool
    (Pragma -> Pragma -> Bool)
    -> (Pragma -> Pragma -> Bool) -> Eq Pragma
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Pragma -> Pragma -> Bool
    $c/= :: Pragma -> Pragma -> Bool
    == :: Pragma -> Pragma -> Bool
    $c== :: Pragma -> Pragma -> Bool
    Eq, Int -> Pragma -> ShowS
    [Pragma] -> ShowS
    Pragma -> String
    (Int -> Pragma -> ShowS)
    -> (Pragma -> String) -> ([Pragma] -> ShowS) -> Show Pragma
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Pragma] -> ShowS
    $cshowList :: [Pragma] -> ShowS
    show :: Pragma -> String
    $cshow :: Pragma -> String
    showsPrec :: Int -> Pragma -> ShowS
    $cshowsPrec :: Int -> Pragma -> ShowS
    Show, (forall x. Pragma -> Rep Pragma x)
    -> (forall x. Rep Pragma x -> Pragma) -> Generic Pragma
    forall x. Rep Pragma x -> Pragma
    forall x. Pragma -> Rep Pragma x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep Pragma x -> Pragma
    $cfrom :: forall x. Pragma -> Rep Pragma x
    Generic, Pragma -> ()
    (Pragma -> ()) -> NFData Pragma
    forall a. (a -> ()) -> NFData a
    rnf :: Pragma -> ()
    $crnf :: Pragma -> ()
    NFData)

    data Newtype name = Newtype { Newtype name -> Located name
    nName   :: Located name        -- ^ Type name
                                , Newtype name -> [TParam name]
    nParams :: [TParam name]       -- ^ Type params
                                , Newtype name -> [Named (Type name)]
    nBody   :: [Named (Type name)] -- ^ Constructor
                                } deriving (Newtype name -> Newtype name -> Bool
    (Newtype name -> Newtype name -> Bool)
    -> (Newtype name -> Newtype name -> Bool) -> Eq (Newtype name)
    forall name. Eq name => Newtype name -> Newtype name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Newtype name -> Newtype name -> Bool
    $c/= :: forall name. Eq name => Newtype name -> Newtype name -> Bool
    == :: Newtype name -> Newtype name -> Bool
    $c== :: forall name. Eq name => Newtype name -> Newtype name -> Bool
    Eq, Int -> Newtype name -> ShowS
    [Newtype name] -> ShowS
    Newtype name -> String
    (Int -> Newtype name -> ShowS)
    -> (Newtype name -> String)
    -> ([Newtype name] -> ShowS)
    -> Show (Newtype name)
    forall name. Show name => Int -> Newtype name -> ShowS
    forall name. Show name => [Newtype name] -> ShowS
    forall name. Show name => Newtype name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Newtype name] -> ShowS
    $cshowList :: forall name. Show name => [Newtype name] -> ShowS
    show :: Newtype name -> String
    $cshow :: forall name. Show name => Newtype name -> String
    showsPrec :: Int -> Newtype name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> Newtype name -> ShowS
    Show, (forall x. Newtype name -> Rep (Newtype name) x)
    -> (forall x. Rep (Newtype name) x -> Newtype name)
    -> Generic (Newtype name)
    forall x. Rep (Newtype name) x -> Newtype name
    forall x. Newtype name -> Rep (Newtype name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (Newtype name) x -> Newtype name
    forall name x. Newtype name -> Rep (Newtype name) x
    $cto :: forall name x. Rep (Newtype name) x -> Newtype name
    $cfrom :: forall name x. Newtype name -> Rep (Newtype name) x
    Generic, Newtype name -> ()
    (Newtype name -> ()) -> NFData (Newtype name)
    forall name. NFData name => Newtype name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Newtype name -> ()
    $crnf :: forall name. NFData name => Newtype name -> ()
    NFData)

    -- | A declaration for a type with no implementation.
    data PrimType name = PrimType { PrimType name -> Located name
    primTName :: Located name
                                  , PrimType name -> Located Kind
    primTKind :: Located Kind
                                  , PrimType name -> ([TParam name], [Prop name])
    primTCts  :: ([TParam name], [Prop name])
                                    -- ^ parameters are in the order used
                                    -- by the type constructor.
                                  , PrimType name -> Maybe Fixity
    primTFixity :: Maybe Fixity
                                  } deriving (Int -> PrimType name -> ShowS
    [PrimType name] -> ShowS
    PrimType name -> String
    (Int -> PrimType name -> ShowS)
    -> (PrimType name -> String)
    -> ([PrimType name] -> ShowS)
    -> Show (PrimType name)
    forall name. Show name => Int -> PrimType name -> ShowS
    forall name. Show name => [PrimType name] -> ShowS
    forall name. Show name => PrimType name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [PrimType name] -> ShowS
    $cshowList :: forall name. Show name => [PrimType name] -> ShowS
    show :: PrimType name -> String
    $cshow :: forall name. Show name => PrimType name -> String
    showsPrec :: Int -> PrimType name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> PrimType name -> ShowS
    Show,(forall x. PrimType name -> Rep (PrimType name) x)
    -> (forall x. Rep (PrimType name) x -> PrimType name)
    -> Generic (PrimType name)
    forall x. Rep (PrimType name) x -> PrimType name
    forall x. PrimType name -> Rep (PrimType name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (PrimType name) x -> PrimType name
    forall name x. PrimType name -> Rep (PrimType name) x
    $cto :: forall name x. Rep (PrimType name) x -> PrimType name
    $cfrom :: forall name x. PrimType name -> Rep (PrimType name) x
    Generic,PrimType name -> ()
    (PrimType name -> ()) -> NFData (PrimType name)
    forall name. NFData name => PrimType name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: PrimType name -> ()
    $crnf :: forall name. NFData name => PrimType name -> ()
    NFData)

    -- | Input at the REPL, which can either be an expression or a @let@
    -- statement.
    data ReplInput name = ExprInput (Expr name)
                        | LetInput (Decl name)
                          deriving (ReplInput name -> ReplInput name -> Bool
    (ReplInput name -> ReplInput name -> Bool)
    -> (ReplInput name -> ReplInput name -> Bool)
    -> Eq (ReplInput name)
    forall name. Eq name => ReplInput name -> ReplInput name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: ReplInput name -> ReplInput name -> Bool
    $c/= :: forall name. Eq name => ReplInput name -> ReplInput name -> Bool
    == :: ReplInput name -> ReplInput name -> Bool
    $c== :: forall name. Eq name => ReplInput name -> ReplInput name -> Bool
    Eq, Int -> ReplInput name -> ShowS
    [ReplInput name] -> ShowS
    ReplInput name -> String
    (Int -> ReplInput name -> ShowS)
    -> (ReplInput name -> String)
    -> ([ReplInput name] -> ShowS)
    -> Show (ReplInput name)
    forall name. Show name => Int -> ReplInput name -> ShowS
    forall name. Show name => [ReplInput name] -> ShowS
    forall name. Show name => ReplInput name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [ReplInput name] -> ShowS
    $cshowList :: forall name. Show name => [ReplInput name] -> ShowS
    show :: ReplInput name -> String
    $cshow :: forall name. Show name => ReplInput name -> String
    showsPrec :: Int -> ReplInput name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> ReplInput name -> ShowS
    Show)

    -- | Export information for a declaration.
    data ExportType = Public
                    | Private
                      deriving (ExportType -> ExportType -> Bool
    (ExportType -> ExportType -> Bool)
    -> (ExportType -> ExportType -> Bool) -> Eq ExportType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: ExportType -> ExportType -> Bool
    $c/= :: ExportType -> ExportType -> Bool
    == :: ExportType -> ExportType -> Bool
    $c== :: ExportType -> ExportType -> Bool
    Eq, Int -> ExportType -> ShowS
    [ExportType] -> ShowS
    ExportType -> String
    (Int -> ExportType -> ShowS)
    -> (ExportType -> String)
    -> ([ExportType] -> ShowS)
    -> Show ExportType
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [ExportType] -> ShowS
    $cshowList :: [ExportType] -> ShowS
    show :: ExportType -> String
    $cshow :: ExportType -> String
    showsPrec :: Int -> ExportType -> ShowS
    $cshowsPrec :: Int -> ExportType -> ShowS
    Show, Eq ExportType
    Eq ExportType =>
    (ExportType -> ExportType -> Ordering)
    -> (ExportType -> ExportType -> Bool)
    -> (ExportType -> ExportType -> Bool)
    -> (ExportType -> ExportType -> Bool)
    -> (ExportType -> ExportType -> Bool)
    -> (ExportType -> ExportType -> ExportType)
    -> (ExportType -> ExportType -> ExportType)
    -> Ord ExportType
    ExportType -> ExportType -> Bool
    ExportType -> ExportType -> Ordering
    ExportType -> ExportType -> ExportType
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: ExportType -> ExportType -> ExportType
    $cmin :: ExportType -> ExportType -> ExportType
    max :: ExportType -> ExportType -> ExportType
    $cmax :: ExportType -> ExportType -> ExportType
    >= :: ExportType -> ExportType -> Bool
    $c>= :: ExportType -> ExportType -> Bool
    > :: ExportType -> ExportType -> Bool
    $c> :: ExportType -> ExportType -> Bool
    <= :: ExportType -> ExportType -> Bool
    $c<= :: ExportType -> ExportType -> Bool
    < :: ExportType -> ExportType -> Bool
    $c< :: ExportType -> ExportType -> Bool
    compare :: ExportType -> ExportType -> Ordering
    $ccompare :: ExportType -> ExportType -> Ordering
    $cp1Ord :: Eq ExportType
    Ord, (forall x. ExportType -> Rep ExportType x)
    -> (forall x. Rep ExportType x -> ExportType) -> Generic ExportType
    forall x. Rep ExportType x -> ExportType
    forall x. ExportType -> Rep ExportType x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep ExportType x -> ExportType
    $cfrom :: forall x. ExportType -> Rep ExportType x
    Generic, ExportType -> ()
    (ExportType -> ()) -> NFData ExportType
    forall a. (a -> ()) -> NFData a
    rnf :: ExportType -> ()
    $crnf :: ExportType -> ()
    NFData)

    -- | A top-level module declaration.
    data TopLevel a = TopLevel { TopLevel a -> ExportType
    tlExport :: ExportType
                               , TopLevel a -> Maybe (Located String)
    tlDoc    :: Maybe (Located String)
                               , TopLevel a -> a
    tlValue  :: a
                               }
      deriving (Int -> TopLevel a -> ShowS
    [TopLevel a] -> ShowS
    TopLevel a -> String
    (Int -> TopLevel a -> ShowS)
    -> (TopLevel a -> String)
    -> ([TopLevel a] -> ShowS)
    -> Show (TopLevel a)
    forall a. Show a => Int -> TopLevel a -> ShowS
    forall a. Show a => [TopLevel a] -> ShowS
    forall a. Show a => TopLevel a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [TopLevel a] -> ShowS
    $cshowList :: forall a. Show a => [TopLevel a] -> ShowS
    show :: TopLevel a -> String
    $cshow :: forall a. Show a => TopLevel a -> String
    showsPrec :: Int -> TopLevel a -> ShowS
    $cshowsPrec :: forall a. Show a => Int -> TopLevel a -> ShowS
    Show, (forall x. TopLevel a -> Rep (TopLevel a) x)
    -> (forall x. Rep (TopLevel a) x -> TopLevel a)
    -> Generic (TopLevel a)
    forall x. Rep (TopLevel a) x -> TopLevel a
    forall x. TopLevel a -> Rep (TopLevel a) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall a x. Rep (TopLevel a) x -> TopLevel a
    forall a x. TopLevel a -> Rep (TopLevel a) x
    $cto :: forall a x. Rep (TopLevel a) x -> TopLevel a
    $cfrom :: forall a x. TopLevel a -> Rep (TopLevel a) x
    Generic, TopLevel a -> ()
    (TopLevel a -> ()) -> NFData (TopLevel a)
    forall a. NFData a => TopLevel a -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: TopLevel a -> ()
    $crnf :: forall a. NFData a => TopLevel a -> ()
    NFData, a -> TopLevel b -> TopLevel a
    (a -> b) -> TopLevel a -> TopLevel b
    (forall a b. (a -> b) -> TopLevel a -> TopLevel b)
    -> (forall a b. a -> TopLevel b -> TopLevel a) -> Functor TopLevel
    forall a b. a -> TopLevel b -> TopLevel a
    forall a b. (a -> b) -> TopLevel a -> TopLevel b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> TopLevel b -> TopLevel a
    $c<$ :: forall a b. a -> TopLevel b -> TopLevel a
    fmap :: (a -> b) -> TopLevel a -> TopLevel b
    $cfmap :: forall a b. (a -> b) -> TopLevel a -> TopLevel b
    Functor, TopLevel a -> Bool
    (a -> m) -> TopLevel a -> m
    (a -> b -> b) -> b -> TopLevel a -> b
    (forall m. Monoid m => TopLevel m -> m)
    -> (forall m a. Monoid m => (a -> m) -> TopLevel a -> m)
    -> (forall m a. Monoid m => (a -> m) -> TopLevel a -> m)
    -> (forall a b. (a -> b -> b) -> b -> TopLevel a -> b)
    -> (forall a b. (a -> b -> b) -> b -> TopLevel a -> b)
    -> (forall b a. (b -> a -> b) -> b -> TopLevel a -> b)
    -> (forall b a. (b -> a -> b) -> b -> TopLevel a -> b)
    -> (forall a. (a -> a -> a) -> TopLevel a -> a)
    -> (forall a. (a -> a -> a) -> TopLevel a -> a)
    -> (forall a. TopLevel a -> [a])
    -> (forall a. TopLevel a -> Bool)
    -> (forall a. TopLevel a -> Int)
    -> (forall a. Eq a => a -> TopLevel a -> Bool)
    -> (forall a. Ord a => TopLevel a -> a)
    -> (forall a. Ord a => TopLevel a -> a)
    -> (forall a. Num a => TopLevel a -> a)
    -> (forall a. Num a => TopLevel a -> a)
    -> Foldable TopLevel
    forall a. Eq a => a -> TopLevel a -> Bool
    forall a. Num a => TopLevel a -> a
    forall a. Ord a => TopLevel a -> a
    forall m. Monoid m => TopLevel m -> m
    forall a. TopLevel a -> Bool
    forall a. TopLevel a -> Int
    forall a. TopLevel a -> [a]
    forall a. (a -> a -> a) -> TopLevel a -> a
    forall m a. Monoid m => (a -> m) -> TopLevel a -> m
    forall b a. (b -> a -> b) -> b -> TopLevel a -> b
    forall a b. (a -> b -> b) -> b -> TopLevel 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 :: TopLevel a -> a
    $cproduct :: forall a. Num a => TopLevel a -> a
    sum :: TopLevel a -> a
    $csum :: forall a. Num a => TopLevel a -> a
    minimum :: TopLevel a -> a
    $cminimum :: forall a. Ord a => TopLevel a -> a
    maximum :: TopLevel a -> a
    $cmaximum :: forall a. Ord a => TopLevel a -> a
    elem :: a -> TopLevel a -> Bool
    $celem :: forall a. Eq a => a -> TopLevel a -> Bool
    length :: TopLevel a -> Int
    $clength :: forall a. TopLevel a -> Int
    null :: TopLevel a -> Bool
    $cnull :: forall a. TopLevel a -> Bool
    toList :: TopLevel a -> [a]
    $ctoList :: forall a. TopLevel a -> [a]
    foldl1 :: (a -> a -> a) -> TopLevel a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> TopLevel a -> a
    foldr1 :: (a -> a -> a) -> TopLevel a -> a
    $cfoldr1 :: forall a. (a -> a -> a) -> TopLevel a -> a
    foldl' :: (b -> a -> b) -> b -> TopLevel a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> TopLevel a -> b
    foldl :: (b -> a -> b) -> b -> TopLevel a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> TopLevel a -> b
    foldr' :: (a -> b -> b) -> b -> TopLevel a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> TopLevel a -> b
    foldr :: (a -> b -> b) -> b -> TopLevel a -> b
    $cfoldr :: forall a b. (a -> b -> b) -> b -> TopLevel a -> b
    foldMap' :: (a -> m) -> TopLevel a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> TopLevel a -> m
    foldMap :: (a -> m) -> TopLevel a -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> TopLevel a -> m
    fold :: TopLevel m -> m
    $cfold :: forall m. Monoid m => TopLevel m -> m
    Foldable, Functor TopLevel
    Foldable TopLevel
    (Functor TopLevel, Foldable TopLevel) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> TopLevel a -> f (TopLevel b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        TopLevel (f a) -> f (TopLevel a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> TopLevel a -> m (TopLevel b))
    -> (forall (m :: * -> *) a.
        Monad m =>
        TopLevel (m a) -> m (TopLevel a))
    -> Traversable TopLevel
    (a -> f b) -> TopLevel a -> f (TopLevel 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 => TopLevel (m a) -> m (TopLevel a)
    forall (f :: * -> *) a.
    Applicative f =>
    TopLevel (f a) -> f (TopLevel a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> TopLevel a -> m (TopLevel b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> TopLevel a -> f (TopLevel b)
    sequence :: TopLevel (m a) -> m (TopLevel a)
    $csequence :: forall (m :: * -> *) a. Monad m => TopLevel (m a) -> m (TopLevel a)
    mapM :: (a -> m b) -> TopLevel a -> m (TopLevel b)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> TopLevel a -> m (TopLevel b)
    sequenceA :: TopLevel (f a) -> f (TopLevel a)
    $csequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    TopLevel (f a) -> f (TopLevel a)
    traverse :: (a -> f b) -> TopLevel a -> f (TopLevel b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> TopLevel a -> f (TopLevel b)
    $cp2Traversable :: Foldable TopLevel
    $cp1Traversable :: Functor TopLevel
    Traversable)

    -- | Infromation about the representation of a numeric constant.
    data NumInfo  = BinLit Int                      -- ^ n-digit binary literal
                  | OctLit Int                      -- ^ n-digit octal  literal
                  | DecLit                          -- ^ overloaded decimal literal
                  | HexLit Int                      -- ^ n-digit hex literal
                  | CharLit                         -- ^ character literal
                  | PolyLit Int                     -- ^ polynomial literal
                    deriving (NumInfo -> NumInfo -> Bool
    (NumInfo -> NumInfo -> Bool)
    -> (NumInfo -> NumInfo -> Bool) -> Eq NumInfo
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: NumInfo -> NumInfo -> Bool
    $c/= :: NumInfo -> NumInfo -> Bool
    == :: NumInfo -> NumInfo -> Bool
    $c== :: NumInfo -> NumInfo -> Bool
    Eq, Int -> NumInfo -> ShowS
    [NumInfo] -> ShowS
    NumInfo -> String
    (Int -> NumInfo -> ShowS)
    -> (NumInfo -> String) -> ([NumInfo] -> ShowS) -> Show NumInfo
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [NumInfo] -> ShowS
    $cshowList :: [NumInfo] -> ShowS
    show :: NumInfo -> String
    $cshow :: NumInfo -> String
    showsPrec :: Int -> NumInfo -> ShowS
    $cshowsPrec :: Int -> NumInfo -> ShowS
    Show, (forall x. NumInfo -> Rep NumInfo x)
    -> (forall x. Rep NumInfo x -> NumInfo) -> Generic NumInfo
    forall x. Rep NumInfo x -> NumInfo
    forall x. NumInfo -> Rep NumInfo x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep NumInfo x -> NumInfo
    $cfrom :: forall x. NumInfo -> Rep NumInfo x
    Generic, NumInfo -> ()
    (NumInfo -> ()) -> NFData NumInfo
    forall a. (a -> ()) -> NFData a
    rnf :: NumInfo -> ()
    $crnf :: NumInfo -> ()
    NFData)

    -- | Literals.
    data Literal  = ECNum Integer NumInfo           -- ^ @0x10@  (HexLit 2)
                  | ECString String                 -- ^ @\"hello\"@
                    deriving (Literal -> Literal -> Bool
    (Literal -> Literal -> Bool)
    -> (Literal -> Literal -> Bool) -> Eq Literal
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Literal -> Literal -> Bool
    $c/= :: Literal -> Literal -> Bool
    == :: Literal -> Literal -> Bool
    $c== :: Literal -> Literal -> Bool
    Eq, Int -> Literal -> ShowS
    [Literal] -> ShowS
    Literal -> String
    (Int -> Literal -> ShowS)
    -> (Literal -> String) -> ([Literal] -> ShowS) -> Show Literal
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Literal] -> ShowS
    $cshowList :: [Literal] -> ShowS
    show :: Literal -> String
    $cshow :: Literal -> String
    showsPrec :: Int -> Literal -> ShowS
    $cshowsPrec :: Int -> Literal -> ShowS
    Show, (forall x. Literal -> Rep Literal x)
    -> (forall x. Rep Literal x -> Literal) -> Generic Literal
    forall x. Rep Literal x -> Literal
    forall x. Literal -> Rep Literal x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep Literal x -> Literal
    $cfrom :: forall x. Literal -> Rep Literal x
    Generic, Literal -> ()
    (Literal -> ()) -> NFData Literal
    forall a. (a -> ()) -> NFData a
    rnf :: Literal -> ()
    $crnf :: Literal -> ()
    NFData)

    data Expr n   = EVar n                          -- ^ @ x @
                  | ELit Literal                    -- ^ @ 0x10 @
                  | ENeg (Expr n)                   -- ^ @ -1 @
                  | EComplement (Expr n)            -- ^ @ ~1 @
                  | EGenerate (Expr n)              -- ^ @ generate f @
                  | ETuple [Expr n]                 -- ^ @ (1,2,3) @
                  | ERecord [Named (Expr n)]        -- ^ @ { x = 1, y = 2 } @
                  | ESel (Expr n) Selector          -- ^ @ e.l @
                  | EUpd (Maybe (Expr n)) [ UpdField n ]  -- ^ @ { r | x = e } @
                  | EList [Expr n]                  -- ^ @ [1,2,3] @
                  | EFromTo (Type n) (Maybe (Type n)) (Type n) (Maybe (Type n))
                                                    -- ^ @ [1, 5 .. 117 : t] @
                  | EInfFrom (Expr n) (Maybe (Expr n))-- ^ @ [1, 3 ...] @
                  | EComp (Expr n) [[Match n]]      -- ^ @ [ 1 | x <- xs ] @
                  | EApp (Expr n) (Expr n)          -- ^ @ f x @
                  | EAppT (Expr n) [(TypeInst n)]   -- ^ @ f `{x = 8}, f`{8} @
                  | EIf (Expr n) (Expr n) (Expr n)  -- ^ @ if ok then e1 else e2 @
                  | EWhere (Expr n) [Decl n]        -- ^ @ 1 + x where { x = 2 } @
                  | ETyped (Expr n) (Type n)        -- ^ @ 1 : [8] @
                  | ETypeVal (Type n)               -- ^ @ `(x + 1)@, @x@ is a type
                  | EFun [Pattern n] (Expr n)       -- ^ @ \\x y -> x @
                  | ELocated (Expr n) Range         -- ^ position annotation

                  | ESplit (Expr n)                 -- ^ @ splitAt x @ (Introduced by NoPat)
                  | EParens (Expr n)                -- ^ @ (e)   @ (Removed by Fixity)
                  | EInfix (Expr n) (Located n) Fixity (Expr n)-- ^ @ a + b @ (Removed by Fixity)
                    deriving (Expr n -> Expr n -> Bool
    (Expr n -> Expr n -> Bool)
    -> (Expr n -> Expr n -> Bool) -> Eq (Expr n)
    forall n. Eq n => Expr n -> Expr n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Expr n -> Expr n -> Bool
    $c/= :: forall n. Eq n => Expr n -> Expr n -> Bool
    == :: Expr n -> Expr n -> Bool
    $c== :: forall n. Eq n => Expr n -> Expr n -> Bool
    Eq, Int -> Expr n -> ShowS
    [Expr n] -> ShowS
    Expr n -> String
    (Int -> Expr n -> ShowS)
    -> (Expr n -> String) -> ([Expr n] -> ShowS) -> Show (Expr n)
    forall n. Show n => Int -> Expr n -> ShowS
    forall n. Show n => [Expr n] -> ShowS
    forall n. Show n => Expr n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Expr n] -> ShowS
    $cshowList :: forall n. Show n => [Expr n] -> ShowS
    show :: Expr n -> String
    $cshow :: forall n. Show n => Expr n -> String
    showsPrec :: Int -> Expr n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> Expr n -> ShowS
    Show, (forall x. Expr n -> Rep (Expr n) x)
    -> (forall x. Rep (Expr n) x -> Expr n) -> Generic (Expr n)
    forall x. Rep (Expr n) x -> Expr n
    forall x. Expr n -> Rep (Expr n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (Expr n) x -> Expr n
    forall n x. Expr n -> Rep (Expr n) x
    $cto :: forall n x. Rep (Expr n) x -> Expr n
    $cfrom :: forall n x. Expr n -> Rep (Expr n) x
    Generic, Expr n -> ()
    (Expr n -> ()) -> NFData (Expr n)
    forall n. NFData n => Expr n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Expr n -> ()
    $crnf :: forall n. NFData n => Expr n -> ()
    NFData, a -> Expr b -> Expr a
    (a -> b) -> Expr a -> Expr b
    (forall a b. (a -> b) -> Expr a -> Expr b)
    -> (forall a b. a -> Expr b -> Expr a) -> Functor Expr
    forall a b. a -> Expr b -> Expr a
    forall a b. (a -> b) -> Expr a -> Expr b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Expr b -> Expr a
    $c<$ :: forall a b. a -> Expr b -> Expr a
    fmap :: (a -> b) -> Expr a -> Expr b
    $cfmap :: forall a b. (a -> b) -> Expr a -> Expr b
    Functor)

    data UpdField n = UpdField UpdHow [Located Selector] (Expr n)
                                                    -- ^ non-empty list @ x.y = e@
                    deriving (UpdField n -> UpdField n -> Bool
    (UpdField n -> UpdField n -> Bool)
    -> (UpdField n -> UpdField n -> Bool) -> Eq (UpdField n)
    forall n. Eq n => UpdField n -> UpdField n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: UpdField n -> UpdField n -> Bool
    $c/= :: forall n. Eq n => UpdField n -> UpdField n -> Bool
    == :: UpdField n -> UpdField n -> Bool
    $c== :: forall n. Eq n => UpdField n -> UpdField n -> Bool
    Eq, Int -> UpdField n -> ShowS
    [UpdField n] -> ShowS
    UpdField n -> String
    (Int -> UpdField n -> ShowS)
    -> (UpdField n -> String)
    -> ([UpdField n] -> ShowS)
    -> Show (UpdField n)
    forall n. Show n => Int -> UpdField n -> ShowS
    forall n. Show n => [UpdField n] -> ShowS
    forall n. Show n => UpdField n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [UpdField n] -> ShowS
    $cshowList :: forall n. Show n => [UpdField n] -> ShowS
    show :: UpdField n -> String
    $cshow :: forall n. Show n => UpdField n -> String
    showsPrec :: Int -> UpdField n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> UpdField n -> ShowS
    Show, (forall x. UpdField n -> Rep (UpdField n) x)
    -> (forall x. Rep (UpdField n) x -> UpdField n)
    -> Generic (UpdField n)
    forall x. Rep (UpdField n) x -> UpdField n
    forall x. UpdField n -> Rep (UpdField n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (UpdField n) x -> UpdField n
    forall n x. UpdField n -> Rep (UpdField n) x
    $cto :: forall n x. Rep (UpdField n) x -> UpdField n
    $cfrom :: forall n x. UpdField n -> Rep (UpdField n) x
    Generic, UpdField n -> ()
    (UpdField n -> ()) -> NFData (UpdField n)
    forall n. NFData n => UpdField n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: UpdField n -> ()
    $crnf :: forall n. NFData n => UpdField n -> ()
    NFData, a -> UpdField b -> UpdField a
    (a -> b) -> UpdField a -> UpdField b
    (forall a b. (a -> b) -> UpdField a -> UpdField b)
    -> (forall a b. a -> UpdField b -> UpdField a) -> Functor UpdField
    forall a b. a -> UpdField b -> UpdField a
    forall a b. (a -> b) -> UpdField a -> UpdField b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> UpdField b -> UpdField a
    $c<$ :: forall a b. a -> UpdField b -> UpdField a
    fmap :: (a -> b) -> UpdField a -> UpdField b
    $cfmap :: forall a b. (a -> b) -> UpdField a -> UpdField b
    Functor)

    data UpdHow     = UpdSet | UpdFun   -- ^ Are we setting or updating a field.
                    deriving (UpdHow -> UpdHow -> Bool
    (UpdHow -> UpdHow -> Bool)
    -> (UpdHow -> UpdHow -> Bool) -> Eq UpdHow
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: UpdHow -> UpdHow -> Bool
    $c/= :: UpdHow -> UpdHow -> Bool
    == :: UpdHow -> UpdHow -> Bool
    $c== :: UpdHow -> UpdHow -> Bool
    Eq, Int -> UpdHow -> ShowS
    [UpdHow] -> ShowS
    UpdHow -> String
    (Int -> UpdHow -> ShowS)
    -> (UpdHow -> String) -> ([UpdHow] -> ShowS) -> Show UpdHow
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [UpdHow] -> ShowS
    $cshowList :: [UpdHow] -> ShowS
    show :: UpdHow -> String
    $cshow :: UpdHow -> String
    showsPrec :: Int -> UpdHow -> ShowS
    $cshowsPrec :: Int -> UpdHow -> ShowS
    Show, (forall x. UpdHow -> Rep UpdHow x)
    -> (forall x. Rep UpdHow x -> UpdHow) -> Generic UpdHow
    forall x. Rep UpdHow x -> UpdHow
    forall x. UpdHow -> Rep UpdHow x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep UpdHow x -> UpdHow
    $cfrom :: forall x. UpdHow -> Rep UpdHow x
    Generic, UpdHow -> ()
    (UpdHow -> ()) -> NFData UpdHow
    forall a. (a -> ()) -> NFData a
    rnf :: UpdHow -> ()
    $crnf :: UpdHow -> ()
    NFData)

    data TypeInst name = NamedInst (Named (Type name))
                       | PosInst (Type name)
                         deriving (TypeInst name -> TypeInst name -> Bool
    (TypeInst name -> TypeInst name -> Bool)
    -> (TypeInst name -> TypeInst name -> Bool) -> Eq (TypeInst name)
    forall name. Eq name => TypeInst name -> TypeInst name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: TypeInst name -> TypeInst name -> Bool
    $c/= :: forall name. Eq name => TypeInst name -> TypeInst name -> Bool
    == :: TypeInst name -> TypeInst name -> Bool
    $c== :: forall name. Eq name => TypeInst name -> TypeInst name -> Bool
    Eq, Int -> TypeInst name -> ShowS
    [TypeInst name] -> ShowS
    TypeInst name -> String
    (Int -> TypeInst name -> ShowS)
    -> (TypeInst name -> String)
    -> ([TypeInst name] -> ShowS)
    -> Show (TypeInst name)
    forall name. Show name => Int -> TypeInst name -> ShowS
    forall name. Show name => [TypeInst name] -> ShowS
    forall name. Show name => TypeInst name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [TypeInst name] -> ShowS
    $cshowList :: forall name. Show name => [TypeInst name] -> ShowS
    show :: TypeInst name -> String
    $cshow :: forall name. Show name => TypeInst name -> String
    showsPrec :: Int -> TypeInst name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> TypeInst name -> ShowS
    Show, (forall x. TypeInst name -> Rep (TypeInst name) x)
    -> (forall x. Rep (TypeInst name) x -> TypeInst name)
    -> Generic (TypeInst name)
    forall x. Rep (TypeInst name) x -> TypeInst name
    forall x. TypeInst name -> Rep (TypeInst name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (TypeInst name) x -> TypeInst name
    forall name x. TypeInst name -> Rep (TypeInst name) x
    $cto :: forall name x. Rep (TypeInst name) x -> TypeInst name
    $cfrom :: forall name x. TypeInst name -> Rep (TypeInst name) x
    Generic, TypeInst name -> ()
    (TypeInst name -> ()) -> NFData (TypeInst name)
    forall name. NFData name => TypeInst name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: TypeInst name -> ()
    $crnf :: forall name. NFData name => TypeInst name -> ()
    NFData, a -> TypeInst b -> TypeInst a
    (a -> b) -> TypeInst a -> TypeInst b
    (forall a b. (a -> b) -> TypeInst a -> TypeInst b)
    -> (forall a b. a -> TypeInst b -> TypeInst a) -> Functor TypeInst
    forall a b. a -> TypeInst b -> TypeInst a
    forall a b. (a -> b) -> TypeInst a -> TypeInst b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> TypeInst b -> TypeInst a
    $c<$ :: forall a b. a -> TypeInst b -> TypeInst a
    fmap :: (a -> b) -> TypeInst a -> TypeInst b
    $cfmap :: forall a b. (a -> b) -> TypeInst a -> TypeInst b
    Functor)

    data Match name = Match (Pattern name) (Expr name)              -- ^ p <- e
                    | MatchLet (Bind name)
                      deriving (Match name -> Match name -> Bool
    (Match name -> Match name -> Bool)
    -> (Match name -> Match name -> Bool) -> Eq (Match name)
    forall name. Eq name => Match name -> Match name -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Match name -> Match name -> Bool
    $c/= :: forall name. Eq name => Match name -> Match name -> Bool
    == :: Match name -> Match name -> Bool
    $c== :: forall name. Eq name => Match name -> Match name -> Bool
    Eq, Int -> Match name -> ShowS
    [Match name] -> ShowS
    Match name -> String
    (Int -> Match name -> ShowS)
    -> (Match name -> String)
    -> ([Match name] -> ShowS)
    -> Show (Match name)
    forall name. Show name => Int -> Match name -> ShowS
    forall name. Show name => [Match name] -> ShowS
    forall name. Show name => Match name -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Match name] -> ShowS
    $cshowList :: forall name. Show name => [Match name] -> ShowS
    show :: Match name -> String
    $cshow :: forall name. Show name => Match name -> String
    showsPrec :: Int -> Match name -> ShowS
    $cshowsPrec :: forall name. Show name => Int -> Match name -> ShowS
    Show, (forall x. Match name -> Rep (Match name) x)
    -> (forall x. Rep (Match name) x -> Match name)
    -> Generic (Match name)
    forall x. Rep (Match name) x -> Match name
    forall x. Match name -> Rep (Match name) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall name x. Rep (Match name) x -> Match name
    forall name x. Match name -> Rep (Match name) x
    $cto :: forall name x. Rep (Match name) x -> Match name
    $cfrom :: forall name x. Match name -> Rep (Match name) x
    Generic, Match name -> ()
    (Match name -> ()) -> NFData (Match name)
    forall name. NFData name => Match name -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Match name -> ()
    $crnf :: forall name. NFData name => Match name -> ()
    NFData, a -> Match b -> Match a
    (a -> b) -> Match a -> Match b
    (forall a b. (a -> b) -> Match a -> Match b)
    -> (forall a b. a -> Match b -> Match a) -> Functor Match
    forall a b. a -> Match b -> Match a
    forall a b. (a -> b) -> Match a -> Match b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Match b -> Match a
    $c<$ :: forall a b. a -> Match b -> Match a
    fmap :: (a -> b) -> Match a -> Match b
    $cfmap :: forall a b. (a -> b) -> Match a -> Match b
    Functor)

    data Pattern n = PVar (Located n)              -- ^ @ x @
                   | PWild                         -- ^ @ _ @
                   | PTuple [Pattern n]            -- ^ @ (x,y,z) @
                   | PRecord [ Named (Pattern n) ] -- ^ @ { x = (a,b,c), y = z } @
                   | PList [ Pattern n ]           -- ^ @ [ x, y, z ] @
                   | PTyped (Pattern n) (Type n)   -- ^ @ x : [8] @
                   | PSplit (Pattern n) (Pattern n)-- ^ @ (x # y) @
                   | PLocated (Pattern n) Range    -- ^ Location information
                     deriving (Pattern n -> Pattern n -> Bool
    (Pattern n -> Pattern n -> Bool)
    -> (Pattern n -> Pattern n -> Bool) -> Eq (Pattern n)
    forall n. Eq n => Pattern n -> Pattern n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Pattern n -> Pattern n -> Bool
    $c/= :: forall n. Eq n => Pattern n -> Pattern n -> Bool
    == :: Pattern n -> Pattern n -> Bool
    $c== :: forall n. Eq n => Pattern n -> Pattern n -> Bool
    Eq, Int -> Pattern n -> ShowS
    [Pattern n] -> ShowS
    Pattern n -> String
    (Int -> Pattern n -> ShowS)
    -> (Pattern n -> String)
    -> ([Pattern n] -> ShowS)
    -> Show (Pattern n)
    forall n. Show n => Int -> Pattern n -> ShowS
    forall n. Show n => [Pattern n] -> ShowS
    forall n. Show n => Pattern n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Pattern n] -> ShowS
    $cshowList :: forall n. Show n => [Pattern n] -> ShowS
    show :: Pattern n -> String
    $cshow :: forall n. Show n => Pattern n -> String
    showsPrec :: Int -> Pattern n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> Pattern n -> ShowS
    Show, (forall x. Pattern n -> Rep (Pattern n) x)
    -> (forall x. Rep (Pattern n) x -> Pattern n)
    -> Generic (Pattern n)
    forall x. Rep (Pattern n) x -> Pattern n
    forall x. Pattern n -> Rep (Pattern n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (Pattern n) x -> Pattern n
    forall n x. Pattern n -> Rep (Pattern n) x
    $cto :: forall n x. Rep (Pattern n) x -> Pattern n
    $cfrom :: forall n x. Pattern n -> Rep (Pattern n) x
    Generic, Pattern n -> ()
    (Pattern n -> ()) -> NFData (Pattern n)
    forall n. NFData n => Pattern n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Pattern n -> ()
    $crnf :: forall n. NFData n => Pattern n -> ()
    NFData, a -> Pattern b -> Pattern a
    (a -> b) -> Pattern a -> Pattern b
    (forall a b. (a -> b) -> Pattern a -> Pattern b)
    -> (forall a b. a -> Pattern b -> Pattern a) -> Functor Pattern
    forall a b. a -> Pattern b -> Pattern a
    forall a b. (a -> b) -> Pattern a -> Pattern b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Pattern b -> Pattern a
    $c<$ :: forall a b. a -> Pattern b -> Pattern a
    fmap :: (a -> b) -> Pattern a -> Pattern b
    $cfmap :: forall a b. (a -> b) -> Pattern a -> Pattern b
    Functor)

    data Named a = Named { Named a -> Located Ident
    name :: Located Ident, Named a -> a
    value :: a }
      deriving (Named a -> Named a -> Bool
    (Named a -> Named a -> Bool)
    -> (Named a -> Named a -> Bool) -> Eq (Named a)
    forall a. Eq a => Named a -> Named a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Named a -> Named a -> Bool
    $c/= :: forall a. Eq a => Named a -> Named a -> Bool
    == :: Named a -> Named a -> Bool
    $c== :: forall a. Eq a => Named a -> Named a -> Bool
    Eq, Int -> Named a -> ShowS
    [Named a] -> ShowS
    Named a -> String
    (Int -> Named a -> ShowS)
    -> (Named a -> String) -> ([Named a] -> ShowS) -> Show (Named a)
    forall a. Show a => Int -> Named a -> ShowS
    forall a. Show a => [Named a] -> ShowS
    forall a. Show a => Named a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Named a] -> ShowS
    $cshowList :: forall a. Show a => [Named a] -> ShowS
    show :: Named a -> String
    $cshow :: forall a. Show a => Named a -> String
    showsPrec :: Int -> Named a -> ShowS
    $cshowsPrec :: forall a. Show a => Int -> Named a -> ShowS
    Show, Named a -> Bool
    (a -> m) -> Named a -> m
    (a -> b -> b) -> b -> Named a -> b
    (forall m. Monoid m => Named m -> m)
    -> (forall m a. Monoid m => (a -> m) -> Named a -> m)
    -> (forall m a. Monoid m => (a -> m) -> Named a -> m)
    -> (forall a b. (a -> b -> b) -> b -> Named a -> b)
    -> (forall a b. (a -> b -> b) -> b -> Named a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Named a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Named a -> b)
    -> (forall a. (a -> a -> a) -> Named a -> a)
    -> (forall a. (a -> a -> a) -> Named a -> a)
    -> (forall a. Named a -> [a])
    -> (forall a. Named a -> Bool)
    -> (forall a. Named a -> Int)
    -> (forall a. Eq a => a -> Named a -> Bool)
    -> (forall a. Ord a => Named a -> a)
    -> (forall a. Ord a => Named a -> a)
    -> (forall a. Num a => Named a -> a)
    -> (forall a. Num a => Named a -> a)
    -> Foldable Named
    forall a. Eq a => a -> Named a -> Bool
    forall a. Num a => Named a -> a
    forall a. Ord a => Named a -> a
    forall m. Monoid m => Named m -> m
    forall a. Named a -> Bool
    forall a. Named a -> Int
    forall a. Named a -> [a]
    forall a. (a -> a -> a) -> Named a -> a
    forall m a. Monoid m => (a -> m) -> Named a -> m
    forall b a. (b -> a -> b) -> b -> Named a -> b
    forall a b. (a -> b -> b) -> b -> Named 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 :: Named a -> a
    $cproduct :: forall a. Num a => Named a -> a
    sum :: Named a -> a
    $csum :: forall a. Num a => Named a -> a
    minimum :: Named a -> a
    $cminimum :: forall a. Ord a => Named a -> a
    maximum :: Named a -> a
    $cmaximum :: forall a. Ord a => Named a -> a
    elem :: a -> Named a -> Bool
    $celem :: forall a. Eq a => a -> Named a -> Bool
    length :: Named a -> Int
    $clength :: forall a. Named a -> Int
    null :: Named a -> Bool
    $cnull :: forall a. Named a -> Bool
    toList :: Named a -> [a]
    $ctoList :: forall a. Named a -> [a]
    foldl1 :: (a -> a -> a) -> Named a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> Named a -> a
    foldr1 :: (a -> a -> a) -> Named a -> a
    $cfoldr1 :: forall a. (a -> a -> a) -> Named a -> a
    foldl' :: (b -> a -> b) -> b -> Named a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> Named a -> b
    foldl :: (b -> a -> b) -> b -> Named a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> Named a -> b
    foldr' :: (a -> b -> b) -> b -> Named a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> Named a -> b
    foldr :: (a -> b -> b) -> b -> Named a -> b
    $cfoldr :: forall a b. (a -> b -> b) -> b -> Named a -> b
    foldMap' :: (a -> m) -> Named a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Named a -> m
    foldMap :: (a -> m) -> Named a -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> Named a -> m
    fold :: Named m -> m
    $cfold :: forall m. Monoid m => Named m -> m
    Foldable, Functor Named
    Foldable Named
    (Functor Named, Foldable Named) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> Named a -> f (Named b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        Named (f a) -> f (Named a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> Named a -> m (Named b))
    -> (forall (m :: * -> *) a. Monad m => Named (m a) -> m (Named a))
    -> Traversable Named
    (a -> f b) -> Named a -> f (Named 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 => Named (m a) -> m (Named a)
    forall (f :: * -> *) a. Applicative f => Named (f a) -> f (Named a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Named a -> m (Named b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Named a -> f (Named b)
    sequence :: Named (m a) -> m (Named a)
    $csequence :: forall (m :: * -> *) a. Monad m => Named (m a) -> m (Named a)
    mapM :: (a -> m b) -> Named a -> m (Named b)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Named a -> m (Named b)
    sequenceA :: Named (f a) -> f (Named a)
    $csequenceA :: forall (f :: * -> *) a. Applicative f => Named (f a) -> f (Named a)
    traverse :: (a -> f b) -> Named a -> f (Named b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Named a -> f (Named b)
    $cp2Traversable :: Foldable Named
    $cp1Traversable :: Functor Named
    Traversable, (forall x. Named a -> Rep (Named a) x)
    -> (forall x. Rep (Named a) x -> Named a) -> Generic (Named a)
    forall x. Rep (Named a) x -> Named a
    forall x. Named a -> Rep (Named a) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall a x. Rep (Named a) x -> Named a
    forall a x. Named a -> Rep (Named a) x
    $cto :: forall a x. Rep (Named a) x -> Named a
    $cfrom :: forall a x. Named a -> Rep (Named a) x
    Generic, Named a -> ()
    (Named a -> ()) -> NFData (Named a)
    forall a. NFData a => Named a -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Named a -> ()
    $crnf :: forall a. NFData a => Named a -> ()
    NFData, a -> Named b -> Named a
    (a -> b) -> Named a -> Named b
    (forall a b. (a -> b) -> Named a -> Named b)
    -> (forall a b. a -> Named b -> Named a) -> Functor Named
    forall a b. a -> Named b -> Named a
    forall a b. (a -> b) -> Named a -> Named b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Named b -> Named a
    $c<$ :: forall a b. a -> Named b -> Named a
    fmap :: (a -> b) -> Named a -> Named b
    $cfmap :: forall a b. (a -> b) -> Named a -> Named b
    Functor)

    data Schema n = Forall [TParam n] [Prop n] (Type n) (Maybe Range)
      deriving (Schema n -> Schema n -> Bool
    (Schema n -> Schema n -> Bool)
    -> (Schema n -> Schema n -> Bool) -> Eq (Schema n)
    forall n. Eq n => Schema n -> Schema n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Schema n -> Schema n -> Bool
    $c/= :: forall n. Eq n => Schema n -> Schema n -> Bool
    == :: Schema n -> Schema n -> Bool
    $c== :: forall n. Eq n => Schema n -> Schema n -> Bool
    Eq, Int -> Schema n -> ShowS
    [Schema n] -> ShowS
    Schema n -> String
    (Int -> Schema n -> ShowS)
    -> (Schema n -> String) -> ([Schema n] -> ShowS) -> Show (Schema n)
    forall n. Show n => Int -> Schema n -> ShowS
    forall n. Show n => [Schema n] -> ShowS
    forall n. Show n => Schema n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Schema n] -> ShowS
    $cshowList :: forall n. Show n => [Schema n] -> ShowS
    show :: Schema n -> String
    $cshow :: forall n. Show n => Schema n -> String
    showsPrec :: Int -> Schema n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> Schema n -> ShowS
    Show, (forall x. Schema n -> Rep (Schema n) x)
    -> (forall x. Rep (Schema n) x -> Schema n) -> Generic (Schema n)
    forall x. Rep (Schema n) x -> Schema n
    forall x. Schema n -> Rep (Schema n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (Schema n) x -> Schema n
    forall n x. Schema n -> Rep (Schema n) x
    $cto :: forall n x. Rep (Schema n) x -> Schema n
    $cfrom :: forall n x. Schema n -> Rep (Schema n) x
    Generic, Schema n -> ()
    (Schema n -> ()) -> NFData (Schema n)
    forall n. NFData n => Schema n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Schema n -> ()
    $crnf :: forall n. NFData n => Schema n -> ()
    NFData, a -> Schema b -> Schema a
    (a -> b) -> Schema a -> Schema b
    (forall a b. (a -> b) -> Schema a -> Schema b)
    -> (forall a b. a -> Schema b -> Schema a) -> Functor Schema
    forall a b. a -> Schema b -> Schema a
    forall a b. (a -> b) -> Schema a -> Schema b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Schema b -> Schema a
    $c<$ :: forall a b. a -> Schema b -> Schema a
    fmap :: (a -> b) -> Schema a -> Schema b
    $cfmap :: forall a b. (a -> b) -> Schema a -> Schema b
    Functor)

    data Kind = KProp | KNum | KType | KFun Kind Kind
      deriving (Kind -> Kind -> Bool
    (Kind -> Kind -> Bool) -> (Kind -> Kind -> Bool) -> Eq Kind
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Kind -> Kind -> Bool
    $c/= :: Kind -> Kind -> Bool
    == :: Kind -> Kind -> Bool
    $c== :: Kind -> Kind -> Bool
    Eq, Int -> Kind -> ShowS
    [Kind] -> ShowS
    Kind -> String
    (Int -> Kind -> ShowS)
    -> (Kind -> String) -> ([Kind] -> ShowS) -> Show Kind
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Kind] -> ShowS
    $cshowList :: [Kind] -> ShowS
    show :: Kind -> String
    $cshow :: Kind -> String
    showsPrec :: Int -> Kind -> ShowS
    $cshowsPrec :: Int -> Kind -> ShowS
    Show, (forall x. Kind -> Rep Kind x)
    -> (forall x. Rep Kind x -> Kind) -> Generic Kind
    forall x. Rep Kind x -> Kind
    forall x. Kind -> Rep Kind x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep Kind x -> Kind
    $cfrom :: forall x. Kind -> Rep Kind x
    Generic, Kind -> ()
    (Kind -> ()) -> NFData Kind
    forall a. (a -> ()) -> NFData a
    rnf :: Kind -> ()
    $crnf :: Kind -> ()
    NFData)

    data TParam n = TParam { TParam n -> n
    tpName  :: n
                           , TParam n -> Maybe Kind
    tpKind  :: Maybe Kind
                           , TParam n -> Maybe Range
    tpRange :: Maybe Range
                           }
      deriving (TParam n -> TParam n -> Bool
    (TParam n -> TParam n -> Bool)
    -> (TParam n -> TParam n -> Bool) -> Eq (TParam n)
    forall n. Eq n => TParam n -> TParam n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: TParam n -> TParam n -> Bool
    $c/= :: forall n. Eq n => TParam n -> TParam n -> Bool
    == :: TParam n -> TParam n -> Bool
    $c== :: forall n. Eq n => TParam n -> TParam n -> Bool
    Eq, Int -> TParam n -> ShowS
    [TParam n] -> ShowS
    TParam n -> String
    (Int -> TParam n -> ShowS)
    -> (TParam n -> String) -> ([TParam n] -> ShowS) -> Show (TParam n)
    forall n. Show n => Int -> TParam n -> ShowS
    forall n. Show n => [TParam n] -> ShowS
    forall n. Show n => TParam n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [TParam n] -> ShowS
    $cshowList :: forall n. Show n => [TParam n] -> ShowS
    show :: TParam n -> String
    $cshow :: forall n. Show n => TParam n -> String
    showsPrec :: Int -> TParam n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> TParam n -> ShowS
    Show, (forall x. TParam n -> Rep (TParam n) x)
    -> (forall x. Rep (TParam n) x -> TParam n) -> Generic (TParam n)
    forall x. Rep (TParam n) x -> TParam n
    forall x. TParam n -> Rep (TParam n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (TParam n) x -> TParam n
    forall n x. TParam n -> Rep (TParam n) x
    $cto :: forall n x. Rep (TParam n) x -> TParam n
    $cfrom :: forall n x. TParam n -> Rep (TParam n) x
    Generic, TParam n -> ()
    (TParam n -> ()) -> NFData (TParam n)
    forall n. NFData n => TParam n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: TParam n -> ()
    $crnf :: forall n. NFData n => TParam n -> ()
    NFData, a -> TParam b -> TParam a
    (a -> b) -> TParam a -> TParam b
    (forall a b. (a -> b) -> TParam a -> TParam b)
    -> (forall a b. a -> TParam b -> TParam a) -> Functor TParam
    forall a b. a -> TParam b -> TParam a
    forall a b. (a -> b) -> TParam a -> TParam b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> TParam b -> TParam a
    $c<$ :: forall a b. a -> TParam b -> TParam a
    fmap :: (a -> b) -> TParam a -> TParam b
    $cfmap :: forall a b. (a -> b) -> TParam a -> TParam b
    Functor)

    data Type n = TFun (Type n) (Type n)  -- ^ @[8] -> [8]@
                | TSeq (Type n) (Type n)  -- ^ @[8] a@
                | TBit                    -- ^ @Bit@
                | TNum Integer            -- ^ @10@
                | TChar Char              -- ^ @'a'@
                | TUser n [Type n]        -- ^ A type variable or synonym
                | TRecord [Named (Type n)]-- ^ @{ x : [8], y : [32] }@
                | TTuple [Type n]         -- ^ @([8], [32])@
                | TWild                   -- ^ @_@, just some type.
                | TLocated (Type n) Range -- ^ Location information
                | TParens (Type n)        -- ^ @ (ty) @
                | TInfix (Type n) (Located n) Fixity (Type n) -- ^ @ ty + ty @
                  deriving (Type n -> Type n -> Bool
    (Type n -> Type n -> Bool)
    -> (Type n -> Type n -> Bool) -> Eq (Type n)
    forall n. Eq n => Type n -> Type n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Type n -> Type n -> Bool
    $c/= :: forall n. Eq n => Type n -> Type n -> Bool
    == :: Type n -> Type n -> Bool
    $c== :: forall n. Eq n => Type n -> Type n -> Bool
    Eq, Int -> Type n -> ShowS
    [Type n] -> ShowS
    Type n -> String
    (Int -> Type n -> ShowS)
    -> (Type n -> String) -> ([Type n] -> ShowS) -> Show (Type n)
    forall n. Show n => Int -> Type n -> ShowS
    forall n. Show n => [Type n] -> ShowS
    forall n. Show n => Type n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Type n] -> ShowS
    $cshowList :: forall n. Show n => [Type n] -> ShowS
    show :: Type n -> String
    $cshow :: forall n. Show n => Type n -> String
    showsPrec :: Int -> Type n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> Type n -> ShowS
    Show, (forall x. Type n -> Rep (Type n) x)
    -> (forall x. Rep (Type n) x -> Type n) -> Generic (Type n)
    forall x. Rep (Type n) x -> Type n
    forall x. Type n -> Rep (Type n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (Type n) x -> Type n
    forall n x. Type n -> Rep (Type n) x
    $cto :: forall n x. Rep (Type n) x -> Type n
    $cfrom :: forall n x. Type n -> Rep (Type n) x
    Generic, Type n -> ()
    (Type n -> ()) -> NFData (Type n)
    forall n. NFData n => Type n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Type n -> ()
    $crnf :: forall n. NFData n => Type n -> ()
    NFData, a -> Type b -> Type a
    (a -> b) -> Type a -> Type b
    (forall a b. (a -> b) -> Type a -> Type b)
    -> (forall a b. a -> Type b -> Type a) -> Functor Type
    forall a b. a -> Type b -> Type a
    forall a b. (a -> b) -> Type a -> Type b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Type b -> Type a
    $c<$ :: forall a b. a -> Type b -> Type a
    fmap :: (a -> b) -> Type a -> Type b
    $cfmap :: forall a b. (a -> b) -> Type a -> Type b
    Functor)

    -- | A 'Prop' is a 'Type' that represents a type constraint.
    newtype Prop n = CType (Type n)
      deriving (Prop n -> Prop n -> Bool
    (Prop n -> Prop n -> Bool)
    -> (Prop n -> Prop n -> Bool) -> Eq (Prop n)
    forall n. Eq n => Prop n -> Prop n -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Prop n -> Prop n -> Bool
    $c/= :: forall n. Eq n => Prop n -> Prop n -> Bool
    == :: Prop n -> Prop n -> Bool
    $c== :: forall n. Eq n => Prop n -> Prop n -> Bool
    Eq, Int -> Prop n -> ShowS
    [Prop n] -> ShowS
    Prop n -> String
    (Int -> Prop n -> ShowS)
    -> (Prop n -> String) -> ([Prop n] -> ShowS) -> Show (Prop n)
    forall n. Show n => Int -> Prop n -> ShowS
    forall n. Show n => [Prop n] -> ShowS
    forall n. Show n => Prop n -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Prop n] -> ShowS
    $cshowList :: forall n. Show n => [Prop n] -> ShowS
    show :: Prop n -> String
    $cshow :: forall n. Show n => Prop n -> String
    showsPrec :: Int -> Prop n -> ShowS
    $cshowsPrec :: forall n. Show n => Int -> Prop n -> ShowS
    Show, (forall x. Prop n -> Rep (Prop n) x)
    -> (forall x. Rep (Prop n) x -> Prop n) -> Generic (Prop n)
    forall x. Rep (Prop n) x -> Prop n
    forall x. Prop n -> Rep (Prop n) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall n x. Rep (Prop n) x -> Prop n
    forall n x. Prop n -> Rep (Prop n) x
    $cto :: forall n x. Rep (Prop n) x -> Prop n
    $cfrom :: forall n x. Prop n -> Rep (Prop n) x
    Generic, Prop n -> ()
    (Prop n -> ()) -> NFData (Prop n)
    forall n. NFData n => Prop n -> ()
    forall a. (a -> ()) -> NFData a
    rnf :: Prop n -> ()
    $crnf :: forall n. NFData n => Prop n -> ()
    NFData, a -> Prop b -> Prop a
    (a -> b) -> Prop a -> Prop b
    (forall a b. (a -> b) -> Prop a -> Prop b)
    -> (forall a b. a -> Prop b -> Prop a) -> Functor Prop
    forall a b. a -> Prop b -> Prop a
    forall a b. (a -> b) -> Prop a -> Prop b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> Prop b -> Prop a
    $c<$ :: forall a b. a -> Prop b -> Prop a
    fmap :: (a -> b) -> Prop a -> Prop b
    $cfmap :: forall a b. (a -> b) -> Prop a -> Prop b
    Functor)

    --------------------------------------------------------------------------------
    -- Note: When an explicit location is missing, we could use the sub-components
    -- to try to estimate a location...

    instance AddLoc (Expr n) where
      addLoc :: Expr n -> Range -> Expr n
    addLoc = Expr n -> Range -> Expr n
    forall n. Expr n -> Range -> Expr n
    ELocated

      dropLoc :: Expr n -> Expr n
    dropLoc (ELocated e :: Expr n
    e _) = Expr n -> Expr n
    forall t. AddLoc t => t -> t
    dropLoc Expr n
    e
      dropLoc e :: Expr n
    e              = Expr n
    e

    instance HasLoc (Expr name) where
      getLoc :: Expr name -> Maybe Range
    getLoc (ELocated _ r :: Range
    r) = Range -> Maybe Range
    forall a. a -> Maybe a
    Just Range
    r
      getLoc _              = Maybe Range
    forall a. Maybe a
    Nothing

    instance HasLoc (TParam name) where
      getLoc :: TParam name -> Maybe Range
    getLoc (TParam _ _ r :: Maybe Range
    r) = Maybe Range
    r

    instance AddLoc (TParam name) where
      addLoc :: TParam name -> Range -> TParam name
    addLoc (TParam a :: name
    a b :: Maybe Kind
    b _) l :: Range
    l = name -> Maybe Kind -> Maybe Range -> TParam name
    forall n. n -> Maybe Kind -> Maybe Range -> TParam n
    TParam name
    a Maybe Kind
    b (Range -> Maybe Range
    forall a. a -> Maybe a
    Just Range
    l)
      dropLoc :: TParam name -> TParam name
    dropLoc (TParam a :: name
    a b :: Maybe Kind
    b _)  = name -> Maybe Kind -> Maybe Range -> TParam name
    forall n. n -> Maybe Kind -> Maybe Range -> TParam n
    TParam name
    a Maybe Kind
    b Maybe Range
    forall a. Maybe a
    Nothing

    instance HasLoc (Type name) where
      getLoc :: Type name -> Maybe Range
    getLoc (TLocated _ r :: Range
    r) = Range -> Maybe Range
    forall a. a -> Maybe a
    Just Range
    r
      getLoc _              = Maybe Range
    forall a. Maybe a
    Nothing

    instance AddLoc (Type name) where
      addLoc :: Type name -> Range -> Type name
    addLoc = Type name -> Range -> Type name
    forall name. Type name -> Range -> Type name
    TLocated

      dropLoc :: Type name -> Type name
    dropLoc (TLocated e :: Type name
    e _) = Type name -> Type name
    forall t. AddLoc t => t -> t
    dropLoc Type name
    e
      dropLoc e :: Type name
    e              = Type name
    e

    instance AddLoc (Pattern name) where
      addLoc :: Pattern name -> Range -> Pattern name
    addLoc = Pattern name -> Range -> Pattern name
    forall name. Pattern name -> Range -> Pattern name
    PLocated

      dropLoc :: Pattern name -> Pattern name
    dropLoc (PLocated e :: Pattern name
    e _) = Pattern name -> Pattern name
    forall t. AddLoc t => t -> t
    dropLoc Pattern name
    e
      dropLoc e :: Pattern name
    e              = Pattern name
    e

    instance HasLoc (Pattern name) where
      getLoc :: Pattern name -> Maybe Range
    getLoc (PLocated _ r :: Range
    r) = Range -> Maybe Range
    forall a. a -> Maybe a
    Just Range
    r
      getLoc (PTyped r :: Pattern name
    r _)   = Pattern name -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc Pattern name
    r
      getLoc (PVar x :: Located name
    x)       = Located name -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc Located name
    x
      getLoc _              = Maybe Range
    forall a. Maybe a
    Nothing

    instance HasLoc (Bind name) where
      getLoc :: Bind name -> Maybe Range
    getLoc b :: Bind name
    b = (Located name, Located (BindDef name)) -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Bind name -> Located name
    forall name. Bind name -> Located name
    bName Bind name
    b, Bind name -> Located (BindDef name)
    forall name. Bind name -> Located (BindDef name)
    bDef Bind name
    b)

    instance HasLoc (Match name) where
      getLoc :: Match name -> Maybe Range
    getLoc (Match p :: Pattern name
    p e :: Expr name
    e)    = (Pattern name, Expr name) -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Pattern name
    p,Expr name
    e)
      getLoc (MatchLet b :: Bind name
    b)   = Bind name -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc Bind name
    b

    instance HasLoc a => HasLoc (Named a) where
      getLoc :: Named a -> Maybe Range
    getLoc l :: Named a
    l = (Located Ident, a) -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Named a -> Located Ident
    forall a. Named a -> Located Ident
    name Named a
    l, Named a -> a
    forall a. Named a -> a
    value Named a
    l)

    instance HasLoc (Schema name) where
      getLoc :: Schema name -> Maybe Range
    getLoc (Forall _ _ _ r :: Maybe Range
    r) = Maybe Range
    r

    instance AddLoc (Schema name) where
      addLoc :: Schema name -> Range -> Schema name
    addLoc  (Forall xs :: [TParam name]
    xs ps :: [Prop name]
    ps t :: Type name
    t _) r :: Range
    r = [TParam name]
    -> [Prop name] -> Type name -> Maybe Range -> Schema name
    forall n.
    [TParam n] -> [Prop n] -> Type n -> Maybe Range -> Schema n
    Forall [TParam name]
    xs [Prop name]
    ps Type name
    t (Range -> Maybe Range
    forall a. a -> Maybe a
    Just Range
    r)
      dropLoc :: Schema name -> Schema name
    dropLoc (Forall xs :: [TParam name]
    xs ps :: [Prop name]
    ps t :: Type name
    t _)   = [TParam name]
    -> [Prop name] -> Type name -> Maybe Range -> Schema name
    forall n.
    [TParam n] -> [Prop n] -> Type n -> Maybe Range -> Schema n
    Forall [TParam name]
    xs [Prop name]
    ps Type name
    t Maybe Range
    forall a. Maybe a
    Nothing

    instance HasLoc (Decl name) where
      getLoc :: Decl name -> Maybe Range
    getLoc (DLocated _ r :: Range
    r) = Range -> Maybe Range
    forall a. a -> Maybe a
    Just Range
    r
      getLoc _              = Maybe Range
    forall a. Maybe a
    Nothing

    instance AddLoc (Decl name) where
      addLoc :: Decl name -> Range -> Decl name
    addLoc d :: Decl name
    d r :: Range
    r             = Decl name -> Range -> Decl name
    forall name. Decl name -> Range -> Decl name
    DLocated Decl name
    d Range
    r

      dropLoc :: Decl name -> Decl name
    dropLoc (DLocated d :: Decl name
    d _) = Decl name -> Decl name
    forall t. AddLoc t => t -> t
    dropLoc Decl name
    d
      dropLoc d :: Decl name
    d              = Decl name
    d

    instance HasLoc a => HasLoc (TopLevel a) where
      getLoc :: TopLevel a -> Maybe Range
    getLoc = a -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (a -> Maybe Range)
    -> (TopLevel a -> a) -> TopLevel a -> Maybe Range
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TopLevel a -> a
    forall a. TopLevel a -> a
    tlValue

    instance HasLoc (TopDecl name) where
      getLoc :: TopDecl name -> Maybe Range
    getLoc td :: TopDecl name
    td = case TopDecl name
    td of
        Decl tld :: TopLevel (Decl name)
    tld    -> TopLevel (Decl name) -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc TopLevel (Decl name)
    tld
        DPrimType pt :: TopLevel (PrimType name)
    pt -> TopLevel (PrimType name) -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc TopLevel (PrimType name)
    pt
        TDNewtype n :: TopLevel (Newtype name)
    n -> TopLevel (Newtype name) -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc TopLevel (Newtype name)
    n
        Include lfp :: Located String
    lfp -> Located String -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc Located String
    lfp
        DParameterType d :: ParameterType name
    d -> ParameterType name -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc ParameterType name
    d
        DParameterFun d :: ParameterFun name
    d  -> ParameterFun name -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc ParameterFun name
    d
        DParameterConstraint d :: [Located (Prop name)]
    d -> [Located (Prop name)] -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc [Located (Prop name)]
    d

    instance HasLoc (PrimType name) where
      getLoc :: PrimType name -> Maybe Range
    getLoc pt :: PrimType name
    pt = Range -> Maybe Range
    forall a. a -> Maybe a
    Just (Range -> Range -> Range
    rComb (Located name -> Range
    forall a. Located a -> Range
    srcRange (PrimType name -> Located name
    forall name. PrimType name -> Located name
    primTName PrimType name
    pt)) (Located Kind -> Range
    forall a. Located a -> Range
    srcRange (PrimType name -> Located Kind
    forall name. PrimType name -> Located Kind
    primTKind PrimType name
    pt)))

    instance HasLoc (ParameterType name) where
      getLoc :: ParameterType name -> Maybe Range
    getLoc a :: ParameterType name
    a = Located name -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (ParameterType name -> Located name
    forall name. ParameterType name -> Located name
    ptName ParameterType name
    a)

    instance HasLoc (ParameterFun name) where
      getLoc :: ParameterFun name -> Maybe Range
    getLoc a :: ParameterFun name
    a = Located name -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (ParameterFun name -> Located name
    forall name. ParameterFun name -> Located name
    pfName ParameterFun name
    a)

    instance HasLoc (Module name) where
      getLoc :: Module name -> Maybe Range
    getLoc m :: Module name
    m
        | [Range] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Range]
    locs = Maybe Range
    forall a. Maybe a
    Nothing
        | Bool
    otherwise = Range -> Maybe Range
    forall a. a -> Maybe a
    Just ([Range] -> Range
    rCombs [Range]
    locs)
        where
        locs :: [Range]
    locs = [Maybe Range] -> [Range]
    forall a. [Maybe a] -> [a]
    catMaybes [ Located ModName -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Module name -> Located ModName
    forall name. Module name -> Located ModName
    mName Module name
    m)
                         , [Located Import] -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Module name -> [Located Import]
    forall name. Module name -> [Located Import]
    mImports Module name
    m)
                         , [TopDecl name] -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Module name -> [TopDecl name]
    forall name. Module name -> [TopDecl name]
    mDecls Module name
    m)
                         ]

    instance HasLoc (Newtype name) where
      getLoc :: Newtype name -> Maybe Range
    getLoc n :: Newtype name
    n
        | [Range] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Range]
    locs = Maybe Range
    forall a. Maybe a
    Nothing
        | Bool
    otherwise = Range -> Maybe Range
    forall a. a -> Maybe a
    Just ([Range] -> Range
    rCombs [Range]
    locs)
        where
        locs :: [Range]
    locs = [Maybe Range] -> [Range]
    forall a. [Maybe a] -> [a]
    catMaybes [ Located name -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Newtype name -> Located name
    forall name. Newtype name -> Located name
    nName Newtype name
    n), [Named (Type name)] -> Maybe Range
    forall t. HasLoc t => t -> Maybe Range
    getLoc (Newtype name -> [Named (Type name)]
    forall name. Newtype name -> [Named (Type name)]
    nBody Newtype name
    n) ]

    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    -- Pretty printing

    ppL :: PP a => Located a -> Doc
    ppL :: Located a -> Doc
    ppL = a -> Doc
    forall a. PP a => a -> Doc
    pp (a -> Doc) -> (Located a -> a) -> Located a -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Located a -> a
    forall a. Located a -> a
    thing

    ppNamed :: PP a => String -> Named a -> Doc
    ppNamed :: String -> Named a -> Doc
    ppNamed s :: String
    s x :: Named a
    x = Located Ident -> Doc
    forall a. PP a => Located a -> Doc
    ppL (Named a -> Located Ident
    forall a. Named a -> Located Ident
    name Named a
    x) Doc -> Doc -> Doc
    <+> String -> Doc
    text String
    s Doc -> Doc -> Doc
    <+> a -> Doc
    forall a. PP a => a -> Doc
    pp (Named a -> a
    forall a. Named a -> a
    value Named a
    x)

    instance (Show name, PPName name) => PP (Module name) where
      ppPrec :: Int -> Module name -> Doc
    ppPrec _ m :: Module name
    m = String -> Doc
    text "module" Doc -> Doc -> Doc
    <+> Located ModName -> Doc
    forall a. PP a => Located a -> Doc
    ppL (Module name -> Located ModName
    forall name. Module name -> Located ModName
    mName Module name
    m) Doc -> Doc -> Doc
    <+> String -> Doc
    text "where"
                Doc -> Doc -> Doc
    $$ [Doc] -> Doc
    vcat ((Located Import -> Doc) -> [Located Import] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Located Import -> Doc
    forall a. PP a => Located a -> Doc
    ppL (Module name -> [Located Import]
    forall name. Module name -> [Located Import]
    mImports Module name
    m))
                Doc -> Doc -> Doc
    $$ [Doc] -> Doc
    vcat ((TopDecl name -> Doc) -> [TopDecl name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map TopDecl name -> Doc
    forall a. PP a => a -> Doc
    pp (Module name -> [TopDecl name]
    forall name. Module name -> [TopDecl name]
    mDecls Module name
    m))

    instance (Show name, PPName name) => PP (Program name) where
      ppPrec :: Int -> Program name -> Doc
    ppPrec _ (Program ds :: [TopDecl name]
    ds) = [Doc] -> Doc
    vcat ((TopDecl name -> Doc) -> [TopDecl name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map TopDecl name -> Doc
    forall a. PP a => a -> Doc
    pp [TopDecl name]
    ds)

    instance (Show name, PPName name) => PP (TopDecl name) where
      ppPrec :: Int -> TopDecl name -> Doc
    ppPrec _ top_decl :: TopDecl name
    top_decl =
        case TopDecl name
    top_decl of
          Decl    d :: TopLevel (Decl name)
    d   -> TopLevel (Decl name) -> Doc
    forall a. PP a => a -> Doc
    pp TopLevel (Decl name)
    d
          DPrimType p :: TopLevel (PrimType name)
    p -> TopLevel (PrimType name) -> Doc
    forall a. PP a => a -> Doc
    pp TopLevel (PrimType name)
    p
          TDNewtype n :: TopLevel (Newtype name)
    n -> TopLevel (Newtype name) -> Doc
    forall a. PP a => a -> Doc
    pp TopLevel (Newtype name)
    n
          Include l :: Located String
    l   -> String -> Doc
    text "include" Doc -> Doc -> Doc
    <+> String -> Doc
    text (ShowS
    forall a. Show a => a -> String
    show (Located String -> String
    forall a. Located a -> a
    thing Located String
    l))
          DParameterFun d :: ParameterFun name
    d -> ParameterFun name -> Doc
    forall a. PP a => a -> Doc
    pp ParameterFun name
    d
          DParameterType d :: ParameterType name
    d -> ParameterType name -> Doc
    forall a. PP a => a -> Doc
    pp ParameterType name
    d
          DParameterConstraint d :: [Located (Prop name)]
    d ->
            "parameter" Doc -> Doc -> Doc
    <+> "type" Doc -> Doc -> Doc
    <+> "constraint" Doc -> Doc -> Doc
    <+> Doc
    prop
            where prop :: Doc
    prop = case (Located (Prop name) -> Doc) -> [Located (Prop name)] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Located (Prop name) -> Doc
    forall a. PP a => a -> Doc
    pp [Located (Prop name)]
    d of
                           [x :: Doc
    x] -> Doc
    x
                           []  -> "()"
                           xs :: [Doc]
    xs  -> Doc -> Doc
    parens ([Doc] -> Doc
    hsep (Doc -> [Doc] -> [Doc]
    punctuate Doc
    comma [Doc]
    xs))

    instance (Show name, PPName name) => PP (PrimType name) where
      ppPrec :: Int -> PrimType name -> Doc
    ppPrec _ pt :: PrimType name
    pt =
        "primitive" Doc -> Doc -> Doc
    <+> "type" Doc -> Doc -> Doc
    <+> Located name -> Doc
    forall a. PP a => a -> Doc
    pp (PrimType name -> Located name
    forall name. PrimType name -> Located name
    primTName PrimType name
    pt) Doc -> Doc -> Doc
    <+> ":" Doc -> Doc -> Doc
    <+> Located Kind -> Doc
    forall a. PP a => a -> Doc
    pp (PrimType name -> Located Kind
    forall name. PrimType name -> Located Kind
    primTKind PrimType name
    pt)

    instance (Show name, PPName name) => PP (ParameterType name) where
      ppPrec :: Int -> ParameterType name -> Doc
    ppPrec _ a :: ParameterType name
    a = String -> Doc
    text "parameter" Doc -> Doc -> Doc
    <+> String -> Doc
    text "type" Doc -> Doc -> Doc
    <+>
                   Located name -> Doc
    forall a. PPName a => a -> Doc
    ppPrefixName (ParameterType name -> Located name
    forall name. ParameterType name -> Located name
    ptName ParameterType name
    a) Doc -> Doc -> Doc
    <+> String -> Doc
    text ":" Doc -> Doc -> Doc
    <+> Kind -> Doc
    forall a. PP a => a -> Doc
    pp (ParameterType name -> Kind
    forall name. ParameterType name -> Kind
    ptKind ParameterType name
    a)

    instance (Show name, PPName name) => PP (ParameterFun name) where
      ppPrec :: Int -> ParameterFun name -> Doc
    ppPrec _ a :: ParameterFun name
    a = String -> Doc
    text "parameter" Doc -> Doc -> Doc
    <+> Located name -> Doc
    forall a. PPName a => a -> Doc
    ppPrefixName (ParameterFun name -> Located name
    forall name. ParameterFun name -> Located name
    pfName ParameterFun name
    a) Doc -> Doc -> Doc
    <+> String -> Doc
    text ":"
                      Doc -> Doc -> Doc
    <+> Schema name -> Doc
    forall a. PP a => a -> Doc
    pp (ParameterFun name -> Schema name
    forall name. ParameterFun name -> Schema name
    pfSchema ParameterFun name
    a)

    instance (Show name, PPName name) => PP (Decl name) where
      ppPrec :: Int -> Decl name -> Doc
    ppPrec n :: Int
    n decl :: Decl name
    decl =
        case Decl name
    decl of
          DSignature xs :: [Located name]
    xs s :: Schema name
    s -> [Doc] -> Doc
    commaSep ((Located name -> Doc) -> [Located name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Located name -> Doc
    forall a. PP a => Located a -> Doc
    ppL [Located name]
    xs) Doc -> Doc -> Doc
    <+> String -> Doc
    text ":" Doc -> Doc -> Doc
    <+> Schema name -> Doc
    forall a. PP a => a -> Doc
    pp Schema name
    s
          DPatBind p :: Pattern name
    p e :: Expr name
    e    -> Pattern name -> Doc
    forall a. PP a => a -> Doc
    pp Pattern name
    p Doc -> Doc -> Doc
    <+> String -> Doc
    text "=" Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e
          DBind b :: Bind name
    b         -> Int -> Bind name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n Bind name
    b
          DFixity f :: Fixity
    f ns :: [Located name]
    ns    -> Fixity -> [Located name] -> Doc
    forall name. PPName name => Fixity -> [Located name] -> Doc
    ppFixity Fixity
    f [Located name]
    ns
          DPragma xs :: [Located name]
    xs p :: Pragma
    p    -> [Located name] -> Pragma -> Doc
    forall name. PPName name => [Located name] -> Pragma -> Doc
    ppPragma [Located name]
    xs Pragma
    p
          DType ts :: TySyn name
    ts        -> Int -> TySyn name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n TySyn name
    ts
          DProp ps :: PropSyn name
    ps        -> Int -> PropSyn name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n PropSyn name
    ps
          DLocated d :: Decl name
    d _    -> Int -> Decl name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n Decl name
    d

    ppFixity :: PPName name => Fixity -> [Located name] -> Doc
    ppFixity :: Fixity -> [Located name] -> Doc
    ppFixity (Fixity LeftAssoc  i :: Int
    i) ns :: [Located name]
    ns = String -> Doc
    text "infixl" Doc -> Doc -> Doc
    <+> Int -> Doc
    int Int
    i Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    commaSep ((Located name -> Doc) -> [Located name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Located name -> Doc
    forall a. PP a => a -> Doc
    pp [Located name]
    ns)
    ppFixity (Fixity RightAssoc i :: Int
    i) ns :: [Located name]
    ns = String -> Doc
    text "infixr" Doc -> Doc -> Doc
    <+> Int -> Doc
    int Int
    i Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    commaSep ((Located name -> Doc) -> [Located name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Located name -> Doc
    forall a. PP a => a -> Doc
    pp [Located name]
    ns)
    ppFixity (Fixity NonAssoc   i :: Int
    i) ns :: [Located name]
    ns = String -> Doc
    text "infix"  Doc -> Doc -> Doc
    <+> Int -> Doc
    int Int
    i Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    commaSep ((Located name -> Doc) -> [Located name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Located name -> Doc
    forall a. PP a => a -> Doc
    pp [Located name]
    ns)

    instance PPName name => PP (Newtype name) where
      ppPrec :: Int -> Newtype name -> Doc
    ppPrec _ nt :: Newtype name
    nt = [Doc] -> Doc
    hsep
        [ String -> Doc
    text "newtype", Located name -> Doc
    forall a. PP a => Located a -> Doc
    ppL (Newtype name -> Located name
    forall name. Newtype name -> Located name
    nName Newtype name
    nt), [Doc] -> Doc
    hsep ((TParam name -> Doc) -> [TParam name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map TParam name -> Doc
    forall a. PP a => a -> Doc
    pp (Newtype name -> [TParam name]
    forall name. Newtype name -> [TParam name]
    nParams Newtype name
    nt)), Char -> Doc
    char '='
        , Doc -> Doc
    braces ([Doc] -> Doc
    commaSep ((Named (Type name) -> Doc) -> [Named (Type name)] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> Named (Type name) -> Doc
    forall a. PP a => String -> Named a -> Doc
    ppNamed ":") (Newtype name -> [Named (Type name)]
    forall name. Newtype name -> [Named (Type name)]
    nBody Newtype name
    nt))) ]

    instance PP Import where
      ppPrec :: Int -> Import -> Doc
    ppPrec _ d :: Import
    d = String -> Doc
    text "import" Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    sep [ ModName -> Doc
    forall a. PP a => a -> Doc
    pp (Import -> ModName
    iModule Import
    d), Doc
    mbAs, Doc
    mbSpec ]
        where
        mbAs :: Doc
    mbAs = Doc -> (ModName -> Doc) -> Maybe ModName -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Doc
    empty (\ name :: ModName
    name -> String -> Doc
    text "as" Doc -> Doc -> Doc
    <+> ModName -> Doc
    forall a. PP a => a -> Doc
    pp ModName
    name ) (Import -> Maybe ModName
    iAs Import
    d)

        mbSpec :: Doc
    mbSpec = Doc -> (ImportSpec -> Doc) -> Maybe ImportSpec -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Doc
    empty ImportSpec -> Doc
    forall a. PP a => a -> Doc
    pp (Import -> Maybe ImportSpec
    iSpec Import
    d)

    instance PP ImportSpec where
      ppPrec :: Int -> ImportSpec -> Doc
    ppPrec _ s :: ImportSpec
    s = case ImportSpec
    s of
        Hiding names :: [Ident]
    names -> String -> Doc
    text "hiding" Doc -> Doc -> Doc
    <+> Doc -> Doc
    parens ([Doc] -> Doc
    commaSep ((Ident -> Doc) -> [Ident] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Ident -> Doc
    forall a. PP a => a -> Doc
    pp [Ident]
    names))
        Only names :: [Ident]
    names   ->                   Doc -> Doc
    parens ([Doc] -> Doc
    commaSep ((Ident -> Doc) -> [Ident] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Ident -> Doc
    forall a. PP a => a -> Doc
    pp [Ident]
    names))

    -- TODO: come up with a good way of showing the export specification here
    instance PP a => PP (TopLevel a) where
      ppPrec :: Int -> TopLevel a -> Doc
    ppPrec _ tl :: TopLevel a
    tl = a -> Doc
    forall a. PP a => a -> Doc
    pp (TopLevel a -> a
    forall a. TopLevel a -> a
    tlValue TopLevel a
    tl)

    instance PP Pragma where
      ppPrec :: Int -> Pragma -> Doc
    ppPrec _ (PragmaNote x :: String
    x) = String -> Doc
    text String
    x
      ppPrec _ PragmaProperty = String -> Doc
    text "property"

    ppPragma :: PPName name => [Located name] -> Pragma -> Doc
    ppPragma :: [Located name] -> Pragma -> Doc
    ppPragma xs :: [Located name]
    xs p :: Pragma
    p =
      String -> Doc
    text "/*" Doc -> Doc -> Doc
    <+> String -> Doc
    text "pragma" Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    commaSep ((Located name -> Doc) -> [Located name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Located name -> Doc
    forall a. PP a => Located a -> Doc
    ppL [Located name]
    xs) Doc -> Doc -> Doc
    <+> String -> Doc
    text ":" Doc -> Doc -> Doc
    <+> Pragma -> Doc
    forall a. PP a => a -> Doc
    pp Pragma
    p
      Doc -> Doc -> Doc
    <+> String -> Doc
    text "*/"

    instance (Show name, PPName name) => PP (Bind name) where
      ppPrec :: Int -> Bind name -> Doc
    ppPrec _ b :: Bind name
    b = Doc
    sig Doc -> Doc -> Doc
    $$ [Doc] -> Doc
    vcat [ [Located name] -> Pragma -> Doc
    forall name. PPName name => [Located name] -> Pragma -> Doc
    ppPragma [Located name
    f] Pragma
    p | Pragma
    p <- Bind name -> [Pragma]
    forall name. Bind name -> [Pragma]
    bPragmas Bind name
    b ] Doc -> Doc -> Doc
    $$
                   Doc -> Int -> Doc -> Doc
    hang (Doc
    def Doc -> Doc -> Doc
    <+> Doc
    eq) 4 (BindDef name -> Doc
    forall a. PP a => a -> Doc
    pp (Located (BindDef name) -> BindDef name
    forall a. Located a -> a
    thing (Bind name -> Located (BindDef name)
    forall name. Bind name -> Located (BindDef name)
    bDef Bind name
    b)))
        where def :: Doc
    def | Bind name -> Bool
    forall name. Bind name -> Bool
    bInfix Bind name
    b  = Doc
    lhsOp
                  | Bool
    otherwise = Doc
    lhs
              f :: Located name
    f = Bind name -> Located name
    forall name. Bind name -> Located name
    bName Bind name
    b
              sig :: Doc
    sig = case Bind name -> Maybe (Schema name)
    forall name. Bind name -> Maybe (Schema name)
    bSignature Bind name
    b of
                      Nothing -> Doc
    empty
                      Just s :: Schema name
    s  -> Decl name -> Doc
    forall a. PP a => a -> Doc
    pp ([Located name] -> Schema name -> Decl name
    forall name. [Located name] -> Schema name -> Decl name
    DSignature [Located name
    f] Schema name
    s)
              eq :: Doc
    eq  = if Bind name -> Bool
    forall name. Bind name -> Bool
    bMono Bind name
    b then String -> Doc
    text ":=" else String -> Doc
    text "="
              lhs :: Doc
    lhs = Located name -> Doc
    forall a. PP a => Located a -> Doc
    ppL Located name
    f Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    fsep ((Pattern name -> Doc) -> [Pattern name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> Pattern name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 3) (Bind name -> [Pattern name]
    forall name. Bind name -> [Pattern name]
    bParams Bind name
    b))

              lhsOp :: Doc
    lhsOp = case Bind name -> [Pattern name]
    forall name. Bind name -> [Pattern name]
    bParams Bind name
    b of
                        [x :: Pattern name
    x,y :: Pattern name
    y] -> Pattern name -> Doc
    forall a. PP a => a -> Doc
    pp Pattern name
    x Doc -> Doc -> Doc
    <+> Located name -> Doc
    forall a. PP a => Located a -> Doc
    ppL Located name
    f Doc -> Doc -> Doc
    <+> Pattern name -> Doc
    forall a. PP a => a -> Doc
    pp Pattern name
    y
                        xs :: [Pattern name]
    xs -> Doc -> Doc
    parens (Doc -> Doc
    parens (Located name -> Doc
    forall a. PP a => Located a -> Doc
    ppL Located name
    f) Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    fsep ((Pattern name -> Doc) -> [Pattern name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> Pattern name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 0) [Pattern name]
    xs))
                        -- _     -> panic "AST" [ "Malformed infix operator", show b ]

    instance (Show name, PPName name) => PP (BindDef name) where
      ppPrec :: Int -> BindDef name -> Doc
    ppPrec _ DPrim     = String -> Doc
    text "<primitive>"
      ppPrec p :: Int
    p (DExpr e :: Expr name
    e) = Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    p Expr name
    e

    instance PPName name => PP (TySyn name) where
      ppPrec :: Int -> TySyn name -> Doc
    ppPrec _ (TySyn x :: Located name
    x _ xs :: [TParam name]
    xs t :: Type name
    t) =
        String -> Doc
    text "type" Doc -> Doc -> Doc
    <+> Located name -> Doc
    forall a. PP a => Located a -> Doc
    ppL Located name
    x Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    fsep ((TParam name -> Doc) -> [TParam name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> TParam name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 1) [TParam name]
    xs)
                    Doc -> Doc -> Doc
    <+> String -> Doc
    text "=" Doc -> Doc -> Doc
    <+> Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t

    instance PPName name => PP (PropSyn name) where
      ppPrec :: Int -> PropSyn name -> Doc
    ppPrec _ (PropSyn x :: Located name
    x _ xs :: [TParam name]
    xs ps :: [Prop name]
    ps) =
        String -> Doc
    text "constraint" Doc -> Doc -> Doc
    <+> Located name -> Doc
    forall a. PP a => Located a -> Doc
    ppL Located name
    x Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    fsep ((TParam name -> Doc) -> [TParam name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> TParam name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 1) [TParam name]
    xs)
                          Doc -> Doc -> Doc
    <+> String -> Doc
    text "=" Doc -> Doc -> Doc
    <+> Doc -> Doc
    parens ([Doc] -> Doc
    commaSep ((Prop name -> Doc) -> [Prop name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Prop name -> Doc
    forall a. PP a => a -> Doc
    pp [Prop name]
    ps))

    instance PP Literal where
      ppPrec :: Int -> Literal -> Doc
    ppPrec _ lit :: Literal
    lit =
        case Literal
    lit of
          ECNum n :: Integer
    n i :: NumInfo
    i     -> Integer -> NumInfo -> Doc
    ppNumLit Integer
    n NumInfo
    i
          ECString s :: String
    s    -> String -> Doc
    text (ShowS
    forall a. Show a => a -> String
    show String
    s)

    ppNumLit :: Integer -> NumInfo -> Doc
    ppNumLit :: Integer -> NumInfo -> Doc
    ppNumLit n :: Integer
    n info :: NumInfo
    info =
      case NumInfo
    info of
        DecLit    -> Integer -> Doc
    integer Integer
    n
        CharLit   -> String -> Doc
    text (Char -> String
    forall a. Show a => a -> String
    show (Int -> Char
    forall a. Enum a => Int -> a
    toEnum (Integer -> Int
    forall a. Num a => Integer -> a
    fromInteger Integer
    n) :: Char))
        BinLit w :: Int
    w  -> Integer -> String -> Int -> Doc
    pad 2  "0b" Int
    w
        OctLit w :: Int
    w  -> Integer -> String -> Int -> Doc
    pad 8  "0o" Int
    w
        HexLit w :: Int
    w  -> Integer -> String -> Int -> Doc
    pad 16 "0x" Int
    w
        PolyLit w :: Int
    w -> String -> Doc
    text "<|" Doc -> Doc -> Doc
    <+> Int -> Doc
    poly Int
    w Doc -> Doc -> Doc
    <+> String -> Doc
    text "|>"
      where
      pad :: Integer -> String -> Int -> Doc
    pad base :: Integer
    base pref :: String
    pref w :: Int
    w =
        let txt :: String
    txt = Integer -> (Int -> Char) -> Integer -> ShowS
    forall a. (Integral a, Show a) => a -> (Int -> Char) -> a -> ShowS
    showIntAtBase Integer
    base ("0123456789abcdef" String -> Int -> Char
    forall a. [a] -> Int -> a
    !!) Integer
    n ""
        in String -> Doc
    text String
    pref Doc -> Doc -> Doc
    <.> String -> Doc
    text (Int -> Char -> String
    forall a. Int -> a -> [a]
    replicate (Int
    w Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - String -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    txt) '0') Doc -> Doc -> Doc
    <.> String -> Doc
    text String
    txt

      poly :: Int -> Doc
    poly w :: Int
    w = let (res :: [Int]
    res,deg :: Maybe Int
    deg) = Maybe Int -> [Int] -> Int -> Integer -> ([Int], Maybe Int)
    forall a a.
    (Integral a, Num a, Bits a) =>
    Maybe a -> [a] -> a -> a -> ([a], Maybe a)
    bits Maybe Int
    forall a. Maybe a
    Nothing [] 0 Integer
    n
                   z :: [Doc]
    z | Int
    w Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == 0 = []
                     | Just d :: Int
    d <- Maybe Int
    deg, Int
    d Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1 Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    w = []
                     | Bool
    otherwise = [Int -> Doc
    polyTerm0 (Int
    wInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -1)]
               in [Doc] -> Doc
    fsep ([Doc] -> Doc) -> [Doc] -> Doc
    forall a b. (a -> b) -> a -> b
    $ Doc -> [Doc] -> [Doc]
    forall a. a -> [a] -> [a]
    intersperse (String -> Doc
    text "+") ([Doc] -> [Doc]) -> [Doc] -> [Doc]
    forall a b. (a -> b) -> a -> b
    $ [Doc]
    z [Doc] -> [Doc] -> [Doc]
    forall a. [a] -> [a] -> [a]
    ++ (Int -> Doc) -> [Int] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Int -> Doc
    polyTerm [Int]
    res

      polyTerm :: Int -> Doc
    polyTerm 0 = String -> Doc
    text "1"
      polyTerm 1 = String -> Doc
    text "x"
      polyTerm p :: Int
    p = String -> Doc
    text "x" Doc -> Doc -> Doc
    <.> String -> Doc
    text "^^" Doc -> Doc -> Doc
    <.> Int -> Doc
    int Int
    p

      polyTerm0 :: Int -> Doc
    polyTerm0 0 = String -> Doc
    text "0"
      polyTerm0 p :: Int
    p = String -> Doc
    text "0" Doc -> Doc -> Doc
    <.> String -> Doc
    text "*" Doc -> Doc -> Doc
    <.> Int -> Doc
    polyTerm Int
    p

      bits :: Maybe a -> [a] -> a -> a -> ([a], Maybe a)
    bits d :: Maybe a
    d res :: [a]
    res p :: a
    p num :: a
    num
        | a
    num a -> a -> Bool
    forall a. Eq a => a -> a -> Bool
    == 0  = ([a]
    res,Maybe a
    d)
        | a -> Bool
    forall a. Integral a => a -> Bool
    even a
    num  = Maybe a -> [a] -> a -> a -> ([a], Maybe a)
    bits Maybe a
    d             [a]
    res  (a
    p a -> a -> a
    forall a. Num a => a -> a -> a
    + 1) (a
    num a -> Int -> a
    forall a. Bits a => a -> Int -> a
    `shiftR` 1)
        | Bool
    otherwise = Maybe a -> [a] -> a -> a -> ([a], Maybe a)
    bits (a -> Maybe a
    forall a. a -> Maybe a
    Just a
    p) (a
    p a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    : [a]
    res) (a
    p a -> a -> a
    forall a. Num a => a -> a -> a
    + 1) (a
    num a -> Int -> a
    forall a. Bits a => a -> Int -> a
    `shiftR` 1)

    wrap :: Int -> Int -> Doc -> Doc
    wrap :: Int -> Int -> Doc -> Doc
    wrap contextPrec :: Int
    contextPrec myPrec :: Int
    myPrec doc :: Doc
    doc = if Int
    myPrec Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    contextPrec then Doc -> Doc
    parens Doc
    doc else Doc
    doc

    isEApp :: Expr n -> Maybe (Expr n, Expr n)
    isEApp :: Expr n -> Maybe (Expr n, Expr n)
    isEApp (ELocated e :: Expr n
    e _)     = Expr n -> Maybe (Expr n, Expr n)
    forall n. Expr n -> Maybe (Expr n, Expr n)
    isEApp Expr n
    e
    isEApp (EApp e1 :: Expr n
    e1 e2 :: Expr n
    e2)       = (Expr n, Expr n) -> Maybe (Expr n, Expr n)
    forall a. a -> Maybe a
    Just (Expr n
    e1,Expr n
    e2)
    isEApp _                  = Maybe (Expr n, Expr n)
    forall a. Maybe a
    Nothing

    asEApps :: Expr n -> (Expr n, [Expr n])
    asEApps :: Expr n -> (Expr n, [Expr n])
    asEApps expr :: Expr n
    expr = Expr n -> [Expr n] -> (Expr n, [Expr n])
    forall n. Expr n -> [Expr n] -> (Expr n, [Expr n])
    go Expr n
    expr []
        where go :: Expr n -> [Expr n] -> (Expr n, [Expr n])
    go e :: Expr n
    e es :: [Expr n]
    es = case Expr n -> Maybe (Expr n, Expr n)
    forall n. Expr n -> Maybe (Expr n, Expr n)
    isEApp Expr n
    e of
                          Nothing       -> (Expr n
    e, [Expr n]
    es)
                          Just (e1 :: Expr n
    e1, e2 :: Expr n
    e2) -> Expr n -> [Expr n] -> (Expr n, [Expr n])
    go Expr n
    e1 (Expr n
    e2 Expr n -> [Expr n] -> [Expr n]
    forall a. a -> [a] -> [a]
    : [Expr n]
    es)

    instance PPName name => PP (TypeInst name) where
      ppPrec :: Int -> TypeInst name -> Doc
    ppPrec _ (PosInst t :: Type name
    t)   = Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t
      ppPrec _ (NamedInst x :: Named (Type name)
    x) = String -> Named (Type name) -> Doc
    forall a. PP a => String -> Named a -> Doc
    ppNamed "=" Named (Type name)
    x

    {- Precedences:
    0: lambda, if, where, type annotation
    2: infix expression   (separate precedence table)
    3: application, prefix expressions
    -}
    instance (Show name, PPName name) => PP (Expr name) where
      -- Wrap if top level operator in expression is less than `n`
      ppPrec :: Int -> Expr name -> Doc
    ppPrec n :: Int
    n expr :: Expr name
    expr =
        case Expr name
    expr of

          -- atoms
          EVar x :: name
    x        -> name -> Doc
    forall a. PPName a => a -> Doc
    ppPrefixName name
    x
          ELit x :: Literal
    x        -> Literal -> Doc
    forall a. PP a => a -> Doc
    pp Literal
    x

          ENeg x :: Expr name
    x        -> Int -> Int -> Doc -> Doc
    wrap Int
    n 3 (String -> Doc
    text "-" Doc -> Doc -> Doc
    <.> Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 4 Expr name
    x)
          EComplement x :: Expr name
    x -> Int -> Int -> Doc -> Doc
    wrap Int
    n 3 (String -> Doc
    text "~" Doc -> Doc -> Doc
    <.> Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 4 Expr name
    x)
          EGenerate x :: Expr name
    x   -> Int -> Int -> Doc -> Doc
    wrap Int
    n 3 (String -> Doc
    text "generate" Doc -> Doc -> Doc
    <+> Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 4 Expr name
    x)

          ETuple es :: [Expr name]
    es     -> Doc -> Doc
    parens ([Doc] -> Doc
    commaSep ((Expr name -> Doc) -> [Expr name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Expr name -> Doc
    forall a. PP a => a -> Doc
    pp [Expr name]
    es))
          ERecord fs :: [Named (Expr name)]
    fs    -> Doc -> Doc
    braces ([Doc] -> Doc
    commaSep ((Named (Expr name) -> Doc) -> [Named (Expr name)] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> Named (Expr name) -> Doc
    forall a. PP a => String -> Named a -> Doc
    ppNamed "=") [Named (Expr name)]
    fs))
          EList es :: [Expr name]
    es      -> Doc -> Doc
    brackets ([Doc] -> Doc
    commaSep ((Expr name -> Doc) -> [Expr name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Expr name -> Doc
    forall a. PP a => a -> Doc
    pp [Expr name]
    es))
          EFromTo e1 :: Type name
    e1 e2 :: Maybe (Type name)
    e2 e3 :: Type name
    e3 t1 :: Maybe (Type name)
    t1 -> Doc -> Doc
    brackets (Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    e1 Doc -> Doc -> Doc
    <.> Doc
    step Doc -> Doc -> Doc
    <+> String -> Doc
    text ".." Doc -> Doc -> Doc
    <+> Doc
    end)
            where step :: Doc
    step = Doc -> (Type name -> Doc) -> Maybe (Type name) -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Doc
    empty (\e :: Type name
    e -> Doc
    comma Doc -> Doc -> Doc
    <+> Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    e) Maybe (Type name)
    e2
                  end :: Doc
    end = Doc -> (Type name -> Doc) -> Maybe (Type name) -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    e3) (\t :: Type name
    t -> Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    e3 Doc -> Doc -> Doc
    <+> Doc
    colon Doc -> Doc -> Doc
    <+> Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t) Maybe (Type name)
    t1
          EInfFrom e1 :: Expr name
    e1 e2 :: Maybe (Expr name)
    e2 -> Doc -> Doc
    brackets (Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e1 Doc -> Doc -> Doc
    <.> Doc
    step Doc -> Doc -> Doc
    <+> String -> Doc
    text "...")
            where step :: Doc
    step = Doc -> (Expr name -> Doc) -> Maybe (Expr name) -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Doc
    empty (\e :: Expr name
    e -> Doc
    comma Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e) Maybe (Expr name)
    e2
          EComp e :: Expr name
    e mss :: [[Match name]]
    mss   -> Doc -> Doc
    brackets (Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    vcat (([Match name] -> Doc) -> [[Match name]] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map [Match name] -> Doc
    forall a. PP a => [a] -> Doc
    arm [[Match name]]
    mss))
            where arm :: [a] -> Doc
    arm ms :: [a]
    ms = String -> Doc
    text "|" Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    commaSep ((a -> Doc) -> [a] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map a -> Doc
    forall a. PP a => a -> Doc
    pp [a]
    ms)
          EUpd mb :: Maybe (Expr name)
    mb fs :: [UpdField name]
    fs    -> Doc -> Doc
    braces (Doc
    hd Doc -> Doc -> Doc
    <+> "|" Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    commaSep ((UpdField name -> Doc) -> [UpdField name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map UpdField name -> Doc
    forall a. PP a => a -> Doc
    pp [UpdField name]
    fs))
            where hd :: Doc
    hd = Doc -> (Expr name -> Doc) -> Maybe (Expr name) -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe "_" Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Maybe (Expr name)
    mb

          ETypeVal t :: Type name
    t    -> String -> Doc
    text "`" Doc -> Doc -> Doc
    <.> Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 5 Type name
    t     -- XXX
          EAppT e :: Expr name
    e ts :: [TypeInst name]
    ts    -> Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 4 Expr name
    e Doc -> Doc -> Doc
    <.> String -> Doc
    text "`" Doc -> Doc -> Doc
    <.> Doc -> Doc
    braces ([Doc] -> Doc
    commaSep ((TypeInst name -> Doc) -> [TypeInst name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map TypeInst name -> Doc
    forall a. PP a => a -> Doc
    pp [TypeInst name]
    ts))
          ESel    e :: Expr name
    e l :: Selector
    l   -> Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 4 Expr name
    e Doc -> Doc -> Doc
    <.> String -> Doc
    text "." Doc -> Doc -> Doc
    <.> Selector -> Doc
    forall a. PP a => a -> Doc
    pp Selector
    l

          -- low prec
          EFun xs :: [Pattern name]
    xs e :: Expr name
    e     -> Int -> Int -> Doc -> Doc
    wrap Int
    n 0 ((String -> Doc
    text "\\" Doc -> Doc -> Doc
    <.> [Doc] -> Doc
    hsep ((Pattern name -> Doc) -> [Pattern name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> Pattern name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 3) [Pattern name]
    xs)) Doc -> Doc -> Doc
    <+>
                                     String -> Doc
    text "->" Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e)

          EIf e1 :: Expr name
    e1 e2 :: Expr name
    e2 e3 :: Expr name
    e3  -> Int -> Int -> Doc -> Doc
    wrap Int
    n 0 (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ [Doc] -> Doc
    sep [ String -> Doc
    text "if"   Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e1
                                          , String -> Doc
    text "then" Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e2
                                          , String -> Doc
    text "else" Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e3 ]

          ETyped e :: Expr name
    e t :: Type name
    t    -> Int -> Int -> Doc -> Doc
    wrap Int
    n 0 (Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 2 Expr name
    e Doc -> Doc -> Doc
    <+> String -> Doc
    text ":" Doc -> Doc -> Doc
    <+> Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t)

          EWhere  e :: Expr name
    e ds :: [Decl name]
    ds  -> Int -> Int -> Doc -> Doc
    wrap Int
    n 0 (Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e
                                    Doc -> Doc -> Doc
    $$ String -> Doc
    text "where"
                                    Doc -> Doc -> Doc
    $$ Int -> Doc -> Doc
    nest 2 ([Doc] -> Doc
    vcat ((Decl name -> Doc) -> [Decl name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Decl name -> Doc
    forall a. PP a => a -> Doc
    pp [Decl name]
    ds))
                                    Doc -> Doc -> Doc
    $$ String -> Doc
    text "")

          -- infix applications
          _ | Just ifix :: Infix name (Expr name)
    ifix <- Expr name -> Maybe (Infix name (Expr name))
    forall op. PPName op => Expr op -> Maybe (Infix op (Expr op))
    isInfix Expr name
    expr ->
                  Bool -> Doc -> Doc
    optParens (Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 2)
                  (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Expr name -> Maybe (Infix name (Expr name)))
    -> Infix name (Expr name)
    -> Doc
    forall thing op.
    (PP thing, PP op) =>
    Int -> (thing -> Maybe (Infix op thing)) -> Infix op thing -> Doc
    ppInfix 2 Expr name -> Maybe (Infix name (Expr name))
    forall op. PPName op => Expr op -> Maybe (Infix op (Expr op))
    isInfix Infix name (Expr name)
    ifix

          EApp _ _      -> let (e :: Expr name
    e, es :: [Expr name]
    es) = Expr name -> (Expr name, [Expr name])
    forall n. Expr n -> (Expr n, [Expr n])
    asEApps Expr name
    expr in
                           Int -> Int -> Doc -> Doc
    wrap Int
    n 3 (Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 3 Expr name
    e Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    fsep ((Expr name -> Doc) -> [Expr name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 4) [Expr name]
    es))

          ELocated e :: Expr name
    e _  -> Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n Expr name
    e

          ESplit e :: Expr name
    e      -> Int -> Int -> Doc -> Doc
    wrap Int
    n 3 (String -> Doc
    text "splitAt" Doc -> Doc -> Doc
    <+> Int -> Expr name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 4 Expr name
    e)

          EParens e :: Expr name
    e -> Doc -> Doc
    parens (Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e)

          EInfix e1 :: Expr name
    e1 op :: Located name
    op _ e2 :: Expr name
    e2 -> Int -> Int -> Doc -> Doc
    wrap Int
    n 0 (Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e1 Doc -> Doc -> Doc
    <+> name -> Doc
    forall a. PPName a => a -> Doc
    ppInfixName (Located name -> name
    forall a. Located a -> a
    thing Located name
    op) Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e2)
       where
       isInfix :: Expr op -> Maybe (Infix op (Expr op))
    isInfix (EApp (EApp (EVar ieOp :: op
    ieOp) ieLeft :: Expr op
    ieLeft) ieRight :: Expr op
    ieRight) = do
         (ieAssoc :: Assoc
    ieAssoc,iePrec :: Int
    iePrec) <- op -> Maybe (Assoc, Int)
    forall a. PPName a => a -> Maybe (Assoc, Int)
    ppNameFixity op
    ieOp
         Infix op (Expr op) -> Maybe (Infix op (Expr op))
    forall (m :: * -> *) a. Monad m => a -> m a
    return Infix :: forall op thing.
    op -> thing -> thing -> Int -> Assoc -> Infix op thing
    Infix { .. }
       isInfix _ = Maybe (Infix op (Expr op))
    forall a. Maybe a
    Nothing

    instance (Show name, PPName name) => PP (UpdField name) where
      ppPrec :: Int -> UpdField name -> Doc
    ppPrec _ (UpdField h :: UpdHow
    h xs :: [Located Selector]
    xs e :: Expr name
    e) = [Selector] -> Doc
    ppNestedSels ((Located Selector -> Selector) -> [Located Selector] -> [Selector]
    forall a b. (a -> b) -> [a] -> [b]
    map Located Selector -> Selector
    forall a. Located a -> a
    thing [Located Selector]
    xs) Doc -> Doc -> Doc
    <+> UpdHow -> Doc
    forall a. PP a => a -> Doc
    pp UpdHow
    h Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e

    instance PP UpdHow where
      ppPrec :: Int -> UpdHow -> Doc
    ppPrec _ h :: UpdHow
    h = case UpdHow
    h of
                     UpdSet -> "="
                     UpdFun -> "->"

    instance PPName name => PP (Pattern name) where
      ppPrec :: Int -> Pattern name -> Doc
    ppPrec n :: Int
    n pat :: Pattern name
    pat =
        case Pattern name
    pat of
          PVar x :: Located name
    x        -> name -> Doc
    forall a. PP a => a -> Doc
    pp (Located name -> name
    forall a. Located a -> a
    thing Located name
    x)
          PWild         -> Char -> Doc
    char '_'
          PTuple ps :: [Pattern name]
    ps     -> Doc -> Doc
    parens   ([Doc] -> Doc
    commaSep ((Pattern name -> Doc) -> [Pattern name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Pattern name -> Doc
    forall a. PP a => a -> Doc
    pp [Pattern name]
    ps))
          PRecord fs :: [Named (Pattern name)]
    fs    -> Doc -> Doc
    braces   ([Doc] -> Doc
    commaSep ((Named (Pattern name) -> Doc) -> [Named (Pattern name)] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> Named (Pattern name) -> Doc
    forall a. PP a => String -> Named a -> Doc
    ppNamed "=") [Named (Pattern name)]
    fs))
          PList ps :: [Pattern name]
    ps      -> Doc -> Doc
    brackets ([Doc] -> Doc
    commaSep ((Pattern name -> Doc) -> [Pattern name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Pattern name -> Doc
    forall a. PP a => a -> Doc
    pp [Pattern name]
    ps))
          PTyped p :: Pattern name
    p t :: Type name
    t    -> Int -> Int -> Doc -> Doc
    wrap Int
    n 0 (Int -> Pattern name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 1 Pattern name
    p  Doc -> Doc -> Doc
    <+> String -> Doc
    text ":" Doc -> Doc -> Doc
    <+> Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t)
          PSplit p1 :: Pattern name
    p1 p2 :: Pattern name
    p2  -> Int -> Int -> Doc -> Doc
    wrap Int
    n 1 (Int -> Pattern name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 1 Pattern name
    p1 Doc -> Doc -> Doc
    <+> String -> Doc
    text "#" Doc -> Doc -> Doc
    <+> Int -> Pattern name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 1 Pattern name
    p2)
          PLocated p :: Pattern name
    p _  -> Int -> Pattern name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n Pattern name
    p

    instance (Show name, PPName name) => PP (Match name) where
      ppPrec :: Int -> Match name -> Doc
    ppPrec _ (Match p :: Pattern name
    p e :: Expr name
    e)  = Pattern name -> Doc
    forall a. PP a => a -> Doc
    pp Pattern name
    p Doc -> Doc -> Doc
    <+> String -> Doc
    text "<-" Doc -> Doc -> Doc
    <+> Expr name -> Doc
    forall a. PP a => a -> Doc
    pp Expr name
    e
      ppPrec _ (MatchLet b :: Bind name
    b) = Bind name -> Doc
    forall a. PP a => a -> Doc
    pp Bind name
    b

    instance PPName name => PP (Schema name) where
      ppPrec :: Int -> Schema name -> Doc
    ppPrec _ (Forall xs :: [TParam name]
    xs ps :: [Prop name]
    ps t :: Type name
    t _) = [Doc] -> Doc
    sep [Doc
    vars Doc -> Doc -> Doc
    <+> Doc
    preds, Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t]
        where vars :: Doc
    vars = case [TParam name]
    xs of
                       [] -> Doc
    empty
                       _  -> Doc -> Doc
    braces ([Doc] -> Doc
    commaSep ((TParam name -> Doc) -> [TParam name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map TParam name -> Doc
    forall a. PP a => a -> Doc
    pp [TParam name]
    xs))
              preds :: Doc
    preds = case [Prop name]
    ps of
                        [] -> Doc
    empty
                        _  -> Doc -> Doc
    parens ([Doc] -> Doc
    commaSep ((Prop name -> Doc) -> [Prop name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Prop name -> Doc
    forall a. PP a => a -> Doc
    pp [Prop name]
    ps)) Doc -> Doc -> Doc
    <+> String -> Doc
    text "=>"

    instance PP Kind where
      ppPrec :: Int -> Kind -> Doc
    ppPrec _ KType  = String -> Doc
    text "*"
      ppPrec _ KNum   = String -> Doc
    text "#"
      ppPrec _ KProp  = String -> Doc
    text "@"
      ppPrec n :: Int
    n (KFun k1 :: Kind
    k1 k2 :: Kind
    k2) = Int -> Int -> Doc -> Doc
    wrap Int
    n 1 (Int -> Kind -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 1 Kind
    k1 Doc -> Doc -> Doc
    <+> "->" Doc -> Doc -> Doc
    <+> Int -> Kind -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 0 Kind
    k2)

    -- | "Conversational" printing of kinds (e.g., to use in error messages)
    cppKind :: Kind -> Doc
    cppKind :: Kind -> Doc
    cppKind KType     = String -> Doc
    text "a value type"
    cppKind KNum      = String -> Doc
    text "a numeric type"
    cppKind KProp     = String -> Doc
    text "a constraint type"
    cppKind (KFun {}) = String -> Doc
    text "a type-constructor type"

    instance PPName name => PP (TParam name) where
      ppPrec :: Int -> TParam name -> Doc
    ppPrec n :: Int
    n (TParam p :: name
    p Nothing _)   = Int -> name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n name
    p
      ppPrec n :: Int
    n (TParam p :: name
    p (Just k :: Kind
    k) _)  = Int -> Int -> Doc -> Doc
    wrap Int
    n 1 (name -> Doc
    forall a. PP a => a -> Doc
    pp name
    p Doc -> Doc -> Doc
    <+> String -> Doc
    text ":" Doc -> Doc -> Doc
    <+> Kind -> Doc
    forall a. PP a => a -> Doc
    pp Kind
    k)

    -- 4: atomic type expression
    -- 3: [_]t or application
    -- 2: infix type
    -- 1: function type
    instance PPName name => PP (Type name) where
      ppPrec :: Int -> Type name -> Doc
    ppPrec n :: Int
    n ty :: Type name
    ty =
        case Type name
    ty of
          TWild          -> String -> Doc
    text "_"
          TTuple ts :: [Type name]
    ts      -> Doc -> Doc
    parens (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ [Doc] -> Doc
    commaSep ([Doc] -> Doc) -> [Doc] -> Doc
    forall a b. (a -> b) -> a -> b
    $ (Type name -> Doc) -> [Type name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map Type name -> Doc
    forall a. PP a => a -> Doc
    pp [Type name]
    ts
          TRecord fs :: [Named (Type name)]
    fs     -> Doc -> Doc
    braces (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ [Doc] -> Doc
    commaSep ([Doc] -> Doc) -> [Doc] -> Doc
    forall a b. (a -> b) -> a -> b
    $ (Named (Type name) -> Doc) -> [Named (Type name)] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> Named (Type name) -> Doc
    forall a. PP a => String -> Named a -> Doc
    ppNamed ":") [Named (Type name)]
    fs
          TBit           -> String -> Doc
    text "Bit"
          TNum x :: Integer
    x         -> Integer -> Doc
    integer Integer
    x
          TChar x :: Char
    x        -> String -> Doc
    text (Char -> String
    forall a. Show a => a -> String
    show Char
    x)
          TSeq t1 :: Type name
    t1 TBit   -> Doc -> Doc
    brackets (Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t1)
          TSeq t1 :: Type name
    t1 t2 :: Type name
    t2     -> Bool -> Doc -> Doc
    optParens (Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 3)
                          (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ Doc -> Doc
    brackets (Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t1) Doc -> Doc -> Doc
    <.> Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 3 Type name
    t2

          TUser f :: name
    f []     -> name -> Doc
    forall a. PPName a => a -> Doc
    ppPrefixName name
    f

          TUser f :: name
    f ts :: [Type name]
    ts     -> Bool -> Doc -> Doc
    optParens (Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 3)
                          (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ name -> Doc
    forall a. PPName a => a -> Doc
    ppPrefixName name
    f Doc -> Doc -> Doc
    <+> [Doc] -> Doc
    fsep ((Type name -> Doc) -> [Type name] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 4) [Type name]
    ts)

          TFun t1 :: Type name
    t1 t2 :: Type name
    t2     -> Bool -> Doc -> Doc
    optParens (Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 1)
                          (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ [Doc] -> Doc
    sep [Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 2 Type name
    t1 Doc -> Doc -> Doc
    <+> String -> Doc
    text "->", Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 1 Type name
    t2]

          TLocated t :: Type name
    t _   -> Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n Type name
    t

          TParens t :: Type name
    t      -> Doc -> Doc
    parens (Type name -> Doc
    forall a. PP a => a -> Doc
    pp Type name
    t)

          TInfix t1 :: Type name
    t1 o :: Located name
    o _ t2 :: Type name
    t2 -> Bool -> Doc -> Doc
    optParens (Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 2)
                            (Doc -> Doc) -> Doc -> Doc
    forall a b. (a -> b) -> a -> b
    $ [Doc] -> Doc
    sep [Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 2 Type name
    t1 Doc -> Doc -> Doc
    <+> Located name -> Doc
    forall a. PPName a => a -> Doc
    ppInfixName Located name
    o, Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec 3 Type name
    t2]

    instance PPName name => PP (Prop name) where
      ppPrec :: Int -> Prop name -> Doc
    ppPrec n :: Int
    n (CType t :: Type name
    t) = Int -> Type name -> Doc
    forall a. PP a => Int -> a -> Doc
    ppPrec Int
    n Type name
    t

    --------------------------------------------------------------------------------
    -- Drop all position information, so equality reflects program structure

    class NoPos t where
      noPos :: t -> t

    -- WARNING: This does not call `noPos` on the `thing` inside
    instance NoPos (Located t) where
      noPos :: Located t -> Located t
    noPos x :: Located t
    x = Located t
    x { srcRange :: Range
    srcRange = Range
    rng }
        where rng :: Range
    rng = $WRange :: Position -> Position -> String -> Range
    Range { from :: Position
    from = Int -> Int -> Position
    Position 0 0, to :: Position
    to = Int -> Int -> Position
    Position 0 0, source :: String
    source = "" }

    instance NoPos t => NoPos (Named t) where
      noPos :: Named t -> Named t
    noPos t :: Named t
    t = Named :: forall a. Located Ident -> a -> Named a
    Named { name :: Located Ident
    name = Located Ident -> Located Ident
    forall t. NoPos t => t -> t
    noPos (Named t -> Located Ident
    forall a. Named a -> Located Ident
    name Named t
    t), value :: t
    value = t -> t
    forall t. NoPos t => t -> t
    noPos (Named t -> t
    forall a. Named a -> a
    value Named t
    t) }

    instance NoPos t => NoPos [t]       where noPos :: [t] -> [t]
    noPos = (t -> t) -> [t] -> [t]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap t -> t
    forall t. NoPos t => t -> t
    noPos
    instance NoPos t => NoPos (Maybe t) where noPos :: Maybe t -> Maybe t
    noPos = (t -> t) -> Maybe t -> Maybe t
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap t -> t
    forall t. NoPos t => t -> t
    noPos

    instance NoPos (Program name) where
      noPos :: Program name -> Program name
    noPos (Program x :: [TopDecl name]
    x) = [TopDecl name] -> Program name
    forall name. [TopDecl name] -> Program name
    Program ([TopDecl name] -> [TopDecl name]
    forall t. NoPos t => t -> t
    noPos [TopDecl name]
    x)

    instance NoPos (Module name) where
      noPos :: Module name -> Module name
    noPos m :: Module name
    m = $WModule :: forall name.
    Located ModName
    -> Maybe (Located ModName)
    -> [Located Import]
    -> [TopDecl name]
    -> Module name
    Module { mName :: Located ModName
    mName      = Module name -> Located ModName
    forall name. Module name -> Located ModName
    mName Module name
    m
                       , mInstance :: Maybe (Located ModName)
    mInstance  = Module name -> Maybe (Located ModName)
    forall name. Module name -> Maybe (Located ModName)
    mInstance Module name
    m
                       , mImports :: [Located Import]
    mImports   = [Located Import] -> [Located Import]
    forall t. NoPos t => t -> t
    noPos (Module name -> [Located Import]
    forall name. Module name -> [Located Import]
    mImports Module name
    m)
                       , mDecls :: [TopDecl name]
    mDecls     = [TopDecl name] -> [TopDecl name]
    forall t. NoPos t => t -> t
    noPos (Module name -> [TopDecl name]
    forall name. Module name -> [TopDecl name]
    mDecls Module name
    m)
                       }

    instance NoPos (TopDecl name) where
      noPos :: TopDecl name -> TopDecl name
    noPos decl :: TopDecl name
    decl =
        case TopDecl name
    decl of
          Decl    x :: TopLevel (Decl name)
    x   -> TopLevel (Decl name) -> TopDecl name
    forall name. TopLevel (Decl name) -> TopDecl name
    Decl     (TopLevel (Decl name) -> TopLevel (Decl name)
    forall t. NoPos t => t -> t
    noPos TopLevel (Decl name)
    x)
          DPrimType t :: TopLevel (PrimType name)
    t -> TopLevel (PrimType name) -> TopDecl name
    forall name. TopLevel (PrimType name) -> TopDecl name
    DPrimType (TopLevel (PrimType name) -> TopLevel (PrimType name)
    forall t. NoPos t => t -> t
    noPos TopLevel (PrimType name)
    t)
          TDNewtype n :: TopLevel (Newtype name)
    n -> TopLevel (Newtype name) -> TopDecl name
    forall name. TopLevel (Newtype name) -> TopDecl name
    TDNewtype(TopLevel (Newtype name) -> TopLevel (Newtype name)
    forall t. NoPos t => t -> t
    noPos TopLevel (Newtype name)
    n)
          Include x :: Located String
    x   -> Located String -> TopDecl name
    forall name. Located String -> TopDecl name
    Include  (Located String -> Located String
    forall t. NoPos t => t -> t
    noPos Located String
    x)
          DParameterFun d :: ParameterFun name
    d  -> ParameterFun name -> TopDecl name
    forall name. ParameterFun name -> TopDecl name
    DParameterFun (ParameterFun name -> ParameterFun name
    forall t. NoPos t => t -> t
    noPos ParameterFun name
    d)
          DParameterType d :: ParameterType name
    d -> ParameterType name -> TopDecl name
    forall name. ParameterType name -> TopDecl name
    DParameterType (ParameterType name -> ParameterType name
    forall t. NoPos t => t -> t
    noPos ParameterType name
    d)
          DParameterConstraint d :: [Located (Prop name)]
    d -> [Located (Prop name)] -> TopDecl name
    forall name. [Located (Prop name)] -> TopDecl name
    DParameterConstraint ([Located (Prop name)] -> [Located (Prop name)]
    forall t. NoPos t => t -> t
    noPos [Located (Prop name)]
    d)

    instance NoPos (PrimType name) where
      noPos :: PrimType name -> PrimType name
    noPos x :: PrimType name
    x = PrimType name
    x

    instance NoPos (ParameterType name) where
      noPos :: ParameterType name -> ParameterType name
    noPos a :: ParameterType name
    a = ParameterType name
    a

    instance NoPos (ParameterFun x) where
      noPos :: ParameterFun x -> ParameterFun x
    noPos x :: ParameterFun x
    x = ParameterFun x
    x { pfSchema :: Schema x
    pfSchema = Schema x -> Schema x
    forall t. NoPos t => t -> t
    noPos (ParameterFun x -> Schema x
    forall name. ParameterFun name -> Schema name
    pfSchema ParameterFun x
    x) }

    instance NoPos a => NoPos (TopLevel a) where
      noPos :: TopLevel a -> TopLevel a
    noPos tl :: TopLevel a
    tl = TopLevel a
    tl { tlValue :: a
    tlValue = a -> a
    forall t. NoPos t => t -> t
    noPos (TopLevel a -> a
    forall a. TopLevel a -> a
    tlValue TopLevel a
    tl) }

    instance NoPos (Decl name) where
      noPos :: Decl name -> Decl name
    noPos decl :: Decl name
    decl =
        case Decl name
    decl of
          DSignature x :: [Located name]
    x y :: Schema name
    y   -> [Located name] -> Schema name -> Decl name
    forall name. [Located name] -> Schema name -> Decl name
    DSignature ([Located name] -> [Located name]
    forall t. NoPos t => t -> t
    noPos [Located name]
    x) (Schema name -> Schema name
    forall t. NoPos t => t -> t
    noPos Schema name
    y)
          DPragma    x :: [Located name]
    x y :: Pragma
    y   -> [Located name] -> Pragma -> Decl name
    forall name. [Located name] -> Pragma -> Decl name
    DPragma    ([Located name] -> [Located name]
    forall t. NoPos t => t -> t
    noPos [Located name]
    x) (Pragma -> Pragma
    forall t. NoPos t => t -> t
    noPos Pragma
    y)
          DPatBind   x :: Pattern name
    x y :: Expr name
    y   -> Pattern name -> Expr name -> Decl name
    forall name. Pattern name -> Expr name -> Decl name
    DPatBind   (Pattern name -> Pattern name
    forall t. NoPos t => t -> t
    noPos Pattern name
    x) (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    y)
          DFixity f :: Fixity
    f ns :: [Located name]
    ns     -> Fixity -> [Located name] -> Decl name
    forall name. Fixity -> [Located name] -> Decl name
    DFixity Fixity
    f ([Located name] -> [Located name]
    forall t. NoPos t => t -> t
    noPos [Located name]
    ns)
          DBind      x :: Bind name
    x     -> Bind name -> Decl name
    forall name. Bind name -> Decl name
    DBind      (Bind name -> Bind name
    forall t. NoPos t => t -> t
    noPos Bind name
    x)
          DType      x :: TySyn name
    x     -> TySyn name -> Decl name
    forall name. TySyn name -> Decl name
    DType      (TySyn name -> TySyn name
    forall t. NoPos t => t -> t
    noPos TySyn name
    x)
          DProp      x :: PropSyn name
    x     -> PropSyn name -> Decl name
    forall name. PropSyn name -> Decl name
    DProp      (PropSyn name -> PropSyn name
    forall t. NoPos t => t -> t
    noPos PropSyn name
    x)
          DLocated   x :: Decl name
    x _   -> Decl name -> Decl name
    forall t. NoPos t => t -> t
    noPos Decl name
    x

    instance NoPos (Newtype name) where
      noPos :: Newtype name -> Newtype name
    noPos n :: Newtype name
    n = Newtype :: forall name.
    Located name
    -> [TParam name] -> [Named (Type name)] -> Newtype name
    Newtype { nName :: Located name
    nName   = Located name -> Located name
    forall t. NoPos t => t -> t
    noPos (Newtype name -> Located name
    forall name. Newtype name -> Located name
    nName Newtype name
    n)
                        , nParams :: [TParam name]
    nParams = Newtype name -> [TParam name]
    forall name. Newtype name -> [TParam name]
    nParams Newtype name
    n
                        , nBody :: [Named (Type name)]
    nBody   = [Named (Type name)] -> [Named (Type name)]
    forall t. NoPos t => t -> t
    noPos (Newtype name -> [Named (Type name)]
    forall name. Newtype name -> [Named (Type name)]
    nBody Newtype name
    n)
                        }

    instance NoPos (Bind name) where
      noPos :: Bind name -> Bind name
    noPos x :: Bind name
    x = Bind :: forall name.
    Located name
    -> [Pattern name]
    -> Located (BindDef name)
    -> Maybe (Schema name)
    -> Bool
    -> Maybe Fixity
    -> [Pragma]
    -> Bool
    -> Maybe String
    -> Bind name
    Bind { bName :: Located name
    bName      = Located name -> Located name
    forall t. NoPos t => t -> t
    noPos (Bind name -> Located name
    forall name. Bind name -> Located name
    bName      Bind name
    x)
                     , bParams :: [Pattern name]
    bParams    = [Pattern name] -> [Pattern name]
    forall t. NoPos t => t -> t
    noPos (Bind name -> [Pattern name]
    forall name. Bind name -> [Pattern name]
    bParams    Bind name
    x)
                     , bDef :: Located (BindDef name)
    bDef       = Located (BindDef name) -> Located (BindDef name)
    forall t. NoPos t => t -> t
    noPos (Bind name -> Located (BindDef name)
    forall name. Bind name -> Located (BindDef name)
    bDef       Bind name
    x)
                     , bSignature :: Maybe (Schema name)
    bSignature = Maybe (Schema name) -> Maybe (Schema name)
    forall t. NoPos t => t -> t
    noPos (Bind name -> Maybe (Schema name)
    forall name. Bind name -> Maybe (Schema name)
    bSignature Bind name
    x)
                     , bInfix :: Bool
    bInfix     = Bind name -> Bool
    forall name. Bind name -> Bool
    bInfix Bind name
    x
                     , bFixity :: Maybe Fixity
    bFixity    = Bind name -> Maybe Fixity
    forall name. Bind name -> Maybe Fixity
    bFixity Bind name
    x
                     , bPragmas :: [Pragma]
    bPragmas   = [Pragma] -> [Pragma]
    forall t. NoPos t => t -> t
    noPos (Bind name -> [Pragma]
    forall name. Bind name -> [Pragma]
    bPragmas   Bind name
    x)
                     , bMono :: Bool
    bMono      = Bind name -> Bool
    forall name. Bind name -> Bool
    bMono Bind name
    x
                     , bDoc :: Maybe String
    bDoc       = Bind name -> Maybe String
    forall name. Bind name -> Maybe String
    bDoc Bind name
    x
                     }

    instance NoPos Pragma where
      noPos :: Pragma -> Pragma
    noPos p :: Pragma
    p@(PragmaNote {})   = Pragma
    p
      noPos p :: Pragma
    p@(Pragma
    PragmaProperty)  = Pragma
    p

    instance NoPos (TySyn name) where
      noPos :: TySyn name -> TySyn name
    noPos (TySyn x :: Located name
    x f :: Maybe Fixity
    f y :: [TParam name]
    y z :: Type name
    z) = Located name
    -> Maybe Fixity -> [TParam name] -> Type name -> TySyn name
    forall n.
    Located n -> Maybe Fixity -> [TParam n] -> Type n -> TySyn n
    TySyn (Located name -> Located name
    forall t. NoPos t => t -> t
    noPos Located name
    x) Maybe Fixity
    f ([TParam name] -> [TParam name]
    forall t. NoPos t => t -> t
    noPos [TParam name]
    y) (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    z)

    instance NoPos (PropSyn name) where
      noPos :: PropSyn name -> PropSyn name
    noPos (PropSyn x :: Located name
    x f :: Maybe Fixity
    f y :: [TParam name]
    y z :: [Prop name]
    z) = Located name
    -> Maybe Fixity -> [TParam name] -> [Prop name] -> PropSyn name
    forall n.
    Located n -> Maybe Fixity -> [TParam n] -> [Prop n] -> PropSyn n
    PropSyn (Located name -> Located name
    forall t. NoPos t => t -> t
    noPos Located name
    x) Maybe Fixity
    f ([TParam name] -> [TParam name]
    forall t. NoPos t => t -> t
    noPos [TParam name]
    y) ([Prop name] -> [Prop name]
    forall t. NoPos t => t -> t
    noPos [Prop name]
    z)

    instance NoPos (Expr name) where
      noPos :: Expr name -> Expr name
    noPos expr :: Expr name
    expr =
        case Expr name
    expr of
          EVar x :: name
    x          -> name -> Expr name
    forall n. n -> Expr n
    EVar     name
    x
          ELit x :: Literal
    x          -> Literal -> Expr name
    forall n. Literal -> Expr n
    ELit     Literal
    x
          ENeg x :: Expr name
    x          -> Expr name -> Expr name
    forall n. Expr n -> Expr n
    ENeg     (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x)
          EComplement x :: Expr name
    x   -> Expr name -> Expr name
    forall n. Expr n -> Expr n
    EComplement (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x)
          EGenerate x :: Expr name
    x     -> Expr name -> Expr name
    forall n. Expr n -> Expr n
    EGenerate (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x)
          ETuple x :: [Expr name]
    x        -> [Expr name] -> Expr name
    forall n. [Expr n] -> Expr n
    ETuple   ([Expr name] -> [Expr name]
    forall t. NoPos t => t -> t
    noPos [Expr name]
    x)
          ERecord x :: [Named (Expr name)]
    x       -> [Named (Expr name)] -> Expr name
    forall n. [Named (Expr n)] -> Expr n
    ERecord  ([Named (Expr name)] -> [Named (Expr name)]
    forall t. NoPos t => t -> t
    noPos [Named (Expr name)]
    x)
          ESel x :: Expr name
    x y :: Selector
    y        -> Expr name -> Selector -> Expr name
    forall n. Expr n -> Selector -> Expr n
    ESel     (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) Selector
    y
          EUpd x :: Maybe (Expr name)
    x y :: [UpdField name]
    y        -> Maybe (Expr name) -> [UpdField name] -> Expr name
    forall n. Maybe (Expr n) -> [UpdField n] -> Expr n
    EUpd     (Maybe (Expr name) -> Maybe (Expr name)
    forall t. NoPos t => t -> t
    noPos Maybe (Expr name)
    x) ([UpdField name] -> [UpdField name]
    forall t. NoPos t => t -> t
    noPos [UpdField name]
    y)
          EList x :: [Expr name]
    x         -> [Expr name] -> Expr name
    forall n. [Expr n] -> Expr n
    EList    ([Expr name] -> [Expr name]
    forall t. NoPos t => t -> t
    noPos [Expr name]
    x)
          EFromTo x :: Type name
    x y :: Maybe (Type name)
    y z :: Type name
    z t :: Maybe (Type name)
    t -> Type name
    -> Maybe (Type name) -> Type name -> Maybe (Type name) -> Expr name
    forall n.
    Type n -> Maybe (Type n) -> Type n -> Maybe (Type n) -> Expr n
    EFromTo  (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    x) (Maybe (Type name) -> Maybe (Type name)
    forall t. NoPos t => t -> t
    noPos Maybe (Type name)
    y) (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    z) (Maybe (Type name) -> Maybe (Type name)
    forall t. NoPos t => t -> t
    noPos Maybe (Type name)
    t)
          EInfFrom x :: Expr name
    x y :: Maybe (Expr name)
    y    -> Expr name -> Maybe (Expr name) -> Expr name
    forall n. Expr n -> Maybe (Expr n) -> Expr n
    EInfFrom (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) (Maybe (Expr name) -> Maybe (Expr name)
    forall t. NoPos t => t -> t
    noPos Maybe (Expr name)
    y)
          EComp x :: Expr name
    x y :: [[Match name]]
    y       -> Expr name -> [[Match name]] -> Expr name
    forall n. Expr n -> [[Match n]] -> Expr n
    EComp    (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) ([[Match name]] -> [[Match name]]
    forall t. NoPos t => t -> t
    noPos [[Match name]]
    y)
          EApp  x :: Expr name
    x y :: Expr name
    y       -> Expr name -> Expr name -> Expr name
    forall n. Expr n -> Expr n -> Expr n
    EApp     (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    y)
          EAppT x :: Expr name
    x y :: [TypeInst name]
    y       -> Expr name -> [TypeInst name] -> Expr name
    forall n. Expr n -> [TypeInst n] -> Expr n
    EAppT    (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) ([TypeInst name] -> [TypeInst name]
    forall t. NoPos t => t -> t
    noPos [TypeInst name]
    y)
          EIf   x :: Expr name
    x y :: Expr name
    y z :: Expr name
    z     -> Expr name -> Expr name -> Expr name -> Expr name
    forall n. Expr n -> Expr n -> Expr n -> Expr n
    EIf      (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    y) (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    z)
          EWhere x :: Expr name
    x y :: [Decl name]
    y      -> Expr name -> [Decl name] -> Expr name
    forall n. Expr n -> [Decl n] -> Expr n
    EWhere   (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) ([Decl name] -> [Decl name]
    forall t. NoPos t => t -> t
    noPos [Decl name]
    y)
          ETyped x :: Expr name
    x y :: Type name
    y      -> Expr name -> Type name -> Expr name
    forall n. Expr n -> Type n -> Expr n
    ETyped   (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    y)
          ETypeVal x :: Type name
    x      -> Type name -> Expr name
    forall n. Type n -> Expr n
    ETypeVal (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    x)
          EFun x :: [Pattern name]
    x y :: Expr name
    y        -> [Pattern name] -> Expr name -> Expr name
    forall n. [Pattern n] -> Expr n -> Expr n
    EFun     ([Pattern name] -> [Pattern name]
    forall t. NoPos t => t -> t
    noPos [Pattern name]
    x) (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    y)
          ELocated x :: Expr name
    x _    -> Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x

          ESplit x :: Expr name
    x        -> Expr name -> Expr name
    forall n. Expr n -> Expr n
    ESplit (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x)
          EParens e :: Expr name
    e       -> Expr name -> Expr name
    forall n. Expr n -> Expr n
    EParens (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    e)
          EInfix x :: Expr name
    x y :: Located name
    y f :: Fixity
    f z :: Expr name
    z  -> Expr name -> Located name -> Fixity -> Expr name -> Expr name
    forall n. Expr n -> Located n -> Fixity -> Expr n -> Expr n
    EInfix (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    x) Located name
    y Fixity
    f (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    z)

    instance NoPos (UpdField name) where
      noPos :: UpdField name -> UpdField name
    noPos (UpdField h :: UpdHow
    h xs :: [Located Selector]
    xs e :: Expr name
    e) = UpdHow -> [Located Selector] -> Expr name -> UpdField name
    forall n. UpdHow -> [Located Selector] -> Expr n -> UpdField n
    UpdField UpdHow
    h [Located Selector]
    xs (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    e)

    instance NoPos (TypeInst name) where
      noPos :: TypeInst name -> TypeInst name
    noPos (PosInst ts :: Type name
    ts)   = Type name -> TypeInst name
    forall name. Type name -> TypeInst name
    PosInst (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    ts)
      noPos (NamedInst fs :: Named (Type name)
    fs) = Named (Type name) -> TypeInst name
    forall name. Named (Type name) -> TypeInst name
    NamedInst (Named (Type name) -> Named (Type name)
    forall t. NoPos t => t -> t
    noPos Named (Type name)
    fs)

    instance NoPos (Match name) where
      noPos :: Match name -> Match name
    noPos (Match x :: Pattern name
    x y :: Expr name
    y)  = Pattern name -> Expr name -> Match name
    forall name. Pattern name -> Expr name -> Match name
    Match (Pattern name -> Pattern name
    forall t. NoPos t => t -> t
    noPos Pattern name
    x) (Expr name -> Expr name
    forall t. NoPos t => t -> t
    noPos Expr name
    y)
      noPos (MatchLet b :: Bind name
    b) = Bind name -> Match name
    forall name. Bind name -> Match name
    MatchLet (Bind name -> Bind name
    forall t. NoPos t => t -> t
    noPos Bind name
    b)

    instance NoPos (Pattern name) where
      noPos :: Pattern name -> Pattern name
    noPos pat :: Pattern name
    pat =
        case Pattern name
    pat of
          PVar x :: Located name
    x       -> Located name -> Pattern name
    forall n. Located n -> Pattern n
    PVar    (Located name -> Located name
    forall t. NoPos t => t -> t
    noPos Located name
    x)
          PWild        -> Pattern name
    forall n. Pattern n
    PWild
          PTuple x :: [Pattern name]
    x     -> [Pattern name] -> Pattern name
    forall n. [Pattern n] -> Pattern n
    PTuple  ([Pattern name] -> [Pattern name]
    forall t. NoPos t => t -> t
    noPos [Pattern name]
    x)
          PRecord x :: [Named (Pattern name)]
    x    -> [Named (Pattern name)] -> Pattern name
    forall n. [Named (Pattern n)] -> Pattern n
    PRecord ([Named (Pattern name)] -> [Named (Pattern name)]
    forall t. NoPos t => t -> t
    noPos [Named (Pattern name)]
    x)
          PList x :: [Pattern name]
    x      -> [Pattern name] -> Pattern name
    forall n. [Pattern n] -> Pattern n
    PList   ([Pattern name] -> [Pattern name]
    forall t. NoPos t => t -> t
    noPos [Pattern name]
    x)
          PTyped x :: Pattern name
    x y :: Type name
    y   -> Pattern name -> Type name -> Pattern name
    forall n. Pattern n -> Type n -> Pattern n
    PTyped  (Pattern name -> Pattern name
    forall t. NoPos t => t -> t
    noPos Pattern name
    x) (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    y)
          PSplit x :: Pattern name
    x y :: Pattern name
    y   -> Pattern name -> Pattern name -> Pattern name
    forall n. Pattern n -> Pattern n -> Pattern n
    PSplit  (Pattern name -> Pattern name
    forall t. NoPos t => t -> t
    noPos Pattern name
    x) (Pattern name -> Pattern name
    forall t. NoPos t => t -> t
    noPos Pattern name
    y)
          PLocated x :: Pattern name
    x _ -> Pattern name -> Pattern name
    forall t. NoPos t => t -> t
    noPos Pattern name
    x

    instance NoPos (Schema name) where
      noPos :: Schema name -> Schema name
    noPos (Forall x :: [TParam name]
    x y :: [Prop name]
    y z :: Type name
    z _) = [TParam name]
    -> [Prop name] -> Type name -> Maybe Range -> Schema name
    forall n.
    [TParam n] -> [Prop n] -> Type n -> Maybe Range -> Schema n
    Forall ([TParam name] -> [TParam name]
    forall t. NoPos t => t -> t
    noPos [TParam name]
    x) ([Prop name] -> [Prop name]
    forall t. NoPos t => t -> t
    noPos [Prop name]
    y) (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    z) Maybe Range
    forall a. Maybe a
    Nothing

    instance NoPos (TParam name) where
      noPos :: TParam name -> TParam name
    noPos (TParam x :: name
    x y :: Maybe Kind
    y _)  = name -> Maybe Kind -> Maybe Range -> TParam name
    forall n. n -> Maybe Kind -> Maybe Range -> TParam n
    TParam name
    x Maybe Kind
    y Maybe Range
    forall a. Maybe a
    Nothing

    instance NoPos (Type name) where
      noPos :: Type name -> Type name
    noPos ty :: Type name
    ty =
        case Type name
    ty of
          TWild         -> Type name
    forall n. Type n
    TWild
          TUser x :: name
    x y :: [Type name]
    y     -> name -> [Type name] -> Type name
    forall n. n -> [Type n] -> Type n
    TUser    name
    x         ([Type name] -> [Type name]
    forall t. NoPos t => t -> t
    noPos [Type name]
    y)
          TRecord x :: [Named (Type name)]
    x     -> [Named (Type name)] -> Type name
    forall n. [Named (Type n)] -> Type n
    TRecord  ([Named (Type name)] -> [Named (Type name)]
    forall t. NoPos t => t -> t
    noPos [Named (Type name)]
    x)
          TTuple x :: [Type name]
    x      -> [Type name] -> Type name
    forall n. [Type n] -> Type n
    TTuple   ([Type name] -> [Type name]
    forall t. NoPos t => t -> t
    noPos [Type name]
    x)
          TFun x :: Type name
    x y :: Type name
    y      -> Type name -> Type name -> Type name
    forall n. Type n -> Type n -> Type n
    TFun     (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    x) (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    y)
          TSeq x :: Type name
    x y :: Type name
    y      -> Type name -> Type name -> Type name
    forall n. Type n -> Type n -> Type n
    TSeq     (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    x) (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    y)
          TBit          -> Type name
    forall n. Type n
    TBit
          TNum n :: Integer
    n        -> Integer -> Type name
    forall n. Integer -> Type n
    TNum Integer
    n
          TChar n :: Char
    n       -> Char -> Type name
    forall n. Char -> Type n
    TChar Char
    n
          TLocated x :: Type name
    x _  -> Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    x
          TParens x :: Type name
    x     -> Type name -> Type name
    forall name. Type name -> Type name
    TParens (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    x)
          TInfix x :: Type name
    x y :: Located name
    y f :: Fixity
    f z :: Type name
    z-> Type name -> Located name -> Fixity -> Type name -> Type name
    forall n. Type n -> Located n -> Fixity -> Type n -> Type n
    TInfix (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    x) Located name
    y Fixity
    f (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    z)

    instance NoPos (Prop name) where
      noPos :: Prop name -> Prop name
    noPos (CType t :: Type name
    t) = Type name -> Prop name
    forall n. Type n -> Prop n
    CType (Type name -> Type name
    forall t. NoPos t => t -> t
    noPos Type name
    t)