{- |
    Module      :  $Header$
    Description :  Abstract syntax for Curry
    Copyright   :  (c) 1999 - 2004 Wolfgang Lux
                       2005        Martin Engelke
                       2011 - 2015 Björn Peemöller
                       2014        Jan Rasmus Tikovsky
                       2016        Finn Teegen
    License     :  BSD-3-clause

    Maintainer  :  bjp@informatik.uni-kiel.de
    Stability   :  experimental
    Portability :  portable

    This module provides the necessary data structures to maintain the
    parsed representation of a Curry program.
-}

module Curry.Syntax.Type
  ( -- * Module header
    Module (..)
    -- ** Module pragmas
  , ModulePragma (..), Extension (..), KnownExtension (..), Tool (..)
    -- ** Export specification
  , ExportSpec (..), Export (..)
    -- ** Import declarations
  , ImportDecl (..), ImportSpec (..), Import (..), Qualified
    -- * Interface
  , Interface (..), IImportDecl (..), Arity, IDecl (..), KindExpr (..)
  , IMethodDecl (..), IMethodImpl
    -- * Declarations
  , Decl (..), Precedence, Infix (..), ConstrDecl (..), NewConstrDecl (..)
  , FieldDecl (..)
  , TypeExpr (..), QualTypeExpr (..)
  , Equation (..), Lhs (..), Rhs (..), CondExpr (..)
  , Literal (..), Pattern (..), Expression (..), InfixOp (..)
  , Statement (..), CaseType (..), Alt (..), Field (..), Var (..)
    -- * Type classes
  , Context, Constraint (..), InstanceType
    -- * Goals
  , Goal (..)
  ) where

import Data.Binary
import Control.Monad

import Curry.Base.Ident
import Curry.Base.Position
import Curry.Base.SpanInfo
import Curry.Base.Span
import Curry.Base.Pretty      (Pretty(..))

import Curry.Syntax.Extension

import Text.PrettyPrint

-- ---------------------------------------------------------------------------
-- Modules
-- ---------------------------------------------------------------------------

-- |Curry module
data Module a = Module SpanInfo LayoutInfo [ModulePragma] ModuleIdent
                       (Maybe ExportSpec) [ImportDecl] [Decl a]
    deriving (Module a -> Module a -> Bool
(Module a -> Module a -> Bool)
-> (Module a -> Module a -> Bool) -> Eq (Module a)
forall a. Eq a => Module a -> Module a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Module a -> Module a -> Bool
$c/= :: forall a. Eq a => Module a -> Module a -> Bool
== :: Module a -> Module a -> Bool
$c== :: forall a. Eq a => Module a -> Module a -> Bool
Eq, ReadPrec [Module a]
ReadPrec (Module a)
Int -> ReadS (Module a)
ReadS [Module a]
(Int -> ReadS (Module a))
-> ReadS [Module a]
-> ReadPrec (Module a)
-> ReadPrec [Module a]
-> Read (Module a)
forall a. Read a => ReadPrec [Module a]
forall a. Read a => ReadPrec (Module a)
forall a. Read a => Int -> ReadS (Module a)
forall a. Read a => ReadS [Module a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Module a]
$creadListPrec :: forall a. Read a => ReadPrec [Module a]
readPrec :: ReadPrec (Module a)
$creadPrec :: forall a. Read a => ReadPrec (Module a)
readList :: ReadS [Module a]
$creadList :: forall a. Read a => ReadS [Module a]
readsPrec :: Int -> ReadS (Module a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Module a)
Read, Int -> Module a -> ShowS
[Module a] -> ShowS
Module a -> String
(Int -> Module a -> ShowS)
-> (Module a -> String) -> ([Module a] -> ShowS) -> Show (Module a)
forall a. Show a => Int -> Module a -> ShowS
forall a. Show a => [Module a] -> ShowS
forall a. Show a => Module a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Module a] -> ShowS
$cshowList :: forall a. Show a => [Module a] -> ShowS
show :: Module a -> String
$cshow :: forall a. Show a => Module a -> String
showsPrec :: Int -> Module a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Module a -> ShowS
Show)

-- |Module pragma
data ModulePragma
  = LanguagePragma SpanInfo [Extension]         -- ^ language pragma
  | OptionsPragma  SpanInfo (Maybe Tool) String -- ^ options pragma
    deriving (ModulePragma -> ModulePragma -> Bool
(ModulePragma -> ModulePragma -> Bool)
-> (ModulePragma -> ModulePragma -> Bool) -> Eq ModulePragma
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModulePragma -> ModulePragma -> Bool
$c/= :: ModulePragma -> ModulePragma -> Bool
== :: ModulePragma -> ModulePragma -> Bool
$c== :: ModulePragma -> ModulePragma -> Bool
Eq, ReadPrec [ModulePragma]
ReadPrec ModulePragma
Int -> ReadS ModulePragma
ReadS [ModulePragma]
(Int -> ReadS ModulePragma)
-> ReadS [ModulePragma]
-> ReadPrec ModulePragma
-> ReadPrec [ModulePragma]
-> Read ModulePragma
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModulePragma]
$creadListPrec :: ReadPrec [ModulePragma]
readPrec :: ReadPrec ModulePragma
$creadPrec :: ReadPrec ModulePragma
readList :: ReadS [ModulePragma]
$creadList :: ReadS [ModulePragma]
readsPrec :: Int -> ReadS ModulePragma
$creadsPrec :: Int -> ReadS ModulePragma
Read, Int -> ModulePragma -> ShowS
[ModulePragma] -> ShowS
ModulePragma -> String
(Int -> ModulePragma -> ShowS)
-> (ModulePragma -> String)
-> ([ModulePragma] -> ShowS)
-> Show ModulePragma
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModulePragma] -> ShowS
$cshowList :: [ModulePragma] -> ShowS
show :: ModulePragma -> String
$cshow :: ModulePragma -> String
showsPrec :: Int -> ModulePragma -> ShowS
$cshowsPrec :: Int -> ModulePragma -> ShowS
Show)

-- |Export specification
data ExportSpec = Exporting SpanInfo [Export]
    deriving (ExportSpec -> ExportSpec -> Bool
(ExportSpec -> ExportSpec -> Bool)
-> (ExportSpec -> ExportSpec -> Bool) -> Eq ExportSpec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportSpec -> ExportSpec -> Bool
$c/= :: ExportSpec -> ExportSpec -> Bool
== :: ExportSpec -> ExportSpec -> Bool
$c== :: ExportSpec -> ExportSpec -> Bool
Eq, ReadPrec [ExportSpec]
ReadPrec ExportSpec
Int -> ReadS ExportSpec
ReadS [ExportSpec]
(Int -> ReadS ExportSpec)
-> ReadS [ExportSpec]
-> ReadPrec ExportSpec
-> ReadPrec [ExportSpec]
-> Read ExportSpec
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportSpec]
$creadListPrec :: ReadPrec [ExportSpec]
readPrec :: ReadPrec ExportSpec
$creadPrec :: ReadPrec ExportSpec
readList :: ReadS [ExportSpec]
$creadList :: ReadS [ExportSpec]
readsPrec :: Int -> ReadS ExportSpec
$creadsPrec :: Int -> ReadS ExportSpec
Read, Int -> ExportSpec -> ShowS
[ExportSpec] -> ShowS
ExportSpec -> String
(Int -> ExportSpec -> ShowS)
-> (ExportSpec -> String)
-> ([ExportSpec] -> ShowS)
-> Show ExportSpec
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportSpec] -> ShowS
$cshowList :: [ExportSpec] -> ShowS
show :: ExportSpec -> String
$cshow :: ExportSpec -> String
showsPrec :: Int -> ExportSpec -> ShowS
$cshowsPrec :: Int -> ExportSpec -> ShowS
Show)

-- |Single exported entity
data Export
  = Export         SpanInfo QualIdent         -- f/T
  | ExportTypeWith SpanInfo QualIdent [Ident] -- T (C1,...,Cn)
  | ExportTypeAll  SpanInfo QualIdent         -- T (..)
  | ExportModule   SpanInfo ModuleIdent       -- module M
    deriving (Export -> Export -> Bool
(Export -> Export -> Bool)
-> (Export -> Export -> Bool) -> Eq Export
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Export -> Export -> Bool
$c/= :: Export -> Export -> Bool
== :: Export -> Export -> Bool
$c== :: Export -> Export -> Bool
Eq, ReadPrec [Export]
ReadPrec Export
Int -> ReadS Export
ReadS [Export]
(Int -> ReadS Export)
-> ReadS [Export]
-> ReadPrec Export
-> ReadPrec [Export]
-> Read Export
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Export]
$creadListPrec :: ReadPrec [Export]
readPrec :: ReadPrec Export
$creadPrec :: ReadPrec Export
readList :: ReadS [Export]
$creadList :: ReadS [Export]
readsPrec :: Int -> ReadS Export
$creadsPrec :: Int -> ReadS Export
Read, Int -> Export -> ShowS
[Export] -> ShowS
Export -> String
(Int -> Export -> ShowS)
-> (Export -> String) -> ([Export] -> ShowS) -> Show Export
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Export] -> ShowS
$cshowList :: [Export] -> ShowS
show :: Export -> String
$cshow :: Export -> String
showsPrec :: Int -> Export -> ShowS
$cshowsPrec :: Int -> Export -> ShowS
Show)

-- |Import declaration
data ImportDecl = ImportDecl SpanInfo ModuleIdent Qualified
                             (Maybe ModuleIdent) (Maybe ImportSpec)
    deriving (ImportDecl -> ImportDecl -> Bool
(ImportDecl -> ImportDecl -> Bool)
-> (ImportDecl -> ImportDecl -> Bool) -> Eq ImportDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportDecl -> ImportDecl -> Bool
$c/= :: ImportDecl -> ImportDecl -> Bool
== :: ImportDecl -> ImportDecl -> Bool
$c== :: ImportDecl -> ImportDecl -> Bool
Eq, ReadPrec [ImportDecl]
ReadPrec ImportDecl
Int -> ReadS ImportDecl
ReadS [ImportDecl]
(Int -> ReadS ImportDecl)
-> ReadS [ImportDecl]
-> ReadPrec ImportDecl
-> ReadPrec [ImportDecl]
-> Read ImportDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportDecl]
$creadListPrec :: ReadPrec [ImportDecl]
readPrec :: ReadPrec ImportDecl
$creadPrec :: ReadPrec ImportDecl
readList :: ReadS [ImportDecl]
$creadList :: ReadS [ImportDecl]
readsPrec :: Int -> ReadS ImportDecl
$creadsPrec :: Int -> ReadS ImportDecl
Read, Int -> ImportDecl -> ShowS
[ImportDecl] -> ShowS
ImportDecl -> String
(Int -> ImportDecl -> ShowS)
-> (ImportDecl -> String)
-> ([ImportDecl] -> ShowS)
-> Show ImportDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportDecl] -> ShowS
$cshowList :: [ImportDecl] -> ShowS
show :: ImportDecl -> String
$cshow :: ImportDecl -> String
showsPrec :: Int -> ImportDecl -> ShowS
$cshowsPrec :: Int -> ImportDecl -> ShowS
Show)

-- |Flag to signal qualified import
type Qualified = Bool

-- |Import specification
data ImportSpec
  = Importing SpanInfo [Import]
  | Hiding    SpanInfo [Import]
    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, ReadPrec [ImportSpec]
ReadPrec ImportSpec
Int -> ReadS ImportSpec
ReadS [ImportSpec]
(Int -> ReadS ImportSpec)
-> ReadS [ImportSpec]
-> ReadPrec ImportSpec
-> ReadPrec [ImportSpec]
-> Read ImportSpec
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportSpec]
$creadListPrec :: ReadPrec [ImportSpec]
readPrec :: ReadPrec ImportSpec
$creadPrec :: ReadPrec ImportSpec
readList :: ReadS [ImportSpec]
$creadList :: ReadS [ImportSpec]
readsPrec :: Int -> ReadS ImportSpec
$creadsPrec :: Int -> ReadS ImportSpec
Read, 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)

-- |Single imported entity
data Import
  = Import         SpanInfo Ident            -- f/T
  | ImportTypeWith SpanInfo Ident [Ident]    -- T (C1,...,Cn)
  | ImportTypeAll  SpanInfo Ident            -- T (..)
    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, ReadPrec [Import]
ReadPrec Import
Int -> ReadS Import
ReadS [Import]
(Int -> ReadS Import)
-> ReadS [Import]
-> ReadPrec Import
-> ReadPrec [Import]
-> Read Import
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Import]
$creadListPrec :: ReadPrec [Import]
readPrec :: ReadPrec Import
$creadPrec :: ReadPrec Import
readList :: ReadS [Import]
$creadList :: ReadS [Import]
readsPrec :: Int -> ReadS Import
$creadsPrec :: Int -> ReadS Import
Read, 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)

-- ---------------------------------------------------------------------------
-- Module interfaces
-- ---------------------------------------------------------------------------

-- | Module interface
--
-- Interface declarations are restricted to type declarations and signatures.
-- Note that an interface function declaration additionaly contains the
-- function arity (= number of parameters) in order to generate
-- correct FlatCurry function applications.
data Interface = Interface ModuleIdent [IImportDecl] [IDecl]
    deriving (Interface -> Interface -> Bool
(Interface -> Interface -> Bool)
-> (Interface -> Interface -> Bool) -> Eq Interface
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Interface -> Interface -> Bool
$c/= :: Interface -> Interface -> Bool
== :: Interface -> Interface -> Bool
$c== :: Interface -> Interface -> Bool
Eq, ReadPrec [Interface]
ReadPrec Interface
Int -> ReadS Interface
ReadS [Interface]
(Int -> ReadS Interface)
-> ReadS [Interface]
-> ReadPrec Interface
-> ReadPrec [Interface]
-> Read Interface
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Interface]
$creadListPrec :: ReadPrec [Interface]
readPrec :: ReadPrec Interface
$creadPrec :: ReadPrec Interface
readList :: ReadS [Interface]
$creadList :: ReadS [Interface]
readsPrec :: Int -> ReadS Interface
$creadsPrec :: Int -> ReadS Interface
Read, Int -> Interface -> ShowS
[Interface] -> ShowS
Interface -> String
(Int -> Interface -> ShowS)
-> (Interface -> String)
-> ([Interface] -> ShowS)
-> Show Interface
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Interface] -> ShowS
$cshowList :: [Interface] -> ShowS
show :: Interface -> String
$cshow :: Interface -> String
showsPrec :: Int -> Interface -> ShowS
$cshowsPrec :: Int -> Interface -> ShowS
Show)

-- |Interface import declaration
data IImportDecl = IImportDecl Position ModuleIdent
    deriving (IImportDecl -> IImportDecl -> Bool
(IImportDecl -> IImportDecl -> Bool)
-> (IImportDecl -> IImportDecl -> Bool) -> Eq IImportDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IImportDecl -> IImportDecl -> Bool
$c/= :: IImportDecl -> IImportDecl -> Bool
== :: IImportDecl -> IImportDecl -> Bool
$c== :: IImportDecl -> IImportDecl -> Bool
Eq, ReadPrec [IImportDecl]
ReadPrec IImportDecl
Int -> ReadS IImportDecl
ReadS [IImportDecl]
(Int -> ReadS IImportDecl)
-> ReadS [IImportDecl]
-> ReadPrec IImportDecl
-> ReadPrec [IImportDecl]
-> Read IImportDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IImportDecl]
$creadListPrec :: ReadPrec [IImportDecl]
readPrec :: ReadPrec IImportDecl
$creadPrec :: ReadPrec IImportDecl
readList :: ReadS [IImportDecl]
$creadList :: ReadS [IImportDecl]
readsPrec :: Int -> ReadS IImportDecl
$creadsPrec :: Int -> ReadS IImportDecl
Read, Int -> IImportDecl -> ShowS
[IImportDecl] -> ShowS
IImportDecl -> String
(Int -> IImportDecl -> ShowS)
-> (IImportDecl -> String)
-> ([IImportDecl] -> ShowS)
-> Show IImportDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IImportDecl] -> ShowS
$cshowList :: [IImportDecl] -> ShowS
show :: IImportDecl -> String
$cshow :: IImportDecl -> String
showsPrec :: Int -> IImportDecl -> ShowS
$cshowsPrec :: Int -> IImportDecl -> ShowS
Show)

-- |Arity of a function
type Arity = Int

-- |Interface declaration
data IDecl
  = IInfixDecl      Position Infix Precedence QualIdent
  | HidingDataDecl  Position QualIdent (Maybe KindExpr) [Ident]
  | IDataDecl       Position QualIdent (Maybe KindExpr) [Ident] [ConstrDecl]  [Ident]
  | INewtypeDecl    Position QualIdent (Maybe KindExpr) [Ident] NewConstrDecl [Ident]
  | ITypeDecl       Position QualIdent (Maybe KindExpr) [Ident] TypeExpr
  | IFunctionDecl   Position QualIdent (Maybe Ident) Arity QualTypeExpr
  | HidingClassDecl Position Context QualIdent (Maybe KindExpr) Ident
  | IClassDecl      Position Context QualIdent (Maybe KindExpr) Ident [IMethodDecl] [Ident]
  | IInstanceDecl   Position Context QualIdent InstanceType [IMethodImpl] (Maybe ModuleIdent)
    deriving (IDecl -> IDecl -> Bool
(IDecl -> IDecl -> Bool) -> (IDecl -> IDecl -> Bool) -> Eq IDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IDecl -> IDecl -> Bool
$c/= :: IDecl -> IDecl -> Bool
== :: IDecl -> IDecl -> Bool
$c== :: IDecl -> IDecl -> Bool
Eq, ReadPrec [IDecl]
ReadPrec IDecl
Int -> ReadS IDecl
ReadS [IDecl]
(Int -> ReadS IDecl)
-> ReadS [IDecl]
-> ReadPrec IDecl
-> ReadPrec [IDecl]
-> Read IDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IDecl]
$creadListPrec :: ReadPrec [IDecl]
readPrec :: ReadPrec IDecl
$creadPrec :: ReadPrec IDecl
readList :: ReadS [IDecl]
$creadList :: ReadS [IDecl]
readsPrec :: Int -> ReadS IDecl
$creadsPrec :: Int -> ReadS IDecl
Read, Int -> IDecl -> ShowS
[IDecl] -> ShowS
IDecl -> String
(Int -> IDecl -> ShowS)
-> (IDecl -> String) -> ([IDecl] -> ShowS) -> Show IDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IDecl] -> ShowS
$cshowList :: [IDecl] -> ShowS
show :: IDecl -> String
$cshow :: IDecl -> String
showsPrec :: Int -> IDecl -> ShowS
$cshowsPrec :: Int -> IDecl -> ShowS
Show)

-- |Class methods
data IMethodDecl = IMethodDecl Position Ident (Maybe Arity) QualTypeExpr
  deriving (IMethodDecl -> IMethodDecl -> Bool
(IMethodDecl -> IMethodDecl -> Bool)
-> (IMethodDecl -> IMethodDecl -> Bool) -> Eq IMethodDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IMethodDecl -> IMethodDecl -> Bool
$c/= :: IMethodDecl -> IMethodDecl -> Bool
== :: IMethodDecl -> IMethodDecl -> Bool
$c== :: IMethodDecl -> IMethodDecl -> Bool
Eq, ReadPrec [IMethodDecl]
ReadPrec IMethodDecl
Int -> ReadS IMethodDecl
ReadS [IMethodDecl]
(Int -> ReadS IMethodDecl)
-> ReadS [IMethodDecl]
-> ReadPrec IMethodDecl
-> ReadPrec [IMethodDecl]
-> Read IMethodDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IMethodDecl]
$creadListPrec :: ReadPrec [IMethodDecl]
readPrec :: ReadPrec IMethodDecl
$creadPrec :: ReadPrec IMethodDecl
readList :: ReadS [IMethodDecl]
$creadList :: ReadS [IMethodDecl]
readsPrec :: Int -> ReadS IMethodDecl
$creadsPrec :: Int -> ReadS IMethodDecl
Read, Int -> IMethodDecl -> ShowS
[IMethodDecl] -> ShowS
IMethodDecl -> String
(Int -> IMethodDecl -> ShowS)
-> (IMethodDecl -> String)
-> ([IMethodDecl] -> ShowS)
-> Show IMethodDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IMethodDecl] -> ShowS
$cshowList :: [IMethodDecl] -> ShowS
show :: IMethodDecl -> String
$cshow :: IMethodDecl -> String
showsPrec :: Int -> IMethodDecl -> ShowS
$cshowsPrec :: Int -> IMethodDecl -> ShowS
Show)

-- |Class method implementations
type IMethodImpl = (Ident, Arity)

-- |Kind expressions
data KindExpr
  = Star
  | ArrowKind KindExpr KindExpr
    deriving (KindExpr -> KindExpr -> Bool
(KindExpr -> KindExpr -> Bool)
-> (KindExpr -> KindExpr -> Bool) -> Eq KindExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KindExpr -> KindExpr -> Bool
$c/= :: KindExpr -> KindExpr -> Bool
== :: KindExpr -> KindExpr -> Bool
$c== :: KindExpr -> KindExpr -> Bool
Eq, ReadPrec [KindExpr]
ReadPrec KindExpr
Int -> ReadS KindExpr
ReadS [KindExpr]
(Int -> ReadS KindExpr)
-> ReadS [KindExpr]
-> ReadPrec KindExpr
-> ReadPrec [KindExpr]
-> Read KindExpr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KindExpr]
$creadListPrec :: ReadPrec [KindExpr]
readPrec :: ReadPrec KindExpr
$creadPrec :: ReadPrec KindExpr
readList :: ReadS [KindExpr]
$creadList :: ReadS [KindExpr]
readsPrec :: Int -> ReadS KindExpr
$creadsPrec :: Int -> ReadS KindExpr
Read, Int -> KindExpr -> ShowS
[KindExpr] -> ShowS
KindExpr -> String
(Int -> KindExpr -> ShowS)
-> (KindExpr -> String) -> ([KindExpr] -> ShowS) -> Show KindExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KindExpr] -> ShowS
$cshowList :: [KindExpr] -> ShowS
show :: KindExpr -> String
$cshow :: KindExpr -> String
showsPrec :: Int -> KindExpr -> ShowS
$cshowsPrec :: Int -> KindExpr -> ShowS
Show)

-- ---------------------------------------------------------------------------
-- Declarations (local or top-level)
-- ---------------------------------------------------------------------------

-- |Declaration in a module
data Decl a
  = InfixDecl        SpanInfo Infix (Maybe Precedence) [Ident]                   -- infixl 5 (op), `fun`
  | DataDecl         SpanInfo Ident [Ident] [ConstrDecl] [QualIdent]             -- data C a b = C1 a | C2 b deriving (D, ...)
  | ExternalDataDecl SpanInfo Ident [Ident]                                      -- external data C a b
  | NewtypeDecl      SpanInfo Ident [Ident] NewConstrDecl [QualIdent]            -- newtype C a b = C a b deriving (D, ...)
  | TypeDecl         SpanInfo Ident [Ident] TypeExpr                             -- type C a b = D a b
  | TypeSig          SpanInfo [Ident] QualTypeExpr                               -- f, g :: Bool
  | FunctionDecl     SpanInfo a Ident [Equation a]                               -- f True = 1 ; f False = 0
  | ExternalDecl     SpanInfo [Var a]                                            -- f, g external
  | PatternDecl      SpanInfo (Pattern a) (Rhs a)                                -- Just x = ...
  | FreeDecl         SpanInfo [Var a]                                            -- x, y free
  | DefaultDecl      SpanInfo [TypeExpr]                                         -- default (Int, Float)
  | ClassDecl        SpanInfo LayoutInfo Context Ident Ident [Decl a]            -- class C a => D a where {TypeSig|InfixDecl|FunctionDecl}
  | InstanceDecl     SpanInfo LayoutInfo Context QualIdent InstanceType [Decl a] -- instance C a => M.D (N.T a b c) where {FunctionDecl}
    deriving (Decl a -> Decl a -> Bool
(Decl a -> Decl a -> Bool)
-> (Decl a -> Decl a -> Bool) -> Eq (Decl a)
forall a. Eq a => Decl a -> Decl a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Decl a -> Decl a -> Bool
$c/= :: forall a. Eq a => Decl a -> Decl a -> Bool
== :: Decl a -> Decl a -> Bool
$c== :: forall a. Eq a => Decl a -> Decl a -> Bool
Eq, ReadPrec [Decl a]
ReadPrec (Decl a)
Int -> ReadS (Decl a)
ReadS [Decl a]
(Int -> ReadS (Decl a))
-> ReadS [Decl a]
-> ReadPrec (Decl a)
-> ReadPrec [Decl a]
-> Read (Decl a)
forall a. Read a => ReadPrec [Decl a]
forall a. Read a => ReadPrec (Decl a)
forall a. Read a => Int -> ReadS (Decl a)
forall a. Read a => ReadS [Decl a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Decl a]
$creadListPrec :: forall a. Read a => ReadPrec [Decl a]
readPrec :: ReadPrec (Decl a)
$creadPrec :: forall a. Read a => ReadPrec (Decl a)
readList :: ReadS [Decl a]
$creadList :: forall a. Read a => ReadS [Decl a]
readsPrec :: Int -> ReadS (Decl a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Decl a)
Read, Int -> Decl a -> ShowS
[Decl a] -> ShowS
Decl a -> String
(Int -> Decl a -> ShowS)
-> (Decl a -> String) -> ([Decl a] -> ShowS) -> Show (Decl a)
forall a. Show a => Int -> Decl a -> ShowS
forall a. Show a => [Decl a] -> ShowS
forall a. Show a => Decl a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Decl a] -> ShowS
$cshowList :: forall a. Show a => [Decl a] -> ShowS
show :: Decl a -> String
$cshow :: forall a. Show a => Decl a -> String
showsPrec :: Int -> Decl a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Decl a -> ShowS
Show)

-- ---------------------------------------------------------------------------
-- Infix declaration
-- ---------------------------------------------------------------------------

-- |Operator precedence
type Precedence = Integer

-- |Fixity of operators
data Infix
  = InfixL -- ^ left-associative
  | InfixR -- ^ right-associative
  | Infix  -- ^ no associativity
    deriving (Infix -> Infix -> Bool
(Infix -> Infix -> Bool) -> (Infix -> Infix -> Bool) -> Eq Infix
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Infix -> Infix -> Bool
$c/= :: Infix -> Infix -> Bool
== :: Infix -> Infix -> Bool
$c== :: Infix -> Infix -> Bool
Eq, ReadPrec [Infix]
ReadPrec Infix
Int -> ReadS Infix
ReadS [Infix]
(Int -> ReadS Infix)
-> ReadS [Infix]
-> ReadPrec Infix
-> ReadPrec [Infix]
-> Read Infix
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Infix]
$creadListPrec :: ReadPrec [Infix]
readPrec :: ReadPrec Infix
$creadPrec :: ReadPrec Infix
readList :: ReadS [Infix]
$creadList :: ReadS [Infix]
readsPrec :: Int -> ReadS Infix
$creadsPrec :: Int -> ReadS Infix
Read, Int -> Infix -> ShowS
[Infix] -> ShowS
Infix -> String
(Int -> Infix -> ShowS)
-> (Infix -> String) -> ([Infix] -> ShowS) -> Show Infix
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Infix] -> ShowS
$cshowList :: [Infix] -> ShowS
show :: Infix -> String
$cshow :: Infix -> String
showsPrec :: Int -> Infix -> ShowS
$cshowsPrec :: Int -> Infix -> ShowS
Show)

-- |Constructor declaration for algebraic data types
data ConstrDecl
  = ConstrDecl SpanInfo Ident [TypeExpr]
  | ConOpDecl  SpanInfo TypeExpr Ident TypeExpr
  | RecordDecl SpanInfo Ident [FieldDecl]
    deriving (ConstrDecl -> ConstrDecl -> Bool
(ConstrDecl -> ConstrDecl -> Bool)
-> (ConstrDecl -> ConstrDecl -> Bool) -> Eq ConstrDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConstrDecl -> ConstrDecl -> Bool
$c/= :: ConstrDecl -> ConstrDecl -> Bool
== :: ConstrDecl -> ConstrDecl -> Bool
$c== :: ConstrDecl -> ConstrDecl -> Bool
Eq, ReadPrec [ConstrDecl]
ReadPrec ConstrDecl
Int -> ReadS ConstrDecl
ReadS [ConstrDecl]
(Int -> ReadS ConstrDecl)
-> ReadS [ConstrDecl]
-> ReadPrec ConstrDecl
-> ReadPrec [ConstrDecl]
-> Read ConstrDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConstrDecl]
$creadListPrec :: ReadPrec [ConstrDecl]
readPrec :: ReadPrec ConstrDecl
$creadPrec :: ReadPrec ConstrDecl
readList :: ReadS [ConstrDecl]
$creadList :: ReadS [ConstrDecl]
readsPrec :: Int -> ReadS ConstrDecl
$creadsPrec :: Int -> ReadS ConstrDecl
Read, Int -> ConstrDecl -> ShowS
[ConstrDecl] -> ShowS
ConstrDecl -> String
(Int -> ConstrDecl -> ShowS)
-> (ConstrDecl -> String)
-> ([ConstrDecl] -> ShowS)
-> Show ConstrDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConstrDecl] -> ShowS
$cshowList :: [ConstrDecl] -> ShowS
show :: ConstrDecl -> String
$cshow :: ConstrDecl -> String
showsPrec :: Int -> ConstrDecl -> ShowS
$cshowsPrec :: Int -> ConstrDecl -> ShowS
Show)

-- |Constructor declaration for renaming types (newtypes)
data NewConstrDecl
  = NewConstrDecl SpanInfo Ident TypeExpr
  | NewRecordDecl SpanInfo Ident (Ident, TypeExpr)
   deriving (NewConstrDecl -> NewConstrDecl -> Bool
(NewConstrDecl -> NewConstrDecl -> Bool)
-> (NewConstrDecl -> NewConstrDecl -> Bool) -> Eq NewConstrDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NewConstrDecl -> NewConstrDecl -> Bool
$c/= :: NewConstrDecl -> NewConstrDecl -> Bool
== :: NewConstrDecl -> NewConstrDecl -> Bool
$c== :: NewConstrDecl -> NewConstrDecl -> Bool
Eq, ReadPrec [NewConstrDecl]
ReadPrec NewConstrDecl
Int -> ReadS NewConstrDecl
ReadS [NewConstrDecl]
(Int -> ReadS NewConstrDecl)
-> ReadS [NewConstrDecl]
-> ReadPrec NewConstrDecl
-> ReadPrec [NewConstrDecl]
-> Read NewConstrDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NewConstrDecl]
$creadListPrec :: ReadPrec [NewConstrDecl]
readPrec :: ReadPrec NewConstrDecl
$creadPrec :: ReadPrec NewConstrDecl
readList :: ReadS [NewConstrDecl]
$creadList :: ReadS [NewConstrDecl]
readsPrec :: Int -> ReadS NewConstrDecl
$creadsPrec :: Int -> ReadS NewConstrDecl
Read, Int -> NewConstrDecl -> ShowS
[NewConstrDecl] -> ShowS
NewConstrDecl -> String
(Int -> NewConstrDecl -> ShowS)
-> (NewConstrDecl -> String)
-> ([NewConstrDecl] -> ShowS)
-> Show NewConstrDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NewConstrDecl] -> ShowS
$cshowList :: [NewConstrDecl] -> ShowS
show :: NewConstrDecl -> String
$cshow :: NewConstrDecl -> String
showsPrec :: Int -> NewConstrDecl -> ShowS
$cshowsPrec :: Int -> NewConstrDecl -> ShowS
Show)

-- |Declaration for labelled fields
data FieldDecl = FieldDecl SpanInfo [Ident] TypeExpr
  deriving (FieldDecl -> FieldDecl -> Bool
(FieldDecl -> FieldDecl -> Bool)
-> (FieldDecl -> FieldDecl -> Bool) -> Eq FieldDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldDecl -> FieldDecl -> Bool
$c/= :: FieldDecl -> FieldDecl -> Bool
== :: FieldDecl -> FieldDecl -> Bool
$c== :: FieldDecl -> FieldDecl -> Bool
Eq, ReadPrec [FieldDecl]
ReadPrec FieldDecl
Int -> ReadS FieldDecl
ReadS [FieldDecl]
(Int -> ReadS FieldDecl)
-> ReadS [FieldDecl]
-> ReadPrec FieldDecl
-> ReadPrec [FieldDecl]
-> Read FieldDecl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldDecl]
$creadListPrec :: ReadPrec [FieldDecl]
readPrec :: ReadPrec FieldDecl
$creadPrec :: ReadPrec FieldDecl
readList :: ReadS [FieldDecl]
$creadList :: ReadS [FieldDecl]
readsPrec :: Int -> ReadS FieldDecl
$creadsPrec :: Int -> ReadS FieldDecl
Read, Int -> FieldDecl -> ShowS
[FieldDecl] -> ShowS
FieldDecl -> String
(Int -> FieldDecl -> ShowS)
-> (FieldDecl -> String)
-> ([FieldDecl] -> ShowS)
-> Show FieldDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldDecl] -> ShowS
$cshowList :: [FieldDecl] -> ShowS
show :: FieldDecl -> String
$cshow :: FieldDecl -> String
showsPrec :: Int -> FieldDecl -> ShowS
$cshowsPrec :: Int -> FieldDecl -> ShowS
Show)

-- |Type expressions
data TypeExpr
  = ConstructorType SpanInfo QualIdent
  | ApplyType       SpanInfo TypeExpr TypeExpr
  | VariableType    SpanInfo Ident
  | TupleType       SpanInfo [TypeExpr]
  | ListType        SpanInfo TypeExpr
  | ArrowType       SpanInfo TypeExpr TypeExpr
  | ParenType       SpanInfo TypeExpr
  | ForallType      SpanInfo [Ident] TypeExpr
    deriving (TypeExpr -> TypeExpr -> Bool
(TypeExpr -> TypeExpr -> Bool)
-> (TypeExpr -> TypeExpr -> Bool) -> Eq TypeExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypeExpr -> TypeExpr -> Bool
$c/= :: TypeExpr -> TypeExpr -> Bool
== :: TypeExpr -> TypeExpr -> Bool
$c== :: TypeExpr -> TypeExpr -> Bool
Eq, ReadPrec [TypeExpr]
ReadPrec TypeExpr
Int -> ReadS TypeExpr
ReadS [TypeExpr]
(Int -> ReadS TypeExpr)
-> ReadS [TypeExpr]
-> ReadPrec TypeExpr
-> ReadPrec [TypeExpr]
-> Read TypeExpr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TypeExpr]
$creadListPrec :: ReadPrec [TypeExpr]
readPrec :: ReadPrec TypeExpr
$creadPrec :: ReadPrec TypeExpr
readList :: ReadS [TypeExpr]
$creadList :: ReadS [TypeExpr]
readsPrec :: Int -> ReadS TypeExpr
$creadsPrec :: Int -> ReadS TypeExpr
Read, Int -> TypeExpr -> ShowS
[TypeExpr] -> ShowS
TypeExpr -> String
(Int -> TypeExpr -> ShowS)
-> (TypeExpr -> String) -> ([TypeExpr] -> ShowS) -> Show TypeExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TypeExpr] -> ShowS
$cshowList :: [TypeExpr] -> ShowS
show :: TypeExpr -> String
$cshow :: TypeExpr -> String
showsPrec :: Int -> TypeExpr -> ShowS
$cshowsPrec :: Int -> TypeExpr -> ShowS
Show)

-- |Qualified type expressions
data QualTypeExpr = QualTypeExpr SpanInfo Context TypeExpr
    deriving (QualTypeExpr -> QualTypeExpr -> Bool
(QualTypeExpr -> QualTypeExpr -> Bool)
-> (QualTypeExpr -> QualTypeExpr -> Bool) -> Eq QualTypeExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QualTypeExpr -> QualTypeExpr -> Bool
$c/= :: QualTypeExpr -> QualTypeExpr -> Bool
== :: QualTypeExpr -> QualTypeExpr -> Bool
$c== :: QualTypeExpr -> QualTypeExpr -> Bool
Eq, ReadPrec [QualTypeExpr]
ReadPrec QualTypeExpr
Int -> ReadS QualTypeExpr
ReadS [QualTypeExpr]
(Int -> ReadS QualTypeExpr)
-> ReadS [QualTypeExpr]
-> ReadPrec QualTypeExpr
-> ReadPrec [QualTypeExpr]
-> Read QualTypeExpr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QualTypeExpr]
$creadListPrec :: ReadPrec [QualTypeExpr]
readPrec :: ReadPrec QualTypeExpr
$creadPrec :: ReadPrec QualTypeExpr
readList :: ReadS [QualTypeExpr]
$creadList :: ReadS [QualTypeExpr]
readsPrec :: Int -> ReadS QualTypeExpr
$creadsPrec :: Int -> ReadS QualTypeExpr
Read, Int -> QualTypeExpr -> ShowS
[QualTypeExpr] -> ShowS
QualTypeExpr -> String
(Int -> QualTypeExpr -> ShowS)
-> (QualTypeExpr -> String)
-> ([QualTypeExpr] -> ShowS)
-> Show QualTypeExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QualTypeExpr] -> ShowS
$cshowList :: [QualTypeExpr] -> ShowS
show :: QualTypeExpr -> String
$cshow :: QualTypeExpr -> String
showsPrec :: Int -> QualTypeExpr -> ShowS
$cshowsPrec :: Int -> QualTypeExpr -> ShowS
Show)

-- ---------------------------------------------------------------------------
-- Type classes
-- ---------------------------------------------------------------------------

type Context = [Constraint]

data Constraint = Constraint SpanInfo QualIdent TypeExpr
    deriving (Constraint -> Constraint -> Bool
(Constraint -> Constraint -> Bool)
-> (Constraint -> Constraint -> Bool) -> Eq Constraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Constraint -> Constraint -> Bool
$c/= :: Constraint -> Constraint -> Bool
== :: Constraint -> Constraint -> Bool
$c== :: Constraint -> Constraint -> Bool
Eq, ReadPrec [Constraint]
ReadPrec Constraint
Int -> ReadS Constraint
ReadS [Constraint]
(Int -> ReadS Constraint)
-> ReadS [Constraint]
-> ReadPrec Constraint
-> ReadPrec [Constraint]
-> Read Constraint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Constraint]
$creadListPrec :: ReadPrec [Constraint]
readPrec :: ReadPrec Constraint
$creadPrec :: ReadPrec Constraint
readList :: ReadS [Constraint]
$creadList :: ReadS [Constraint]
readsPrec :: Int -> ReadS Constraint
$creadsPrec :: Int -> ReadS Constraint
Read, Int -> Constraint -> ShowS
[Constraint] -> ShowS
Constraint -> String
(Int -> Constraint -> ShowS)
-> (Constraint -> String)
-> ([Constraint] -> ShowS)
-> Show Constraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Constraint] -> ShowS
$cshowList :: [Constraint] -> ShowS
show :: Constraint -> String
$cshow :: Constraint -> String
showsPrec :: Int -> Constraint -> ShowS
$cshowsPrec :: Int -> Constraint -> ShowS
Show)

type InstanceType = TypeExpr

-- ---------------------------------------------------------------------------
-- Functions
-- ---------------------------------------------------------------------------

-- |Function defining equation
data Equation a = Equation SpanInfo (Lhs a) (Rhs a)
    deriving (Equation a -> Equation a -> Bool
(Equation a -> Equation a -> Bool)
-> (Equation a -> Equation a -> Bool) -> Eq (Equation a)
forall a. Eq a => Equation a -> Equation a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Equation a -> Equation a -> Bool
$c/= :: forall a. Eq a => Equation a -> Equation a -> Bool
== :: Equation a -> Equation a -> Bool
$c== :: forall a. Eq a => Equation a -> Equation a -> Bool
Eq, ReadPrec [Equation a]
ReadPrec (Equation a)
Int -> ReadS (Equation a)
ReadS [Equation a]
(Int -> ReadS (Equation a))
-> ReadS [Equation a]
-> ReadPrec (Equation a)
-> ReadPrec [Equation a]
-> Read (Equation a)
forall a. Read a => ReadPrec [Equation a]
forall a. Read a => ReadPrec (Equation a)
forall a. Read a => Int -> ReadS (Equation a)
forall a. Read a => ReadS [Equation a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Equation a]
$creadListPrec :: forall a. Read a => ReadPrec [Equation a]
readPrec :: ReadPrec (Equation a)
$creadPrec :: forall a. Read a => ReadPrec (Equation a)
readList :: ReadS [Equation a]
$creadList :: forall a. Read a => ReadS [Equation a]
readsPrec :: Int -> ReadS (Equation a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Equation a)
Read, Int -> Equation a -> ShowS
[Equation a] -> ShowS
Equation a -> String
(Int -> Equation a -> ShowS)
-> (Equation a -> String)
-> ([Equation a] -> ShowS)
-> Show (Equation a)
forall a. Show a => Int -> Equation a -> ShowS
forall a. Show a => [Equation a] -> ShowS
forall a. Show a => Equation a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Equation a] -> ShowS
$cshowList :: forall a. Show a => [Equation a] -> ShowS
show :: Equation a -> String
$cshow :: forall a. Show a => Equation a -> String
showsPrec :: Int -> Equation a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Equation a -> ShowS
Show)

-- |Left-hand-side of an 'Equation' (function identifier and patterns)
data Lhs a
  = FunLhs SpanInfo Ident [Pattern a]             -- f x y
  | OpLhs  SpanInfo (Pattern a) Ident (Pattern a) -- x $ y
  | ApLhs  SpanInfo (Lhs a) [Pattern a]           -- ($) x y
    deriving (Lhs a -> Lhs a -> Bool
(Lhs a -> Lhs a -> Bool) -> (Lhs a -> Lhs a -> Bool) -> Eq (Lhs a)
forall a. Eq a => Lhs a -> Lhs a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Lhs a -> Lhs a -> Bool
$c/= :: forall a. Eq a => Lhs a -> Lhs a -> Bool
== :: Lhs a -> Lhs a -> Bool
$c== :: forall a. Eq a => Lhs a -> Lhs a -> Bool
Eq, ReadPrec [Lhs a]
ReadPrec (Lhs a)
Int -> ReadS (Lhs a)
ReadS [Lhs a]
(Int -> ReadS (Lhs a))
-> ReadS [Lhs a]
-> ReadPrec (Lhs a)
-> ReadPrec [Lhs a]
-> Read (Lhs a)
forall a. Read a => ReadPrec [Lhs a]
forall a. Read a => ReadPrec (Lhs a)
forall a. Read a => Int -> ReadS (Lhs a)
forall a. Read a => ReadS [Lhs a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Lhs a]
$creadListPrec :: forall a. Read a => ReadPrec [Lhs a]
readPrec :: ReadPrec (Lhs a)
$creadPrec :: forall a. Read a => ReadPrec (Lhs a)
readList :: ReadS [Lhs a]
$creadList :: forall a. Read a => ReadS [Lhs a]
readsPrec :: Int -> ReadS (Lhs a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Lhs a)
Read, Int -> Lhs a -> ShowS
[Lhs a] -> ShowS
Lhs a -> String
(Int -> Lhs a -> ShowS)
-> (Lhs a -> String) -> ([Lhs a] -> ShowS) -> Show (Lhs a)
forall a. Show a => Int -> Lhs a -> ShowS
forall a. Show a => [Lhs a] -> ShowS
forall a. Show a => Lhs a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Lhs a] -> ShowS
$cshowList :: forall a. Show a => [Lhs a] -> ShowS
show :: Lhs a -> String
$cshow :: forall a. Show a => Lhs a -> String
showsPrec :: Int -> Lhs a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Lhs a -> ShowS
Show)

-- |Right-hand-side of an 'Equation'
data Rhs a
  = SimpleRhs  SpanInfo LayoutInfo (Expression a) [Decl a] -- @expr where decls@
  | GuardedRhs SpanInfo LayoutInfo [CondExpr a]   [Decl a] -- @| cond = expr where decls@
    deriving (Rhs a -> Rhs a -> Bool
(Rhs a -> Rhs a -> Bool) -> (Rhs a -> Rhs a -> Bool) -> Eq (Rhs a)
forall a. Eq a => Rhs a -> Rhs a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rhs a -> Rhs a -> Bool
$c/= :: forall a. Eq a => Rhs a -> Rhs a -> Bool
== :: Rhs a -> Rhs a -> Bool
$c== :: forall a. Eq a => Rhs a -> Rhs a -> Bool
Eq, ReadPrec [Rhs a]
ReadPrec (Rhs a)
Int -> ReadS (Rhs a)
ReadS [Rhs a]
(Int -> ReadS (Rhs a))
-> ReadS [Rhs a]
-> ReadPrec (Rhs a)
-> ReadPrec [Rhs a]
-> Read (Rhs a)
forall a. Read a => ReadPrec [Rhs a]
forall a. Read a => ReadPrec (Rhs a)
forall a. Read a => Int -> ReadS (Rhs a)
forall a. Read a => ReadS [Rhs a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rhs a]
$creadListPrec :: forall a. Read a => ReadPrec [Rhs a]
readPrec :: ReadPrec (Rhs a)
$creadPrec :: forall a. Read a => ReadPrec (Rhs a)
readList :: ReadS [Rhs a]
$creadList :: forall a. Read a => ReadS [Rhs a]
readsPrec :: Int -> ReadS (Rhs a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Rhs a)
Read, Int -> Rhs a -> ShowS
[Rhs a] -> ShowS
Rhs a -> String
(Int -> Rhs a -> ShowS)
-> (Rhs a -> String) -> ([Rhs a] -> ShowS) -> Show (Rhs a)
forall a. Show a => Int -> Rhs a -> ShowS
forall a. Show a => [Rhs a] -> ShowS
forall a. Show a => Rhs a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rhs a] -> ShowS
$cshowList :: forall a. Show a => [Rhs a] -> ShowS
show :: Rhs a -> String
$cshow :: forall a. Show a => Rhs a -> String
showsPrec :: Int -> Rhs a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Rhs a -> ShowS
Show)

-- |Conditional expression (expression conditioned by a guard)
data CondExpr a = CondExpr SpanInfo (Expression a) (Expression a)
    deriving (CondExpr a -> CondExpr a -> Bool
(CondExpr a -> CondExpr a -> Bool)
-> (CondExpr a -> CondExpr a -> Bool) -> Eq (CondExpr a)
forall a. Eq a => CondExpr a -> CondExpr a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CondExpr a -> CondExpr a -> Bool
$c/= :: forall a. Eq a => CondExpr a -> CondExpr a -> Bool
== :: CondExpr a -> CondExpr a -> Bool
$c== :: forall a. Eq a => CondExpr a -> CondExpr a -> Bool
Eq, ReadPrec [CondExpr a]
ReadPrec (CondExpr a)
Int -> ReadS (CondExpr a)
ReadS [CondExpr a]
(Int -> ReadS (CondExpr a))
-> ReadS [CondExpr a]
-> ReadPrec (CondExpr a)
-> ReadPrec [CondExpr a]
-> Read (CondExpr a)
forall a. Read a => ReadPrec [CondExpr a]
forall a. Read a => ReadPrec (CondExpr a)
forall a. Read a => Int -> ReadS (CondExpr a)
forall a. Read a => ReadS [CondExpr a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CondExpr a]
$creadListPrec :: forall a. Read a => ReadPrec [CondExpr a]
readPrec :: ReadPrec (CondExpr a)
$creadPrec :: forall a. Read a => ReadPrec (CondExpr a)
readList :: ReadS [CondExpr a]
$creadList :: forall a. Read a => ReadS [CondExpr a]
readsPrec :: Int -> ReadS (CondExpr a)
$creadsPrec :: forall a. Read a => Int -> ReadS (CondExpr a)
Read, Int -> CondExpr a -> ShowS
[CondExpr a] -> ShowS
CondExpr a -> String
(Int -> CondExpr a -> ShowS)
-> (CondExpr a -> String)
-> ([CondExpr a] -> ShowS)
-> Show (CondExpr a)
forall a. Show a => Int -> CondExpr a -> ShowS
forall a. Show a => [CondExpr a] -> ShowS
forall a. Show a => CondExpr a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CondExpr a] -> ShowS
$cshowList :: forall a. Show a => [CondExpr a] -> ShowS
show :: CondExpr a -> String
$cshow :: forall a. Show a => CondExpr a -> String
showsPrec :: Int -> CondExpr a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> CondExpr a -> ShowS
Show)

-- |Literal
data Literal
  = Char   Char
  | Int    Integer
  | Float  Double
  | String String
    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, ReadPrec [Literal]
ReadPrec Literal
Int -> ReadS Literal
ReadS [Literal]
(Int -> ReadS Literal)
-> ReadS [Literal]
-> ReadPrec Literal
-> ReadPrec [Literal]
-> Read Literal
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Literal]
$creadListPrec :: ReadPrec [Literal]
readPrec :: ReadPrec Literal
$creadPrec :: ReadPrec Literal
readList :: ReadS [Literal]
$creadList :: ReadS [Literal]
readsPrec :: Int -> ReadS Literal
$creadsPrec :: Int -> ReadS Literal
Read, 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)

-- |Constructor term (used for patterns)
data Pattern a
  = LiteralPattern     SpanInfo a Literal
  | NegativePattern    SpanInfo a Literal
  | VariablePattern    SpanInfo a Ident
  | ConstructorPattern SpanInfo a QualIdent [Pattern a]
  | InfixPattern       SpanInfo a (Pattern a) QualIdent (Pattern a)
  | ParenPattern       SpanInfo (Pattern a)
  | RecordPattern      SpanInfo a QualIdent [Field (Pattern a)] -- C { l1 = p1, ..., ln = pn }
  | TuplePattern       SpanInfo [Pattern a]
  | ListPattern        SpanInfo a [Pattern a]
  | AsPattern          SpanInfo Ident (Pattern a)
  | LazyPattern        SpanInfo (Pattern a)
  | FunctionPattern    SpanInfo a QualIdent [Pattern a]
  | InfixFuncPattern   SpanInfo a (Pattern a) QualIdent (Pattern a)
    deriving (Pattern a -> Pattern a -> Bool
(Pattern a -> Pattern a -> Bool)
-> (Pattern a -> Pattern a -> Bool) -> Eq (Pattern a)
forall a. Eq a => Pattern a -> Pattern a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pattern a -> Pattern a -> Bool
$c/= :: forall a. Eq a => Pattern a -> Pattern a -> Bool
== :: Pattern a -> Pattern a -> Bool
$c== :: forall a. Eq a => Pattern a -> Pattern a -> Bool
Eq, ReadPrec [Pattern a]
ReadPrec (Pattern a)
Int -> ReadS (Pattern a)
ReadS [Pattern a]
(Int -> ReadS (Pattern a))
-> ReadS [Pattern a]
-> ReadPrec (Pattern a)
-> ReadPrec [Pattern a]
-> Read (Pattern a)
forall a. Read a => ReadPrec [Pattern a]
forall a. Read a => ReadPrec (Pattern a)
forall a. Read a => Int -> ReadS (Pattern a)
forall a. Read a => ReadS [Pattern a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Pattern a]
$creadListPrec :: forall a. Read a => ReadPrec [Pattern a]
readPrec :: ReadPrec (Pattern a)
$creadPrec :: forall a. Read a => ReadPrec (Pattern a)
readList :: ReadS [Pattern a]
$creadList :: forall a. Read a => ReadS [Pattern a]
readsPrec :: Int -> ReadS (Pattern a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Pattern a)
Read, Int -> Pattern a -> ShowS
[Pattern a] -> ShowS
Pattern a -> String
(Int -> Pattern a -> ShowS)
-> (Pattern a -> String)
-> ([Pattern a] -> ShowS)
-> Show (Pattern a)
forall a. Show a => Int -> Pattern a -> ShowS
forall a. Show a => [Pattern a] -> ShowS
forall a. Show a => Pattern a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Pattern a] -> ShowS
$cshowList :: forall a. Show a => [Pattern a] -> ShowS
show :: Pattern a -> String
$cshow :: forall a. Show a => Pattern a -> String
showsPrec :: Int -> Pattern a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Pattern a -> ShowS
Show)

-- |Expression
data Expression a
  = Literal           SpanInfo a Literal
  | Variable          SpanInfo a QualIdent
  | Constructor       SpanInfo a QualIdent
  | Paren             SpanInfo (Expression a)
  | Typed             SpanInfo (Expression a) QualTypeExpr
  | Record            SpanInfo a QualIdent [Field (Expression a)]    -- C {l1 = e1,..., ln = en}
  | RecordUpdate      SpanInfo (Expression a) [Field (Expression a)] -- e {l1 = e1,..., ln = en}
  | Tuple             SpanInfo [Expression a]
  | List              SpanInfo a [Expression a]
  | ListCompr         SpanInfo (Expression a) [Statement a]   -- the ref corresponds to the main list
  | EnumFrom          SpanInfo (Expression a)
  | EnumFromThen      SpanInfo (Expression a) (Expression a)
  | EnumFromTo        SpanInfo (Expression a) (Expression a)
  | EnumFromThenTo    SpanInfo (Expression a) (Expression a) (Expression a)
  | UnaryMinus        SpanInfo (Expression a)
  | Apply             SpanInfo (Expression a) (Expression a)
  | InfixApply        SpanInfo (Expression a) (InfixOp a) (Expression a)
  | LeftSection       SpanInfo (Expression a) (InfixOp a)
  | RightSection      SpanInfo (InfixOp a) (Expression a)
  | Lambda            SpanInfo [Pattern a] (Expression a)
  | Let               SpanInfo LayoutInfo [Decl a] (Expression a)
  | Do                SpanInfo LayoutInfo [Statement a] (Expression a)
  | IfThenElse        SpanInfo (Expression a) (Expression a) (Expression a)
  | Case              SpanInfo LayoutInfo CaseType (Expression a) [Alt a]
    deriving (Expression a -> Expression a -> Bool
(Expression a -> Expression a -> Bool)
-> (Expression a -> Expression a -> Bool) -> Eq (Expression a)
forall a. Eq a => Expression a -> Expression a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Expression a -> Expression a -> Bool
$c/= :: forall a. Eq a => Expression a -> Expression a -> Bool
== :: Expression a -> Expression a -> Bool
$c== :: forall a. Eq a => Expression a -> Expression a -> Bool
Eq, ReadPrec [Expression a]
ReadPrec (Expression a)
Int -> ReadS (Expression a)
ReadS [Expression a]
(Int -> ReadS (Expression a))
-> ReadS [Expression a]
-> ReadPrec (Expression a)
-> ReadPrec [Expression a]
-> Read (Expression a)
forall a. Read a => ReadPrec [Expression a]
forall a. Read a => ReadPrec (Expression a)
forall a. Read a => Int -> ReadS (Expression a)
forall a. Read a => ReadS [Expression a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Expression a]
$creadListPrec :: forall a. Read a => ReadPrec [Expression a]
readPrec :: ReadPrec (Expression a)
$creadPrec :: forall a. Read a => ReadPrec (Expression a)
readList :: ReadS [Expression a]
$creadList :: forall a. Read a => ReadS [Expression a]
readsPrec :: Int -> ReadS (Expression a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Expression a)
Read, Int -> Expression a -> ShowS
[Expression a] -> ShowS
Expression a -> String
(Int -> Expression a -> ShowS)
-> (Expression a -> String)
-> ([Expression a] -> ShowS)
-> Show (Expression a)
forall a. Show a => Int -> Expression a -> ShowS
forall a. Show a => [Expression a] -> ShowS
forall a. Show a => Expression a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Expression a] -> ShowS
$cshowList :: forall a. Show a => [Expression a] -> ShowS
show :: Expression a -> String
$cshow :: forall a. Show a => Expression a -> String
showsPrec :: Int -> Expression a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Expression a -> ShowS
Show)

-- |Infix operation
data InfixOp a
  = InfixOp     a QualIdent
  | InfixConstr a QualIdent
    deriving (InfixOp a -> InfixOp a -> Bool
(InfixOp a -> InfixOp a -> Bool)
-> (InfixOp a -> InfixOp a -> Bool) -> Eq (InfixOp a)
forall a. Eq a => InfixOp a -> InfixOp a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InfixOp a -> InfixOp a -> Bool
$c/= :: forall a. Eq a => InfixOp a -> InfixOp a -> Bool
== :: InfixOp a -> InfixOp a -> Bool
$c== :: forall a. Eq a => InfixOp a -> InfixOp a -> Bool
Eq, ReadPrec [InfixOp a]
ReadPrec (InfixOp a)
Int -> ReadS (InfixOp a)
ReadS [InfixOp a]
(Int -> ReadS (InfixOp a))
-> ReadS [InfixOp a]
-> ReadPrec (InfixOp a)
-> ReadPrec [InfixOp a]
-> Read (InfixOp a)
forall a. Read a => ReadPrec [InfixOp a]
forall a. Read a => ReadPrec (InfixOp a)
forall a. Read a => Int -> ReadS (InfixOp a)
forall a. Read a => ReadS [InfixOp a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InfixOp a]
$creadListPrec :: forall a. Read a => ReadPrec [InfixOp a]
readPrec :: ReadPrec (InfixOp a)
$creadPrec :: forall a. Read a => ReadPrec (InfixOp a)
readList :: ReadS [InfixOp a]
$creadList :: forall a. Read a => ReadS [InfixOp a]
readsPrec :: Int -> ReadS (InfixOp a)
$creadsPrec :: forall a. Read a => Int -> ReadS (InfixOp a)
Read, Int -> InfixOp a -> ShowS
[InfixOp a] -> ShowS
InfixOp a -> String
(Int -> InfixOp a -> ShowS)
-> (InfixOp a -> String)
-> ([InfixOp a] -> ShowS)
-> Show (InfixOp a)
forall a. Show a => Int -> InfixOp a -> ShowS
forall a. Show a => [InfixOp a] -> ShowS
forall a. Show a => InfixOp a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InfixOp a] -> ShowS
$cshowList :: forall a. Show a => [InfixOp a] -> ShowS
show :: InfixOp a -> String
$cshow :: forall a. Show a => InfixOp a -> String
showsPrec :: Int -> InfixOp a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> InfixOp a -> ShowS
Show)

-- |Statement (used for do-sequence and list comprehensions)
data Statement a
  = StmtExpr SpanInfo (Expression a)
  | StmtDecl SpanInfo LayoutInfo [Decl a]
  | StmtBind SpanInfo (Pattern a) (Expression a)
    deriving (Statement a -> Statement a -> Bool
(Statement a -> Statement a -> Bool)
-> (Statement a -> Statement a -> Bool) -> Eq (Statement a)
forall a. Eq a => Statement a -> Statement a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Statement a -> Statement a -> Bool
$c/= :: forall a. Eq a => Statement a -> Statement a -> Bool
== :: Statement a -> Statement a -> Bool
$c== :: forall a. Eq a => Statement a -> Statement a -> Bool
Eq, ReadPrec [Statement a]
ReadPrec (Statement a)
Int -> ReadS (Statement a)
ReadS [Statement a]
(Int -> ReadS (Statement a))
-> ReadS [Statement a]
-> ReadPrec (Statement a)
-> ReadPrec [Statement a]
-> Read (Statement a)
forall a. Read a => ReadPrec [Statement a]
forall a. Read a => ReadPrec (Statement a)
forall a. Read a => Int -> ReadS (Statement a)
forall a. Read a => ReadS [Statement a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Statement a]
$creadListPrec :: forall a. Read a => ReadPrec [Statement a]
readPrec :: ReadPrec (Statement a)
$creadPrec :: forall a. Read a => ReadPrec (Statement a)
readList :: ReadS [Statement a]
$creadList :: forall a. Read a => ReadS [Statement a]
readsPrec :: Int -> ReadS (Statement a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Statement a)
Read, Int -> Statement a -> ShowS
[Statement a] -> ShowS
Statement a -> String
(Int -> Statement a -> ShowS)
-> (Statement a -> String)
-> ([Statement a] -> ShowS)
-> Show (Statement a)
forall a. Show a => Int -> Statement a -> ShowS
forall a. Show a => [Statement a] -> ShowS
forall a. Show a => Statement a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Statement a] -> ShowS
$cshowList :: forall a. Show a => [Statement a] -> ShowS
show :: Statement a -> String
$cshow :: forall a. Show a => Statement a -> String
showsPrec :: Int -> Statement a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Statement a -> ShowS
Show)

-- |Type of case expressions
data CaseType
  = Rigid
  | Flex
    deriving (CaseType -> CaseType -> Bool
(CaseType -> CaseType -> Bool)
-> (CaseType -> CaseType -> Bool) -> Eq CaseType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaseType -> CaseType -> Bool
$c/= :: CaseType -> CaseType -> Bool
== :: CaseType -> CaseType -> Bool
$c== :: CaseType -> CaseType -> Bool
Eq, ReadPrec [CaseType]
ReadPrec CaseType
Int -> ReadS CaseType
ReadS [CaseType]
(Int -> ReadS CaseType)
-> ReadS [CaseType]
-> ReadPrec CaseType
-> ReadPrec [CaseType]
-> Read CaseType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaseType]
$creadListPrec :: ReadPrec [CaseType]
readPrec :: ReadPrec CaseType
$creadPrec :: ReadPrec CaseType
readList :: ReadS [CaseType]
$creadList :: ReadS [CaseType]
readsPrec :: Int -> ReadS CaseType
$creadsPrec :: Int -> ReadS CaseType
Read, Int -> CaseType -> ShowS
[CaseType] -> ShowS
CaseType -> String
(Int -> CaseType -> ShowS)
-> (CaseType -> String) -> ([CaseType] -> ShowS) -> Show CaseType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaseType] -> ShowS
$cshowList :: [CaseType] -> ShowS
show :: CaseType -> String
$cshow :: CaseType -> String
showsPrec :: Int -> CaseType -> ShowS
$cshowsPrec :: Int -> CaseType -> ShowS
Show)

-- |Single case alternative
data Alt a = Alt SpanInfo (Pattern a) (Rhs a)
    deriving (Alt a -> Alt a -> Bool
(Alt a -> Alt a -> Bool) -> (Alt a -> Alt a -> Bool) -> Eq (Alt a)
forall a. Eq a => Alt a -> Alt a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Alt a -> Alt a -> Bool
$c/= :: forall a. Eq a => Alt a -> Alt a -> Bool
== :: Alt a -> Alt a -> Bool
$c== :: forall a. Eq a => Alt a -> Alt a -> Bool
Eq, ReadPrec [Alt a]
ReadPrec (Alt a)
Int -> ReadS (Alt a)
ReadS [Alt a]
(Int -> ReadS (Alt a))
-> ReadS [Alt a]
-> ReadPrec (Alt a)
-> ReadPrec [Alt a]
-> Read (Alt a)
forall a. Read a => ReadPrec [Alt a]
forall a. Read a => ReadPrec (Alt a)
forall a. Read a => Int -> ReadS (Alt a)
forall a. Read a => ReadS [Alt a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Alt a]
$creadListPrec :: forall a. Read a => ReadPrec [Alt a]
readPrec :: ReadPrec (Alt a)
$creadPrec :: forall a. Read a => ReadPrec (Alt a)
readList :: ReadS [Alt a]
$creadList :: forall a. Read a => ReadS [Alt a]
readsPrec :: Int -> ReadS (Alt a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Alt a)
Read, Int -> Alt a -> ShowS
[Alt a] -> ShowS
Alt a -> String
(Int -> Alt a -> ShowS)
-> (Alt a -> String) -> ([Alt a] -> ShowS) -> Show (Alt a)
forall a. Show a => Int -> Alt a -> ShowS
forall a. Show a => [Alt a] -> ShowS
forall a. Show a => Alt a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Alt a] -> ShowS
$cshowList :: forall a. Show a => [Alt a] -> ShowS
show :: Alt a -> String
$cshow :: forall a. Show a => Alt a -> String
showsPrec :: Int -> Alt a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Alt a -> ShowS
Show)

-- |Record field
data Field a = Field SpanInfo QualIdent a
    deriving (Field a -> Field a -> Bool
(Field a -> Field a -> Bool)
-> (Field a -> Field a -> Bool) -> Eq (Field a)
forall a. Eq a => Field a -> Field a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Field a -> Field a -> Bool
$c/= :: forall a. Eq a => Field a -> Field a -> Bool
== :: Field a -> Field a -> Bool
$c== :: forall a. Eq a => Field a -> Field a -> Bool
Eq, ReadPrec [Field a]
ReadPrec (Field a)
Int -> ReadS (Field a)
ReadS [Field a]
(Int -> ReadS (Field a))
-> ReadS [Field a]
-> ReadPrec (Field a)
-> ReadPrec [Field a]
-> Read (Field a)
forall a. Read a => ReadPrec [Field a]
forall a. Read a => ReadPrec (Field a)
forall a. Read a => Int -> ReadS (Field a)
forall a. Read a => ReadS [Field a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Field a]
$creadListPrec :: forall a. Read a => ReadPrec [Field a]
readPrec :: ReadPrec (Field a)
$creadPrec :: forall a. Read a => ReadPrec (Field a)
readList :: ReadS [Field a]
$creadList :: forall a. Read a => ReadS [Field a]
readsPrec :: Int -> ReadS (Field a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Field a)
Read, Int -> Field a -> ShowS
[Field a] -> ShowS
Field a -> String
(Int -> Field a -> ShowS)
-> (Field a -> String) -> ([Field a] -> ShowS) -> Show (Field a)
forall a. Show a => Int -> Field a -> ShowS
forall a. Show a => [Field a] -> ShowS
forall a. Show a => Field a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Field a] -> ShowS
$cshowList :: forall a. Show a => [Field a] -> ShowS
show :: Field a -> String
$cshow :: forall a. Show a => Field a -> String
showsPrec :: Int -> Field a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Field a -> ShowS
Show)

-- |Annotated identifier
data Var a = Var a Ident
    deriving (Var a -> Var a -> Bool
(Var a -> Var a -> Bool) -> (Var a -> Var a -> Bool) -> Eq (Var a)
forall a. Eq a => Var a -> Var a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Var a -> Var a -> Bool
$c/= :: forall a. Eq a => Var a -> Var a -> Bool
== :: Var a -> Var a -> Bool
$c== :: forall a. Eq a => Var a -> Var a -> Bool
Eq, ReadPrec [Var a]
ReadPrec (Var a)
Int -> ReadS (Var a)
ReadS [Var a]
(Int -> ReadS (Var a))
-> ReadS [Var a]
-> ReadPrec (Var a)
-> ReadPrec [Var a]
-> Read (Var a)
forall a. Read a => ReadPrec [Var a]
forall a. Read a => ReadPrec (Var a)
forall a. Read a => Int -> ReadS (Var a)
forall a. Read a => ReadS [Var a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Var a]
$creadListPrec :: forall a. Read a => ReadPrec [Var a]
readPrec :: ReadPrec (Var a)
$creadPrec :: forall a. Read a => ReadPrec (Var a)
readList :: ReadS [Var a]
$creadList :: forall a. Read a => ReadS [Var a]
readsPrec :: Int -> ReadS (Var a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Var a)
Read, Int -> Var a -> ShowS
[Var a] -> ShowS
Var a -> String
(Int -> Var a -> ShowS)
-> (Var a -> String) -> ([Var a] -> ShowS) -> Show (Var a)
forall a. Show a => Int -> Var a -> ShowS
forall a. Show a => [Var a] -> ShowS
forall a. Show a => Var a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Var a] -> ShowS
$cshowList :: forall a. Show a => [Var a] -> ShowS
show :: Var a -> String
$cshow :: forall a. Show a => Var a -> String
showsPrec :: Int -> Var a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Var a -> ShowS
Show)

-- ---------------------------------------------------------------------------
-- Goals
-- ---------------------------------------------------------------------------

-- |Goal in REPL (expression to evaluate)
data Goal a = Goal SpanInfo LayoutInfo (Expression a) [Decl a]
    deriving (Goal a -> Goal a -> Bool
(Goal a -> Goal a -> Bool)
-> (Goal a -> Goal a -> Bool) -> Eq (Goal a)
forall a. Eq a => Goal a -> Goal a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Goal a -> Goal a -> Bool
$c/= :: forall a. Eq a => Goal a -> Goal a -> Bool
== :: Goal a -> Goal a -> Bool
$c== :: forall a. Eq a => Goal a -> Goal a -> Bool
Eq, ReadPrec [Goal a]
ReadPrec (Goal a)
Int -> ReadS (Goal a)
ReadS [Goal a]
(Int -> ReadS (Goal a))
-> ReadS [Goal a]
-> ReadPrec (Goal a)
-> ReadPrec [Goal a]
-> Read (Goal a)
forall a. Read a => ReadPrec [Goal a]
forall a. Read a => ReadPrec (Goal a)
forall a. Read a => Int -> ReadS (Goal a)
forall a. Read a => ReadS [Goal a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Goal a]
$creadListPrec :: forall a. Read a => ReadPrec [Goal a]
readPrec :: ReadPrec (Goal a)
$creadPrec :: forall a. Read a => ReadPrec (Goal a)
readList :: ReadS [Goal a]
$creadList :: forall a. Read a => ReadS [Goal a]
readsPrec :: Int -> ReadS (Goal a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Goal a)
Read, Int -> Goal a -> ShowS
[Goal a] -> ShowS
Goal a -> String
(Int -> Goal a -> ShowS)
-> (Goal a -> String) -> ([Goal a] -> ShowS) -> Show (Goal a)
forall a. Show a => Int -> Goal a -> ShowS
forall a. Show a => [Goal a] -> ShowS
forall a. Show a => Goal a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Goal a] -> ShowS
$cshowList :: forall a. Show a => [Goal a] -> ShowS
show :: Goal a -> String
$cshow :: forall a. Show a => Goal a -> String
showsPrec :: Int -> Goal a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Goal a -> ShowS
Show)

-- ---------------------------------------------------------------------------
-- instances
-- ---------------------------------------------------------------------------

instance Functor Module where
  fmap :: (a -> b) -> Module a -> Module b
fmap f :: a -> b
f (Module sp :: SpanInfo
sp li :: LayoutInfo
li ps :: [ModulePragma]
ps m :: ModuleIdent
m es :: Maybe ExportSpec
es is :: [ImportDecl]
is ds :: [Decl a]
ds) = SpanInfo
-> LayoutInfo
-> [ModulePragma]
-> ModuleIdent
-> Maybe ExportSpec
-> [ImportDecl]
-> [Decl b]
-> Module b
forall a.
SpanInfo
-> LayoutInfo
-> [ModulePragma]
-> ModuleIdent
-> Maybe ExportSpec
-> [ImportDecl]
-> [Decl a]
-> Module a
Module SpanInfo
sp LayoutInfo
li [ModulePragma]
ps ModuleIdent
m Maybe ExportSpec
es [ImportDecl]
is ((Decl a -> Decl b) -> [Decl a] -> [Decl b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Decl a -> Decl b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Decl a]
ds)

instance Functor Decl where
  fmap :: (a -> b) -> Decl a -> Decl b
fmap _ (InfixDecl sp :: SpanInfo
sp fix :: Infix
fix prec :: Maybe Precedence
prec ops :: [Ident]
ops) = SpanInfo -> Infix -> Maybe Precedence -> [Ident] -> Decl b
forall a.
SpanInfo -> Infix -> Maybe Precedence -> [Ident] -> Decl a
InfixDecl SpanInfo
sp Infix
fix Maybe Precedence
prec [Ident]
ops
  fmap _ (DataDecl sp :: SpanInfo
sp tc :: Ident
tc tvs :: [Ident]
tvs cs :: [ConstrDecl]
cs clss :: [QualIdent]
clss) = SpanInfo
-> Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl b
forall a.
SpanInfo
-> Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a
DataDecl SpanInfo
sp Ident
tc [Ident]
tvs [ConstrDecl]
cs [QualIdent]
clss
  fmap _ (ExternalDataDecl sp :: SpanInfo
sp tc :: Ident
tc tvs :: [Ident]
tvs) = SpanInfo -> Ident -> [Ident] -> Decl b
forall a. SpanInfo -> Ident -> [Ident] -> Decl a
ExternalDataDecl SpanInfo
sp Ident
tc [Ident]
tvs
  fmap _ (NewtypeDecl sp :: SpanInfo
sp tc :: Ident
tc tvs :: [Ident]
tvs nc :: NewConstrDecl
nc clss :: [QualIdent]
clss) = SpanInfo
-> Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl b
forall a.
SpanInfo
-> Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a
NewtypeDecl SpanInfo
sp Ident
tc [Ident]
tvs NewConstrDecl
nc [QualIdent]
clss
  fmap _ (TypeDecl sp :: SpanInfo
sp tc :: Ident
tc tvs :: [Ident]
tvs ty :: TypeExpr
ty) = SpanInfo -> Ident -> [Ident] -> TypeExpr -> Decl b
forall a. SpanInfo -> Ident -> [Ident] -> TypeExpr -> Decl a
TypeDecl SpanInfo
sp Ident
tc [Ident]
tvs TypeExpr
ty
  fmap _ (TypeSig sp :: SpanInfo
sp fs :: [Ident]
fs qty :: QualTypeExpr
qty) = SpanInfo -> [Ident] -> QualTypeExpr -> Decl b
forall a. SpanInfo -> [Ident] -> QualTypeExpr -> Decl a
TypeSig SpanInfo
sp [Ident]
fs QualTypeExpr
qty
  fmap f :: a -> b
f (FunctionDecl sp :: SpanInfo
sp a :: a
a f' :: Ident
f' eqs :: [Equation a]
eqs) = SpanInfo -> b -> Ident -> [Equation b] -> Decl b
forall a. SpanInfo -> a -> Ident -> [Equation a] -> Decl a
FunctionDecl SpanInfo
sp (a -> b
f a
a) Ident
f' ((Equation a -> Equation b) -> [Equation a] -> [Equation b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Equation a -> Equation b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Equation a]
eqs)
  fmap f :: a -> b
f (ExternalDecl sp :: SpanInfo
sp vs :: [Var a]
vs) = SpanInfo -> [Var b] -> Decl b
forall a. SpanInfo -> [Var a] -> Decl a
ExternalDecl SpanInfo
sp ((Var a -> Var b) -> [Var a] -> [Var b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Var a -> Var b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Var a]
vs)
  fmap f :: a -> b
f (PatternDecl sp :: SpanInfo
sp t :: Pattern a
t rhs :: Rhs a
rhs) = SpanInfo -> Pattern b -> Rhs b -> Decl b
forall a. SpanInfo -> Pattern a -> Rhs a -> Decl a
PatternDecl SpanInfo
sp ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t) ((a -> b) -> Rhs a -> Rhs b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Rhs a
rhs)
  fmap f :: a -> b
f (FreeDecl sp :: SpanInfo
sp vs :: [Var a]
vs) = SpanInfo -> [Var b] -> Decl b
forall a. SpanInfo -> [Var a] -> Decl a
FreeDecl SpanInfo
sp ((Var a -> Var b) -> [Var a] -> [Var b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Var a -> Var b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Var a]
vs)
  fmap _ (DefaultDecl sp :: SpanInfo
sp tys :: [TypeExpr]
tys) = SpanInfo -> [TypeExpr] -> Decl b
forall a. SpanInfo -> [TypeExpr] -> Decl a
DefaultDecl SpanInfo
sp [TypeExpr]
tys
  fmap f :: a -> b
f (ClassDecl sp :: SpanInfo
sp li :: LayoutInfo
li cx :: [Constraint]
cx cls :: Ident
cls clsvar :: Ident
clsvar ds :: [Decl a]
ds) =
    SpanInfo
-> LayoutInfo
-> [Constraint]
-> Ident
-> Ident
-> [Decl b]
-> Decl b
forall a.
SpanInfo
-> LayoutInfo
-> [Constraint]
-> Ident
-> Ident
-> [Decl a]
-> Decl a
ClassDecl SpanInfo
sp LayoutInfo
li [Constraint]
cx Ident
cls Ident
clsvar ((Decl a -> Decl b) -> [Decl a] -> [Decl b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Decl a -> Decl b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Decl a]
ds)
  fmap f :: a -> b
f (InstanceDecl sp :: SpanInfo
sp li :: LayoutInfo
li cx :: [Constraint]
cx qcls :: QualIdent
qcls inst :: TypeExpr
inst ds :: [Decl a]
ds) =
    SpanInfo
-> LayoutInfo
-> [Constraint]
-> QualIdent
-> TypeExpr
-> [Decl b]
-> Decl b
forall a.
SpanInfo
-> LayoutInfo
-> [Constraint]
-> QualIdent
-> TypeExpr
-> [Decl a]
-> Decl a
InstanceDecl SpanInfo
sp LayoutInfo
li [Constraint]
cx QualIdent
qcls TypeExpr
inst ((Decl a -> Decl b) -> [Decl a] -> [Decl b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Decl a -> Decl b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Decl a]
ds)

instance Functor Equation where
  fmap :: (a -> b) -> Equation a -> Equation b
fmap f :: a -> b
f (Equation p :: SpanInfo
p lhs :: Lhs a
lhs rhs :: Rhs a
rhs) = SpanInfo -> Lhs b -> Rhs b -> Equation b
forall a. SpanInfo -> Lhs a -> Rhs a -> Equation a
Equation SpanInfo
p ((a -> b) -> Lhs a -> Lhs b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Lhs a
lhs) ((a -> b) -> Rhs a -> Rhs b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Rhs a
rhs)

instance Functor Lhs where
  fmap :: (a -> b) -> Lhs a -> Lhs b
fmap f :: a -> b
f (FunLhs p :: SpanInfo
p f' :: Ident
f' ts :: [Pattern a]
ts) = SpanInfo -> Ident -> [Pattern b] -> Lhs b
forall a. SpanInfo -> Ident -> [Pattern a] -> Lhs a
FunLhs SpanInfo
p Ident
f' ((Pattern a -> Pattern b) -> [Pattern a] -> [Pattern b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Pattern a]
ts)
  fmap f :: a -> b
f (OpLhs p :: SpanInfo
p t1 :: Pattern a
t1 op :: Ident
op t2 :: Pattern a
t2) = SpanInfo -> Pattern b -> Ident -> Pattern b -> Lhs b
forall a. SpanInfo -> Pattern a -> Ident -> Pattern a -> Lhs a
OpLhs SpanInfo
p ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t1) Ident
op ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t2)
  fmap f :: a -> b
f (ApLhs p :: SpanInfo
p lhs :: Lhs a
lhs ts :: [Pattern a]
ts) = SpanInfo -> Lhs b -> [Pattern b] -> Lhs b
forall a. SpanInfo -> Lhs a -> [Pattern a] -> Lhs a
ApLhs SpanInfo
p ((a -> b) -> Lhs a -> Lhs b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Lhs a
lhs) ((Pattern a -> Pattern b) -> [Pattern a] -> [Pattern b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Pattern a]
ts)

instance Functor Rhs where
  fmap :: (a -> b) -> Rhs a -> Rhs b
fmap f :: a -> b
f (SimpleRhs p :: SpanInfo
p li :: LayoutInfo
li e :: Expression a
e ds :: [Decl a]
ds) = SpanInfo -> LayoutInfo -> Expression b -> [Decl b] -> Rhs b
forall a.
SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Rhs a
SimpleRhs SpanInfo
p LayoutInfo
li ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e) ((Decl a -> Decl b) -> [Decl a] -> [Decl b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Decl a -> Decl b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Decl a]
ds)
  fmap f :: a -> b
f (GuardedRhs p :: SpanInfo
p li :: LayoutInfo
li cs :: [CondExpr a]
cs ds :: [Decl a]
ds) = SpanInfo -> LayoutInfo -> [CondExpr b] -> [Decl b] -> Rhs b
forall a.
SpanInfo -> LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a
GuardedRhs SpanInfo
p LayoutInfo
li ((CondExpr a -> CondExpr b) -> [CondExpr a] -> [CondExpr b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> CondExpr a -> CondExpr b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [CondExpr a]
cs) ((Decl a -> Decl b) -> [Decl a] -> [Decl b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Decl a -> Decl b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Decl a]
ds)

instance Functor CondExpr where
  fmap :: (a -> b) -> CondExpr a -> CondExpr b
fmap f :: a -> b
f (CondExpr p :: SpanInfo
p g :: Expression a
g e :: Expression a
e) = SpanInfo -> Expression b -> Expression b -> CondExpr b
forall a. SpanInfo -> Expression a -> Expression a -> CondExpr a
CondExpr SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
g) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)

instance Functor Pattern where
  fmap :: (a -> b) -> Pattern a -> Pattern b
fmap f :: a -> b
f (LiteralPattern p :: SpanInfo
p a :: a
a l :: Literal
l) = SpanInfo -> b -> Literal -> Pattern b
forall a. SpanInfo -> a -> Literal -> Pattern a
LiteralPattern SpanInfo
p (a -> b
f a
a) Literal
l
  fmap f :: a -> b
f (NegativePattern p :: SpanInfo
p a :: a
a l :: Literal
l) = SpanInfo -> b -> Literal -> Pattern b
forall a. SpanInfo -> a -> Literal -> Pattern a
NegativePattern SpanInfo
p (a -> b
f a
a) Literal
l
  fmap f :: a -> b
f (VariablePattern p :: SpanInfo
p a :: a
a v :: Ident
v) = SpanInfo -> b -> Ident -> Pattern b
forall a. SpanInfo -> a -> Ident -> Pattern a
VariablePattern SpanInfo
p (a -> b
f a
a) Ident
v
  fmap f :: a -> b
f (ConstructorPattern p :: SpanInfo
p a :: a
a c :: QualIdent
c ts :: [Pattern a]
ts) =
    SpanInfo -> b -> QualIdent -> [Pattern b] -> Pattern b
forall a. SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
ConstructorPattern SpanInfo
p (a -> b
f a
a) QualIdent
c ((Pattern a -> Pattern b) -> [Pattern a] -> [Pattern b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Pattern a]
ts)
  fmap f :: a -> b
f (InfixPattern p :: SpanInfo
p a :: a
a t1 :: Pattern a
t1 op :: QualIdent
op t2 :: Pattern a
t2) =
    SpanInfo -> b -> Pattern b -> QualIdent -> Pattern b -> Pattern b
forall a.
SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
InfixPattern SpanInfo
p (a -> b
f a
a) ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t1) QualIdent
op ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t2)
  fmap f :: a -> b
f (ParenPattern p :: SpanInfo
p t :: Pattern a
t) = SpanInfo -> Pattern b -> Pattern b
forall a. SpanInfo -> Pattern a -> Pattern a
ParenPattern SpanInfo
p ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t)
  fmap f :: a -> b
f (RecordPattern p :: SpanInfo
p a :: a
a c :: QualIdent
c fs :: [Field (Pattern a)]
fs) =
    SpanInfo -> b -> QualIdent -> [Field (Pattern b)] -> Pattern b
forall a.
SpanInfo -> a -> QualIdent -> [Field (Pattern a)] -> Pattern a
RecordPattern SpanInfo
p (a -> b
f a
a) QualIdent
c ((Field (Pattern a) -> Field (Pattern b))
-> [Field (Pattern a)] -> [Field (Pattern b)]
forall a b. (a -> b) -> [a] -> [b]
map ((Pattern a -> Pattern b) -> Field (Pattern a) -> Field (Pattern b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f)) [Field (Pattern a)]
fs)
  fmap f :: a -> b
f (TuplePattern p :: SpanInfo
p ts :: [Pattern a]
ts) = SpanInfo -> [Pattern b] -> Pattern b
forall a. SpanInfo -> [Pattern a] -> Pattern a
TuplePattern SpanInfo
p ((Pattern a -> Pattern b) -> [Pattern a] -> [Pattern b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Pattern a]
ts)
  fmap f :: a -> b
f (ListPattern p :: SpanInfo
p a :: a
a ts :: [Pattern a]
ts) = SpanInfo -> b -> [Pattern b] -> Pattern b
forall a. SpanInfo -> a -> [Pattern a] -> Pattern a
ListPattern SpanInfo
p (a -> b
f a
a) ((Pattern a -> Pattern b) -> [Pattern a] -> [Pattern b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Pattern a]
ts)
  fmap f :: a -> b
f (AsPattern p :: SpanInfo
p v :: Ident
v t :: Pattern a
t) = SpanInfo -> Ident -> Pattern b -> Pattern b
forall a. SpanInfo -> Ident -> Pattern a -> Pattern a
AsPattern SpanInfo
p Ident
v ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t)
  fmap f :: a -> b
f (LazyPattern p :: SpanInfo
p t :: Pattern a
t) = SpanInfo -> Pattern b -> Pattern b
forall a. SpanInfo -> Pattern a -> Pattern a
LazyPattern SpanInfo
p ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t)
  fmap f :: a -> b
f (FunctionPattern p :: SpanInfo
p a :: a
a f' :: QualIdent
f' ts :: [Pattern a]
ts) =
    SpanInfo -> b -> QualIdent -> [Pattern b] -> Pattern b
forall a. SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
FunctionPattern SpanInfo
p (a -> b
f a
a) QualIdent
f' ((Pattern a -> Pattern b) -> [Pattern a] -> [Pattern b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Pattern a]
ts)
  fmap f :: a -> b
f (InfixFuncPattern p :: SpanInfo
p a :: a
a t1 :: Pattern a
t1 op :: QualIdent
op t2 :: Pattern a
t2) =
    SpanInfo -> b -> Pattern b -> QualIdent -> Pattern b -> Pattern b
forall a.
SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
InfixFuncPattern SpanInfo
p (a -> b
f a
a) ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t1) QualIdent
op ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t2)

instance Functor Expression where
  fmap :: (a -> b) -> Expression a -> Expression b
fmap f :: a -> b
f (Literal p :: SpanInfo
p a :: a
a l :: Literal
l) = SpanInfo -> b -> Literal -> Expression b
forall a. SpanInfo -> a -> Literal -> Expression a
Literal SpanInfo
p (a -> b
f a
a) Literal
l
  fmap f :: a -> b
f (Variable p :: SpanInfo
p a :: a
a v :: QualIdent
v) = SpanInfo -> b -> QualIdent -> Expression b
forall a. SpanInfo -> a -> QualIdent -> Expression a
Variable SpanInfo
p (a -> b
f a
a) QualIdent
v
  fmap f :: a -> b
f (Constructor p :: SpanInfo
p a :: a
a c :: QualIdent
c) = SpanInfo -> b -> QualIdent -> Expression b
forall a. SpanInfo -> a -> QualIdent -> Expression a
Constructor SpanInfo
p (a -> b
f a
a) QualIdent
c
  fmap f :: a -> b
f (Paren p :: SpanInfo
p e :: Expression a
e) = SpanInfo -> Expression b -> Expression b
forall a. SpanInfo -> Expression a -> Expression a
Paren SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)
  fmap f :: a -> b
f (Typed p :: SpanInfo
p e :: Expression a
e qty :: QualTypeExpr
qty) = SpanInfo -> Expression b -> QualTypeExpr -> Expression b
forall a. SpanInfo -> Expression a -> QualTypeExpr -> Expression a
Typed SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e) QualTypeExpr
qty
  fmap f :: a -> b
f (Record p :: SpanInfo
p a :: a
a c :: QualIdent
c fs :: [Field (Expression a)]
fs) = SpanInfo
-> b -> QualIdent -> [Field (Expression b)] -> Expression b
forall a.
SpanInfo
-> a -> QualIdent -> [Field (Expression a)] -> Expression a
Record SpanInfo
p (a -> b
f a
a) QualIdent
c ((Field (Expression a) -> Field (Expression b))
-> [Field (Expression a)] -> [Field (Expression b)]
forall a b. (a -> b) -> [a] -> [b]
map ((Expression a -> Expression b)
-> Field (Expression a) -> Field (Expression b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f)) [Field (Expression a)]
fs)
  fmap f :: a -> b
f (RecordUpdate p :: SpanInfo
p e :: Expression a
e fs :: [Field (Expression a)]
fs) = SpanInfo -> Expression b -> [Field (Expression b)] -> Expression b
forall a.
SpanInfo -> Expression a -> [Field (Expression a)] -> Expression a
RecordUpdate SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e) ((Field (Expression a) -> Field (Expression b))
-> [Field (Expression a)] -> [Field (Expression b)]
forall a b. (a -> b) -> [a] -> [b]
map ((Expression a -> Expression b)
-> Field (Expression a) -> Field (Expression b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f)) [Field (Expression a)]
fs)
  fmap f :: a -> b
f (Tuple p :: SpanInfo
p es :: [Expression a]
es) = SpanInfo -> [Expression b] -> Expression b
forall a. SpanInfo -> [Expression a] -> Expression a
Tuple SpanInfo
p ((Expression a -> Expression b) -> [Expression a] -> [Expression b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Expression a]
es)
  fmap f :: a -> b
f (List p :: SpanInfo
p a :: a
a es :: [Expression a]
es) = SpanInfo -> b -> [Expression b] -> Expression b
forall a. SpanInfo -> a -> [Expression a] -> Expression a
List SpanInfo
p (a -> b
f a
a) ((Expression a -> Expression b) -> [Expression a] -> [Expression b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Expression a]
es)
  fmap f :: a -> b
f (ListCompr p :: SpanInfo
p e :: Expression a
e stms :: [Statement a]
stms) = SpanInfo -> Expression b -> [Statement b] -> Expression b
forall a. SpanInfo -> Expression a -> [Statement a] -> Expression a
ListCompr SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e) ((Statement a -> Statement b) -> [Statement a] -> [Statement b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Statement a -> Statement b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Statement a]
stms)
  fmap f :: a -> b
f (EnumFrom p :: SpanInfo
p e :: Expression a
e) = SpanInfo -> Expression b -> Expression b
forall a. SpanInfo -> Expression a -> Expression a
EnumFrom SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)
  fmap f :: a -> b
f (EnumFromThen p :: SpanInfo
p e1 :: Expression a
e1 e2 :: Expression a
e2) = SpanInfo -> Expression b -> Expression b -> Expression b
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
EnumFromThen SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e1) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e2)
  fmap f :: a -> b
f (EnumFromTo p :: SpanInfo
p e1 :: Expression a
e1 e2 :: Expression a
e2) = SpanInfo -> Expression b -> Expression b -> Expression b
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
EnumFromTo SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e1) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e2)
  fmap f :: a -> b
f (EnumFromThenTo p :: SpanInfo
p e1 :: Expression a
e1 e2 :: Expression a
e2 e3 :: Expression a
e3) =
    SpanInfo
-> Expression b -> Expression b -> Expression b -> Expression b
forall a.
SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
EnumFromThenTo SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e1) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e2) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e3)
  fmap f :: a -> b
f (UnaryMinus p :: SpanInfo
p e :: Expression a
e) = SpanInfo -> Expression b -> Expression b
forall a. SpanInfo -> Expression a -> Expression a
UnaryMinus SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)
  fmap f :: a -> b
f (Apply p :: SpanInfo
p e1 :: Expression a
e1 e2 :: Expression a
e2) = SpanInfo -> Expression b -> Expression b -> Expression b
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
Apply SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e1) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e2)
  fmap f :: a -> b
f (InfixApply p :: SpanInfo
p e1 :: Expression a
e1 op :: InfixOp a
op e2 :: Expression a
e2) =
    SpanInfo
-> Expression b -> InfixOp b -> Expression b -> Expression b
forall a.
SpanInfo
-> Expression a -> InfixOp a -> Expression a -> Expression a
InfixApply SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e1) ((a -> b) -> InfixOp a -> InfixOp b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f InfixOp a
op) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e2)
  fmap f :: a -> b
f (LeftSection p :: SpanInfo
p e :: Expression a
e op :: InfixOp a
op) = SpanInfo -> Expression b -> InfixOp b -> Expression b
forall a. SpanInfo -> Expression a -> InfixOp a -> Expression a
LeftSection SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e) ((a -> b) -> InfixOp a -> InfixOp b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f InfixOp a
op)
  fmap f :: a -> b
f (RightSection p :: SpanInfo
p op :: InfixOp a
op e :: Expression a
e) = SpanInfo -> InfixOp b -> Expression b -> Expression b
forall a. SpanInfo -> InfixOp a -> Expression a -> Expression a
RightSection SpanInfo
p ((a -> b) -> InfixOp a -> InfixOp b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f InfixOp a
op) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)
  fmap f :: a -> b
f (Lambda p :: SpanInfo
p ts :: [Pattern a]
ts e :: Expression a
e) = SpanInfo -> [Pattern b] -> Expression b -> Expression b
forall a. SpanInfo -> [Pattern a] -> Expression a -> Expression a
Lambda SpanInfo
p ((Pattern a -> Pattern b) -> [Pattern a] -> [Pattern b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Pattern a]
ts) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)
  fmap f :: a -> b
f (Let p :: SpanInfo
p li :: LayoutInfo
li ds :: [Decl a]
ds e :: Expression a
e) = SpanInfo -> LayoutInfo -> [Decl b] -> Expression b -> Expression b
forall a.
SpanInfo -> LayoutInfo -> [Decl a] -> Expression a -> Expression a
Let SpanInfo
p LayoutInfo
li ((Decl a -> Decl b) -> [Decl a] -> [Decl b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Decl a -> Decl b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Decl a]
ds) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)
  fmap f :: a -> b
f (Do p :: SpanInfo
p li :: LayoutInfo
li stms :: [Statement a]
stms e :: Expression a
e) = SpanInfo
-> LayoutInfo -> [Statement b] -> Expression b -> Expression b
forall a.
SpanInfo
-> LayoutInfo -> [Statement a] -> Expression a -> Expression a
Do SpanInfo
p LayoutInfo
li ((Statement a -> Statement b) -> [Statement a] -> [Statement b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Statement a -> Statement b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Statement a]
stms) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)
  fmap f :: a -> b
f (IfThenElse p :: SpanInfo
p e1 :: Expression a
e1 e2 :: Expression a
e2 e3 :: Expression a
e3) =
    SpanInfo
-> Expression b -> Expression b -> Expression b -> Expression b
forall a.
SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
IfThenElse SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e1) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e2) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e3)
  fmap f :: a -> b
f (Case p :: SpanInfo
p li :: LayoutInfo
li ct :: CaseType
ct e :: Expression a
e as :: [Alt a]
as) = SpanInfo
-> LayoutInfo
-> CaseType
-> Expression b
-> [Alt b]
-> Expression b
forall a.
SpanInfo
-> LayoutInfo
-> CaseType
-> Expression a
-> [Alt a]
-> Expression a
Case SpanInfo
p LayoutInfo
li CaseType
ct ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e) ((Alt a -> Alt b) -> [Alt a] -> [Alt b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Alt a -> Alt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Alt a]
as)

instance Functor InfixOp where
  fmap :: (a -> b) -> InfixOp a -> InfixOp b
fmap f :: a -> b
f (InfixOp a :: a
a op :: QualIdent
op) = b -> QualIdent -> InfixOp b
forall a. a -> QualIdent -> InfixOp a
InfixOp (a -> b
f a
a) QualIdent
op
  fmap f :: a -> b
f (InfixConstr a :: a
a op :: QualIdent
op) = b -> QualIdent -> InfixOp b
forall a. a -> QualIdent -> InfixOp a
InfixConstr (a -> b
f a
a) QualIdent
op

instance Functor Statement where
  fmap :: (a -> b) -> Statement a -> Statement b
fmap f :: a -> b
f (StmtExpr p :: SpanInfo
p e :: Expression a
e) = SpanInfo -> Expression b -> Statement b
forall a. SpanInfo -> Expression a -> Statement a
StmtExpr SpanInfo
p ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)
  fmap f :: a -> b
f (StmtDecl p :: SpanInfo
p li :: LayoutInfo
li ds :: [Decl a]
ds) = SpanInfo -> LayoutInfo -> [Decl b] -> Statement b
forall a. SpanInfo -> LayoutInfo -> [Decl a] -> Statement a
StmtDecl SpanInfo
p LayoutInfo
li ((Decl a -> Decl b) -> [Decl a] -> [Decl b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Decl a -> Decl b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Decl a]
ds)
  fmap f :: a -> b
f (StmtBind p :: SpanInfo
p t :: Pattern a
t e :: Expression a
e) = SpanInfo -> Pattern b -> Expression b -> Statement b
forall a. SpanInfo -> Pattern a -> Expression a -> Statement a
StmtBind SpanInfo
p ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t) ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e)

instance Functor Alt where
  fmap :: (a -> b) -> Alt a -> Alt b
fmap f :: a -> b
f (Alt p :: SpanInfo
p t :: Pattern a
t rhs :: Rhs a
rhs) = SpanInfo -> Pattern b -> Rhs b -> Alt b
forall a. SpanInfo -> Pattern a -> Rhs a -> Alt a
Alt SpanInfo
p ((a -> b) -> Pattern a -> Pattern b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Pattern a
t) ((a -> b) -> Rhs a -> Rhs b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Rhs a
rhs)

instance Functor Field where
  fmap :: (a -> b) -> Field a -> Field b
fmap f :: a -> b
f (Field p :: SpanInfo
p l :: QualIdent
l x :: a
x) = SpanInfo -> QualIdent -> b -> Field b
forall a. SpanInfo -> QualIdent -> a -> Field a
Field SpanInfo
p QualIdent
l (a -> b
f a
x)

instance Functor Var where
  fmap :: (a -> b) -> Var a -> Var b
fmap f :: a -> b
f (Var a :: a
a v :: Ident
v) = b -> Ident -> Var b
forall a. a -> Ident -> Var a
Var (a -> b
f a
a) Ident
v

instance Functor Goal where
  fmap :: (a -> b) -> Goal a -> Goal b
fmap f :: a -> b
f (Goal p :: SpanInfo
p li :: LayoutInfo
li e :: Expression a
e ds :: [Decl a]
ds) = SpanInfo -> LayoutInfo -> Expression b -> [Decl b] -> Goal b
forall a.
SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Goal a
Goal SpanInfo
p LayoutInfo
li ((a -> b) -> Expression a -> Expression b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Expression a
e) ((Decl a -> Decl b) -> [Decl a] -> [Decl b]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> Decl a -> Decl b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) [Decl a]
ds)

instance Pretty Infix where
  pPrint :: Infix -> Doc
pPrint InfixL = String -> Doc
text "infixl"
  pPrint InfixR = String -> Doc
text "infixr"
  pPrint Infix  = String -> Doc
text "infix"

instance HasSpanInfo (Module a) where
  getSpanInfo :: Module a -> SpanInfo
getSpanInfo (Module sp :: SpanInfo
sp _ _ _ _ _ _) = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Module a -> Module a
setSpanInfo sp :: SpanInfo
sp (Module _ li :: LayoutInfo
li ps :: [ModulePragma]
ps m :: ModuleIdent
m es :: Maybe ExportSpec
es is :: [ImportDecl]
is ds :: [Decl a]
ds) = SpanInfo
-> LayoutInfo
-> [ModulePragma]
-> ModuleIdent
-> Maybe ExportSpec
-> [ImportDecl]
-> [Decl a]
-> Module a
forall a.
SpanInfo
-> LayoutInfo
-> [ModulePragma]
-> ModuleIdent
-> Maybe ExportSpec
-> [ImportDecl]
-> [Decl a]
-> Module a
Module SpanInfo
sp LayoutInfo
li [ModulePragma]
ps ModuleIdent
m Maybe ExportSpec
es [ImportDecl]
is [Decl a]
ds

  updateEndPos :: Module a -> Module a
updateEndPos m :: Module a
m@(Module _ _ _ _ _ _ (d :: Decl a
d:ds :: [Decl a]
ds)) =
    Position -> Module a -> Module a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Decl a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Decl a] -> Decl a
forall a. [a] -> a
last (Decl a
dDecl a -> [Decl a] -> [Decl a]
forall a. a -> [a] -> [a]
:[Decl a]
ds))) Module a
m
  updateEndPos m :: Module a
m@(Module _ _ _ _ _ (i :: ImportDecl
i:is :: [ImportDecl]
is) _) =
    Position -> Module a -> Module a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (ImportDecl -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([ImportDecl] -> ImportDecl
forall a. [a] -> a
last (ImportDecl
iImportDecl -> [ImportDecl] -> [ImportDecl]
forall a. a -> [a] -> [a]
:[ImportDecl]
is))) Module a
m
  updateEndPos m :: Module a
m@(Module (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _ _ _ _ _) =
    Position -> Module a -> Module a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Module a
m
  updateEndPos m :: Module a
m@(Module _ _ (p :: ModulePragma
p:ps :: [ModulePragma]
ps) _ _ _ _) =
    Position -> Module a -> Module a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (ModulePragma -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([ModulePragma] -> ModulePragma
forall a. [a] -> a
last (ModulePragma
pModulePragma -> [ModulePragma] -> [ModulePragma]
forall a. a -> [a] -> [a]
:[ModulePragma]
ps))) Module a
m
  updateEndPos m :: Module a
m = Module a
m

  getLayoutInfo :: Module a -> LayoutInfo
getLayoutInfo (Module _ li :: LayoutInfo
li _ _ _ _ _) = LayoutInfo
li

instance HasSpanInfo (Decl a) where
  getSpanInfo :: Decl a -> SpanInfo
getSpanInfo (InfixDecl        sp :: SpanInfo
sp _ _ _)   = SpanInfo
sp
  getSpanInfo (DataDecl         sp :: SpanInfo
sp _ _ _ _) = SpanInfo
sp
  getSpanInfo (ExternalDataDecl sp :: SpanInfo
sp _ _)     = SpanInfo
sp
  getSpanInfo (NewtypeDecl      sp :: SpanInfo
sp _ _ _ _) = SpanInfo
sp
  getSpanInfo (TypeDecl         sp :: SpanInfo
sp _ _ _)   = SpanInfo
sp
  getSpanInfo (TypeSig          sp :: SpanInfo
sp _ _)     = SpanInfo
sp
  getSpanInfo (FunctionDecl     sp :: SpanInfo
sp _ _ _)   = SpanInfo
sp
  getSpanInfo (ExternalDecl     sp :: SpanInfo
sp _)       = SpanInfo
sp
  getSpanInfo (PatternDecl      sp :: SpanInfo
sp _ _)     = SpanInfo
sp
  getSpanInfo (FreeDecl         sp :: SpanInfo
sp _)       = SpanInfo
sp
  getSpanInfo (DefaultDecl      sp :: SpanInfo
sp _)       = SpanInfo
sp
  getSpanInfo (ClassDecl        sp :: SpanInfo
sp _ _ _ _ _) = SpanInfo
sp
  getSpanInfo (InstanceDecl     sp :: SpanInfo
sp _ _ _ _ _) = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Decl a -> Decl a
setSpanInfo sp :: SpanInfo
sp (InfixDecl _ fix :: Infix
fix prec :: Maybe Precedence
prec ops :: [Ident]
ops) = SpanInfo -> Infix -> Maybe Precedence -> [Ident] -> Decl a
forall a.
SpanInfo -> Infix -> Maybe Precedence -> [Ident] -> Decl a
InfixDecl SpanInfo
sp Infix
fix Maybe Precedence
prec [Ident]
ops
  setSpanInfo sp :: SpanInfo
sp (DataDecl _ tc :: Ident
tc tvs :: [Ident]
tvs cs :: [ConstrDecl]
cs clss :: [QualIdent]
clss) = SpanInfo
-> Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a
forall a.
SpanInfo
-> Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a
DataDecl SpanInfo
sp Ident
tc [Ident]
tvs [ConstrDecl]
cs [QualIdent]
clss
  setSpanInfo sp :: SpanInfo
sp (ExternalDataDecl _ tc :: Ident
tc tvs :: [Ident]
tvs) = SpanInfo -> Ident -> [Ident] -> Decl a
forall a. SpanInfo -> Ident -> [Ident] -> Decl a
ExternalDataDecl SpanInfo
sp Ident
tc [Ident]
tvs
  setSpanInfo sp :: SpanInfo
sp (NewtypeDecl _ tc :: Ident
tc tvs :: [Ident]
tvs nc :: NewConstrDecl
nc clss :: [QualIdent]
clss) = SpanInfo
-> Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a
forall a.
SpanInfo
-> Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a
NewtypeDecl SpanInfo
sp Ident
tc [Ident]
tvs NewConstrDecl
nc [QualIdent]
clss
  setSpanInfo sp :: SpanInfo
sp (TypeDecl _ tc :: Ident
tc tvs :: [Ident]
tvs ty :: TypeExpr
ty) = SpanInfo -> Ident -> [Ident] -> TypeExpr -> Decl a
forall a. SpanInfo -> Ident -> [Ident] -> TypeExpr -> Decl a
TypeDecl SpanInfo
sp Ident
tc [Ident]
tvs TypeExpr
ty
  setSpanInfo sp :: SpanInfo
sp (TypeSig _ fs :: [Ident]
fs qty :: QualTypeExpr
qty) = SpanInfo -> [Ident] -> QualTypeExpr -> Decl a
forall a. SpanInfo -> [Ident] -> QualTypeExpr -> Decl a
TypeSig SpanInfo
sp [Ident]
fs QualTypeExpr
qty
  setSpanInfo sp :: SpanInfo
sp (FunctionDecl _ a :: a
a f' :: Ident
f' eqs :: [Equation a]
eqs) = SpanInfo -> a -> Ident -> [Equation a] -> Decl a
forall a. SpanInfo -> a -> Ident -> [Equation a] -> Decl a
FunctionDecl SpanInfo
sp a
a Ident
f' [Equation a]
eqs
  setSpanInfo sp :: SpanInfo
sp (ExternalDecl _ vs :: [Var a]
vs) = SpanInfo -> [Var a] -> Decl a
forall a. SpanInfo -> [Var a] -> Decl a
ExternalDecl SpanInfo
sp [Var a]
vs
  setSpanInfo sp :: SpanInfo
sp (PatternDecl _ t :: Pattern a
t rhs :: Rhs a
rhs) = SpanInfo -> Pattern a -> Rhs a -> Decl a
forall a. SpanInfo -> Pattern a -> Rhs a -> Decl a
PatternDecl SpanInfo
sp Pattern a
t Rhs a
rhs
  setSpanInfo sp :: SpanInfo
sp (FreeDecl _ vs :: [Var a]
vs) = SpanInfo -> [Var a] -> Decl a
forall a. SpanInfo -> [Var a] -> Decl a
FreeDecl SpanInfo
sp [Var a]
vs
  setSpanInfo sp :: SpanInfo
sp (DefaultDecl _ tys :: [TypeExpr]
tys) = SpanInfo -> [TypeExpr] -> Decl a
forall a. SpanInfo -> [TypeExpr] -> Decl a
DefaultDecl SpanInfo
sp [TypeExpr]
tys
  setSpanInfo sp :: SpanInfo
sp (ClassDecl _ li :: LayoutInfo
li cx :: [Constraint]
cx cls :: Ident
cls clsvar :: Ident
clsvar ds :: [Decl a]
ds) = SpanInfo
-> LayoutInfo
-> [Constraint]
-> Ident
-> Ident
-> [Decl a]
-> Decl a
forall a.
SpanInfo
-> LayoutInfo
-> [Constraint]
-> Ident
-> Ident
-> [Decl a]
-> Decl a
ClassDecl SpanInfo
sp LayoutInfo
li [Constraint]
cx Ident
cls Ident
clsvar [Decl a]
ds
  setSpanInfo sp :: SpanInfo
sp (InstanceDecl _ li :: LayoutInfo
li cx :: [Constraint]
cx qcls :: QualIdent
qcls inst :: TypeExpr
inst ds :: [Decl a]
ds) = SpanInfo
-> LayoutInfo
-> [Constraint]
-> QualIdent
-> TypeExpr
-> [Decl a]
-> Decl a
forall a.
SpanInfo
-> LayoutInfo
-> [Constraint]
-> QualIdent
-> TypeExpr
-> [Decl a]
-> Decl a
InstanceDecl SpanInfo
sp LayoutInfo
li [Constraint]
cx QualIdent
qcls TypeExpr
inst [Decl a]
ds

  updateEndPos :: Decl a -> Decl a
updateEndPos d :: Decl a
d@(InfixDecl _ _ _ ops :: [Ident]
ops) =
    let i' :: Ident
i' = [Ident] -> Ident
forall a. [a] -> a
last [Ident]
ops
    in Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
i') (Ident -> Int
identLength Ident
i' Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Decl a
d
  updateEndPos d :: Decl a
d@(DataDecl _ _ _ _ (c :: QualIdent
c:cs :: [QualIdent]
cs)) =
    let i' :: QualIdent
i' = [QualIdent] -> QualIdent
forall a. [a] -> a
last (QualIdent
cQualIdent -> [QualIdent] -> [QualIdent]
forall a. a -> [a] -> [a]
:[QualIdent]
cs)
    in Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
i') (QualIdent -> Int
qIdentLength QualIdent
i' Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Decl a
d
  updateEndPos d :: Decl a
d@(DataDecl _ _ _ (c :: ConstrDecl
c:cs :: [ConstrDecl]
cs) _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (ConstrDecl -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([ConstrDecl] -> ConstrDecl
forall a. [a] -> a
last (ConstrDecl
cConstrDecl -> [ConstrDecl] -> [ConstrDecl]
forall a. a -> [a] -> [a]
:[ConstrDecl]
cs))) Decl a
d
  updateEndPos d :: Decl a
d@(DataDecl _ _ (i :: Ident
i:is :: [Ident]
is) _ _) =
    let i' :: Ident
i' = [Ident] -> Ident
forall a. [a] -> a
last (Ident
iIdent -> [Ident] -> [Ident]
forall a. a -> [a] -> [a]
:[Ident]
is)
    in Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
i') (Ident -> Int
identLength Ident
i' Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Decl a
d
  updateEndPos d :: Decl a
d@(DataDecl _ i :: Ident
i _ _ _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
i) (Ident -> Int
identLength Ident
i Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Decl a
d
  updateEndPos d :: Decl a
d@(ExternalDataDecl _ _ (i :: Ident
i:is :: [Ident]
is)) =
    let i' :: Ident
i' = [Ident] -> Ident
forall a. [a] -> a
last (Ident
iIdent -> [Ident] -> [Ident]
forall a. a -> [a] -> [a]
:[Ident]
is)
    in Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
i') (Ident -> Int
identLength Ident
i' Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Decl a
d
  updateEndPos d :: Decl a
d@(ExternalDataDecl _ i :: Ident
i _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
i) (Ident -> Int
identLength Ident
i Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Decl a
d
  updateEndPos d :: Decl a
d@(NewtypeDecl _ _ _ _ (c :: QualIdent
c:cs :: [QualIdent]
cs)) =
    let i' :: QualIdent
i' = [QualIdent] -> QualIdent
forall a. [a] -> a
last (QualIdent
cQualIdent -> [QualIdent] -> [QualIdent]
forall a. a -> [a] -> [a]
:[QualIdent]
cs)
    in Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
i') (QualIdent -> Int
qIdentLength QualIdent
i' Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Decl a
d
  updateEndPos d :: Decl a
d@(NewtypeDecl _ _ _ c :: NewConstrDecl
c _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (NewConstrDecl -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd NewConstrDecl
c) Decl a
d
  updateEndPos d :: Decl a
d@(TypeDecl _ _ _ ty :: TypeExpr
ty) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd TypeExpr
ty) Decl a
d
  updateEndPos d :: Decl a
d@(TypeSig _ _ qty :: QualTypeExpr
qty) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (QualTypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd QualTypeExpr
qty) Decl a
d
  updateEndPos d :: Decl a
d@(FunctionDecl _ _ _ eqs :: [Equation a]
eqs) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Equation a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Equation a] -> Equation a
forall a. [a] -> a
last [Equation a]
eqs)) Decl a
d
  updateEndPos d :: Decl a
d@(ExternalDecl (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Decl a
d
  updateEndPos d :: Decl a
d@(ExternalDecl _ _) = Decl a
d
  updateEndPos d :: Decl a
d@(PatternDecl _ _ rhs :: Rhs a
rhs) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Rhs a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Rhs a
rhs) Decl a
d
  updateEndPos d :: Decl a
d@(FreeDecl (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Decl a
d
  updateEndPos d :: Decl a
d@(FreeDecl _ _) = Decl a
d
  updateEndPos d :: Decl a
d@(DefaultDecl (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Decl a
d
  updateEndPos d :: Decl a
d@(DefaultDecl _ _) = Decl a
d
  updateEndPos d :: Decl a
d@(ClassDecl _ _ _ _ _ (d' :: Decl a
d':ds :: [Decl a]
ds)) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Decl a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Decl a] -> Decl a
forall a. [a] -> a
last (Decl a
d'Decl a -> [Decl a] -> [Decl a]
forall a. a -> [a] -> [a]
:[Decl a]
ds))) Decl a
d
  updateEndPos d :: Decl a
d@(ClassDecl (SpanInfo _ ss :: [Span]
ss) _ _ _ _ _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Decl a
d
  updateEndPos d :: Decl a
d@(ClassDecl _ _ _ _ _ _) = Decl a
d
  updateEndPos d :: Decl a
d@(InstanceDecl _ _ _ _ _ (d' :: Decl a
d':ds :: [Decl a]
ds)) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Decl a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Decl a] -> Decl a
forall a. [a] -> a
last (Decl a
d'Decl a -> [Decl a] -> [Decl a]
forall a. a -> [a] -> [a]
:[Decl a]
ds))) Decl a
d
  updateEndPos d :: Decl a
d@(InstanceDecl (SpanInfo _ ss :: [Span]
ss) _ _ _ _ _) =
    Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Decl a
d
  updateEndPos d :: Decl a
d@(InstanceDecl _ _ _ _ _ _) = Decl a
d

  getLayoutInfo :: Decl a -> LayoutInfo
getLayoutInfo (ClassDecl _ li :: LayoutInfo
li _ _ _ _) = LayoutInfo
li
  getLayoutInfo (InstanceDecl _ li :: LayoutInfo
li _ _ _ _) = LayoutInfo
li
  getLayoutInfo _ = LayoutInfo
WhitespaceLayout

instance HasSpanInfo (Equation a) where
  getSpanInfo :: Equation a -> SpanInfo
getSpanInfo (Equation spi :: SpanInfo
spi _ _) = SpanInfo
spi
  setSpanInfo :: SpanInfo -> Equation a -> Equation a
setSpanInfo spi :: SpanInfo
spi (Equation _ lhs :: Lhs a
lhs rhs :: Rhs a
rhs) = SpanInfo -> Lhs a -> Rhs a -> Equation a
forall a. SpanInfo -> Lhs a -> Rhs a -> Equation a
Equation SpanInfo
spi Lhs a
lhs Rhs a
rhs
  updateEndPos :: Equation a -> Equation a
updateEndPos e :: Equation a
e@(Equation _ _ rhs :: Rhs a
rhs) =
    Position -> Equation a -> Equation a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Rhs a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Rhs a
rhs) Equation a
e

instance HasSpanInfo ModulePragma where
  getSpanInfo :: ModulePragma -> SpanInfo
getSpanInfo (LanguagePragma sp :: SpanInfo
sp _  ) = SpanInfo
sp
  getSpanInfo (OptionsPragma  sp :: SpanInfo
sp _ _) = SpanInfo
sp

  setSpanInfo :: SpanInfo -> ModulePragma -> ModulePragma
setSpanInfo sp :: SpanInfo
sp (LanguagePragma _ ex :: [Extension]
ex ) = SpanInfo -> [Extension] -> ModulePragma
LanguagePragma SpanInfo
sp [Extension]
ex
  setSpanInfo sp :: SpanInfo
sp (OptionsPragma  _ t :: Maybe Tool
t a :: String
a) = SpanInfo -> Maybe Tool -> String -> ModulePragma
OptionsPragma SpanInfo
sp Maybe Tool
t String
a

  updateEndPos :: ModulePragma -> ModulePragma
updateEndPos p :: ModulePragma
p@(LanguagePragma (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> ModulePragma -> ModulePragma
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) ModulePragma
p
  updateEndPos p :: ModulePragma
p@(LanguagePragma _ _) = ModulePragma
p
  updateEndPos p :: ModulePragma
p@(OptionsPragma (SpanInfo _ ss :: [Span]
ss) _ _) =
    Position -> ModulePragma -> ModulePragma
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) ModulePragma
p
  updateEndPos p :: ModulePragma
p@(OptionsPragma _ _ _) = ModulePragma
p

instance HasSpanInfo ExportSpec where
  getSpanInfo :: ExportSpec -> SpanInfo
getSpanInfo (Exporting sp :: SpanInfo
sp _) = SpanInfo
sp
  setSpanInfo :: SpanInfo -> ExportSpec -> ExportSpec
setSpanInfo sp :: SpanInfo
sp (Exporting _ ex :: [Export]
ex) = SpanInfo -> [Export] -> ExportSpec
Exporting SpanInfo
sp [Export]
ex

  updateEndPos :: ExportSpec -> ExportSpec
updateEndPos e :: ExportSpec
e@(Exporting (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> ExportSpec -> ExportSpec
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) ExportSpec
e
  updateEndPos e :: ExportSpec
e@(Exporting _ _) = ExportSpec
e

instance HasSpanInfo Export where
  getSpanInfo :: Export -> SpanInfo
getSpanInfo (Export sp :: SpanInfo
sp _)           = SpanInfo
sp
  getSpanInfo (ExportTypeWith sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (ExportTypeAll sp :: SpanInfo
sp _)    = SpanInfo
sp
  getSpanInfo (ExportModule sp :: SpanInfo
sp _)     = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Export -> Export
setSpanInfo sp :: SpanInfo
sp (Export _ qid :: QualIdent
qid)            = SpanInfo -> QualIdent -> Export
Export SpanInfo
sp QualIdent
qid
  setSpanInfo sp :: SpanInfo
sp (ExportTypeWith _ qid :: QualIdent
qid cs :: [Ident]
cs) = SpanInfo -> QualIdent -> [Ident] -> Export
ExportTypeWith SpanInfo
sp QualIdent
qid [Ident]
cs
  setSpanInfo sp :: SpanInfo
sp (ExportTypeAll _ qid :: QualIdent
qid)     = SpanInfo -> QualIdent -> Export
ExportTypeAll SpanInfo
sp QualIdent
qid
  setSpanInfo sp :: SpanInfo
sp (ExportModule _ mid :: ModuleIdent
mid)      = SpanInfo -> ModuleIdent -> Export
ExportModule SpanInfo
sp ModuleIdent
mid

  updateEndPos :: Export -> Export
updateEndPos e :: Export
e@(Export _ idt :: QualIdent
idt) =
    Position -> Export -> Export
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
idt) (QualIdent -> Int
qIdentLength QualIdent
idt Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Export
e
  updateEndPos e :: Export
e@(ExportTypeWith (SpanInfo _ ss :: [Span]
ss) _ _) =
    Position -> Export -> Export
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Export
e
  updateEndPos e :: Export
e@(ExportTypeWith _ _ _) = Export
e
  updateEndPos e :: Export
e@(ExportTypeAll (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> Export -> Export
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Export
e
  updateEndPos e :: Export
e@(ExportTypeAll _ _) = Export
e
  updateEndPos e :: Export
e@(ExportModule _ mid :: ModuleIdent
mid) =
    Position -> Export -> Export
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (ModuleIdent -> Position
forall a. HasPosition a => a -> Position
getPosition ModuleIdent
mid) (ModuleIdent -> Int
mIdentLength ModuleIdent
mid Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Export
e

instance HasSpanInfo ImportDecl where
  getSpanInfo :: ImportDecl -> SpanInfo
getSpanInfo (ImportDecl sp :: SpanInfo
sp _ _ _ _) = SpanInfo
sp
  setSpanInfo :: SpanInfo -> ImportDecl -> ImportDecl
setSpanInfo sp :: SpanInfo
sp (ImportDecl _ mid :: ModuleIdent
mid q :: Bool
q as :: Maybe ModuleIdent
as spec :: Maybe ImportSpec
spec) = SpanInfo
-> ModuleIdent
-> Bool
-> Maybe ModuleIdent
-> Maybe ImportSpec
-> ImportDecl
ImportDecl SpanInfo
sp ModuleIdent
mid Bool
q Maybe ModuleIdent
as Maybe ImportSpec
spec

  updateEndPos :: ImportDecl -> ImportDecl
updateEndPos i :: ImportDecl
i@(ImportDecl _ _ _ _ (Just spec :: ImportSpec
spec)) =
    Position -> ImportDecl -> ImportDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (ImportSpec -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ImportSpec
spec) ImportDecl
i
  updateEndPos i :: ImportDecl
i@(ImportDecl _ _ _ (Just mid :: ModuleIdent
mid) _) =
    Position -> ImportDecl -> ImportDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (ModuleIdent -> Position
forall a. HasPosition a => a -> Position
getPosition ModuleIdent
mid) (ModuleIdent -> Int
mIdentLength ModuleIdent
mid Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) ImportDecl
i
  updateEndPos i :: ImportDecl
i@(ImportDecl _ mid :: ModuleIdent
mid _ _ _) =
    Position -> ImportDecl -> ImportDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (ModuleIdent -> Position
forall a. HasPosition a => a -> Position
getPosition ModuleIdent
mid) (ModuleIdent -> Int
mIdentLength ModuleIdent
mid Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) ImportDecl
i

instance HasSpanInfo ImportSpec where
  getSpanInfo :: ImportSpec -> SpanInfo
getSpanInfo (Importing sp :: SpanInfo
sp _) = SpanInfo
sp
  getSpanInfo (Hiding    sp :: SpanInfo
sp _) = SpanInfo
sp

  setSpanInfo :: SpanInfo -> ImportSpec -> ImportSpec
setSpanInfo sp :: SpanInfo
sp (Importing _ im :: [Import]
im) = SpanInfo -> [Import] -> ImportSpec
Importing SpanInfo
sp [Import]
im
  setSpanInfo sp :: SpanInfo
sp (Hiding    _ im :: [Import]
im) = SpanInfo -> [Import] -> ImportSpec
Hiding SpanInfo
sp [Import]
im

  updateEndPos :: ImportSpec -> ImportSpec
updateEndPos i :: ImportSpec
i@(Importing (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> ImportSpec -> ImportSpec
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) ImportSpec
i
  updateEndPos i :: ImportSpec
i@(Importing _ _) = ImportSpec
i
  updateEndPos i :: ImportSpec
i@(Hiding (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> ImportSpec -> ImportSpec
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) ImportSpec
i
  updateEndPos i :: ImportSpec
i@(Hiding _ _) = ImportSpec
i

instance HasSpanInfo Import where
  getSpanInfo :: Import -> SpanInfo
getSpanInfo (Import sp :: SpanInfo
sp _)           = SpanInfo
sp
  getSpanInfo (ImportTypeWith sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (ImportTypeAll sp :: SpanInfo
sp _)    = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Import -> Import
setSpanInfo sp :: SpanInfo
sp (Import _ qid :: Ident
qid)            = SpanInfo -> Ident -> Import
Import SpanInfo
sp Ident
qid
  setSpanInfo sp :: SpanInfo
sp (ImportTypeWith _ qid :: Ident
qid cs :: [Ident]
cs) = SpanInfo -> Ident -> [Ident] -> Import
ImportTypeWith SpanInfo
sp Ident
qid [Ident]
cs
  setSpanInfo sp :: SpanInfo
sp (ImportTypeAll _ qid :: Ident
qid)     = SpanInfo -> Ident -> Import
ImportTypeAll SpanInfo
sp Ident
qid

  updateEndPos :: Import -> Import
updateEndPos i :: Import
i@(Import _ idt :: Ident
idt) =
    Position -> Import -> Import
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
idt) (Ident -> Int
identLength Ident
idt Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Import
i
  updateEndPos i :: Import
i@(ImportTypeWith (SpanInfo _ ss :: [Span]
ss) _ _) =
    Position -> Import -> Import
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Import
i
  updateEndPos i :: Import
i@(ImportTypeWith _ _ _) = Import
i
  updateEndPos i :: Import
i@(ImportTypeAll (SpanInfo _ ss :: [Span]
ss) _) =
    Position -> Import -> Import
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Import
i
  updateEndPos i :: Import
i@(ImportTypeAll _ _) = Import
i

instance HasSpanInfo ConstrDecl where
  getSpanInfo :: ConstrDecl -> SpanInfo
getSpanInfo (ConstrDecl sp :: SpanInfo
sp _ _)   = SpanInfo
sp
  getSpanInfo (ConOpDecl  sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (RecordDecl sp :: SpanInfo
sp _ _)   = SpanInfo
sp

  setSpanInfo :: SpanInfo -> ConstrDecl -> ConstrDecl
setSpanInfo sp :: SpanInfo
sp (ConstrDecl _ idt :: Ident
idt ty :: [TypeExpr]
ty) = SpanInfo -> Ident -> [TypeExpr] -> ConstrDecl
ConstrDecl SpanInfo
sp Ident
idt [TypeExpr]
ty
  setSpanInfo sp :: SpanInfo
sp (ConOpDecl  _ ty1 :: TypeExpr
ty1 idt :: Ident
idt ty2 :: TypeExpr
ty2) = SpanInfo -> TypeExpr -> Ident -> TypeExpr -> ConstrDecl
ConOpDecl SpanInfo
sp TypeExpr
ty1 Ident
idt TypeExpr
ty2
  setSpanInfo sp :: SpanInfo
sp (RecordDecl _ idt :: Ident
idt fd :: [FieldDecl]
fd) = SpanInfo -> Ident -> [FieldDecl] -> ConstrDecl
RecordDecl SpanInfo
sp Ident
idt [FieldDecl]
fd

  updateEndPos :: ConstrDecl -> ConstrDecl
updateEndPos c :: ConstrDecl
c@(ConstrDecl _ _ (t :: TypeExpr
t:ts :: [TypeExpr]
ts)) =
    Position -> ConstrDecl -> ConstrDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([TypeExpr] -> TypeExpr
forall a. [a] -> a
last (TypeExpr
tTypeExpr -> [TypeExpr] -> [TypeExpr]
forall a. a -> [a] -> [a]
:[TypeExpr]
ts))) ConstrDecl
c
  updateEndPos c :: ConstrDecl
c@(ConstrDecl _ idt :: Ident
idt _) =
    Position -> ConstrDecl -> ConstrDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
idt) (Ident -> Int
identLength Ident
idt Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) ConstrDecl
c
  updateEndPos c :: ConstrDecl
c@(ConOpDecl _ _ _ ty :: TypeExpr
ty) =
    Position -> ConstrDecl -> ConstrDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd TypeExpr
ty) ConstrDecl
c
  updateEndPos c :: ConstrDecl
c@(RecordDecl (SpanInfo _ ss :: [Span]
ss) _ _) =
    Position -> ConstrDecl -> ConstrDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) ConstrDecl
c
  updateEndPos c :: ConstrDecl
c@(RecordDecl _ _ _) = ConstrDecl
c

instance HasSpanInfo NewConstrDecl where
  getSpanInfo :: NewConstrDecl -> SpanInfo
getSpanInfo (NewConstrDecl sp :: SpanInfo
sp _ _)   = SpanInfo
sp
  getSpanInfo (NewRecordDecl sp :: SpanInfo
sp _ _)   = SpanInfo
sp

  setSpanInfo :: SpanInfo -> NewConstrDecl -> NewConstrDecl
setSpanInfo sp :: SpanInfo
sp (NewConstrDecl _ idt :: Ident
idt ty :: TypeExpr
ty)  = SpanInfo -> Ident -> TypeExpr -> NewConstrDecl
NewConstrDecl SpanInfo
sp Ident
idt TypeExpr
ty
  setSpanInfo sp :: SpanInfo
sp (NewRecordDecl _ idt :: Ident
idt fty :: (Ident, TypeExpr)
fty) = SpanInfo -> Ident -> (Ident, TypeExpr) -> NewConstrDecl
NewRecordDecl SpanInfo
sp Ident
idt (Ident, TypeExpr)
fty

  updateEndPos :: NewConstrDecl -> NewConstrDecl
updateEndPos c :: NewConstrDecl
c@(NewConstrDecl _ _ ty :: TypeExpr
ty) =
    Position -> NewConstrDecl -> NewConstrDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd TypeExpr
ty) NewConstrDecl
c
  updateEndPos c :: NewConstrDecl
c@(NewRecordDecl (SpanInfo _ ss :: [Span]
ss) _ _) =
    Position -> NewConstrDecl -> NewConstrDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) NewConstrDecl
c
  updateEndPos c :: NewConstrDecl
c@(NewRecordDecl _ _ _) = NewConstrDecl
c

instance HasSpanInfo FieldDecl where
    getSpanInfo :: FieldDecl -> SpanInfo
getSpanInfo (FieldDecl sp :: SpanInfo
sp _ _) = SpanInfo
sp
    setSpanInfo :: SpanInfo -> FieldDecl -> FieldDecl
setSpanInfo sp :: SpanInfo
sp (FieldDecl _ idt :: [Ident]
idt ty :: TypeExpr
ty) = SpanInfo -> [Ident] -> TypeExpr -> FieldDecl
FieldDecl SpanInfo
sp [Ident]
idt TypeExpr
ty
    updateEndPos :: FieldDecl -> FieldDecl
updateEndPos d :: FieldDecl
d@(FieldDecl _ _ ty :: TypeExpr
ty) =
      Position -> FieldDecl -> FieldDecl
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd TypeExpr
ty) FieldDecl
d

instance HasSpanInfo TypeExpr where
  getSpanInfo :: TypeExpr -> SpanInfo
getSpanInfo (ConstructorType sp :: SpanInfo
sp _) = SpanInfo
sp
  getSpanInfo (ApplyType sp :: SpanInfo
sp _ _)     = SpanInfo
sp
  getSpanInfo (VariableType sp :: SpanInfo
sp _)    = SpanInfo
sp
  getSpanInfo (TupleType sp :: SpanInfo
sp _)       = SpanInfo
sp
  getSpanInfo (ListType sp :: SpanInfo
sp _)        = SpanInfo
sp
  getSpanInfo (ArrowType sp :: SpanInfo
sp _ _)     = SpanInfo
sp
  getSpanInfo (ParenType sp :: SpanInfo
sp _)       = SpanInfo
sp
  getSpanInfo (ForallType sp :: SpanInfo
sp _ _)    = SpanInfo
sp

  setSpanInfo :: SpanInfo -> TypeExpr -> TypeExpr
setSpanInfo sp :: SpanInfo
sp (ConstructorType _ qid :: QualIdent
qid) = SpanInfo -> QualIdent -> TypeExpr
ConstructorType SpanInfo
sp QualIdent
qid
  setSpanInfo sp :: SpanInfo
sp (ApplyType _ ty1 :: TypeExpr
ty1 ty2 :: TypeExpr
ty2)   = SpanInfo -> TypeExpr -> TypeExpr -> TypeExpr
ApplyType SpanInfo
sp TypeExpr
ty1 TypeExpr
ty2
  setSpanInfo sp :: SpanInfo
sp (VariableType _ idt :: Ident
idt)    = SpanInfo -> Ident -> TypeExpr
VariableType SpanInfo
sp Ident
idt
  setSpanInfo sp :: SpanInfo
sp (TupleType _ tys :: [TypeExpr]
tys)       = SpanInfo -> [TypeExpr] -> TypeExpr
TupleType SpanInfo
sp [TypeExpr]
tys
  setSpanInfo sp :: SpanInfo
sp (ListType _ ty :: TypeExpr
ty)         = SpanInfo -> TypeExpr -> TypeExpr
ListType SpanInfo
sp TypeExpr
ty
  setSpanInfo sp :: SpanInfo
sp (ArrowType _ ty1 :: TypeExpr
ty1 ty2 :: TypeExpr
ty2)   = SpanInfo -> TypeExpr -> TypeExpr -> TypeExpr
ArrowType SpanInfo
sp TypeExpr
ty1 TypeExpr
ty2
  setSpanInfo sp :: SpanInfo
sp (ParenType _ ty :: TypeExpr
ty)        = SpanInfo -> TypeExpr -> TypeExpr
ParenType SpanInfo
sp TypeExpr
ty
  setSpanInfo sp :: SpanInfo
sp (ForallType _ idt :: [Ident]
idt ty :: TypeExpr
ty)   = SpanInfo -> [Ident] -> TypeExpr -> TypeExpr
ForallType SpanInfo
sp [Ident]
idt TypeExpr
ty

  updateEndPos :: TypeExpr -> TypeExpr
updateEndPos t :: TypeExpr
t@(ConstructorType _ qid :: QualIdent
qid) =
    Position -> TypeExpr -> TypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
qid) (QualIdent -> Int
qIdentLength QualIdent
qid Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) TypeExpr
t
  updateEndPos t :: TypeExpr
t@(ApplyType _ _ t2 :: TypeExpr
t2) =
    Position -> TypeExpr -> TypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd TypeExpr
t2) TypeExpr
t
  updateEndPos t :: TypeExpr
t@(VariableType _ idt :: Ident
idt) =
    Position -> TypeExpr -> TypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
idt) (Ident -> Int
identLength Ident
idt Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) TypeExpr
t
  updateEndPos t :: TypeExpr
t@(ListType (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _) =
    Position -> TypeExpr -> TypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) TypeExpr
t
  updateEndPos t :: TypeExpr
t@(ListType _ _) = TypeExpr
t
  updateEndPos t :: TypeExpr
t@(TupleType _ tys :: [TypeExpr]
tys) =
    Position -> TypeExpr -> TypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([TypeExpr] -> TypeExpr
forall a. [a] -> a
last [TypeExpr]
tys)) TypeExpr
t
  updateEndPos t :: TypeExpr
t@(ArrowType _ _ t2 :: TypeExpr
t2) =
    Position -> TypeExpr -> TypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd TypeExpr
t2) TypeExpr
t
  updateEndPos t :: TypeExpr
t@(ParenType (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _) =
    Position -> TypeExpr -> TypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) TypeExpr
t
  updateEndPos t :: TypeExpr
t@(ParenType _ _) = TypeExpr
t
  updateEndPos t :: TypeExpr
t@(ForallType _ _ _) = TypeExpr
t -- not a parseable type

instance HasSpanInfo QualTypeExpr where
  getSpanInfo :: QualTypeExpr -> SpanInfo
getSpanInfo (QualTypeExpr sp :: SpanInfo
sp _ _) = SpanInfo
sp
  setSpanInfo :: SpanInfo -> QualTypeExpr -> QualTypeExpr
setSpanInfo sp :: SpanInfo
sp (QualTypeExpr _ cx :: [Constraint]
cx ty :: TypeExpr
ty) = SpanInfo -> [Constraint] -> TypeExpr -> QualTypeExpr
QualTypeExpr SpanInfo
sp [Constraint]
cx TypeExpr
ty
  updateEndPos :: QualTypeExpr -> QualTypeExpr
updateEndPos t :: QualTypeExpr
t@(QualTypeExpr _ _ ty :: TypeExpr
ty) =
    Position -> QualTypeExpr -> QualTypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd TypeExpr
ty) QualTypeExpr
t

instance HasSpanInfo Constraint where
  getSpanInfo :: Constraint -> SpanInfo
getSpanInfo (Constraint sp :: SpanInfo
sp _ _) = SpanInfo
sp
  setSpanInfo :: SpanInfo -> Constraint -> Constraint
setSpanInfo sp :: SpanInfo
sp (Constraint _ qid :: QualIdent
qid ty :: TypeExpr
ty) = SpanInfo -> QualIdent -> TypeExpr -> Constraint
Constraint SpanInfo
sp QualIdent
qid TypeExpr
ty
  updateEndPos :: Constraint -> Constraint
updateEndPos c :: Constraint
c@(Constraint (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _) =
    Position -> Constraint -> Constraint
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Constraint
c
  updateEndPos c :: Constraint
c@(Constraint _ _ ty :: TypeExpr
ty) =
    Position -> Constraint -> Constraint
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd TypeExpr
ty) Constraint
c

instance HasSpanInfo (Lhs a) where
  getSpanInfo :: Lhs a -> SpanInfo
getSpanInfo (FunLhs sp :: SpanInfo
sp _ _)   = SpanInfo
sp
  getSpanInfo (OpLhs  sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (ApLhs  sp :: SpanInfo
sp _ _)   = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Lhs a -> Lhs a
setSpanInfo sp :: SpanInfo
sp (FunLhs _ idt :: Ident
idt ps :: [Pattern a]
ps)    = SpanInfo -> Ident -> [Pattern a] -> Lhs a
forall a. SpanInfo -> Ident -> [Pattern a] -> Lhs a
FunLhs SpanInfo
sp Ident
idt [Pattern a]
ps
  setSpanInfo sp :: SpanInfo
sp (OpLhs  _ p1 :: Pattern a
p1 idt :: Ident
idt p2 :: Pattern a
p2) = SpanInfo -> Pattern a -> Ident -> Pattern a -> Lhs a
forall a. SpanInfo -> Pattern a -> Ident -> Pattern a -> Lhs a
OpLhs SpanInfo
sp Pattern a
p1 Ident
idt Pattern a
p2
  setSpanInfo sp :: SpanInfo
sp (ApLhs  _ lhs :: Lhs a
lhs ps :: [Pattern a]
ps)    = SpanInfo -> Lhs a -> [Pattern a] -> Lhs a
forall a. SpanInfo -> Lhs a -> [Pattern a] -> Lhs a
ApLhs SpanInfo
sp Lhs a
lhs [Pattern a]
ps

  updateEndPos :: Lhs a -> Lhs a
updateEndPos l :: Lhs a
l@(FunLhs _ _ (p :: Pattern a
p:ps :: [Pattern a]
ps)) =
    Position -> Lhs a -> Lhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Pattern a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Pattern a] -> Pattern a
forall a. [a] -> a
last (Pattern a
pPattern a -> [Pattern a] -> [Pattern a]
forall a. a -> [a] -> [a]
:[Pattern a]
ps))) Lhs a
l
  updateEndPos l :: Lhs a
l@(FunLhs _ idt :: Ident
idt _) =
    Position -> Lhs a -> Lhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
idt) (Ident -> Int
identLength Ident
idt Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Lhs a
l
  updateEndPos l :: Lhs a
l@(OpLhs _ _ _ p :: Pattern a
p) =
    Position -> Lhs a -> Lhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Pattern a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Pattern a
p) Lhs a
l
  updateEndPos l :: Lhs a
l@(ApLhs _ _ (p :: Pattern a
p:ps :: [Pattern a]
ps)) =
    Position -> Lhs a -> Lhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Pattern a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Pattern a] -> Pattern a
forall a. [a] -> a
last (Pattern a
pPattern a -> [Pattern a] -> [Pattern a]
forall a. a -> [a] -> [a]
:[Pattern a]
ps))) Lhs a
l
  updateEndPos l :: Lhs a
l@(ApLhs (SpanInfo _ [_,s :: Span
s]) _ _) =
    Position -> Lhs a -> Lhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Lhs a
l
  updateEndPos l :: Lhs a
l@(ApLhs _ _ _) = Lhs a
l


instance HasSpanInfo (Rhs a) where
  getSpanInfo :: Rhs a -> SpanInfo
getSpanInfo (SimpleRhs sp :: SpanInfo
sp _ _ _)  = SpanInfo
sp
  getSpanInfo (GuardedRhs sp :: SpanInfo
sp _ _ _) = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Rhs a -> Rhs a
setSpanInfo sp :: SpanInfo
sp (SimpleRhs _ li :: LayoutInfo
li ex :: Expression a
ex ds :: [Decl a]
ds)  = SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Rhs a
forall a.
SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Rhs a
SimpleRhs SpanInfo
sp LayoutInfo
li Expression a
ex [Decl a]
ds
  setSpanInfo sp :: SpanInfo
sp (GuardedRhs _ li :: LayoutInfo
li cs :: [CondExpr a]
cs ds :: [Decl a]
ds) = SpanInfo -> LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a
forall a.
SpanInfo -> LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a
GuardedRhs SpanInfo
sp LayoutInfo
li [CondExpr a]
cs [Decl a]
ds

  updateEndPos :: Rhs a -> Rhs a
updateEndPos r :: Rhs a
r@(SimpleRhs (SpanInfo _ [_,_]) _ _ (d :: Decl a
d:ds :: [Decl a]
ds)) =
    Position -> Rhs a -> Rhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Decl a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Decl a] -> Decl a
forall a. [a] -> a
last (Decl a
dDecl a -> [Decl a] -> [Decl a]
forall a. a -> [a] -> [a]
:[Decl a]
ds))) Rhs a
r
  updateEndPos r :: Rhs a
r@(SimpleRhs (SpanInfo _ [_,s :: Span
s]) _ _ _) =
    Position -> Rhs a -> Rhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Rhs a
r
  updateEndPos r :: Rhs a
r@(SimpleRhs _ _ e :: Expression a
e _) =
    Position -> Rhs a -> Rhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e) Rhs a
r
  updateEndPos r :: Rhs a
r@(GuardedRhs (SpanInfo _ [_,_]) _ _ (d :: Decl a
d:ds :: [Decl a]
ds)) =
    Position -> Rhs a -> Rhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Decl a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Decl a] -> Decl a
forall a. [a] -> a
last (Decl a
dDecl a -> [Decl a] -> [Decl a]
forall a. a -> [a] -> [a]
:[Decl a]
ds))) Rhs a
r
  updateEndPos r :: Rhs a
r@(GuardedRhs (SpanInfo _ [_,s :: Span
s]) _ _ _) =
    Position -> Rhs a -> Rhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Rhs a
r
  updateEndPos r :: Rhs a
r@(GuardedRhs _ _ cs :: [CondExpr a]
cs _) =
    Position -> Rhs a -> Rhs a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (CondExpr a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([CondExpr a] -> CondExpr a
forall a. [a] -> a
last [CondExpr a]
cs)) Rhs a
r

  getLayoutInfo :: Rhs a -> LayoutInfo
getLayoutInfo (SimpleRhs _ li :: LayoutInfo
li _ _) = LayoutInfo
li
  getLayoutInfo (GuardedRhs _ li :: LayoutInfo
li _ _) = LayoutInfo
li

instance HasSpanInfo (CondExpr a) where
  getSpanInfo :: CondExpr a -> SpanInfo
getSpanInfo (CondExpr sp :: SpanInfo
sp _ _) = SpanInfo
sp
  setSpanInfo :: SpanInfo -> CondExpr a -> CondExpr a
setSpanInfo sp :: SpanInfo
sp (CondExpr _ e1 :: Expression a
e1 e2 :: Expression a
e2) = SpanInfo -> Expression a -> Expression a -> CondExpr a
forall a. SpanInfo -> Expression a -> Expression a -> CondExpr a
CondExpr SpanInfo
sp Expression a
e1 Expression a
e2
  updateEndPos :: CondExpr a -> CondExpr a
updateEndPos ce :: CondExpr a
ce@(CondExpr _ _ e :: Expression a
e) =
    Position -> CondExpr a -> CondExpr a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e) CondExpr a
ce

instance HasSpanInfo (Pattern a) where
  getSpanInfo :: Pattern a -> SpanInfo
getSpanInfo (LiteralPattern  sp :: SpanInfo
sp _ _)      = SpanInfo
sp
  getSpanInfo (NegativePattern sp :: SpanInfo
sp _ _)      = SpanInfo
sp
  getSpanInfo (VariablePattern sp :: SpanInfo
sp _ _)      = SpanInfo
sp
  getSpanInfo (ConstructorPattern sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (InfixPattern sp :: SpanInfo
sp _ _ _ _)     = SpanInfo
sp
  getSpanInfo (ParenPattern sp :: SpanInfo
sp _)           = SpanInfo
sp
  getSpanInfo (RecordPattern sp :: SpanInfo
sp _ _ _)      = SpanInfo
sp
  getSpanInfo (TuplePattern sp :: SpanInfo
sp _)           = SpanInfo
sp
  getSpanInfo (ListPattern sp :: SpanInfo
sp _ _)          = SpanInfo
sp
  getSpanInfo (AsPattern sp :: SpanInfo
sp _ _)            = SpanInfo
sp
  getSpanInfo (LazyPattern sp :: SpanInfo
sp _)            = SpanInfo
sp
  getSpanInfo (FunctionPattern sp :: SpanInfo
sp _ _ _)    = SpanInfo
sp
  getSpanInfo (InfixFuncPattern sp :: SpanInfo
sp _ _ _ _) = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Pattern a -> Pattern a
setSpanInfo sp :: SpanInfo
sp (LiteralPattern _ a :: a
a l :: Literal
l) = SpanInfo -> a -> Literal -> Pattern a
forall a. SpanInfo -> a -> Literal -> Pattern a
LiteralPattern SpanInfo
sp a
a Literal
l
  setSpanInfo sp :: SpanInfo
sp (NegativePattern _ a :: a
a l :: Literal
l) = SpanInfo -> a -> Literal -> Pattern a
forall a. SpanInfo -> a -> Literal -> Pattern a
NegativePattern SpanInfo
sp a
a Literal
l
  setSpanInfo sp :: SpanInfo
sp (VariablePattern _ a :: a
a v :: Ident
v) = SpanInfo -> a -> Ident -> Pattern a
forall a. SpanInfo -> a -> Ident -> Pattern a
VariablePattern SpanInfo
sp a
a Ident
v
  setSpanInfo sp :: SpanInfo
sp (ConstructorPattern _ a :: a
a c :: QualIdent
c ts :: [Pattern a]
ts) = SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
forall a. SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
ConstructorPattern SpanInfo
sp a
a QualIdent
c [Pattern a]
ts
  setSpanInfo sp :: SpanInfo
sp (InfixPattern _ a :: a
a t1 :: Pattern a
t1 op :: QualIdent
op t2 :: Pattern a
t2) = SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
forall a.
SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
InfixPattern SpanInfo
sp a
a Pattern a
t1 QualIdent
op Pattern a
t2
  setSpanInfo sp :: SpanInfo
sp (ParenPattern _ t :: Pattern a
t) = SpanInfo -> Pattern a -> Pattern a
forall a. SpanInfo -> Pattern a -> Pattern a
ParenPattern SpanInfo
sp Pattern a
t
  setSpanInfo sp :: SpanInfo
sp (RecordPattern _ a :: a
a c :: QualIdent
c fs :: [Field (Pattern a)]
fs) = SpanInfo -> a -> QualIdent -> [Field (Pattern a)] -> Pattern a
forall a.
SpanInfo -> a -> QualIdent -> [Field (Pattern a)] -> Pattern a
RecordPattern SpanInfo
sp a
a QualIdent
c [Field (Pattern a)]
fs
  setSpanInfo sp :: SpanInfo
sp (TuplePattern _ ts :: [Pattern a]
ts) = SpanInfo -> [Pattern a] -> Pattern a
forall a. SpanInfo -> [Pattern a] -> Pattern a
TuplePattern SpanInfo
sp [Pattern a]
ts
  setSpanInfo sp :: SpanInfo
sp (ListPattern _ a :: a
a ts :: [Pattern a]
ts) = SpanInfo -> a -> [Pattern a] -> Pattern a
forall a. SpanInfo -> a -> [Pattern a] -> Pattern a
ListPattern SpanInfo
sp a
a [Pattern a]
ts
  setSpanInfo sp :: SpanInfo
sp (AsPattern _ v :: Ident
v t :: Pattern a
t) = SpanInfo -> Ident -> Pattern a -> Pattern a
forall a. SpanInfo -> Ident -> Pattern a -> Pattern a
AsPattern SpanInfo
sp Ident
v Pattern a
t
  setSpanInfo sp :: SpanInfo
sp (LazyPattern _ t :: Pattern a
t) = SpanInfo -> Pattern a -> Pattern a
forall a. SpanInfo -> Pattern a -> Pattern a
LazyPattern SpanInfo
sp Pattern a
t
  setSpanInfo sp :: SpanInfo
sp (FunctionPattern _ a :: a
a f' :: QualIdent
f' ts :: [Pattern a]
ts) = SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
forall a. SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
FunctionPattern SpanInfo
sp a
a QualIdent
f' [Pattern a]
ts
  setSpanInfo sp :: SpanInfo
sp (InfixFuncPattern _ a :: a
a t1 :: Pattern a
t1 op :: QualIdent
op t2 :: Pattern a
t2) = SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
forall a.
SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
InfixFuncPattern SpanInfo
sp a
a Pattern a
t1 QualIdent
op Pattern a
t2

  updateEndPos :: Pattern a -> Pattern a
updateEndPos p :: Pattern a
p@(LiteralPattern  _ _ _) = Pattern a
p
  updateEndPos p :: Pattern a
p@(NegativePattern _ _ _) = Pattern a
p
  updateEndPos p :: Pattern a
p@(VariablePattern _ _ v :: Ident
v) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (Ident -> Position
forall a. HasPosition a => a -> Position
getPosition Ident
v) (Ident -> Int
identLength Ident
v Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Pattern a
p
  updateEndPos p :: Pattern a
p@(ConstructorPattern _ _ _ (t :: Pattern a
t:ts :: [Pattern a]
ts)) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Pattern a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Pattern a] -> Pattern a
forall a. [a] -> a
last (Pattern a
tPattern a -> [Pattern a] -> [Pattern a]
forall a. a -> [a] -> [a]
:[Pattern a]
ts))) Pattern a
p
  updateEndPos p :: Pattern a
p@(ConstructorPattern _ _ c :: QualIdent
c _) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
c) (QualIdent -> Int
qIdentLength QualIdent
c Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Pattern a
p
  updateEndPos p :: Pattern a
p@(InfixPattern _ _ _ _ t2 :: Pattern a
t2) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Pattern a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Pattern a
t2) Pattern a
p
  updateEndPos p :: Pattern a
p@(ParenPattern (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Pattern a
p
  updateEndPos p :: Pattern a
p@(ParenPattern _ _) = Pattern a
p
  updateEndPos p :: Pattern a
p@(RecordPattern (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _ _) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Pattern a
p
  updateEndPos p :: Pattern a
p@(RecordPattern _ _ _ _) = Pattern a
p
  updateEndPos p :: Pattern a
p@(TuplePattern (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Pattern a
p
  updateEndPos p :: Pattern a
p@(TuplePattern _ _) = Pattern a
p
  updateEndPos p :: Pattern a
p@(ListPattern (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Pattern a
p
  updateEndPos p :: Pattern a
p@(ListPattern _ _ _) = Pattern a
p
  updateEndPos p :: Pattern a
p@(AsPattern _ _ t :: Pattern a
t) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Pattern a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Pattern a
t) Pattern a
p
  updateEndPos p :: Pattern a
p@(LazyPattern _ t :: Pattern a
t) =
    Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Pattern a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Pattern a
t) Pattern a
p
  updateEndPos p :: Pattern a
p@(FunctionPattern _ _ _ _) = Pattern a
p
  updateEndPos p :: Pattern a
p@(InfixFuncPattern _ _ _ _ _) = Pattern a
p

instance HasSpanInfo (Expression a) where
  getSpanInfo :: Expression a -> SpanInfo
getSpanInfo (Literal sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (Variable sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (Constructor sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (Paren sp :: SpanInfo
sp _) = SpanInfo
sp
  getSpanInfo (Typed sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (Record sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (RecordUpdate sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (Tuple sp :: SpanInfo
sp _) = SpanInfo
sp
  getSpanInfo (List sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (ListCompr sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (EnumFrom sp :: SpanInfo
sp _) = SpanInfo
sp
  getSpanInfo (EnumFromThen sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (EnumFromTo sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (EnumFromThenTo sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (UnaryMinus sp :: SpanInfo
sp _) = SpanInfo
sp
  getSpanInfo (Apply sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (InfixApply sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (LeftSection sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (RightSection sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (Lambda sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (Let sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (Do sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (IfThenElse sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  getSpanInfo (Case sp :: SpanInfo
sp _ _ _ _) = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Expression a -> Expression a
setSpanInfo sp :: SpanInfo
sp (Literal _ a :: a
a l :: Literal
l) = SpanInfo -> a -> Literal -> Expression a
forall a. SpanInfo -> a -> Literal -> Expression a
Literal SpanInfo
sp a
a Literal
l
  setSpanInfo sp :: SpanInfo
sp (Variable _ a :: a
a v :: QualIdent
v) = SpanInfo -> a -> QualIdent -> Expression a
forall a. SpanInfo -> a -> QualIdent -> Expression a
Variable SpanInfo
sp a
a QualIdent
v
  setSpanInfo sp :: SpanInfo
sp (Constructor _ a :: a
a c :: QualIdent
c) = SpanInfo -> a -> QualIdent -> Expression a
forall a. SpanInfo -> a -> QualIdent -> Expression a
Constructor SpanInfo
sp a
a QualIdent
c
  setSpanInfo sp :: SpanInfo
sp (Paren _ e :: Expression a
e) = SpanInfo -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a
Paren SpanInfo
sp Expression a
e
  setSpanInfo sp :: SpanInfo
sp (Typed _ e :: Expression a
e qty :: QualTypeExpr
qty) = SpanInfo -> Expression a -> QualTypeExpr -> Expression a
forall a. SpanInfo -> Expression a -> QualTypeExpr -> Expression a
Typed SpanInfo
sp Expression a
e QualTypeExpr
qty
  setSpanInfo sp :: SpanInfo
sp (Record _ a :: a
a c :: QualIdent
c fs :: [Field (Expression a)]
fs) = SpanInfo
-> a -> QualIdent -> [Field (Expression a)] -> Expression a
forall a.
SpanInfo
-> a -> QualIdent -> [Field (Expression a)] -> Expression a
Record SpanInfo
sp a
a QualIdent
c [Field (Expression a)]
fs
  setSpanInfo sp :: SpanInfo
sp (RecordUpdate _ e :: Expression a
e fs :: [Field (Expression a)]
fs) = SpanInfo -> Expression a -> [Field (Expression a)] -> Expression a
forall a.
SpanInfo -> Expression a -> [Field (Expression a)] -> Expression a
RecordUpdate SpanInfo
sp Expression a
e [Field (Expression a)]
fs
  setSpanInfo sp :: SpanInfo
sp (Tuple _ es :: [Expression a]
es) = SpanInfo -> [Expression a] -> Expression a
forall a. SpanInfo -> [Expression a] -> Expression a
Tuple SpanInfo
sp [Expression a]
es
  setSpanInfo sp :: SpanInfo
sp (List _ a :: a
a es :: [Expression a]
es) = SpanInfo -> a -> [Expression a] -> Expression a
forall a. SpanInfo -> a -> [Expression a] -> Expression a
List SpanInfo
sp a
a [Expression a]
es
  setSpanInfo sp :: SpanInfo
sp (ListCompr _ e :: Expression a
e stms :: [Statement a]
stms) = SpanInfo -> Expression a -> [Statement a] -> Expression a
forall a. SpanInfo -> Expression a -> [Statement a] -> Expression a
ListCompr SpanInfo
sp Expression a
e [Statement a]
stms
  setSpanInfo sp :: SpanInfo
sp (EnumFrom _ e :: Expression a
e) = SpanInfo -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a
EnumFrom SpanInfo
sp Expression a
e
  setSpanInfo sp :: SpanInfo
sp (EnumFromThen _ e1 :: Expression a
e1 e2 :: Expression a
e2) = SpanInfo -> Expression a -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
EnumFromThen SpanInfo
sp Expression a
e1 Expression a
e2
  setSpanInfo sp :: SpanInfo
sp (EnumFromTo _ e1 :: Expression a
e1 e2 :: Expression a
e2) = SpanInfo -> Expression a -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
EnumFromTo SpanInfo
sp Expression a
e1 Expression a
e2
  setSpanInfo sp :: SpanInfo
sp (EnumFromThenTo _ e1 :: Expression a
e1 e2 :: Expression a
e2 e3 :: Expression a
e3) = SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
forall a.
SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
EnumFromThenTo SpanInfo
sp Expression a
e1 Expression a
e2 Expression a
e3
  setSpanInfo sp :: SpanInfo
sp (UnaryMinus _ e :: Expression a
e) = SpanInfo -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a
UnaryMinus SpanInfo
sp Expression a
e
  setSpanInfo sp :: SpanInfo
sp (Apply _ e1 :: Expression a
e1 e2 :: Expression a
e2) = SpanInfo -> Expression a -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
Apply SpanInfo
sp Expression a
e1 Expression a
e2
  setSpanInfo sp :: SpanInfo
sp (InfixApply _ e1 :: Expression a
e1 op :: InfixOp a
op e2 :: Expression a
e2) = SpanInfo
-> Expression a -> InfixOp a -> Expression a -> Expression a
forall a.
SpanInfo
-> Expression a -> InfixOp a -> Expression a -> Expression a
InfixApply SpanInfo
sp Expression a
e1 InfixOp a
op Expression a
e2
  setSpanInfo sp :: SpanInfo
sp (LeftSection _ e :: Expression a
e op :: InfixOp a
op) = SpanInfo -> Expression a -> InfixOp a -> Expression a
forall a. SpanInfo -> Expression a -> InfixOp a -> Expression a
LeftSection SpanInfo
sp Expression a
e InfixOp a
op
  setSpanInfo sp :: SpanInfo
sp (RightSection _ op :: InfixOp a
op e :: Expression a
e) = SpanInfo -> InfixOp a -> Expression a -> Expression a
forall a. SpanInfo -> InfixOp a -> Expression a -> Expression a
RightSection SpanInfo
sp InfixOp a
op Expression a
e
  setSpanInfo sp :: SpanInfo
sp (Lambda _ ts :: [Pattern a]
ts e :: Expression a
e) = SpanInfo -> [Pattern a] -> Expression a -> Expression a
forall a. SpanInfo -> [Pattern a] -> Expression a -> Expression a
Lambda SpanInfo
sp [Pattern a]
ts Expression a
e
  setSpanInfo sp :: SpanInfo
sp (Let _ li :: LayoutInfo
li ds :: [Decl a]
ds e :: Expression a
e) = SpanInfo -> LayoutInfo -> [Decl a] -> Expression a -> Expression a
forall a.
SpanInfo -> LayoutInfo -> [Decl a] -> Expression a -> Expression a
Let SpanInfo
sp LayoutInfo
li [Decl a]
ds Expression a
e
  setSpanInfo sp :: SpanInfo
sp (Do _ li :: LayoutInfo
li stms :: [Statement a]
stms e :: Expression a
e) = SpanInfo
-> LayoutInfo -> [Statement a] -> Expression a -> Expression a
forall a.
SpanInfo
-> LayoutInfo -> [Statement a] -> Expression a -> Expression a
Do SpanInfo
sp LayoutInfo
li [Statement a]
stms Expression a
e
  setSpanInfo sp :: SpanInfo
sp (IfThenElse _ e1 :: Expression a
e1 e2 :: Expression a
e2 e3 :: Expression a
e3) = SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
forall a.
SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
IfThenElse SpanInfo
sp Expression a
e1 Expression a
e2 Expression a
e3
  setSpanInfo sp :: SpanInfo
sp (Case _ li :: LayoutInfo
li ct :: CaseType
ct e :: Expression a
e as :: [Alt a]
as) = SpanInfo
-> LayoutInfo
-> CaseType
-> Expression a
-> [Alt a]
-> Expression a
forall a.
SpanInfo
-> LayoutInfo
-> CaseType
-> Expression a
-> [Alt a]
-> Expression a
Case SpanInfo
sp LayoutInfo
li CaseType
ct Expression a
e [Alt a]
as

  updateEndPos :: Expression a -> Expression a
updateEndPos e :: Expression a
e@(Literal _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(Variable _ _ v :: QualIdent
v) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
v) (QualIdent -> Int
qIdentLength QualIdent
v Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Expression a
e
  updateEndPos e :: Expression a
e@(Constructor _ _ c :: QualIdent
c) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Position -> Int -> Position
incr (QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
c) (QualIdent -> Int
qIdentLength QualIdent
c Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) Expression a
e
  updateEndPos e :: Expression a
e@(Paren (SpanInfo _ [_,s :: Span
s]) _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Expression a
e
  updateEndPos e :: Expression a
e@(Paren _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(Typed _ _ qty :: QualTypeExpr
qty) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (QualTypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd QualTypeExpr
qty) Expression a
e
  updateEndPos e :: Expression a
e@(Record (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Expression a
e
  updateEndPos e :: Expression a
e@(Record _ _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(RecordUpdate (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Expression a
e
  updateEndPos e :: Expression a
e@(RecordUpdate _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(Tuple (SpanInfo _ [_,s :: Span
s]) _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Expression a
e
  updateEndPos e :: Expression a
e@(Tuple _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(List (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Expression a
e
  updateEndPos e :: Expression a
e@(List _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(ListCompr (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Expression a
e
  updateEndPos e :: Expression a
e@(ListCompr _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(EnumFrom (SpanInfo _ [_,_,s :: Span
s]) _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Expression a
e
  updateEndPos e :: Expression a
e@(EnumFrom _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(EnumFromTo (SpanInfo _ [_,_,s :: Span
s]) _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Expression a
e
  updateEndPos e :: Expression a
e@(EnumFromTo _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(EnumFromThen (SpanInfo _ [_,_,_,s :: Span
s]) _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Expression a
e
  updateEndPos e :: Expression a
e@(EnumFromThen _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(EnumFromThenTo (SpanInfo _ [_,_,_,s :: Span
s]) _ _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Expression a
e
  updateEndPos e :: Expression a
e@(EnumFromThenTo _ _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(UnaryMinus _ e' :: Expression a
e') =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e') Expression a
e
  updateEndPos e :: Expression a
e@(Apply _ _ e' :: Expression a
e') =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e') Expression a
e
  updateEndPos e :: Expression a
e@(InfixApply _ _ _ e' :: Expression a
e') =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e') Expression a
e
  updateEndPos e :: Expression a
e@(LeftSection (SpanInfo _ [_,s :: Span
s]) _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Expression a
e
  updateEndPos e :: Expression a
e@(LeftSection _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(RightSection (SpanInfo _ [_,s :: Span
s]) _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Expression a
e
  updateEndPos e :: Expression a
e@(RightSection _ _ _) = Expression a
e
  updateEndPos e :: Expression a
e@(Lambda _ _ e' :: Expression a
e') =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e') Expression a
e
  updateEndPos e :: Expression a
e@(Let _ _ _ e' :: Expression a
e') =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e') Expression a
e
  updateEndPos e :: Expression a
e@(Do _ _ _ e' :: Expression a
e') =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e') Expression a
e
  updateEndPos e :: Expression a
e@(IfThenElse _ _ _ e' :: Expression a
e') =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e') Expression a
e
  updateEndPos e :: Expression a
e@(Case _ _ _ _ (a :: Alt a
a:as :: [Alt a]
as)) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Alt a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Alt a] -> Alt a
forall a. [a] -> a
last (Alt a
aAlt a -> [Alt a] -> [Alt a]
forall a. a -> [a] -> [a]
:[Alt a]
as))) Expression a
e
  updateEndPos e :: Expression a
e@(Case (SpanInfo _ (s :: Span
s:ss :: [Span]
ss)) _ _ _ _) =
    Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last (Span
sSpan -> [Span] -> [Span]
forall a. a -> [a] -> [a]
:[Span]
ss))) Expression a
e
  updateEndPos e :: Expression a
e@(Case _ _ _ _ _) = Expression a
e

  getLayoutInfo :: Expression a -> LayoutInfo
getLayoutInfo (Let _ li :: LayoutInfo
li _ _) = LayoutInfo
li
  getLayoutInfo (Do _ li :: LayoutInfo
li _ _) = LayoutInfo
li
  getLayoutInfo (Case _ li :: LayoutInfo
li _ _ _) = LayoutInfo
li
  getLayoutInfo _ = LayoutInfo
WhitespaceLayout

instance HasSpanInfo (Statement a) where
  getSpanInfo :: Statement a -> SpanInfo
getSpanInfo (StmtExpr sp :: SpanInfo
sp _)   = SpanInfo
sp
  getSpanInfo (StmtDecl sp :: SpanInfo
sp _ _) = SpanInfo
sp
  getSpanInfo (StmtBind sp :: SpanInfo
sp _ _) = SpanInfo
sp

  setSpanInfo :: SpanInfo -> Statement a -> Statement a
setSpanInfo sp :: SpanInfo
sp (StmtExpr _    ex :: Expression a
ex) = SpanInfo -> Expression a -> Statement a
forall a. SpanInfo -> Expression a -> Statement a
StmtExpr SpanInfo
sp Expression a
ex
  setSpanInfo sp :: SpanInfo
sp (StmtDecl _ li :: LayoutInfo
li ds :: [Decl a]
ds) = SpanInfo -> LayoutInfo -> [Decl a] -> Statement a
forall a. SpanInfo -> LayoutInfo -> [Decl a] -> Statement a
StmtDecl SpanInfo
sp LayoutInfo
li [Decl a]
ds
  setSpanInfo sp :: SpanInfo
sp (StmtBind _ p :: Pattern a
p  ex :: Expression a
ex) = SpanInfo -> Pattern a -> Expression a -> Statement a
forall a. SpanInfo -> Pattern a -> Expression a -> Statement a
StmtBind SpanInfo
sp Pattern a
p Expression a
ex

  updateEndPos :: Statement a -> Statement a
updateEndPos s :: Statement a
s@(StmtExpr _ e :: Expression a
e) =
    Position -> Statement a -> Statement a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e) Statement a
s
  updateEndPos s :: Statement a
s@(StmtBind _ _ e :: Expression a
e) =
    Position -> Statement a -> Statement a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Expression a
e) Statement a
s
  updateEndPos s :: Statement a
s@(StmtDecl _ _ (d :: Decl a
d:ds :: [Decl a]
ds)) =
    Position -> Statement a -> Statement a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Decl a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Decl a] -> Decl a
forall a. [a] -> a
last (Decl a
dDecl a -> [Decl a] -> [Decl a]
forall a. a -> [a] -> [a]
:[Decl a]
ds))) Statement a
s
  updateEndPos s :: Statement a
s@(StmtDecl (SpanInfo _ [s' :: Span
s']) _ _) = -- empty let
    Position -> Statement a -> Statement a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s') Statement a
s
  updateEndPos s :: Statement a
s@(StmtDecl _ _ _) = Statement a
s

  getLayoutInfo :: Statement a -> LayoutInfo
getLayoutInfo (StmtDecl _ li :: LayoutInfo
li _) = LayoutInfo
li
  getLayoutInfo _ = LayoutInfo
WhitespaceLayout

instance HasSpanInfo (Alt a) where
  getSpanInfo :: Alt a -> SpanInfo
getSpanInfo (Alt sp :: SpanInfo
sp _ _) = SpanInfo
sp
  setSpanInfo :: SpanInfo -> Alt a -> Alt a
setSpanInfo sp :: SpanInfo
sp (Alt _ p :: Pattern a
p rhs :: Rhs a
rhs) = SpanInfo -> Pattern a -> Rhs a -> Alt a
forall a. SpanInfo -> Pattern a -> Rhs a -> Alt a
Alt SpanInfo
sp Pattern a
p Rhs a
rhs
  updateEndPos :: Alt a -> Alt a
updateEndPos a :: Alt a
a@(Alt _ _ rhs :: Rhs a
rhs) =
    Position -> Alt a -> Alt a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Rhs a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd Rhs a
rhs) Alt a
a

instance HasSpanInfo (Field a) where
  getSpanInfo :: Field a -> SpanInfo
getSpanInfo (Field sp :: SpanInfo
sp _ _) = SpanInfo
sp
  setSpanInfo :: SpanInfo -> Field a -> Field a
setSpanInfo sp :: SpanInfo
sp (Field _ qid :: QualIdent
qid a :: a
a) = SpanInfo -> QualIdent -> a -> Field a
forall a. SpanInfo -> QualIdent -> a -> Field a
Field SpanInfo
sp QualIdent
qid a
a
  updateEndPos :: Field a -> Field a
updateEndPos f :: Field a
f@(Field (SpanInfo _ ss :: [Span]
ss) _ _) =
    Position -> Field a -> Field a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end ([Span] -> Span
forall a. [a] -> a
last [Span]
ss)) Field a
f
  updateEndPos f :: Field a
f@ (Field _ _ _) = Field a
f

instance HasSpanInfo (Goal a) where
  getSpanInfo :: Goal a -> SpanInfo
getSpanInfo (Goal sp :: SpanInfo
sp _ _ _) = SpanInfo
sp
  setSpanInfo :: SpanInfo -> Goal a -> Goal a
setSpanInfo sp :: SpanInfo
sp (Goal _ li :: LayoutInfo
li e :: Expression a
e ds :: [Decl a]
ds) = SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Goal a
forall a.
SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Goal a
Goal SpanInfo
sp LayoutInfo
li Expression a
e [Decl a]
ds

  updateEndPos :: Goal a -> Goal a
updateEndPos g :: Goal a
g@(Goal (SpanInfo _ [_]) _ _ (d :: Decl a
d:ds :: [Decl a]
ds)) =
    Position -> Goal a -> Goal a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Decl a -> Position
forall a. HasSpanInfo a => a -> Position
getSrcSpanEnd ([Decl a] -> Decl a
forall a. [a] -> a
last (Decl a
dDecl a -> [Decl a] -> [Decl a]
forall a. a -> [a] -> [a]
:[Decl a]
ds))) Goal a
g
  updateEndPos g :: Goal a
g@(Goal (SpanInfo _ [s :: Span
s]) _ _ _) =
    Position -> Goal a -> Goal a
forall a. HasSpanInfo a => Position -> a -> a
setEndPosition (Span -> Position
end Span
s) Goal a
g
  updateEndPos g :: Goal a
g@(Goal _ _ _ _) = Goal a
g

  getLayoutInfo :: Goal a -> LayoutInfo
getLayoutInfo (Goal _ li :: LayoutInfo
li _ _) = LayoutInfo
li

instance HasPosition (Module a) where
  getPosition :: Module a -> Position
getPosition = Module a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Module a -> Module a
setPosition = Position -> Module a -> Module a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Decl a) where
  getPosition :: Decl a -> Position
getPosition = Decl a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Decl a -> Decl a
setPosition = Position -> Decl a -> Decl a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Equation a) where
  getPosition :: Equation a -> Position
getPosition = Equation a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Equation a -> Equation a
setPosition = Position -> Equation a -> Equation a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition ModulePragma where
  getPosition :: ModulePragma -> Position
getPosition = ModulePragma -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> ModulePragma -> ModulePragma
setPosition = Position -> ModulePragma -> ModulePragma
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition ExportSpec where
  getPosition :: ExportSpec -> Position
getPosition = ExportSpec -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> ExportSpec -> ExportSpec
setPosition = Position -> ExportSpec -> ExportSpec
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition ImportDecl where
  getPosition :: ImportDecl -> Position
getPosition = ImportDecl -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> ImportDecl -> ImportDecl
setPosition = Position -> ImportDecl -> ImportDecl
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition ImportSpec where
  getPosition :: ImportSpec -> Position
getPosition = ImportSpec -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> ImportSpec -> ImportSpec
setPosition = Position -> ImportSpec -> ImportSpec
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition Export where
  getPosition :: Export -> Position
getPosition = Export -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Export -> Export
setPosition = Position -> Export -> Export
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition Import where
  getPosition :: Import -> Position
getPosition = Import -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Import -> Import
setPosition = Position -> Import -> Import
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition ConstrDecl where
  getPosition :: ConstrDecl -> Position
getPosition = ConstrDecl -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> ConstrDecl -> ConstrDecl
setPosition = Position -> ConstrDecl -> ConstrDecl
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition TypeExpr where
  getPosition :: TypeExpr -> Position
getPosition = TypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> TypeExpr -> TypeExpr
setPosition = Position -> TypeExpr -> TypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition QualTypeExpr where
  getPosition :: QualTypeExpr -> Position
getPosition = QualTypeExpr -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> QualTypeExpr -> QualTypeExpr
setPosition = Position -> QualTypeExpr -> QualTypeExpr
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition NewConstrDecl where
  getPosition :: NewConstrDecl -> Position
getPosition = NewConstrDecl -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> NewConstrDecl -> NewConstrDecl
setPosition = Position -> NewConstrDecl -> NewConstrDecl
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition Constraint where
  getPosition :: Constraint -> Position
getPosition = Constraint -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Constraint -> Constraint
setPosition = Position -> Constraint -> Constraint
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition FieldDecl where
  getPosition :: FieldDecl -> Position
getPosition = FieldDecl -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> FieldDecl -> FieldDecl
setPosition = Position -> FieldDecl -> FieldDecl
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Lhs a) where
  getPosition :: Lhs a -> Position
getPosition = Lhs a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Lhs a -> Lhs a
setPosition = Position -> Lhs a -> Lhs a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Rhs a) where
  getPosition :: Rhs a -> Position
getPosition = Rhs a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Rhs a -> Rhs a
setPosition = Position -> Rhs a -> Rhs a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (CondExpr a) where
  getPosition :: CondExpr a -> Position
getPosition = CondExpr a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition

instance HasPosition (Pattern a) where
  getPosition :: Pattern a -> Position
getPosition = Pattern a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Pattern a -> Pattern a
setPosition = Position -> Pattern a -> Pattern a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Expression a) where
  getPosition :: Expression a -> Position
getPosition = Expression a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Expression a -> Expression a
setPosition = Position -> Expression a -> Expression a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Alt a) where
  getPosition :: Alt a -> Position
getPosition = Alt a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Alt a -> Alt a
setPosition = Position -> Alt a -> Alt a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Goal a) where
  getPosition :: Goal a -> Position
getPosition = Goal a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Goal a -> Goal a
setPosition = Position -> Goal a -> Goal a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Field a) where
  getPosition :: Field a -> Position
getPosition = Field a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Field a -> Field a
setPosition = Position -> Field a -> Field a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (Statement a) where
  getPosition :: Statement a -> Position
getPosition = Statement a -> Position
forall a. HasSpanInfo a => a -> Position
getStartPosition
  setPosition :: Position -> Statement a -> Statement a
setPosition = Position -> Statement a -> Statement a
forall a. HasSpanInfo a => Position -> a -> a
setStartPosition

instance HasPosition (InfixOp a) where
  getPosition :: InfixOp a -> Position
getPosition (InfixOp     _ q :: QualIdent
q) = QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
q
  getPosition (InfixConstr _ q :: QualIdent
q) = QualIdent -> Position
forall a. HasPosition a => a -> Position
getPosition QualIdent
q

  setPosition :: Position -> InfixOp a -> InfixOp a
setPosition p :: Position
p (InfixOp     a :: a
a q :: QualIdent
q) = a -> QualIdent -> InfixOp a
forall a. a -> QualIdent -> InfixOp a
InfixOp     a
a (Position -> QualIdent -> QualIdent
forall a. HasPosition a => Position -> a -> a
setPosition Position
p QualIdent
q)
  setPosition p :: Position
p (InfixConstr a :: a
a q :: QualIdent
q) = a -> QualIdent -> InfixOp a
forall a. a -> QualIdent -> InfixOp a
InfixConstr a
a (Position -> QualIdent -> QualIdent
forall a. HasPosition a => Position -> a -> a
setPosition Position
p QualIdent
q)

instance Binary a => Binary (Module a) where
  put :: Module a -> Put
put (Module spi :: SpanInfo
spi li :: LayoutInfo
li ps :: [ModulePragma]
ps mid :: ModuleIdent
mid ex :: Maybe ExportSpec
ex im :: [ImportDecl]
im ds :: [Decl a]
ds) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [ModulePragma] -> Put
forall t. Binary t => t -> Put
put [ModulePragma]
ps Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
                                        ModuleIdent -> Put
forall t. Binary t => t -> Put
put ModuleIdent
mid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Maybe ExportSpec -> Put
forall t. Binary t => t -> Put
put Maybe ExportSpec
ex Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [ImportDecl] -> Put
forall t. Binary t => t -> Put
put [ImportDecl]
im Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Decl a] -> Put
forall t. Binary t => t -> Put
put [Decl a]
ds
  get :: Get (Module a)
get = SpanInfo
-> LayoutInfo
-> [ModulePragma]
-> ModuleIdent
-> Maybe ExportSpec
-> [ImportDecl]
-> [Decl a]
-> Module a
forall a.
SpanInfo
-> LayoutInfo
-> [ModulePragma]
-> ModuleIdent
-> Maybe ExportSpec
-> [ImportDecl]
-> [Decl a]
-> Module a
Module (SpanInfo
 -> LayoutInfo
 -> [ModulePragma]
 -> ModuleIdent
 -> Maybe ExportSpec
 -> [ImportDecl]
 -> [Decl a]
 -> Module a)
-> Get SpanInfo
-> Get
     (LayoutInfo
      -> [ModulePragma]
      -> ModuleIdent
      -> Maybe ExportSpec
      -> [ImportDecl]
      -> [Decl a]
      -> Module a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get
  (LayoutInfo
   -> [ModulePragma]
   -> ModuleIdent
   -> Maybe ExportSpec
   -> [ImportDecl]
   -> [Decl a]
   -> Module a)
-> Get LayoutInfo
-> Get
     ([ModulePragma]
      -> ModuleIdent
      -> Maybe ExportSpec
      -> [ImportDecl]
      -> [Decl a]
      -> Module a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get LayoutInfo
forall t. Binary t => Get t
get Get
  ([ModulePragma]
   -> ModuleIdent
   -> Maybe ExportSpec
   -> [ImportDecl]
   -> [Decl a]
   -> Module a)
-> Get [ModulePragma]
-> Get
     (ModuleIdent
      -> Maybe ExportSpec -> [ImportDecl] -> [Decl a] -> Module a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [ModulePragma]
forall t. Binary t => Get t
get Get
  (ModuleIdent
   -> Maybe ExportSpec -> [ImportDecl] -> [Decl a] -> Module a)
-> Get ModuleIdent
-> Get (Maybe ExportSpec -> [ImportDecl] -> [Decl a] -> Module a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get ModuleIdent
forall t. Binary t => Get t
get Get (Maybe ExportSpec -> [ImportDecl] -> [Decl a] -> Module a)
-> Get (Maybe ExportSpec)
-> Get ([ImportDecl] -> [Decl a] -> Module a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Maybe ExportSpec)
forall t. Binary t => Get t
get Get ([ImportDecl] -> [Decl a] -> Module a)
-> Get [ImportDecl] -> Get ([Decl a] -> Module a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [ImportDecl]
forall t. Binary t => Get t
get Get ([Decl a] -> Module a) -> Get [Decl a] -> Get (Module a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Decl a]
forall t. Binary t => Get t
get

instance Binary ModulePragma where
  put :: ModulePragma -> Put
put (LanguagePragma spi :: SpanInfo
spi ex :: [Extension]
ex  ) = Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Extension] -> Put
forall t. Binary t => t -> Put
put [Extension]
ex
  put (OptionsPragma  spi :: SpanInfo
spi t :: Maybe Tool
t  s :: String
s) = Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Maybe Tool -> Put
forall t. Binary t => t -> Put
put Maybe Tool
t Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> Put
forall t. Binary t => t -> Put
put String
s

  get :: Get ModulePragma
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> [Extension] -> ModulePragma)
-> Get SpanInfo -> Get [Extension] -> Get ModulePragma
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> [Extension] -> ModulePragma
LanguagePragma Get SpanInfo
forall t. Binary t => Get t
get Get [Extension]
forall t. Binary t => Get t
get
      1 -> (SpanInfo -> Maybe Tool -> String -> ModulePragma)
-> Get SpanInfo
-> Get (Maybe Tool)
-> Get String
-> Get ModulePragma
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Maybe Tool -> String -> ModulePragma
OptionsPragma Get SpanInfo
forall t. Binary t => Get t
get Get (Maybe Tool)
forall t. Binary t => Get t
get Get String
forall t. Binary t => Get t
get
      _ -> String -> Get ModulePragma
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for ModulePragma"

instance Binary ExportSpec where
  put :: ExportSpec -> Put
put (Exporting spi :: SpanInfo
spi es :: [Export]
es) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Export] -> Put
forall t. Binary t => t -> Put
put [Export]
es
  get :: Get ExportSpec
get = (SpanInfo -> [Export] -> ExportSpec)
-> Get SpanInfo -> Get [Export] -> Get ExportSpec
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> [Export] -> ExportSpec
Exporting Get SpanInfo
forall t. Binary t => Get t
get Get [Export]
forall t. Binary t => Get t
get

instance Binary Export where
  put :: Export -> Put
put (Export         spi :: SpanInfo
spi qid :: QualIdent
qid   ) = Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid
  put (ExportTypeWith spi :: SpanInfo
spi qid :: QualIdent
qid is :: [Ident]
is) = Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
is
  put (ExportTypeAll  spi :: SpanInfo
spi qid :: QualIdent
qid   ) = Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid
  put (ExportModule   spi :: SpanInfo
spi mid :: ModuleIdent
mid   ) = Word8 -> Put
putWord8 3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ModuleIdent -> Put
forall t. Binary t => t -> Put
put ModuleIdent
mid

  get :: Get Export
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> QualIdent -> Export)
-> Get SpanInfo -> Get QualIdent -> Get Export
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> QualIdent -> Export
Export Get SpanInfo
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get
      1 -> (SpanInfo -> QualIdent -> [Ident] -> Export)
-> Get SpanInfo -> Get QualIdent -> Get [Ident] -> Get Export
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> QualIdent -> [Ident] -> Export
ExportTypeWith Get SpanInfo
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get Get [Ident]
forall t. Binary t => Get t
get
      2 -> (SpanInfo -> QualIdent -> Export)
-> Get SpanInfo -> Get QualIdent -> Get Export
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> QualIdent -> Export
ExportTypeAll Get SpanInfo
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get
      3 -> (SpanInfo -> ModuleIdent -> Export)
-> Get SpanInfo -> Get ModuleIdent -> Get Export
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> ModuleIdent -> Export
ExportModule Get SpanInfo
forall t. Binary t => Get t
get Get ModuleIdent
forall t. Binary t => Get t
get
      _ -> String -> Get Export
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Export"

instance Binary ImportDecl where
  put :: ImportDecl -> Put
put (ImportDecl spi :: SpanInfo
spi mid :: ModuleIdent
mid q :: Bool
q al :: Maybe ModuleIdent
al im :: Maybe ImportSpec
im) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ModuleIdent -> Put
forall t. Binary t => t -> Put
put ModuleIdent
mid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Bool -> Put
forall t. Binary t => t -> Put
put Bool
q Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
                                     Maybe ModuleIdent -> Put
forall t. Binary t => t -> Put
put Maybe ModuleIdent
al Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Maybe ImportSpec -> Put
forall t. Binary t => t -> Put
put Maybe ImportSpec
im
  get :: Get ImportDecl
get = SpanInfo
-> ModuleIdent
-> Bool
-> Maybe ModuleIdent
-> Maybe ImportSpec
-> ImportDecl
ImportDecl (SpanInfo
 -> ModuleIdent
 -> Bool
 -> Maybe ModuleIdent
 -> Maybe ImportSpec
 -> ImportDecl)
-> Get SpanInfo
-> Get
     (ModuleIdent
      -> Bool -> Maybe ModuleIdent -> Maybe ImportSpec -> ImportDecl)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get
  (ModuleIdent
   -> Bool -> Maybe ModuleIdent -> Maybe ImportSpec -> ImportDecl)
-> Get ModuleIdent
-> Get
     (Bool -> Maybe ModuleIdent -> Maybe ImportSpec -> ImportDecl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get ModuleIdent
forall t. Binary t => Get t
get Get (Bool -> Maybe ModuleIdent -> Maybe ImportSpec -> ImportDecl)
-> Get Bool
-> Get (Maybe ModuleIdent -> Maybe ImportSpec -> ImportDecl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Bool
forall t. Binary t => Get t
get Get (Maybe ModuleIdent -> Maybe ImportSpec -> ImportDecl)
-> Get (Maybe ModuleIdent) -> Get (Maybe ImportSpec -> ImportDecl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Maybe ModuleIdent)
forall t. Binary t => Get t
get Get (Maybe ImportSpec -> ImportDecl)
-> Get (Maybe ImportSpec) -> Get ImportDecl
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Maybe ImportSpec)
forall t. Binary t => Get t
get

instance Binary ImportSpec where
  put :: ImportSpec -> Put
put (Importing spi :: SpanInfo
spi im :: [Import]
im) = Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Import] -> Put
forall t. Binary t => t -> Put
put [Import]
im
  put (Hiding    spi :: SpanInfo
spi im :: [Import]
im) = Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Import] -> Put
forall t. Binary t => t -> Put
put [Import]
im

  get :: Get ImportSpec
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> [Import] -> ImportSpec)
-> Get SpanInfo -> Get [Import] -> Get ImportSpec
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> [Import] -> ImportSpec
Importing Get SpanInfo
forall t. Binary t => Get t
get Get [Import]
forall t. Binary t => Get t
get
      1 -> (SpanInfo -> [Import] -> ImportSpec)
-> Get SpanInfo -> Get [Import] -> Get ImportSpec
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> [Import] -> ImportSpec
Hiding Get SpanInfo
forall t. Binary t => Get t
get Get [Import]
forall t. Binary t => Get t
get
      _ -> String -> Get ImportSpec
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for ImportSpec"

instance Binary Import where
  put :: Import -> Put
put (Import         spi :: SpanInfo
spi idt :: Ident
idt   ) = Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt
  put (ImportTypeWith spi :: SpanInfo
spi idt :: Ident
idt is :: [Ident]
is) = Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
is
  put (ImportTypeAll  spi :: SpanInfo
spi idt :: Ident
idt   ) = Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt

  get :: Get Import
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> Ident -> Import)
-> Get SpanInfo -> Get Ident -> Get Import
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Ident -> Import
Import Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get
      1 -> (SpanInfo -> Ident -> [Ident] -> Import)
-> Get SpanInfo -> Get Ident -> Get [Ident] -> Get Import
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Ident -> [Ident] -> Import
ImportTypeWith Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get Get [Ident]
forall t. Binary t => Get t
get
      2 -> (SpanInfo -> Ident -> Import)
-> Get SpanInfo -> Get Ident -> Get Import
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Ident -> Import
ImportTypeAll Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get
      _ -> String -> Get Import
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Import"

instance Binary a => Binary (Decl a) where
  put :: Decl a -> Put
put (InfixDecl spi :: SpanInfo
spi i :: Infix
i pr :: Maybe Precedence
pr is :: [Ident]
is) =
    Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Infix -> Put
forall t. Binary t => t -> Put
put Infix
i Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Maybe Precedence -> Put
forall t. Binary t => t -> Put
put Maybe Precedence
pr Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
is
  put (DataDecl spi :: SpanInfo
spi idt :: Ident
idt vs :: [Ident]
vs cns :: [ConstrDecl]
cns cls :: [QualIdent]
cls) =
    Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
vs Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [ConstrDecl] -> Put
forall t. Binary t => t -> Put
put [ConstrDecl]
cns Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [QualIdent] -> Put
forall t. Binary t => t -> Put
put [QualIdent]
cls
  put (ExternalDataDecl spi :: SpanInfo
spi idt :: Ident
idt vs :: [Ident]
vs) =
    Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
vs
  put (NewtypeDecl spi :: SpanInfo
spi idt :: Ident
idt vs :: [Ident]
vs cn :: NewConstrDecl
cn cls :: [QualIdent]
cls) =
    Word8 -> Put
putWord8 3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
vs  Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> NewConstrDecl -> Put
forall t. Binary t => t -> Put
put NewConstrDecl
cn Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [QualIdent] -> Put
forall t. Binary t => t -> Put
put [QualIdent]
cls Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [QualIdent] -> Put
forall t. Binary t => t -> Put
put [QualIdent]
cls
  put (TypeDecl spi :: SpanInfo
spi idt :: Ident
idt vs :: [Ident]
vs ty :: TypeExpr
ty) =
    Word8 -> Put
putWord8 4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
vs  Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty
  put (TypeSig spi :: SpanInfo
spi fs :: [Ident]
fs ty :: QualTypeExpr
ty) =
    Word8 -> Put
putWord8 5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
fs Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualTypeExpr -> Put
forall t. Binary t => t -> Put
put QualTypeExpr
ty
  put (FunctionDecl spi :: SpanInfo
spi a :: a
a f :: Ident
f eqs :: [Equation a]
eqs) =
    Word8 -> Put
putWord8 6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
f Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Equation a] -> Put
forall t. Binary t => t -> Put
put [Equation a]
eqs
  put (ExternalDecl spi :: SpanInfo
spi vs :: [Var a]
vs) =
    Word8 -> Put
putWord8 7 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Var a] -> Put
forall t. Binary t => t -> Put
put [Var a]
vs
  put (PatternDecl spi :: SpanInfo
spi p :: Pattern a
p rhs :: Rhs a
rhs) =
    Word8 -> Put
putWord8 8 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Rhs a -> Put
forall t. Binary t => t -> Put
put Rhs a
rhs
  put (FreeDecl spi :: SpanInfo
spi vs :: [Var a]
vs) =
    Word8 -> Put
putWord8 9 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Var a] -> Put
forall t. Binary t => t -> Put
put [Var a]
vs
  put (DefaultDecl spi :: SpanInfo
spi tys :: [TypeExpr]
tys) =
    Word8 -> Put
putWord8 10 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [TypeExpr] -> Put
forall t. Binary t => t -> Put
put [TypeExpr]
tys
  put (ClassDecl spi :: SpanInfo
spi li :: LayoutInfo
li cx :: [Constraint]
cx cls :: Ident
cls v :: Ident
v ds :: [Decl a]
ds) =
    Word8 -> Put
putWord8 11 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Constraint] -> Put
forall t. Binary t => t -> Put
put [Constraint]
cx Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
cls Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
v Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Decl a] -> Put
forall t. Binary t => t -> Put
put [Decl a]
ds
  put (InstanceDecl spi :: SpanInfo
spi li :: LayoutInfo
li cx :: [Constraint]
cx cls :: QualIdent
cls ty :: TypeExpr
ty ds :: [Decl a]
ds) =
    Word8 -> Put
putWord8 12 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Constraint] -> Put
forall t. Binary t => t -> Put
put [Constraint]
cx Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
cls Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Decl a] -> Put
forall t. Binary t => t -> Put
put [Decl a]
ds

  get :: Get (Decl a)
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0  -> SpanInfo -> Infix -> Maybe Precedence -> [Ident] -> Decl a
forall a.
SpanInfo -> Infix -> Maybe Precedence -> [Ident] -> Decl a
InfixDecl (SpanInfo -> Infix -> Maybe Precedence -> [Ident] -> Decl a)
-> Get SpanInfo
-> Get (Infix -> Maybe Precedence -> [Ident] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Infix -> Maybe Precedence -> [Ident] -> Decl a)
-> Get Infix -> Get (Maybe Precedence -> [Ident] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Infix
forall t. Binary t => Get t
get Get (Maybe Precedence -> [Ident] -> Decl a)
-> Get (Maybe Precedence) -> Get ([Ident] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Maybe Precedence)
forall t. Binary t => Get t
get Get ([Ident] -> Decl a) -> Get [Ident] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Ident]
forall t. Binary t => Get t
get
      1  -> SpanInfo
-> Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a
forall a.
SpanInfo
-> Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a
DataDecl (SpanInfo
 -> Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a)
-> Get SpanInfo
-> Get (Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a)
-> Get Ident
-> Get ([Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get ([Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a)
-> Get [Ident] -> Get ([ConstrDecl] -> [QualIdent] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Ident]
forall t. Binary t => Get t
get Get ([ConstrDecl] -> [QualIdent] -> Decl a)
-> Get [ConstrDecl] -> Get ([QualIdent] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [ConstrDecl]
forall t. Binary t => Get t
get Get ([QualIdent] -> Decl a) -> Get [QualIdent] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [QualIdent]
forall t. Binary t => Get t
get
      2  -> SpanInfo -> Ident -> [Ident] -> Decl a
forall a. SpanInfo -> Ident -> [Ident] -> Decl a
ExternalDataDecl (SpanInfo -> Ident -> [Ident] -> Decl a)
-> Get SpanInfo -> Get (Ident -> [Ident] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Ident -> [Ident] -> Decl a)
-> Get Ident -> Get ([Ident] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get ([Ident] -> Decl a) -> Get [Ident] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Ident]
forall t. Binary t => Get t
get
      3  -> SpanInfo
-> Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a
forall a.
SpanInfo
-> Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a
NewtypeDecl (SpanInfo
 -> Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a)
-> Get SpanInfo
-> Get (Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a)
-> Get Ident
-> Get ([Ident] -> NewConstrDecl -> [QualIdent] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get ([Ident] -> NewConstrDecl -> [QualIdent] -> Decl a)
-> Get [Ident] -> Get (NewConstrDecl -> [QualIdent] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Ident]
forall t. Binary t => Get t
get Get (NewConstrDecl -> [QualIdent] -> Decl a)
-> Get NewConstrDecl -> Get ([QualIdent] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get NewConstrDecl
forall t. Binary t => Get t
get Get ([QualIdent] -> Decl a) -> Get [QualIdent] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [QualIdent]
forall t. Binary t => Get t
get
      4  -> SpanInfo -> Ident -> [Ident] -> TypeExpr -> Decl a
forall a. SpanInfo -> Ident -> [Ident] -> TypeExpr -> Decl a
TypeDecl (SpanInfo -> Ident -> [Ident] -> TypeExpr -> Decl a)
-> Get SpanInfo -> Get (Ident -> [Ident] -> TypeExpr -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Ident -> [Ident] -> TypeExpr -> Decl a)
-> Get Ident -> Get ([Ident] -> TypeExpr -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get ([Ident] -> TypeExpr -> Decl a)
-> Get [Ident] -> Get (TypeExpr -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Ident]
forall t. Binary t => Get t
get Get (TypeExpr -> Decl a) -> Get TypeExpr -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get TypeExpr
forall t. Binary t => Get t
get
      5  -> SpanInfo -> [Ident] -> QualTypeExpr -> Decl a
forall a. SpanInfo -> [Ident] -> QualTypeExpr -> Decl a
TypeSig (SpanInfo -> [Ident] -> QualTypeExpr -> Decl a)
-> Get SpanInfo -> Get ([Ident] -> QualTypeExpr -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get ([Ident] -> QualTypeExpr -> Decl a)
-> Get [Ident] -> Get (QualTypeExpr -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Ident]
forall t. Binary t => Get t
get Get (QualTypeExpr -> Decl a) -> Get QualTypeExpr -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get QualTypeExpr
forall t. Binary t => Get t
get
      6  -> SpanInfo -> a -> Ident -> [Equation a] -> Decl a
forall a. SpanInfo -> a -> Ident -> [Equation a] -> Decl a
FunctionDecl (SpanInfo -> a -> Ident -> [Equation a] -> Decl a)
-> Get SpanInfo -> Get (a -> Ident -> [Equation a] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (a -> Ident -> [Equation a] -> Decl a)
-> Get a -> Get (Ident -> [Equation a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get a
forall t. Binary t => Get t
get Get (Ident -> [Equation a] -> Decl a)
-> Get Ident -> Get ([Equation a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get ([Equation a] -> Decl a) -> Get [Equation a] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Equation a]
forall t. Binary t => Get t
get
      7  -> SpanInfo -> [Var a] -> Decl a
forall a. SpanInfo -> [Var a] -> Decl a
ExternalDecl (SpanInfo -> [Var a] -> Decl a)
-> Get SpanInfo -> Get ([Var a] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get ([Var a] -> Decl a) -> Get [Var a] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Var a]
forall t. Binary t => Get t
get
      8  -> SpanInfo -> Pattern a -> Rhs a -> Decl a
forall a. SpanInfo -> Pattern a -> Rhs a -> Decl a
PatternDecl (SpanInfo -> Pattern a -> Rhs a -> Decl a)
-> Get SpanInfo -> Get (Pattern a -> Rhs a -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Pattern a -> Rhs a -> Decl a)
-> Get (Pattern a) -> Get (Rhs a -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Pattern a)
forall t. Binary t => Get t
get Get (Rhs a -> Decl a) -> Get (Rhs a) -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Rhs a)
forall t. Binary t => Get t
get
      9  -> SpanInfo -> [Var a] -> Decl a
forall a. SpanInfo -> [Var a] -> Decl a
FreeDecl (SpanInfo -> [Var a] -> Decl a)
-> Get SpanInfo -> Get ([Var a] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get ([Var a] -> Decl a) -> Get [Var a] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Var a]
forall t. Binary t => Get t
get
      10 -> SpanInfo -> [TypeExpr] -> Decl a
forall a. SpanInfo -> [TypeExpr] -> Decl a
DefaultDecl (SpanInfo -> [TypeExpr] -> Decl a)
-> Get SpanInfo -> Get ([TypeExpr] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get ([TypeExpr] -> Decl a) -> Get [TypeExpr] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [TypeExpr]
forall t. Binary t => Get t
get
      11 -> SpanInfo
-> LayoutInfo
-> [Constraint]
-> Ident
-> Ident
-> [Decl a]
-> Decl a
forall a.
SpanInfo
-> LayoutInfo
-> [Constraint]
-> Ident
-> Ident
-> [Decl a]
-> Decl a
ClassDecl (SpanInfo
 -> LayoutInfo
 -> [Constraint]
 -> Ident
 -> Ident
 -> [Decl a]
 -> Decl a)
-> Get SpanInfo
-> Get
     (LayoutInfo
      -> [Constraint] -> Ident -> Ident -> [Decl a] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get
  (LayoutInfo
   -> [Constraint] -> Ident -> Ident -> [Decl a] -> Decl a)
-> Get LayoutInfo
-> Get ([Constraint] -> Ident -> Ident -> [Decl a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get LayoutInfo
forall t. Binary t => Get t
get Get ([Constraint] -> Ident -> Ident -> [Decl a] -> Decl a)
-> Get [Constraint] -> Get (Ident -> Ident -> [Decl a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Constraint]
forall t. Binary t => Get t
get Get (Ident -> Ident -> [Decl a] -> Decl a)
-> Get Ident -> Get (Ident -> [Decl a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get (Ident -> [Decl a] -> Decl a)
-> Get Ident -> Get ([Decl a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get ([Decl a] -> Decl a) -> Get [Decl a] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Decl a]
forall t. Binary t => Get t
get
      12 -> SpanInfo
-> LayoutInfo
-> [Constraint]
-> QualIdent
-> TypeExpr
-> [Decl a]
-> Decl a
forall a.
SpanInfo
-> LayoutInfo
-> [Constraint]
-> QualIdent
-> TypeExpr
-> [Decl a]
-> Decl a
InstanceDecl (SpanInfo
 -> LayoutInfo
 -> [Constraint]
 -> QualIdent
 -> TypeExpr
 -> [Decl a]
 -> Decl a)
-> Get SpanInfo
-> Get
     (LayoutInfo
      -> [Constraint] -> QualIdent -> TypeExpr -> [Decl a] -> Decl a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get
  (LayoutInfo
   -> [Constraint] -> QualIdent -> TypeExpr -> [Decl a] -> Decl a)
-> Get LayoutInfo
-> Get
     ([Constraint] -> QualIdent -> TypeExpr -> [Decl a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get LayoutInfo
forall t. Binary t => Get t
get Get ([Constraint] -> QualIdent -> TypeExpr -> [Decl a] -> Decl a)
-> Get [Constraint]
-> Get (QualIdent -> TypeExpr -> [Decl a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Constraint]
forall t. Binary t => Get t
get Get (QualIdent -> TypeExpr -> [Decl a] -> Decl a)
-> Get QualIdent -> Get (TypeExpr -> [Decl a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get QualIdent
forall t. Binary t => Get t
get Get (TypeExpr -> [Decl a] -> Decl a)
-> Get TypeExpr -> Get ([Decl a] -> Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get TypeExpr
forall t. Binary t => Get t
get Get ([Decl a] -> Decl a) -> Get [Decl a] -> Get (Decl a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Decl a]
forall t. Binary t => Get t
get
      _  -> String -> Get (Decl a)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Decl"

instance Binary Infix where
  put :: Infix -> Put
put InfixL = Word8 -> Put
putWord8 0
  put InfixR = Word8 -> Put
putWord8 1
  put Infix  = Word8 -> Put
putWord8 2

  get :: Get Infix
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> Infix -> Get Infix
forall (m :: * -> *) a. Monad m => a -> m a
return Infix
InfixL
      1 -> Infix -> Get Infix
forall (m :: * -> *) a. Monad m => a -> m a
return Infix
InfixR
      2 -> Infix -> Get Infix
forall (m :: * -> *) a. Monad m => a -> m a
return Infix
Infix
      _ -> String -> Get Infix
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Infix"

instance Binary ConstrDecl where
  put :: ConstrDecl -> Put
put (ConstrDecl spi :: SpanInfo
spi idt :: Ident
idt tys :: [TypeExpr]
tys) =
    Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [TypeExpr] -> Put
forall t. Binary t => t -> Put
put [TypeExpr]
tys
  put (ConOpDecl spi :: SpanInfo
spi ty1 :: TypeExpr
ty1 idt :: Ident
idt ty2 :: TypeExpr
ty2) =
    Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty2
  put (RecordDecl spi :: SpanInfo
spi idt :: Ident
idt fs :: [FieldDecl]
fs) =
    Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [FieldDecl] -> Put
forall t. Binary t => t -> Put
put [FieldDecl]
fs

  get :: Get ConstrDecl
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> Ident -> [TypeExpr] -> ConstrDecl)
-> Get SpanInfo -> Get Ident -> Get [TypeExpr] -> Get ConstrDecl
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Ident -> [TypeExpr] -> ConstrDecl
ConstrDecl Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get Get [TypeExpr]
forall t. Binary t => Get t
get
      1 -> SpanInfo -> TypeExpr -> Ident -> TypeExpr -> ConstrDecl
ConOpDecl (SpanInfo -> TypeExpr -> Ident -> TypeExpr -> ConstrDecl)
-> Get SpanInfo
-> Get (TypeExpr -> Ident -> TypeExpr -> ConstrDecl)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (TypeExpr -> Ident -> TypeExpr -> ConstrDecl)
-> Get TypeExpr -> Get (Ident -> TypeExpr -> ConstrDecl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get TypeExpr
forall t. Binary t => Get t
get Get (Ident -> TypeExpr -> ConstrDecl)
-> Get Ident -> Get (TypeExpr -> ConstrDecl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get (TypeExpr -> ConstrDecl) -> Get TypeExpr -> Get ConstrDecl
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get TypeExpr
forall t. Binary t => Get t
get
      2 -> (SpanInfo -> Ident -> [FieldDecl] -> ConstrDecl)
-> Get SpanInfo -> Get Ident -> Get [FieldDecl] -> Get ConstrDecl
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Ident -> [FieldDecl] -> ConstrDecl
RecordDecl Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get Get [FieldDecl]
forall t. Binary t => Get t
get
      _ -> String -> Get ConstrDecl
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for ConstrDecl"

instance Binary NewConstrDecl where
  put :: NewConstrDecl -> Put
put (NewConstrDecl spi :: SpanInfo
spi c :: Ident
c ty :: TypeExpr
ty) =
    Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
c Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty
  put (NewRecordDecl spi :: SpanInfo
spi c :: Ident
c fs :: (Ident, TypeExpr)
fs) =
    Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
c Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Ident, TypeExpr) -> Put
forall t. Binary t => t -> Put
put (Ident, TypeExpr)
fs

  get :: Get NewConstrDecl
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> Ident -> TypeExpr -> NewConstrDecl)
-> Get SpanInfo -> Get Ident -> Get TypeExpr -> Get NewConstrDecl
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Ident -> TypeExpr -> NewConstrDecl
NewConstrDecl Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get
      1 -> (SpanInfo -> Ident -> (Ident, TypeExpr) -> NewConstrDecl)
-> Get SpanInfo
-> Get Ident
-> Get (Ident, TypeExpr)
-> Get NewConstrDecl
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Ident -> (Ident, TypeExpr) -> NewConstrDecl
NewRecordDecl Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get Get (Ident, TypeExpr)
forall t. Binary t => Get t
get
      _ -> String -> Get NewConstrDecl
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for NewConstrDecl"

instance Binary FieldDecl where
  put :: FieldDecl -> Put
put (FieldDecl spi :: SpanInfo
spi is :: [Ident]
is ty :: TypeExpr
ty) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
is Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty
  get :: Get FieldDecl
get = (SpanInfo -> [Ident] -> TypeExpr -> FieldDecl)
-> Get SpanInfo -> Get [Ident] -> Get TypeExpr -> Get FieldDecl
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> [Ident] -> TypeExpr -> FieldDecl
FieldDecl Get SpanInfo
forall t. Binary t => Get t
get Get [Ident]
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get

instance Binary QualTypeExpr where
  put :: QualTypeExpr -> Put
put (QualTypeExpr spi :: SpanInfo
spi ctx :: [Constraint]
ctx te :: TypeExpr
te) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Constraint] -> Put
forall t. Binary t => t -> Put
put [Constraint]
ctx Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
te
  get :: Get QualTypeExpr
get = (SpanInfo -> [Constraint] -> TypeExpr -> QualTypeExpr)
-> Get SpanInfo
-> Get [Constraint]
-> Get TypeExpr
-> Get QualTypeExpr
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> [Constraint] -> TypeExpr -> QualTypeExpr
QualTypeExpr Get SpanInfo
forall t. Binary t => Get t
get Get [Constraint]
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get

instance Binary TypeExpr where
  put :: TypeExpr -> Put
put (ConstructorType spi :: SpanInfo
spi qid :: QualIdent
qid) =
    Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid
  put (ApplyType spi :: SpanInfo
spi ty1 :: TypeExpr
ty1 ty2 :: TypeExpr
ty2) =
    Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty2
  put (VariableType spi :: SpanInfo
spi idt :: Ident
idt) =
    Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt
  put (TupleType spi :: SpanInfo
spi tys :: [TypeExpr]
tys) =
    Word8 -> Put
putWord8 3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [TypeExpr] -> Put
forall t. Binary t => t -> Put
put [TypeExpr]
tys
  put (ListType spi :: SpanInfo
spi ty :: TypeExpr
ty) =
    Word8 -> Put
putWord8 4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty
  put (ArrowType spi :: SpanInfo
spi ty1 :: TypeExpr
ty1 ty2 :: TypeExpr
ty2) =
    Word8 -> Put
putWord8 5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty2
  put (ParenType spi :: SpanInfo
spi ty :: TypeExpr
ty) =
    Word8 -> Put
putWord8 6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty
  put (ForallType spi :: SpanInfo
spi is :: [Ident]
is ty :: TypeExpr
ty) =
    Word8 -> Put
putWord8 7 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
is Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty

  get :: Get TypeExpr
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> QualIdent -> TypeExpr)
-> Get SpanInfo -> Get QualIdent -> Get TypeExpr
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> QualIdent -> TypeExpr
ConstructorType Get SpanInfo
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get
      1 -> (SpanInfo -> TypeExpr -> TypeExpr -> TypeExpr)
-> Get SpanInfo -> Get TypeExpr -> Get TypeExpr -> Get TypeExpr
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> TypeExpr -> TypeExpr -> TypeExpr
ApplyType Get SpanInfo
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get
      2 -> (SpanInfo -> Ident -> TypeExpr)
-> Get SpanInfo -> Get Ident -> Get TypeExpr
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Ident -> TypeExpr
VariableType Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get
      3 -> (SpanInfo -> [TypeExpr] -> TypeExpr)
-> Get SpanInfo -> Get [TypeExpr] -> Get TypeExpr
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> [TypeExpr] -> TypeExpr
TupleType Get SpanInfo
forall t. Binary t => Get t
get Get [TypeExpr]
forall t. Binary t => Get t
get
      4 -> (SpanInfo -> TypeExpr -> TypeExpr)
-> Get SpanInfo -> Get TypeExpr -> Get TypeExpr
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> TypeExpr -> TypeExpr
ListType Get SpanInfo
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get
      5 -> (SpanInfo -> TypeExpr -> TypeExpr -> TypeExpr)
-> Get SpanInfo -> Get TypeExpr -> Get TypeExpr -> Get TypeExpr
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> TypeExpr -> TypeExpr -> TypeExpr
ArrowType Get SpanInfo
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get
      6 -> (SpanInfo -> TypeExpr -> TypeExpr)
-> Get SpanInfo -> Get TypeExpr -> Get TypeExpr
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> TypeExpr -> TypeExpr
ParenType Get SpanInfo
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get
      7 -> (SpanInfo -> [Ident] -> TypeExpr -> TypeExpr)
-> Get SpanInfo -> Get [Ident] -> Get TypeExpr -> Get TypeExpr
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> [Ident] -> TypeExpr -> TypeExpr
ForallType Get SpanInfo
forall t. Binary t => Get t
get Get [Ident]
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get
      _ -> String -> Get TypeExpr
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for TypeExpr"

instance Binary Constraint where
  put :: Constraint -> Put
put (Constraint spi :: SpanInfo
spi cls :: QualIdent
cls ty :: TypeExpr
ty) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
cls Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TypeExpr -> Put
forall t. Binary t => t -> Put
put TypeExpr
ty
  get :: Get Constraint
get = (SpanInfo -> QualIdent -> TypeExpr -> Constraint)
-> Get SpanInfo -> Get QualIdent -> Get TypeExpr -> Get Constraint
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> QualIdent -> TypeExpr -> Constraint
Constraint Get SpanInfo
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get Get TypeExpr
forall t. Binary t => Get t
get

instance Binary a => Binary (Equation a) where
  put :: Equation a -> Put
put (Equation spi :: SpanInfo
spi lhs :: Lhs a
lhs rhs :: Rhs a
rhs) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Lhs a -> Put
forall t. Binary t => t -> Put
put Lhs a
lhs Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Rhs a -> Put
forall t. Binary t => t -> Put
put Rhs a
rhs
  get :: Get (Equation a)
get = (SpanInfo -> Lhs a -> Rhs a -> Equation a)
-> Get SpanInfo -> Get (Lhs a) -> Get (Rhs a) -> Get (Equation a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Lhs a -> Rhs a -> Equation a
forall a. SpanInfo -> Lhs a -> Rhs a -> Equation a
Equation Get SpanInfo
forall t. Binary t => Get t
get Get (Lhs a)
forall t. Binary t => Get t
get Get (Rhs a)
forall t. Binary t => Get t
get

instance Binary a => Binary (Lhs a) where
  put :: Lhs a -> Put
put (FunLhs spi :: SpanInfo
spi f :: Ident
f ps :: [Pattern a]
ps) =
    Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
f Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Pattern a] -> Put
forall t. Binary t => t -> Put
put [Pattern a]
ps
  put (OpLhs spi :: SpanInfo
spi p1 :: Pattern a
p1 op :: Ident
op p2 :: Pattern a
p2) =
    Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
op Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p2
  put (ApLhs spi :: SpanInfo
spi lhs :: Lhs a
lhs ps :: [Pattern a]
ps) =
    Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Lhs a -> Put
forall t. Binary t => t -> Put
put Lhs a
lhs Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Pattern a] -> Put
forall t. Binary t => t -> Put
put [Pattern a]
ps

  get :: Get (Lhs a)
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> Ident -> [Pattern a] -> Lhs a)
-> Get SpanInfo -> Get Ident -> Get [Pattern a] -> Get (Lhs a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Ident -> [Pattern a] -> Lhs a
forall a. SpanInfo -> Ident -> [Pattern a] -> Lhs a
FunLhs Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get Get [Pattern a]
forall t. Binary t => Get t
get
      1 -> SpanInfo -> Pattern a -> Ident -> Pattern a -> Lhs a
forall a. SpanInfo -> Pattern a -> Ident -> Pattern a -> Lhs a
OpLhs (SpanInfo -> Pattern a -> Ident -> Pattern a -> Lhs a)
-> Get SpanInfo -> Get (Pattern a -> Ident -> Pattern a -> Lhs a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Pattern a -> Ident -> Pattern a -> Lhs a)
-> Get (Pattern a) -> Get (Ident -> Pattern a -> Lhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Pattern a)
forall t. Binary t => Get t
get Get (Ident -> Pattern a -> Lhs a)
-> Get Ident -> Get (Pattern a -> Lhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Ident
forall t. Binary t => Get t
get Get (Pattern a -> Lhs a) -> Get (Pattern a) -> Get (Lhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Pattern a)
forall t. Binary t => Get t
get
      2 -> (SpanInfo -> Lhs a -> [Pattern a] -> Lhs a)
-> Get SpanInfo -> Get (Lhs a) -> Get [Pattern a] -> Get (Lhs a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Lhs a -> [Pattern a] -> Lhs a
forall a. SpanInfo -> Lhs a -> [Pattern a] -> Lhs a
ApLhs Get SpanInfo
forall t. Binary t => Get t
get Get (Lhs a)
forall t. Binary t => Get t
get Get [Pattern a]
forall t. Binary t => Get t
get
      _ -> String -> Get (Lhs a)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Lhs"

instance Binary a => Binary (Rhs a) where
  put :: Rhs a -> Put
put (SimpleRhs spi :: SpanInfo
spi li :: LayoutInfo
li e :: Expression a
e ds :: [Decl a]
ds) =
    Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Decl a] -> Put
forall t. Binary t => t -> Put
put [Decl a]
ds
  put (GuardedRhs spi :: SpanInfo
spi li :: LayoutInfo
li gs :: [CondExpr a]
gs ds :: [Decl a]
ds) =
    Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [CondExpr a] -> Put
forall t. Binary t => t -> Put
put [CondExpr a]
gs Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Decl a] -> Put
forall t. Binary t => t -> Put
put [Decl a]
ds

  get :: Get (Rhs a)
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Rhs a
forall a.
SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Rhs a
SimpleRhs (SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Rhs a)
-> Get SpanInfo
-> Get (LayoutInfo -> Expression a -> [Decl a] -> Rhs a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (LayoutInfo -> Expression a -> [Decl a] -> Rhs a)
-> Get LayoutInfo -> Get (Expression a -> [Decl a] -> Rhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get LayoutInfo
forall t. Binary t => Get t
get Get (Expression a -> [Decl a] -> Rhs a)
-> Get (Expression a) -> Get ([Decl a] -> Rhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get Get ([Decl a] -> Rhs a) -> Get [Decl a] -> Get (Rhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Decl a]
forall t. Binary t => Get t
get
      1 -> SpanInfo -> LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a
forall a.
SpanInfo -> LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a
GuardedRhs (SpanInfo -> LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a)
-> Get SpanInfo
-> Get (LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a)
-> Get LayoutInfo -> Get ([CondExpr a] -> [Decl a] -> Rhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get LayoutInfo
forall t. Binary t => Get t
get Get ([CondExpr a] -> [Decl a] -> Rhs a)
-> Get [CondExpr a] -> Get ([Decl a] -> Rhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [CondExpr a]
forall t. Binary t => Get t
get Get ([Decl a] -> Rhs a) -> Get [Decl a] -> Get (Rhs a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Decl a]
forall t. Binary t => Get t
get
      _ -> String -> Get (Rhs a)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Rhs"

instance Binary a => Binary (CondExpr a) where
  put :: CondExpr a -> Put
put (CondExpr spi :: SpanInfo
spi g :: Expression a
g e :: Expression a
e) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
g Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e
  get :: Get (CondExpr a)
get = (SpanInfo -> Expression a -> Expression a -> CondExpr a)
-> Get SpanInfo
-> Get (Expression a)
-> Get (Expression a)
-> Get (CondExpr a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Expression a -> Expression a -> CondExpr a
forall a. SpanInfo -> Expression a -> Expression a -> CondExpr a
CondExpr Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get

instance Binary Literal where
  put :: Literal -> Put
put (Char   c :: Char
c) = Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char -> Put
forall t. Binary t => t -> Put
put Char
c
  put (Int    i :: Precedence
i) = Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Precedence -> Put
forall t. Binary t => t -> Put
put Precedence
i
  put (Float  f :: Double
f) = Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> Put
forall t. Binary t => t -> Put
put (Double -> String
forall a. Show a => a -> String
show Double
f)
  put (String s :: String
s) = Word8 -> Put
putWord8 3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> Put
forall t. Binary t => t -> Put
put String
s

  get :: Get Literal
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (Char -> Literal) -> Get Char -> Get Literal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Char -> Literal
Char Get Char
forall t. Binary t => Get t
get
      1 -> (Precedence -> Literal) -> Get Precedence -> Get Literal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Precedence -> Literal
Int Get Precedence
forall t. Binary t => Get t
get
      2 -> (String -> Literal) -> Get String -> Get Literal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Double -> Literal
Float (Double -> Literal) -> (String -> Double) -> String -> Literal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Double
forall a. Read a => String -> a
read) Get String
forall t. Binary t => Get t
get
      3 -> (String -> Literal) -> Get String -> Get Literal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Literal
String Get String
forall t. Binary t => Get t
get
      _ -> String -> Get Literal
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Literal"

instance Binary a => Binary (Pattern a) where
  put :: Pattern a -> Put
put (LiteralPattern  spi :: SpanInfo
spi a :: a
a l :: Literal
l) =
    Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Literal -> Put
forall t. Binary t => t -> Put
put Literal
l
  put (NegativePattern spi :: SpanInfo
spi a :: a
a l :: Literal
l) =
    Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Literal -> Put
forall t. Binary t => t -> Put
put Literal
l
  put (VariablePattern spi :: SpanInfo
spi a :: a
a idt :: Ident
idt) =
    Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt
  put (ConstructorPattern spi :: SpanInfo
spi a :: a
a qid :: QualIdent
qid ps :: [Pattern a]
ps) =
    Word8 -> Put
putWord8 3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Pattern a] -> Put
forall t. Binary t => t -> Put
put [Pattern a]
ps
  put (InfixPattern spi :: SpanInfo
spi a :: a
a p1 :: Pattern a
p1 qid :: QualIdent
qid p2 :: Pattern a
p2) =
    Word8 -> Put
putWord8 4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p2
  put (ParenPattern spi :: SpanInfo
spi p :: Pattern a
p) =
    Word8 -> Put
putWord8 5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p
  put (RecordPattern spi :: SpanInfo
spi a :: a
a qid :: QualIdent
qid fs :: [Field (Pattern a)]
fs) =
    Word8 -> Put
putWord8 6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Field (Pattern a)] -> Put
forall t. Binary t => t -> Put
put [Field (Pattern a)]
fs
  put (TuplePattern spi :: SpanInfo
spi ps :: [Pattern a]
ps) =
    Word8 -> Put
putWord8 7 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Pattern a] -> Put
forall t. Binary t => t -> Put
put [Pattern a]
ps
  put (ListPattern spi :: SpanInfo
spi a :: a
a ps :: [Pattern a]
ps) =
    Word8 -> Put
putWord8 8 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Pattern a] -> Put
forall t. Binary t => t -> Put
put [Pattern a]
ps
  put (AsPattern spi :: SpanInfo
spi idt :: Ident
idt p :: Pattern a
p) =
    Word8 -> Put
putWord8 9 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p
  put (LazyPattern spi :: SpanInfo
spi p :: Pattern a
p) =
    Word8 -> Put
putWord8 10 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p
  put (FunctionPattern spi :: SpanInfo
spi a :: a
a qid :: QualIdent
qid ps :: [Pattern a]
ps) =
    Word8 -> Put
putWord8 11 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Pattern a] -> Put
forall t. Binary t => t -> Put
put [Pattern a]
ps
  put (InfixFuncPattern spi :: SpanInfo
spi a :: a
a p1 :: Pattern a
p1 qid :: QualIdent
qid p2 :: Pattern a
p2) =
    Word8 -> Put
putWord8 12 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p2

  get :: Get (Pattern a)
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0  -> (SpanInfo -> a -> Literal -> Pattern a)
-> Get SpanInfo -> Get a -> Get Literal -> Get (Pattern a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> a -> Literal -> Pattern a
forall a. SpanInfo -> a -> Literal -> Pattern a
LiteralPattern Get SpanInfo
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get Get Literal
forall t. Binary t => Get t
get
      1  -> (SpanInfo -> a -> Literal -> Pattern a)
-> Get SpanInfo -> Get a -> Get Literal -> Get (Pattern a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> a -> Literal -> Pattern a
forall a. SpanInfo -> a -> Literal -> Pattern a
NegativePattern Get SpanInfo
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get Get Literal
forall t. Binary t => Get t
get
      2  -> (SpanInfo -> a -> Ident -> Pattern a)
-> Get SpanInfo -> Get a -> Get Ident -> Get (Pattern a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> a -> Ident -> Pattern a
forall a. SpanInfo -> a -> Ident -> Pattern a
VariablePattern Get SpanInfo
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get
      3  -> SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
forall a. SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
ConstructorPattern (SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a)
-> Get SpanInfo -> Get (a -> QualIdent -> [Pattern a] -> Pattern a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (a -> QualIdent -> [Pattern a] -> Pattern a)
-> Get a -> Get (QualIdent -> [Pattern a] -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get a
forall t. Binary t => Get t
get Get (QualIdent -> [Pattern a] -> Pattern a)
-> Get QualIdent -> Get ([Pattern a] -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get QualIdent
forall t. Binary t => Get t
get Get ([Pattern a] -> Pattern a)
-> Get [Pattern a] -> Get (Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Pattern a]
forall t. Binary t => Get t
get
      4  -> SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
forall a.
SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
InfixPattern (SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a)
-> Get SpanInfo
-> Get (a -> Pattern a -> QualIdent -> Pattern a -> Pattern a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (a -> Pattern a -> QualIdent -> Pattern a -> Pattern a)
-> Get a -> Get (Pattern a -> QualIdent -> Pattern a -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get a
forall t. Binary t => Get t
get Get (Pattern a -> QualIdent -> Pattern a -> Pattern a)
-> Get (Pattern a) -> Get (QualIdent -> Pattern a -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Pattern a)
forall t. Binary t => Get t
get Get (QualIdent -> Pattern a -> Pattern a)
-> Get QualIdent -> Get (Pattern a -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get QualIdent
forall t. Binary t => Get t
get Get (Pattern a -> Pattern a) -> Get (Pattern a) -> Get (Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Pattern a)
forall t. Binary t => Get t
get
      5  -> (SpanInfo -> Pattern a -> Pattern a)
-> Get SpanInfo -> Get (Pattern a) -> Get (Pattern a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Pattern a -> Pattern a
forall a. SpanInfo -> Pattern a -> Pattern a
ParenPattern Get SpanInfo
forall t. Binary t => Get t
get Get (Pattern a)
forall t. Binary t => Get t
get
      6  -> SpanInfo -> a -> QualIdent -> [Field (Pattern a)] -> Pattern a
forall a.
SpanInfo -> a -> QualIdent -> [Field (Pattern a)] -> Pattern a
RecordPattern (SpanInfo -> a -> QualIdent -> [Field (Pattern a)] -> Pattern a)
-> Get SpanInfo
-> Get (a -> QualIdent -> [Field (Pattern a)] -> Pattern a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (a -> QualIdent -> [Field (Pattern a)] -> Pattern a)
-> Get a -> Get (QualIdent -> [Field (Pattern a)] -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get a
forall t. Binary t => Get t
get Get (QualIdent -> [Field (Pattern a)] -> Pattern a)
-> Get QualIdent -> Get ([Field (Pattern a)] -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get QualIdent
forall t. Binary t => Get t
get Get ([Field (Pattern a)] -> Pattern a)
-> Get [Field (Pattern a)] -> Get (Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Field (Pattern a)]
forall t. Binary t => Get t
get
      7  -> (SpanInfo -> [Pattern a] -> Pattern a)
-> Get SpanInfo -> Get [Pattern a] -> Get (Pattern a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> [Pattern a] -> Pattern a
forall a. SpanInfo -> [Pattern a] -> Pattern a
TuplePattern Get SpanInfo
forall t. Binary t => Get t
get Get [Pattern a]
forall t. Binary t => Get t
get
      8  -> (SpanInfo -> a -> [Pattern a] -> Pattern a)
-> Get SpanInfo -> Get a -> Get [Pattern a] -> Get (Pattern a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> a -> [Pattern a] -> Pattern a
forall a. SpanInfo -> a -> [Pattern a] -> Pattern a
ListPattern Get SpanInfo
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get Get [Pattern a]
forall t. Binary t => Get t
get
      9  -> (SpanInfo -> Ident -> Pattern a -> Pattern a)
-> Get SpanInfo -> Get Ident -> Get (Pattern a) -> Get (Pattern a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Ident -> Pattern a -> Pattern a
forall a. SpanInfo -> Ident -> Pattern a -> Pattern a
AsPattern Get SpanInfo
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get Get (Pattern a)
forall t. Binary t => Get t
get
      10 -> (SpanInfo -> Pattern a -> Pattern a)
-> Get SpanInfo -> Get (Pattern a) -> Get (Pattern a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Pattern a -> Pattern a
forall a. SpanInfo -> Pattern a -> Pattern a
LazyPattern Get SpanInfo
forall t. Binary t => Get t
get Get (Pattern a)
forall t. Binary t => Get t
get
      11 -> SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
forall a. SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
FunctionPattern (SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a)
-> Get SpanInfo -> Get (a -> QualIdent -> [Pattern a] -> Pattern a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (a -> QualIdent -> [Pattern a] -> Pattern a)
-> Get a -> Get (QualIdent -> [Pattern a] -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get a
forall t. Binary t => Get t
get Get (QualIdent -> [Pattern a] -> Pattern a)
-> Get QualIdent -> Get ([Pattern a] -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get QualIdent
forall t. Binary t => Get t
get Get ([Pattern a] -> Pattern a)
-> Get [Pattern a] -> Get (Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Pattern a]
forall t. Binary t => Get t
get
      12 -> SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
forall a.
SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
InfixFuncPattern (SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a)
-> Get SpanInfo
-> Get (a -> Pattern a -> QualIdent -> Pattern a -> Pattern a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (a -> Pattern a -> QualIdent -> Pattern a -> Pattern a)
-> Get a -> Get (Pattern a -> QualIdent -> Pattern a -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get a
forall t. Binary t => Get t
get Get (Pattern a -> QualIdent -> Pattern a -> Pattern a)
-> Get (Pattern a) -> Get (QualIdent -> Pattern a -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Pattern a)
forall t. Binary t => Get t
get Get (QualIdent -> Pattern a -> Pattern a)
-> Get QualIdent -> Get (Pattern a -> Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get QualIdent
forall t. Binary t => Get t
get Get (Pattern a -> Pattern a) -> Get (Pattern a) -> Get (Pattern a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Pattern a)
forall t. Binary t => Get t
get
      _  -> String -> Get (Pattern a)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Pattern"

instance Binary a => Binary (Expression a) where
  put :: Expression a -> Put
put (Literal spi :: SpanInfo
spi a :: a
a l :: Literal
l) =
    Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Literal -> Put
forall t. Binary t => t -> Put
put Literal
l
  put (Variable spi :: SpanInfo
spi a :: a
a qid :: QualIdent
qid) =
    Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid
  put (Constructor spi :: SpanInfo
spi a :: a
a qid :: QualIdent
qid) =
    Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid
  put (Paren spi :: SpanInfo
spi e :: Expression a
e) =
    Word8 -> Put
putWord8 3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e
  put (Typed spi :: SpanInfo
spi e :: Expression a
e ty :: QualTypeExpr
ty) =
    Word8 -> Put
putWord8 4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualTypeExpr -> Put
forall t. Binary t => t -> Put
put QualTypeExpr
ty
  put (Record spi :: SpanInfo
spi a :: a
a qid :: QualIdent
qid fs :: [Field (Expression a)]
fs) =
    Word8 -> Put
putWord8 5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Field (Expression a)] -> Put
forall t. Binary t => t -> Put
put [Field (Expression a)]
fs
  put (RecordUpdate spi :: SpanInfo
spi e :: Expression a
e fs :: [Field (Expression a)]
fs) =
    Word8 -> Put
putWord8 6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Field (Expression a)] -> Put
forall t. Binary t => t -> Put
put [Field (Expression a)]
fs
  put (Tuple spi :: SpanInfo
spi es :: [Expression a]
es) =
    Word8 -> Put
putWord8 7 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Expression a] -> Put
forall t. Binary t => t -> Put
put [Expression a]
es
  put (List spi :: SpanInfo
spi a :: a
a es :: [Expression a]
es) =
    Word8 -> Put
putWord8 8 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Expression a] -> Put
forall t. Binary t => t -> Put
put [Expression a]
es
  put (ListCompr spi :: SpanInfo
spi e :: Expression a
e stms :: [Statement a]
stms) =
    Word8 -> Put
putWord8 9 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Statement a] -> Put
forall t. Binary t => t -> Put
put [Statement a]
stms
  put (EnumFrom spi :: SpanInfo
spi e1 :: Expression a
e1) =
    Word8 -> Put
putWord8 10 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e1
  put (EnumFromThen spi :: SpanInfo
spi e1 :: Expression a
e1 e2 :: Expression a
e2) =
    Word8 -> Put
putWord8 11 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e2
  put (EnumFromTo spi :: SpanInfo
spi e1 :: Expression a
e1 e2 :: Expression a
e2) =
    Word8 -> Put
putWord8 12 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e2
  put (EnumFromThenTo spi :: SpanInfo
spi e1 :: Expression a
e1 e2 :: Expression a
e2 e3 :: Expression a
e3) =
    Word8 -> Put
putWord8 13 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e3
  put (UnaryMinus spi :: SpanInfo
spi e :: Expression a
e) =
    Word8 -> Put
putWord8 14 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e
  put (Apply spi :: SpanInfo
spi e1 :: Expression a
e1 e2 :: Expression a
e2) =
    Word8 -> Put
putWord8 15 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e2
  put (InfixApply spi :: SpanInfo
spi e1 :: Expression a
e1 op :: InfixOp a
op e2 :: Expression a
e2) =
    Word8 -> Put
putWord8 16 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> InfixOp a -> Put
forall t. Binary t => t -> Put
put InfixOp a
op Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e2
  put (LeftSection spi :: SpanInfo
spi e :: Expression a
e op :: InfixOp a
op) =
    Word8 -> Put
putWord8 17 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> InfixOp a -> Put
forall t. Binary t => t -> Put
put InfixOp a
op
  put (RightSection spi :: SpanInfo
spi op :: InfixOp a
op e :: Expression a
e) =
    Word8 -> Put
putWord8 18 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> InfixOp a -> Put
forall t. Binary t => t -> Put
put InfixOp a
op Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e
  put (Lambda spi :: SpanInfo
spi ps :: [Pattern a]
ps e :: Expression a
e) =
    Word8 -> Put
putWord8 19 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Pattern a] -> Put
forall t. Binary t => t -> Put
put [Pattern a]
ps Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e
  put (Let spi :: SpanInfo
spi li :: LayoutInfo
li ds :: [Decl a]
ds e :: Expression a
e) =
    Word8 -> Put
putWord8 20 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Decl a] -> Put
forall t. Binary t => t -> Put
put [Decl a]
ds Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e
  put (Do spi :: SpanInfo
spi li :: LayoutInfo
li stms :: [Statement a]
stms e :: Expression a
e) =
    Word8 -> Put
putWord8 21 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Statement a] -> Put
forall t. Binary t => t -> Put
put [Statement a]
stms Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e
  put (IfThenElse spi :: SpanInfo
spi e1 :: Expression a
e1 e2 :: Expression a
e2 e3 :: Expression a
e3) =
    Word8 -> Put
putWord8 22 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e3
  put (Case spi :: SpanInfo
spi li :: LayoutInfo
li cty :: CaseType
cty e :: Expression a
e as :: [Alt a]
as) =
    Word8 -> Put
putWord8 23 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CaseType -> Put
forall t. Binary t => t -> Put
put CaseType
cty Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Alt a] -> Put
forall t. Binary t => t -> Put
put [Alt a]
as

  get :: Get (Expression a)
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0  -> (SpanInfo -> a -> Literal -> Expression a)
-> Get SpanInfo -> Get a -> Get Literal -> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> a -> Literal -> Expression a
forall a. SpanInfo -> a -> Literal -> Expression a
Literal Get SpanInfo
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get Get Literal
forall t. Binary t => Get t
get
      1  -> (SpanInfo -> a -> QualIdent -> Expression a)
-> Get SpanInfo -> Get a -> Get QualIdent -> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> a -> QualIdent -> Expression a
forall a. SpanInfo -> a -> QualIdent -> Expression a
Variable Get SpanInfo
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get
      2  -> (SpanInfo -> a -> QualIdent -> Expression a)
-> Get SpanInfo -> Get a -> Get QualIdent -> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> a -> QualIdent -> Expression a
forall a. SpanInfo -> a -> QualIdent -> Expression a
Constructor Get SpanInfo
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get
      3  -> (SpanInfo -> Expression a -> Expression a)
-> Get SpanInfo -> Get (Expression a) -> Get (Expression a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a
Paren Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      4  -> (SpanInfo -> Expression a -> QualTypeExpr -> Expression a)
-> Get SpanInfo
-> Get (Expression a)
-> Get QualTypeExpr
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Expression a -> QualTypeExpr -> Expression a
forall a. SpanInfo -> Expression a -> QualTypeExpr -> Expression a
Typed Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get Get QualTypeExpr
forall t. Binary t => Get t
get
      5  -> SpanInfo
-> a -> QualIdent -> [Field (Expression a)] -> Expression a
forall a.
SpanInfo
-> a -> QualIdent -> [Field (Expression a)] -> Expression a
Record (SpanInfo
 -> a -> QualIdent -> [Field (Expression a)] -> Expression a)
-> Get SpanInfo
-> Get (a -> QualIdent -> [Field (Expression a)] -> Expression a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (a -> QualIdent -> [Field (Expression a)] -> Expression a)
-> Get a
-> Get (QualIdent -> [Field (Expression a)] -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get a
forall t. Binary t => Get t
get Get (QualIdent -> [Field (Expression a)] -> Expression a)
-> Get QualIdent -> Get ([Field (Expression a)] -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get QualIdent
forall t. Binary t => Get t
get Get ([Field (Expression a)] -> Expression a)
-> Get [Field (Expression a)] -> Get (Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Field (Expression a)]
forall t. Binary t => Get t
get
      6  -> SpanInfo -> Expression a -> [Field (Expression a)] -> Expression a
forall a.
SpanInfo -> Expression a -> [Field (Expression a)] -> Expression a
RecordUpdate (SpanInfo
 -> Expression a -> [Field (Expression a)] -> Expression a)
-> Get SpanInfo
-> Get (Expression a -> [Field (Expression a)] -> Expression a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a -> [Field (Expression a)] -> Expression a)
-> Get (Expression a)
-> Get ([Field (Expression a)] -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get Get ([Field (Expression a)] -> Expression a)
-> Get [Field (Expression a)] -> Get (Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Field (Expression a)]
forall t. Binary t => Get t
get
      7  -> (SpanInfo -> [Expression a] -> Expression a)
-> Get SpanInfo -> Get [Expression a] -> Get (Expression a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> [Expression a] -> Expression a
forall a. SpanInfo -> [Expression a] -> Expression a
Tuple Get SpanInfo
forall t. Binary t => Get t
get Get [Expression a]
forall t. Binary t => Get t
get
      8  -> (SpanInfo -> a -> [Expression a] -> Expression a)
-> Get SpanInfo
-> Get a
-> Get [Expression a]
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> a -> [Expression a] -> Expression a
forall a. SpanInfo -> a -> [Expression a] -> Expression a
List Get SpanInfo
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get Get [Expression a]
forall t. Binary t => Get t
get
      9  -> (SpanInfo -> Expression a -> [Statement a] -> Expression a)
-> Get SpanInfo
-> Get (Expression a)
-> Get [Statement a]
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Expression a -> [Statement a] -> Expression a
forall a. SpanInfo -> Expression a -> [Statement a] -> Expression a
ListCompr Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get Get [Statement a]
forall t. Binary t => Get t
get
      10 -> (SpanInfo -> Expression a -> Expression a)
-> Get SpanInfo -> Get (Expression a) -> Get (Expression a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a
EnumFrom Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      11 -> (SpanInfo -> Expression a -> Expression a -> Expression a)
-> Get SpanInfo
-> Get (Expression a)
-> Get (Expression a)
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Expression a -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
EnumFromThen Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      12 -> (SpanInfo -> Expression a -> Expression a -> Expression a)
-> Get SpanInfo
-> Get (Expression a)
-> Get (Expression a)
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Expression a -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
EnumFromTo Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      13 -> SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
forall a.
SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
EnumFromThenTo (SpanInfo
 -> Expression a -> Expression a -> Expression a -> Expression a)
-> Get SpanInfo
-> Get
     (Expression a -> Expression a -> Expression a -> Expression a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a -> Expression a -> Expression a -> Expression a)
-> Get (Expression a)
-> Get (Expression a -> Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get Get (Expression a -> Expression a -> Expression a)
-> Get (Expression a) -> Get (Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get Get (Expression a -> Expression a)
-> Get (Expression a) -> Get (Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get
      14 -> (SpanInfo -> Expression a -> Expression a)
-> Get SpanInfo -> Get (Expression a) -> Get (Expression a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a
UnaryMinus Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      15 -> (SpanInfo -> Expression a -> Expression a -> Expression a)
-> Get SpanInfo
-> Get (Expression a)
-> Get (Expression a)
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Expression a -> Expression a -> Expression a
forall a. SpanInfo -> Expression a -> Expression a -> Expression a
Apply Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      16 -> SpanInfo
-> Expression a -> InfixOp a -> Expression a -> Expression a
forall a.
SpanInfo
-> Expression a -> InfixOp a -> Expression a -> Expression a
InfixApply (SpanInfo
 -> Expression a -> InfixOp a -> Expression a -> Expression a)
-> Get SpanInfo
-> Get (Expression a -> InfixOp a -> Expression a -> Expression a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a -> InfixOp a -> Expression a -> Expression a)
-> Get (Expression a)
-> Get (InfixOp a -> Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get Get (InfixOp a -> Expression a -> Expression a)
-> Get (InfixOp a) -> Get (Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (InfixOp a)
forall t. Binary t => Get t
get Get (Expression a -> Expression a)
-> Get (Expression a) -> Get (Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get
      17 -> (SpanInfo -> Expression a -> InfixOp a -> Expression a)
-> Get SpanInfo
-> Get (Expression a)
-> Get (InfixOp a)
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Expression a -> InfixOp a -> Expression a
forall a. SpanInfo -> Expression a -> InfixOp a -> Expression a
LeftSection Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get Get (InfixOp a)
forall t. Binary t => Get t
get
      18 -> (SpanInfo -> InfixOp a -> Expression a -> Expression a)
-> Get SpanInfo
-> Get (InfixOp a)
-> Get (Expression a)
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> InfixOp a -> Expression a -> Expression a
forall a. SpanInfo -> InfixOp a -> Expression a -> Expression a
RightSection Get SpanInfo
forall t. Binary t => Get t
get Get (InfixOp a)
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      19 -> (SpanInfo -> [Pattern a] -> Expression a -> Expression a)
-> Get SpanInfo
-> Get [Pattern a]
-> Get (Expression a)
-> Get (Expression a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> [Pattern a] -> Expression a -> Expression a
forall a. SpanInfo -> [Pattern a] -> Expression a -> Expression a
Lambda Get SpanInfo
forall t. Binary t => Get t
get Get [Pattern a]
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      20 -> SpanInfo -> LayoutInfo -> [Decl a] -> Expression a -> Expression a
forall a.
SpanInfo -> LayoutInfo -> [Decl a] -> Expression a -> Expression a
Let (SpanInfo
 -> LayoutInfo -> [Decl a] -> Expression a -> Expression a)
-> Get SpanInfo
-> Get (LayoutInfo -> [Decl a] -> Expression a -> Expression a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (LayoutInfo -> [Decl a] -> Expression a -> Expression a)
-> Get LayoutInfo -> Get ([Decl a] -> Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get LayoutInfo
forall t. Binary t => Get t
get Get ([Decl a] -> Expression a -> Expression a)
-> Get [Decl a] -> Get (Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Decl a]
forall t. Binary t => Get t
get Get (Expression a -> Expression a)
-> Get (Expression a) -> Get (Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get
      21 -> SpanInfo
-> LayoutInfo -> [Statement a] -> Expression a -> Expression a
forall a.
SpanInfo
-> LayoutInfo -> [Statement a] -> Expression a -> Expression a
Do (SpanInfo
 -> LayoutInfo -> [Statement a] -> Expression a -> Expression a)
-> Get SpanInfo
-> Get
     (LayoutInfo -> [Statement a] -> Expression a -> Expression a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (LayoutInfo -> [Statement a] -> Expression a -> Expression a)
-> Get LayoutInfo
-> Get ([Statement a] -> Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get LayoutInfo
forall t. Binary t => Get t
get Get ([Statement a] -> Expression a -> Expression a)
-> Get [Statement a] -> Get (Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Statement a]
forall t. Binary t => Get t
get Get (Expression a -> Expression a)
-> Get (Expression a) -> Get (Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get
      22 -> SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
forall a.
SpanInfo
-> Expression a -> Expression a -> Expression a -> Expression a
IfThenElse (SpanInfo
 -> Expression a -> Expression a -> Expression a -> Expression a)
-> Get SpanInfo
-> Get
     (Expression a -> Expression a -> Expression a -> Expression a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a -> Expression a -> Expression a -> Expression a)
-> Get (Expression a)
-> Get (Expression a -> Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get Get (Expression a -> Expression a -> Expression a)
-> Get (Expression a) -> Get (Expression a -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get Get (Expression a -> Expression a)
-> Get (Expression a) -> Get (Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get
      23 -> SpanInfo
-> LayoutInfo
-> CaseType
-> Expression a
-> [Alt a]
-> Expression a
forall a.
SpanInfo
-> LayoutInfo
-> CaseType
-> Expression a
-> [Alt a]
-> Expression a
Case (SpanInfo
 -> LayoutInfo
 -> CaseType
 -> Expression a
 -> [Alt a]
 -> Expression a)
-> Get SpanInfo
-> Get
     (LayoutInfo -> CaseType -> Expression a -> [Alt a] -> Expression a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get SpanInfo
forall t. Binary t => Get t
get Get
  (LayoutInfo -> CaseType -> Expression a -> [Alt a] -> Expression a)
-> Get LayoutInfo
-> Get (CaseType -> Expression a -> [Alt a] -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get LayoutInfo
forall t. Binary t => Get t
get Get (CaseType -> Expression a -> [Alt a] -> Expression a)
-> Get CaseType -> Get (Expression a -> [Alt a] -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get CaseType
forall t. Binary t => Get t
get Get (Expression a -> [Alt a] -> Expression a)
-> Get (Expression a) -> Get ([Alt a] -> Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (Expression a)
forall t. Binary t => Get t
get Get ([Alt a] -> Expression a) -> Get [Alt a] -> Get (Expression a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get [Alt a]
forall t. Binary t => Get t
get
      _  -> String -> Get (Expression a)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Expression"

instance Binary a => Binary (InfixOp a) where
  put :: InfixOp a -> Put
put (InfixOp     a :: a
a qid :: QualIdent
qid) = Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid
  put (InfixConstr a :: a
a qid :: QualIdent
qid) = Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid

  get :: Get (InfixOp a)
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (a -> QualIdent -> InfixOp a)
-> Get a -> Get QualIdent -> Get (InfixOp a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 a -> QualIdent -> InfixOp a
forall a. a -> QualIdent -> InfixOp a
InfixOp Get a
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get
      1 -> (a -> QualIdent -> InfixOp a)
-> Get a -> Get QualIdent -> Get (InfixOp a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 a -> QualIdent -> InfixOp a
forall a. a -> QualIdent -> InfixOp a
InfixConstr Get a
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get
      _ -> String -> Get (InfixOp a)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for InfixOp"

instance Binary a => Binary (Statement a) where
  put :: Statement a -> Put
put (StmtExpr spi :: SpanInfo
spi     e :: Expression a
e) = Word8 -> Put
putWord8 0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e
  put (StmtDecl spi :: SpanInfo
spi li :: LayoutInfo
li ds :: [Decl a]
ds) = Word8 -> Put
putWord8 1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LayoutInfo -> Put
forall t. Binary t => t -> Put
put LayoutInfo
li Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Decl a] -> Put
forall t. Binary t => t -> Put
put [Decl a]
ds
  put (StmtBind spi :: SpanInfo
spi p :: Pattern a
p   e :: Expression a
e) = Word8 -> Put
putWord8 2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expression a -> Put
forall t. Binary t => t -> Put
put Expression a
e

  get :: Get (Statement a)
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> (SpanInfo -> Expression a -> Statement a)
-> Get SpanInfo -> Get (Expression a) -> Get (Statement a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 SpanInfo -> Expression a -> Statement a
forall a. SpanInfo -> Expression a -> Statement a
StmtExpr Get SpanInfo
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      1 -> (SpanInfo -> LayoutInfo -> [Decl a] -> Statement a)
-> Get SpanInfo
-> Get LayoutInfo
-> Get [Decl a]
-> Get (Statement a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> LayoutInfo -> [Decl a] -> Statement a
forall a. SpanInfo -> LayoutInfo -> [Decl a] -> Statement a
StmtDecl Get SpanInfo
forall t. Binary t => Get t
get Get LayoutInfo
forall t. Binary t => Get t
get Get [Decl a]
forall t. Binary t => Get t
get
      2 -> (SpanInfo -> Pattern a -> Expression a -> Statement a)
-> Get SpanInfo
-> Get (Pattern a)
-> Get (Expression a)
-> Get (Statement a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Pattern a -> Expression a -> Statement a
forall a. SpanInfo -> Pattern a -> Expression a -> Statement a
StmtBind Get SpanInfo
forall t. Binary t => Get t
get Get (Pattern a)
forall t. Binary t => Get t
get Get (Expression a)
forall t. Binary t => Get t
get
      _ -> String -> Get (Statement a)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for Statement"

instance Binary CaseType where
  put :: CaseType -> Put
put Rigid = Word8 -> Put
putWord8 0
  put Flex  = Word8 -> Put
putWord8 1

  get :: Get CaseType
get = do
    Word8
x <- Get Word8
getWord8
    case Word8
x of
      0 -> CaseType -> Get CaseType
forall (m :: * -> *) a. Monad m => a -> m a
return CaseType
Rigid
      1 -> CaseType -> Get CaseType
forall (m :: * -> *) a. Monad m => a -> m a
return CaseType
Flex
      _ -> String -> Get CaseType
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Invalid encoding for CaseType"

instance Binary a => Binary (Alt a) where
  put :: Alt a -> Put
put (Alt spi :: SpanInfo
spi p :: Pattern a
p rhs :: Rhs a
rhs) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pattern a -> Put
forall t. Binary t => t -> Put
put Pattern a
p Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Rhs a -> Put
forall t. Binary t => t -> Put
put Rhs a
rhs
  get :: Get (Alt a)
get = (SpanInfo -> Pattern a -> Rhs a -> Alt a)
-> Get SpanInfo -> Get (Pattern a) -> Get (Rhs a) -> Get (Alt a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> Pattern a -> Rhs a -> Alt a
forall a. SpanInfo -> Pattern a -> Rhs a -> Alt a
Alt Get SpanInfo
forall t. Binary t => Get t
get Get (Pattern a)
forall t. Binary t => Get t
get Get (Rhs a)
forall t. Binary t => Get t
get

instance Binary a => Binary (Field a) where
  put :: Field a -> Put
put (Field spi :: SpanInfo
spi qid :: QualIdent
qid a :: a
a) = SpanInfo -> Put
forall t. Binary t => t -> Put
put SpanInfo
spi Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QualIdent -> Put
forall t. Binary t => t -> Put
put QualIdent
qid Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> Put
forall t. Binary t => t -> Put
put a
a
  get :: Get (Field a)
get = (SpanInfo -> QualIdent -> a -> Field a)
-> Get SpanInfo -> Get QualIdent -> Get a -> Get (Field a)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 SpanInfo -> QualIdent -> a -> Field a
forall a. SpanInfo -> QualIdent -> a -> Field a
Field Get SpanInfo
forall t. Binary t => Get t
get Get QualIdent
forall t. Binary t => Get t
get Get a
forall t. Binary t => Get t
get

instance Binary a => Binary (Var a) where
  put :: Var a -> Put
put (Var a :: a
a idt :: Ident
idt) = a -> Put
forall t. Binary t => t -> Put
put a
a Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
idt
  get :: Get (Var a)
get = (a -> Ident -> Var a) -> Get a -> Get Ident -> Get (Var a)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 a -> Ident -> Var a
forall a. a -> Ident -> Var a
Var Get a
forall t. Binary t => Get t
get Get Ident
forall t. Binary t => Get t
get

{- HLINT ignore "Use record patterns"-}