{-# LANGUAGE DataKinds, DeriveGeneric, DuplicateRecordFields, FlexibleContexts, FlexibleInstances,
             MultiParamTypeClasses, OverloadedStrings, RankNTypes,
             ScopedTypeVariables, TemplateHaskell, TypeFamilies, UndecidableInstances #-}

-- | The main export of this module is the function 'foldConstants' that folds the constants in a Modula-2 AST using
-- an attribute grammar. Other exports are helper functions and attribute types that can be reused for other languages
-- or attribute grammars.

module Language.Modula2.ConstantFolder (foldConstants,
                                        ConstantFold, Sem, Environment,
                                        InhCF, SynCF(..), SynCFDesignator(..), SynCFExp(..), SynCFMod(..), SynCFMod',
                                        foldBinaryArithmetic, foldBinaryBoolean,
                                        foldBinaryFractional, foldBinaryInteger,
                                        maxCardinal, maxInteger, minInteger, maxInt32, minInt32, maxSet, minSet,
                                        doubleSize, floatSize, intSize, int32Size,
                                        maxReal, minReal) where

import Control.Applicative (liftA2, ZipList(ZipList, getZipList))
import Control.Arrow (first)
import Control.Monad (join)
import Data.Bits (shift)
import Data.Char (chr, ord, toUpper)
import Data.Functor.Identity (Identity(..))
import Data.Int (Int32)
import Data.Foldable (fold)
import Data.List.NonEmpty (NonEmpty((:|)), toList)
import Data.Map.Lazy (Map)
import qualified Data.Map.Lazy as Map
import Data.Semigroup (Semigroup(..))
import qualified Data.Text as Text
import Foreign.Storable (sizeOf)
import GHC.Generics (Generic)
import Language.Haskell.TH (appT, conT, varT, varE, newName)
import Data.Text.Prettyprint.Doc (Pretty)

import qualified Rank2
import qualified Transformation
import qualified Transformation.Deep as Deep
import qualified Transformation.Full as Full
import qualified Transformation.Full.TH
import qualified Transformation.AG as AG
import Transformation.AG (Attribution(..), Atts, Inherited(..), Synthesized(..), Semantics)
import Transformation.AG.Generics (Bequether(..), Synthesizer(..), SynthesizedField(..), Auto(Auto), Mapped(..))

import qualified Language.Modula2.Abstract as Abstract
import qualified Language.Modula2.AST as AST
import Language.Modula2.Grammar (ParsedLexemes(Trailing), Lexeme(WhiteSpace))
import qualified Language.Oberon.Abstract as Oberon.Abstract
import qualified Language.Oberon.AST as Oberon.AST
import qualified Language.Oberon.ConstantFolder as Oberon
import Language.Oberon.ConstantFolder (ConstantFold(ConstantFold), Sem, Environment,
                                       InhCF(..), InhCFRoot(..), SynCF(..), SynCF',
                                       SynCFRoot(..), SynCFMod(..), SynCFDesignator(..), SynCFMod', SynCFExp(..),
                                       anyWhitespace, folded', foldedExp, foldedExp')

-- | Fold the constants in the given collection of Modula-2 modules (a 'Map' of modules keyed by module name). It uses
-- the constant declarations from the modules as well as the given 'Environment' of predefined constants and
-- functions.
--
-- Note that the Modula-2 'AST.Language' satisfies all constraints in the function's type signature.
foldConstants :: forall l. (Abstract.Modula2 l, Abstract.Nameable l,
                            Ord (Abstract.QualIdent l), Show (Abstract.QualIdent l),
                            Atts (Inherited (Auto ConstantFold)) (Abstract.Block l l Sem Sem) ~ InhCF l,
                            Atts (Inherited (Auto ConstantFold)) (Abstract.Definition l l Sem Sem) ~ InhCF l,
                            Atts (Inherited (Auto ConstantFold)) (Abstract.Expression l l Sem Sem) ~ InhCF l,
                            Atts (Synthesized (Auto ConstantFold)) (Abstract.Block l l Sem Sem)
                            ~ SynCFMod' l (Abstract.Block l l),
                            Atts (Synthesized (Auto ConstantFold)) (Abstract.Block l l Placed Placed)
                            ~ SynCFMod' l (Abstract.Block l l),
                            Atts (Synthesized (Auto ConstantFold)) (Abstract.Definition l l Sem Sem)
                            ~ SynCFMod' l (Abstract.Definition l l),
                            Atts (Synthesized (Auto ConstantFold)) (Abstract.Definition l l Placed Placed)
                            ~ SynCFMod' l (Abstract.Definition l l),
                            Atts (Synthesized (Auto ConstantFold)) (Abstract.Expression l l Sem Sem) ~ SynCFExp l l,
                            Atts (Synthesized (Auto ConstantFold)) (Abstract.Expression l l Placed Placed)
                            ~ SynCFExp l l,
                            Full.Functor (Auto ConstantFold) (Abstract.Block l l),
                            Full.Functor (Auto ConstantFold) (Abstract.Definition l l),
                            Full.Functor (Auto ConstantFold) (Abstract.Expression l l))
              => Environment l -> AST.Module l l Placed Placed -> AST.Module l l Placed Placed
foldConstants :: Environment l
-> Module l l Placed Placed -> Module l l Placed Placed
foldConstants Environment l
predef Module l l Placed Placed
aModule =
   ((Int, ParsedLexemes, Int), Module l l Placed Placed)
-> Module l l Placed Placed
forall a b. (a, b) -> b
snd (((Int, ParsedLexemes, Int), Module l l Placed Placed)
 -> Module l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Module l l Placed Placed)
-> Module l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Mapped Placed (Module l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Module l l Placed Placed)
forall k (f :: k -> *) (a :: k). Mapped f a -> f a
getMapped
   (Mapped Placed (Module l l Placed Placed)
 -> ((Int, ParsedLexemes, Int), Module l l Placed Placed))
-> Mapped Placed (Module l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Module l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ SynCFMod l (Module l l Placed Placed)
-> Mapped Placed (Module l l Placed Placed)
forall l a. SynCFMod l a -> Mapped Placed a
folded (Synthesized
  (Auto ConstantFold)
  (Module
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn (Auto ConstantFold
-> Domain
     (Auto ConstantFold)
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Codomain
     (Auto ConstantFold)
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.apply (ConstantFold -> Auto ConstantFold
forall t. t -> Auto t
Auto ConstantFold
ConstantFold) ((Int
0, [Lexeme] -> ParsedLexemes
Trailing [], Int
0), ConstantFold -> Auto ConstantFold
forall t. t -> Auto t
Auto ConstantFold
ConstantFold Auto ConstantFold
-> Module
     l l (Domain (Auto ConstantFold)) (Domain (Auto ConstantFold))
-> Module
     l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold))
forall t (g :: (* -> *) -> (* -> *) -> *).
Functor t g =>
t -> g (Domain t) (Domain t) -> g (Codomain t) (Codomain t)
Deep.<$> Module l l Placed Placed
Module
  l l (Domain (Auto ConstantFold)) (Domain (Auto ConstantFold))
aModule)
                  Semantics
  (Auto ConstantFold)
  (Module
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Inherited
     (Auto ConstantFold)
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Synthesized
     (Auto ConstantFold)
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall k (p :: k -> *) (q :: k -> *) (a :: k).
Arrow p q a -> p a -> q a
`Rank2.apply`
                  Atts
  (Inherited (Auto ConstantFold))
  (Module
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Inherited
     (Auto ConstantFold)
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Atts (Inherited t) a -> Inherited t a
Inherited (Environment l -> Ident -> InhCF l
forall l. Environment l -> Ident -> InhCF l
InhCF Environment l
predef Ident
forall a. HasCallStack => a
undefined))
             :: SynCFMod' l (AST.Module l l))

newtype Modules l f' f = Modules {Modules l f' f -> Map Ident (f (Module l l f' f'))
getModules :: Map AST.Ident (f (AST.Module l l f' f'))}

-- * Modules instances, TH candidates
instance (Transformation.Transformation t, Functor (Transformation.Domain t), Deep.Functor t (AST.Module l l),
          Transformation.At t (AST.Module l l (Transformation.Codomain t) (Transformation.Codomain t))) =>
         Deep.Functor t (Modules l) where
   t
t <$> :: t
-> Modules l (Domain t) (Domain t)
-> Modules l (Codomain t) (Codomain t)
<$> ~(Modules Map Ident (Domain t (Module l l (Domain t) (Domain t)))
ms) = Map Ident (Codomain t (Module l l (Codomain t) (Codomain t)))
-> Modules l (Codomain t) (Codomain t)
forall l (f' :: * -> *) (f :: * -> *).
Map Ident (f (Module l l f' f')) -> Modules l f' f
Modules (Domain t (Module l l (Domain t) (Domain t))
-> Codomain t (Module l l (Codomain t) (Codomain t))
mapModule (Domain t (Module l l (Domain t) (Domain t))
 -> Codomain t (Module l l (Codomain t) (Codomain t)))
-> Map Ident (Domain t (Module l l (Domain t) (Domain t)))
-> Map Ident (Codomain t (Module l l (Codomain t) (Codomain t)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map Ident (Domain t (Module l l (Domain t) (Domain t)))
ms)
      where mapModule :: Domain t (Module l l (Domain t) (Domain t))
-> Codomain t (Module l l (Codomain t) (Codomain t))
mapModule Domain t (Module l l (Domain t) (Domain t))
m = t
t t
-> Domain t (Module l l (Codomain t) (Codomain t))
-> Codomain t (Module l l (Codomain t) (Codomain t))
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ ((t
t t
-> Module l l (Domain t) (Domain t)
-> Module l l (Codomain t) (Codomain t)
forall t (g :: (* -> *) -> (* -> *) -> *).
Functor t g =>
t -> g (Domain t) (Domain t) -> g (Codomain t) (Codomain t)
Deep.<$>) (Module l l (Domain t) (Domain t)
 -> Module l l (Codomain t) (Codomain t))
-> Domain t (Module l l (Domain t) (Domain t))
-> Domain t (Module l l (Codomain t) (Codomain t))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Domain t (Module l l (Domain t) (Domain t))
m)

instance Rank2.Functor (Modules l f') where
   forall a. p a -> q a
f <$> :: (forall a. p a -> q a) -> Modules l f' p -> Modules l f' q
<$> ~(Modules Map Ident (p (Module l l f' f'))
ms) = Map Ident (q (Module l l f' f')) -> Modules l f' q
forall l (f' :: * -> *) (f :: * -> *).
Map Ident (f (Module l l f' f')) -> Modules l f' f
Modules (p (Module l l f' f') -> q (Module l l f' f')
forall a. p a -> q a
f (p (Module l l f' f') -> q (Module l l f' f'))
-> Map Ident (p (Module l l f' f'))
-> Map Ident (q (Module l l f' f'))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map Ident (p (Module l l f' f'))
ms)

instance Rank2.Apply (Modules l f') where
   ~(Modules Map Ident ((~>) p q (Module l l f' f'))
fs) <*> :: Modules l f' (p ~> q) -> Modules l f' p -> Modules l f' q
<*> ~(Modules Map Ident (p (Module l l f' f'))
ms) = Map Ident (q (Module l l f' f')) -> Modules l f' q
forall l (f' :: * -> *) (f :: * -> *).
Map Ident (f (Module l l f' f')) -> Modules l f' f
Modules (((~>) p q (Module l l f' f')
 -> p (Module l l f' f') -> q (Module l l f' f'))
-> Map Ident ((~>) p q (Module l l f' f'))
-> Map Ident (p (Module l l f' f'))
-> Map Ident (q (Module l l f' f'))
forall k a b c.
Ord k =>
(a -> b -> c) -> Map k a -> Map k b -> Map k c
Map.intersectionWith (~>) p q (Module l l f' f')
-> p (Module l l f' f') -> q (Module l l f' f')
forall k (p :: k -> *) (q :: k -> *) (a :: k).
Arrow p q a -> p a -> q a
Rank2.apply Map Ident ((~>) p q (Module l l f' f'))
fs Map Ident (p (Module l l f' f'))
ms)

-- * Boring attribute types
type instance Atts (Synthesized (Auto ConstantFold)) (Modules l _ _) = SynCFRoot (Modules l Placed Identity)
type instance Atts (Synthesized (Auto ConstantFold)) (AST.Module λ l _ _) = SynCFMod' l (AST.Module λ l)
type instance Atts (Synthesized (Auto ConstantFold)) (AST.Declaration full λ l _ _) = SynCFMod' l (AST.Declaration full λ l)
type instance Atts (Synthesized (Auto ConstantFold)) (AST.ProcedureHeading λ l _ _) = SynCF' (AST.ProcedureHeading λ l)
type instance Atts (Synthesized (Auto ConstantFold)) (AST.Type λ l _ _) = SynCF' (AST.Type λ l)
type instance Atts (Synthesized (Auto ConstantFold)) (AST.FieldList λ l _ _) = SynCF' (AST.FieldList λ l)
type instance Atts (Synthesized (Auto ConstantFold)) (AST.Expression λ l _ _) = SynCFExp λ l
type instance Atts (Synthesized (Auto ConstantFold)) (AST.Designator λ l _ _) = SynCFDesignator l
type instance Atts (Synthesized (Auto ConstantFold)) (AST.Statement λ l _ _) = SynCF' (AST.Statement λ l)
type instance Atts (Synthesized (Auto ConstantFold)) (AST.Variant λ l _ _) = SynCF' (AST.Variant λ l)

type instance Atts (Inherited (Auto ConstantFold)) (Modules l _ _) = InhCFRoot l
type instance Atts (Inherited (Auto ConstantFold)) (AST.Module λ l _ _) = InhCF λ
type instance Atts (Inherited (Auto ConstantFold)) (AST.Declaration full λ l _ _) = InhCF λ
type instance Atts (Inherited (Auto ConstantFold)) (AST.ProcedureHeading λ l _ _) = InhCF λ
type instance Atts (Inherited (Auto ConstantFold)) (AST.Type λ l _ _) = InhCF λ
type instance Atts (Inherited (Auto ConstantFold)) (AST.FieldList λ l _ _) = InhCF λ
type instance Atts (Inherited (Auto ConstantFold)) (AST.Expression λ l _ _) = InhCF λ
type instance Atts (Inherited (Auto ConstantFold)) (AST.Designator λ l _ _) = InhCF λ
type instance Atts (Inherited (Auto ConstantFold)) (AST.Statement λ l _ _) = InhCF λ
type instance Atts (Inherited (Auto ConstantFold)) (AST.Variant λ l _ _) = InhCF λ

type Placed = (,) (Int, ParsedLexemes, Int)

wrap :: a -> Mapped Placed a
wrap :: a -> Mapped Placed a
wrap = ((Int, ParsedLexemes, Int), a) -> Mapped Placed a
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped (((Int, ParsedLexemes, Int), a) -> Mapped Placed a)
-> (a -> ((Int, ParsedLexemes, Int), a)) -> a -> Mapped Placed a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (,) (Int
0, [Lexeme] -> ParsedLexemes
Trailing [], Int
0)

-- * Rules

instance Ord (Abstract.QualIdent l) => Attribution (Auto ConstantFold) (Modules l) Sem Placed where
   attribution :: Auto ConstantFold
-> Placed
     (Modules
        l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold)))
-> Rule (Auto ConstantFold) (Modules l)
attribution Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
_, Modules Map
  Ident
  (Sem
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
self) (Inherited Atts (Inherited (Auto ConstantFold)) (Modules l sem sem)
inheritance, Modules Map Ident (Synthesized (Auto ConstantFold) (Module l l sem sem))
ms) =
     (Atts (Synthesized (Auto ConstantFold)) (Modules l sem sem)
-> Synthesized (Auto ConstantFold) (Modules l sem sem)
forall t a. Atts (Synthesized t) a -> Synthesized t a
Synthesized SynCFRoot :: forall a. a -> SynCFRoot a
SynCFRoot{$sel:modulesFolded:SynCFRoot :: Modules l Placed Identity
modulesFolded= Map Ident (Identity (Module l l Placed Placed))
-> Modules l Placed Identity
forall l (f' :: * -> *) (f :: * -> *).
Map Ident (f (Module l l f' f')) -> Modules l f' f
Modules (Module l l Placed Placed -> Identity (Module l l Placed Placed)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Module l l Placed Placed -> Identity (Module l l Placed Placed))
-> (Synthesized (Auto ConstantFold) (Module l l sem sem)
    -> Module l l Placed Placed)
-> Synthesized (Auto ConstantFold) (Module l l sem sem)
-> Identity (Module l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Int, ParsedLexemes, Int), Module l l Placed Placed)
-> Module l l Placed Placed
forall a b. (a, b) -> b
snd (((Int, ParsedLexemes, Int), Module l l Placed Placed)
 -> Module l l Placed Placed)
-> (Synthesized (Auto ConstantFold) (Module l l sem sem)
    -> ((Int, ParsedLexemes, Int), Module l l Placed Placed))
-> Synthesized (Auto ConstantFold) (Module l l sem sem)
-> Module l l Placed Placed
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Mapped Placed (Module l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Module l l Placed Placed)
forall k (f :: k -> *) (a :: k). Mapped f a -> f a
getMapped (Mapped Placed (Module l l Placed Placed)
 -> ((Int, ParsedLexemes, Int), Module l l Placed Placed))
-> (Synthesized (Auto ConstantFold) (Module l l sem sem)
    -> Mapped Placed (Module l l Placed Placed))
-> Synthesized (Auto ConstantFold) (Module l l sem sem)
-> ((Int, ParsedLexemes, Int), Module l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SynCFMod' l (Module l l)
-> Mapped Placed (Module l l Placed Placed)
foldedModule (SynCFMod' l (Module l l)
 -> Mapped Placed (Module l l Placed Placed))
-> (Synthesized (Auto ConstantFold) (Module l l sem sem)
    -> SynCFMod' l (Module l l))
-> Synthesized (Auto ConstantFold) (Module l l sem sem)
-> Mapped Placed (Module l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthesized (Auto ConstantFold) (Module l l sem sem)
-> SynCFMod' l (Module l l)
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn (Synthesized (Auto ConstantFold) (Module l l sem sem)
 -> Identity (Module l l Placed Placed))
-> Map Ident (Synthesized (Auto ConstantFold) (Module l l sem sem))
-> Map Ident (Identity (Module l l Placed Placed))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map Ident (Synthesized (Auto ConstantFold) (Module l l sem sem))
ms)},
      Map Ident (Inherited (Auto ConstantFold) (Module l l sem sem))
-> Modules l sem (Inherited (Auto ConstantFold))
forall l (f' :: * -> *) (f :: * -> *).
Map Ident (f (Module l l f' f')) -> Modules l f' f
Modules ((Ident
 -> Sem
      (Module
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))
 -> Inherited (Auto ConstantFold) (Module l l sem sem))
-> Map
     Ident
     (Sem
        (Module
           l
           l
           (Semantics (Auto ConstantFold))
           (Semantics (Auto ConstantFold))))
-> Map Ident (Inherited (Auto ConstantFold) (Module l l sem sem))
forall k a b. (k -> a -> b) -> Map k a -> Map k b
Map.mapWithKey Ident
-> Sem
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Inherited (Auto ConstantFold) (Module l l sem sem)
moduleInheritance Map
  Ident
  (Sem
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
self))
     where moduleInheritance :: Ident
-> Sem
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Inherited (Auto ConstantFold) (Module l l sem sem)
moduleInheritance Ident
name Sem
  (Module
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
mod = Atts (Inherited (Auto ConstantFold)) (Module l l sem sem)
-> Inherited (Auto ConstantFold) (Module l l sem sem)
forall t a. Atts (Inherited t) a -> Inherited t a
Inherited InhCF :: forall l. Environment l -> Ident -> InhCF l
InhCF{$sel:env:InhCF :: Environment l
env= InhCFRoot l -> Environment l
forall l. InhCFRoot l -> Environment l
rootEnv Atts (Inherited (Auto ConstantFold)) (Modules l sem sem)
InhCFRoot l
inheritance Environment l -> Environment l -> Environment l
forall a. Semigroup a => a -> a -> a
<> (Synthesized (Auto ConstantFold) (Module l l sem sem)
 -> Environment l)
-> Map Ident (Synthesized (Auto ConstantFold) (Module l l sem sem))
-> Environment l
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (SynCFMod' l (Module l l) -> Environment l
forall l a. SynCFMod l a -> Environment l
moduleEnv (SynCFMod' l (Module l l) -> Environment l)
-> (Synthesized (Auto ConstantFold) (Module l l sem sem)
    -> SynCFMod' l (Module l l))
-> Synthesized (Auto ConstantFold) (Module l l sem sem)
-> Environment l
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthesized (Auto ConstantFold) (Module l l sem sem)
-> SynCFMod' l (Module l l)
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn) Map Ident (Synthesized (Auto ConstantFold) (Module l l sem sem))
ms,
                                                        $sel:currentModule:InhCF :: Ident
currentModule= Ident
name}
           foldedModule :: SynCFMod' l (AST.Module l l) -> Mapped Placed (AST.Module l l Placed Placed)
           foldedModule :: SynCFMod' l (Module l l)
-> Mapped Placed (Module l l Placed Placed)
foldedModule = SynCFMod' l (Module l l)
-> Mapped Placed (Module l l Placed Placed)
forall l a. SynCFMod l a -> Mapped Placed a
folded

instance (Abstract.Modula2 l, Abstract.Nameable l, k ~ Abstract.QualIdent l, Ord k, Show k,
          v ~ Abstract.Value l l Placed Placed,
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Block l l Sem Sem) ~ SynCFMod' l (Abstract.Block l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Definition l l Sem Sem)
          ~ SynCFMod' l (Abstract.Definition l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Definition l l Placed Placed)
          ~ SynCFMod' l (Abstract.Definition l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Expression l l Sem Sem) ~ SynCFExp l l) =>
         SynthesizedField "moduleEnv" (Map k (Maybe v)) (Auto ConstantFold) (AST.Module l l) Sem Placed where
   synthesizedField :: Proxy "moduleEnv"
-> Auto ConstantFold
-> Placed
     (Module
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Atts (Inherited (Auto ConstantFold)) (Module l l sem sem)
-> Module l l sem (Synthesized (Auto ConstantFold))
-> Map k (Maybe v)
synthesizedField Proxy "moduleEnv"
_ Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
_, Module
  l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
mod) Atts (Inherited (Auto ConstantFold)) (Module l l sem sem)
inheritance Module l l sem (Synthesized (Auto ConstantFold))
mod' =
      case (Module
  l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
mod, Module l l sem (Synthesized (Auto ConstantFold))
mod') of
        (AST.DefinitionModule{}, AST.DefinitionModule Ident
_ [Import l]
_ Maybe (Export l)
_ ZipList (Synthesized (Auto ConstantFold) (Definition l l sem sem))
definitions) -> (Synthesized
   (Auto ConstantFold)
   (Definition
      l
      l
      (Semantics (Auto ConstantFold))
      (Semantics (Auto ConstantFold)))
 -> Map k (Maybe v))
-> ZipList
     (Synthesized
        (Auto ConstantFold)
        (Definition
           l
           l
           (Semantics (Auto ConstantFold))
           (Semantics (Auto ConstantFold))))
-> Map k (Maybe v)
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (SynCFMod' l (Definition l l) -> Map k (Maybe v)
forall l a. SynCFMod l a -> Environment l
moduleEnv (SynCFMod' l (Definition l l) -> Map k (Maybe v))
-> (Synthesized
      (Auto ConstantFold)
      (Definition
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))
    -> SynCFMod' l (Definition l l))
-> Synthesized
     (Auto ConstantFold)
     (Definition
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Map k (Maybe v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthesized
  (Auto ConstantFold)
  (Definition
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> SynCFMod' l (Definition l l)
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn) ZipList (Synthesized (Auto ConstantFold) (Definition l l sem sem))
ZipList
  (Synthesized
     (Auto ConstantFold)
     (Definition
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
definitions
        (Module
   l
   l
   (Semantics (Auto ConstantFold))
   (Semantics (Auto ConstantFold)),
 Module l l sem (Synthesized (Auto ConstantFold)))
_ -> Map k (Maybe v)
forall a. Monoid a => a
mempty

instance (Abstract.Modula2 l, Abstract.Nameable l, k ~ Abstract.QualIdent l, Ord k, v ~ Abstract.Value l l Placed Placed,
          Abstract.Export l ~ AST.Export l, Abstract.Value l ~ AST.Value l,
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Declaration l l Sem Sem)
          ~ SynCFMod' l (Abstract.Declaration l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Type l l Sem Sem) ~ SynCF' (Abstract.Type l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.ProcedureHeading l l Sem Sem)
          ~ SynCF' (Abstract.ProcedureHeading l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.FormalParameters l l Sem Sem)
          ~ SynCF' (Abstract.FormalParameters l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Block l l Sem Sem) ~ SynCFMod' l (Abstract.Block l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.ConstExpression l l Sem Sem) ~ SynCFExp l l) =>
         SynthesizedField "moduleEnv" (Map k (Maybe v)) (Auto ConstantFold) (AST.Declaration full l l) Sem Placed where
   synthesizedField :: Proxy "moduleEnv"
-> Auto ConstantFold
-> Placed
     (Declaration
        full
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Atts
     (Inherited (Auto ConstantFold)) (Declaration full l l sem sem)
-> Declaration full l l sem (Synthesized (Auto ConstantFold))
-> Map k (Maybe v)
synthesizedField Proxy "moduleEnv"
_ Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
_, AST.ConstantDeclaration IdentDef l
namedef Sem
  (ConstExpression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
_) Atts (Inherited (Auto ConstantFold)) (Declaration full l l sem sem)
_ (AST.ConstantDeclaration IdentDef l
_ Synthesized (Auto ConstantFold) (ConstExpression l l sem sem)
expression) =
      k -> Maybe v -> Map k (Maybe v)
forall k a. k -> a -> Map k a
Map.singleton (Ident -> QualIdent l
forall l. Wirthy l => Ident -> QualIdent l
Abstract.nonQualIdent (Ident -> QualIdent l) -> Ident -> QualIdent l
forall a b. (a -> b) -> a -> b
$ IdentDef l -> Ident
forall l. Nameable l => IdentDef l -> Ident
Abstract.getIdentDefName IdentDef l
namedef)
                    ((((Int, ParsedLexemes, Int), v) -> v
forall a b. (a, b) -> b
snd (((Int, ParsedLexemes, Int), v) -> v)
-> Maybe ((Int, ParsedLexemes, Int), v) -> Maybe v
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Maybe ((Int, ParsedLexemes, Int), v) -> Maybe v)
-> (SynCFExp l l -> Maybe ((Int, ParsedLexemes, Int), v))
-> SynCFExp l l
-> Maybe v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SynCFExp l l -> Maybe ((Int, ParsedLexemes, Int), v)
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue (SynCFExp l l -> Maybe v) -> SynCFExp l l -> Maybe v
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (ConstExpression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (ConstExpression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (ConstExpression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (ConstExpression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
expression)
   synthesizedField Proxy "moduleEnv"
_ Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, AST.ModuleDeclaration Ident
moduleName Maybe
  (Sem
     (ConstExpression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
_priority [Import l]
imports Maybe (Export l)
exports Sem
  (Block
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
_body)
                    Atts (Inherited (Auto ConstantFold)) (Declaration full l l sem sem)
_ (AST.ModuleDeclaration Ident
_name Maybe
  (Synthesized (Auto ConstantFold) (ConstExpression l l sem sem))
priority [Import l]
_imports Maybe (Export l)
_exports Synthesized (Auto ConstantFold) (Block l l sem sem)
body) =
      (Export l -> Map k (Maybe v))
-> Maybe (Export l) -> Map k (Maybe v)
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap Export l -> Map k (Maybe v)
exportedEnv Maybe (Export l)
Maybe (Export l)
exports
      where exportedEnv :: Export l -> Map k (Maybe v)
exportedEnv (AST.Export Bool
qualified NonEmpty Ident
names) =
               (k -> k) -> Map k (Maybe v) -> Map k (Maybe v)
forall k1 k2 a. (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysMonotonic k -> k
qualify ((k -> Maybe v -> Bool) -> Map k (Maybe v) -> Map k (Maybe v)
forall k a. (k -> a -> Bool) -> Map k a -> Map k a
Map.filterWithKey (Bool -> Maybe v -> Bool
forall a b. a -> b -> a
const (Bool -> Maybe v -> Bool) -> (k -> Bool) -> k -> Maybe v -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (k -> [k] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [k]
exportList)) (SynCFMod' l (Block l l) -> Environment l
forall l a. SynCFMod l a -> Environment l
moduleEnv (SynCFMod' l (Block l l) -> Environment l)
-> SynCFMod' l (Block l l) -> Environment l
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (Block
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Block
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Block l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Block
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
body))
               where exportList :: [k]
exportList = [Ident] -> Ident -> QualIdent l
forall l. Modula2 l => [Ident] -> Ident -> QualIdent l
Abstract.qualIdent [] (Ident -> k) -> [Ident] -> [k]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty Ident -> [Ident]
forall a. NonEmpty a -> [a]
toList NonEmpty Ident
names
                     qualify :: k -> k
qualify k
qname
                        | Bool
qualified,
                          Just Ident
name <- QualIdent l -> Maybe Ident
forall l. Nameable l => QualIdent l -> Maybe Ident
Abstract.getNonQualIdentName k
QualIdent l
qname = [Ident] -> Ident -> QualIdent l
forall l. Modula2 l => [Ident] -> Ident -> QualIdent l
Abstract.qualIdent [Ident
moduleName] Ident
name
                        | Bool
otherwise = k
qname
   synthesizedField Proxy "moduleEnv"
_ Auto ConstantFold
_ Placed
  (Declaration
     full
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
_ Atts (Inherited (Auto ConstantFold)) (Declaration full l l sem sem)
_ Declaration full l l sem (Synthesized (Auto ConstantFold))
_ = Map k (Maybe v)
forall a. Monoid a => a
mempty

instance (Abstract.Nameable l, Ord (Abstract.QualIdent l), Abstract.Modula2 λ,
          Abstract.Value l ~ AST.Value l, Abstract.QualIdent l ~ AST.QualIdent l,
          Pretty (AST.Value l l Identity Identity),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Expression l l Sem Sem) ~ SynCFExp l l,
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Element l l Sem Sem) ~ SynCF' (Abstract.Element l l),
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Designator l l Sem Sem) ~ SynCFDesignator l) =>
         Synthesizer (Auto ConstantFold) (AST.Expression λ l) Sem Placed where
   synthesis :: Auto ConstantFold
-> Placed
     (Expression
        λ
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
-> Expression λ l sem (Synthesized (Auto ConstantFold))
-> Atts (Synthesized (Auto ConstantFold)) (Expression λ l sem sem)
synthesis Auto ConstantFold
_ (pos :: (Int, ParsedLexemes, Int)
pos@(Int
start, ParsedLexemes
ls, Int
end), AST.Relation RelOp
op Sem
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
_ Sem
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Relation RelOp
_op Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      case Maybe (Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
compareValues (((Int, ParsedLexemes, Int), Value l l Placed Placed)
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
 -> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Maybe
     (((Int, ParsedLexemes, Int), Value l l Placed Placed)
      -> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SynCFExp l l
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) Maybe
  (((Int, ParsedLexemes, Int), Value l l Placed Placed)
   -> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Maybe
     (Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SynCFExp l l
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right))
      of Just ((Int, ParsedLexemes, Int), Value l l Placed Placed)
value -> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis ((Int, ParsedLexemes, Int), Value l l Placed Placed)
value
         Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
Nothing -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos,
                                             RelOp
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
RelOp
-> f (Expression l' l' f' f')
-> f (Expression l' l' f' f')
-> Expression l l' f' f
Abstract.relation RelOp
op (SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' (SynCFExp l l
 -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed))
-> SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' (SynCFExp l l
 -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed))
-> SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)),
                             $sel:foldedValue:SynCFExp :: Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
foldedValue= Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. Maybe a
Nothing}
      where compareValues :: ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
compareValues ((Int, ParsedLexemes, Int)
_, AST.Boolean Bool
l) ((Int, ParsedLexemes, Int)
ls, AST.Boolean Bool
r)   = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Bool -> Bool -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Bool
l Bool
r)
            compareValues ((Int, ParsedLexemes, Int)
_, AST.Integer Integer
l) ((Int, ParsedLexemes, Int)
ls, AST.Integer Integer
r)   = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
l Integer
r)
            compareValues ((Int, ParsedLexemes, Int)
_, AST.Real Double
l) ((Int, ParsedLexemes, Int)
ls, AST.Real Double
r)         = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Double -> Double -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Double
l Double
r)
            compareValues ((Int, ParsedLexemes, Int)
_, AST.Integer Integer
l) ((Int, ParsedLexemes, Int)
ls, AST.Real Double
r)      = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Double -> Double -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
l) Double
r)
            compareValues ((Int, ParsedLexemes, Int)
_, AST.Real Double
l) ((Int, ParsedLexemes, Int)
ls, AST.Integer Integer
r)      = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Double -> Double -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Double
l (Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
r))
            compareValues ((Int, ParsedLexemes, Int)
_, AST.CharCode Int
l) ((Int, ParsedLexemes, Int)
ls, AST.CharCode Int
r) = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Int
l Int
r)
            compareValues ((Int, ParsedLexemes, Int)
_, AST.String Ident
l) ((Int, ParsedLexemes, Int)
ls, AST.String Ident
r)     = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Ident -> Ident -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Ident
l Ident
r)
            compareValues ((Int, ParsedLexemes, Int)
_, AST.CharCode Int
l) ((Int, ParsedLexemes, Int)
ls, AST.String Ident
r) = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls
                                                                   (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Ident -> Ident -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Char -> Ident
Text.singleton (Char -> Ident) -> Char -> Ident
forall a b. (a -> b) -> a -> b
$ Int -> Char
chr Int
l) Ident
r)
            compareValues ((Int, ParsedLexemes, Int)
_, AST.String Ident
l) ((Int, ParsedLexemes, Int)
ls, AST.CharCode Int
r) = (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int, ParsedLexemes, Int)
ls
                                                                   (Value l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Maybe (Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RelOp -> Ordering -> Maybe (Value l l Placed Placed)
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
op (Ident -> Ident -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Ident
l (Char -> Ident
Text.singleton (Char -> Ident) -> Char -> Ident
forall a b. (a -> b) -> a -> b
$ Int -> Char
chr Int
r))
            compareValues ((Int, ParsedLexemes, Int), Value l l Placed Placed)
_ ((Int, ParsedLexemes, Int), Value l l Placed Placed)
_                               = Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. Maybe a
Nothing
            repos :: (Int, ParsedLexemes, Int)
-> Value l l Placed Placed
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
repos (Int
_, ParsedLexemes
ls', Int
_) Value l l Placed Placed
v = ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end), Value l l Placed Placed
v)
            relate :: RelOp -> Ordering -> Maybe (Value l l' f' f)
relate RelOp
Abstract.Equal Ordering
EQ          = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.true
            relate RelOp
Abstract.Equal Ordering
_           = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.false
            relate RelOp
Abstract.Unequal Ordering
EQ        = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.false
            relate RelOp
Abstract.Unequal Ordering
_         = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.true
            relate RelOp
Abstract.Less Ordering
LT           = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.true
            relate RelOp
Abstract.Less Ordering
_            = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.false
            relate RelOp
Abstract.LessOrEqual Ordering
GT    = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.false
            relate RelOp
Abstract.LessOrEqual Ordering
_     = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.true
            relate RelOp
Abstract.Greater Ordering
GT        = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.true
            relate RelOp
Abstract.Greater Ordering
_         = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.false
            relate RelOp
Abstract.GreaterOrEqual Ordering
LT = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.false
            relate RelOp
Abstract.GreaterOrEqual Ordering
_  = Value l l' f' f -> Maybe (Value l l' f' f)
forall a. a -> Maybe a
Just Value l l' f' f
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.true
            relate RelOp
Abstract.In Ordering
_              = Maybe (Value l l' f' f)
forall a. Maybe a
Nothing
   synthesis Auto ConstantFold
_ (pos :: (Int, ParsedLexemes, Int)
pos@(Int
start, ParsedLexemes
ls, Int
end), Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Positive Synthesized (Auto ConstantFold) (Expression l l sem sem)
expr) =
      case SynCFExp l l
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
expr)
      of Just ((Int
_, ParsedLexemes
ls', Int
_), AST.Integer n) -> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end),
                                                                       Integer -> Value l l Placed Placed
forall λ l (f' :: * -> *) (f :: * -> *). Integer -> Value λ l f' f
AST.Integer Integer
n)
         Just ((Int
_, ParsedLexemes
ls', Int
_), AST.Real n) -> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end), Double -> Value l l Placed Placed
forall λ l (f' :: * -> *) (f :: * -> *). Double -> Value λ l f' f
AST.Real Double
n)
         Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
_ -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.positive (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
 -> Expression λ l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall a b. (a -> b) -> a -> b
$ SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' (SynCFExp l l
 -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed))
-> SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
expr),
                       $sel:foldedValue:SynCFExp :: Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
foldedValue= Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. Maybe a
Nothing}
   synthesis Auto ConstantFold
_ (pos :: (Int, ParsedLexemes, Int)
pos@(Int
start, ParsedLexemes
ls, Int
end), Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Negative Synthesized (Auto ConstantFold) (Expression l l sem sem)
expr) =
      case SynCFExp l l
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
expr)
      of Just ((Int
_, ParsedLexemes
ls', Int
_), AST.Integer n) -> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end),
                                                                       Integer -> Value l l Placed Placed
forall λ l (f' :: * -> *) (f :: * -> *). Integer -> Value λ l f' f
AST.Integer (Integer -> Value l l Placed Placed)
-> Integer -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Integer -> Integer
forall a. Num a => a -> a
negate Integer
n)
         Just ((Int
_, ParsedLexemes
ls', Int
_), AST.Real n) -> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end),
                                                                    Double -> Value l l Placed Placed
forall λ l (f' :: * -> *) (f :: * -> *). Double -> Value λ l f' f
AST.Real (Double -> Value l l Placed Placed)
-> Double -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Double -> Double
forall a. Num a => a -> a
negate Double
n)
         Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
_ -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.negative (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
 -> Expression λ l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall a b. (a -> b) -> a -> b
$ SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' (SynCFExp l l
 -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed))
-> SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
expr),
                       $sel:foldedValue:SynCFExp :: Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
foldedValue= Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. Maybe a
Nothing}
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Add Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      (Int, ParsedLexemes, Int)
-> (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> Expression λ l Placed Placed)
-> (forall n. Num n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
forall λ l (f :: * -> *).
(f ~ Placed, Value l ~ Value l, Wirthy λ,
 Pretty (Value l l Identity Identity)) =>
(Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Num n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryArithmetic (Int, ParsedLexemes, Int)
pos ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f')
-> f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.add forall n. Num n => n -> n -> n
(+) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Subtract Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      (Int, ParsedLexemes, Int)
-> (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> Expression λ l Placed Placed)
-> (forall n. Num n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
forall λ l (f :: * -> *).
(f ~ Placed, Value l ~ Value l, Wirthy λ,
 Pretty (Value l l Identity Identity)) =>
(Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Num n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryArithmetic (Int, ParsedLexemes, Int)
pos ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f')
-> f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.subtract (-) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Or Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      (Int, ParsedLexemes, Int)
-> (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> Expression λ l Placed Placed)
-> (Bool -> Bool -> Bool)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
forall λ l (f :: * -> *).
(f ~ Placed, Value l ~ Value l, Wirthy λ,
 Pretty (Value l l Identity Identity)) =>
(Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (Bool -> Bool -> Bool)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryBoolean (Int, ParsedLexemes, Int)
pos ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f')
-> f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.or Bool -> Bool -> Bool
(||) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Multiply Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      (Int, ParsedLexemes, Int)
-> (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> Expression λ l Placed Placed)
-> (forall n. Num n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
forall λ l (f :: * -> *).
(f ~ Placed, Value l ~ Value l, Wirthy λ,
 Pretty (Value l l Identity Identity)) =>
(Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Num n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryArithmetic (Int, ParsedLexemes, Int)
pos ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f')
-> f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.multiply forall n. Num n => n -> n -> n
(*) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Divide Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      (Int, ParsedLexemes, Int)
-> (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> Expression λ l Placed Placed)
-> (forall n. Fractional n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
forall λ l (f :: * -> *).
(f ~ Placed, Value l ~ Value l, Wirthy λ,
 Pretty (Value l l Identity Identity)) =>
(Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Fractional n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryFractional (Int, ParsedLexemes, Int)
pos ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f')
-> f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.divide forall n. Fractional n => n -> n -> n
(/) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.IntegerDivide Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      (Int, ParsedLexemes, Int)
-> (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> Expression λ l Placed Placed)
-> (forall n. Integral n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
forall λ l (f :: * -> *).
(f ~ Placed, Value l ~ Value l, Wirthy λ,
 Pretty (Value l l Identity Identity)) =>
(Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Integral n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryInteger (Int, ParsedLexemes, Int)
pos ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f')
-> f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.integerDivide forall n. Integral n => n -> n -> n
div (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Modulo Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      (Int, ParsedLexemes, Int)
-> (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> Expression λ l Placed Placed)
-> (forall n. Integral n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
forall λ l (f :: * -> *).
(f ~ Placed, Value l ~ Value l, Wirthy λ,
 Pretty (Value l l Identity Identity)) =>
(Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Integral n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryInteger (Int, ParsedLexemes, Int)
pos ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f')
-> f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.modulo forall n. Integral n => n -> n -> n
mod (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.And Synthesized (Auto ConstantFold) (Expression l l sem sem)
left Synthesized (Auto ConstantFold) (Expression l l sem sem)
right) =
      (Int, ParsedLexemes, Int)
-> (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
    -> Expression λ l Placed Placed)
-> (Bool -> Bool -> Bool)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
forall λ l (f :: * -> *).
(f ~ Placed, Value l ~ Value l, Wirthy λ,
 Pretty (Value l l Identity Identity)) =>
(Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (Bool -> Bool -> Bool)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryBoolean (Int, ParsedLexemes, Int)
pos ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f')
-> f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.and Bool -> Bool -> Bool
(&&) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
left) (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
right)
   synthesis Auto ConstantFold
_ (pos :: (Int, ParsedLexemes, Int)
pos@(Int
start, ParsedLexemes
ls, Int
end), Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Not Synthesized (Auto ConstantFold) (Expression l l sem sem)
expr) =
      case SynCFExp l l
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue (Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
expr)
      of Just ((Int
_, ParsedLexemes
ls', Int
_), AST.Boolean b) -> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end),
                                                                       if Bool
b then Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.false else Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.true)
         Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
_ -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Expression l' l' f' f') -> Expression l l' f' f
Abstract.not (((Int, ParsedLexemes, Int), Expression l l Placed Placed)
 -> Expression λ l Placed Placed)
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
-> Expression λ l Placed Placed
forall a b. (a -> b) -> a -> b
$ SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' (SynCFExp l l
 -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed))
-> SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Expression l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
expr),
                       $sel:foldedValue:SynCFExp :: Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
foldedValue= Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. Maybe a
Nothing}
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, AST.Set Maybe (QualIdent l)
t ZipList
  (Sem
     (Element
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
_elements) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Set Maybe (QualIdent l)
_t ZipList (Synthesized (Auto ConstantFold) (Element l l sem sem))
elements) =
      SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, Maybe (QualIdent l)
-> [((Int, ParsedLexemes, Int), Element l l Placed Placed)]
-> Expression λ l Placed Placed
forall l l' (f :: * -> *) (f' :: * -> *).
Modula2 l =>
Maybe (QualIdent l')
-> [f (Element l' l' f' f')] -> Expression l l' f' f
Abstract.set Maybe (QualIdent l)
t (Mapped Placed (Element l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Element l l Placed Placed)
forall k (f :: k -> *) (a :: k). Mapped f a -> f a
getMapped (Mapped Placed (Element l l Placed Placed)
 -> ((Int, ParsedLexemes, Int), Element l l Placed Placed))
-> (Synthesized
      (Auto ConstantFold)
      (Element
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))
    -> Mapped Placed (Element l l Placed Placed))
-> Synthesized
     (Auto ConstantFold)
     (Element
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> ((Int, ParsedLexemes, Int), Element l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SynCF' (Element l l) -> Mapped Placed (Element l l Placed Placed)
forall (node :: (* -> *) -> (* -> *) -> *).
SynCF' node -> Mapped Placed (node Placed Placed)
folded' (SynCF' (Element l l) -> Mapped Placed (Element l l Placed Placed))
-> (Synthesized
      (Auto ConstantFold)
      (Element
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))
    -> SynCF' (Element l l))
-> Synthesized
     (Auto ConstantFold)
     (Element
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Mapped Placed (Element l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthesized
  (Auto ConstantFold)
  (Element
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> SynCF' (Element l l)
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn (Synthesized
   (Auto ConstantFold)
   (Element
      l
      l
      (Semantics (Auto ConstantFold))
      (Semantics (Auto ConstantFold)))
 -> ((Int, ParsedLexemes, Int), Element l l Placed Placed))
-> [Synthesized
      (Auto ConstantFold)
      (Element
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))]
-> [((Int, ParsedLexemes, Int), Element l l Placed Placed)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ZipList
  (Synthesized
     (Auto ConstantFold)
     (Element
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
-> [Synthesized
      (Auto ConstantFold)
      (Element
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))]
forall a. ZipList a -> [a]
getZipList ZipList (Synthesized (Auto ConstantFold) (Element l l sem sem))
ZipList
  (Synthesized
     (Auto ConstantFold)
     (Element
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
elements)),
               $sel:foldedValue:SynCFExp :: Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
foldedValue= Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. Maybe a
Nothing}
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Read Synthesized (Auto ConstantFold) (Designator l l sem sem)
des) =
      case (SynCFDesignator l
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall l.
SynCFDesignator l -> Maybe (Placed (Value l l Placed Placed))
designatorValue (Synthesized
  (Auto ConstantFold)
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Designator
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Designator l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
des), Mapped Placed (Designator l l Placed Placed)
-> Placed (Designator l l Placed Placed)
forall k (f :: k -> *) (a :: k). Mapped f a -> f a
getMapped (Mapped Placed (Designator l l Placed Placed)
 -> Placed (Designator l l Placed Placed))
-> Mapped Placed (Designator l l Placed Placed)
-> Placed (Designator l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ SynCFDesignator l -> Mapped Placed (Designator l l Placed Placed)
forall l.
SynCFDesignator l -> Mapped Placed (Designator l l Placed Placed)
folded (Synthesized
  (Auto ConstantFold)
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Designator
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Designator l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
des :: SynCFDesignator l))
      of (Just ((Int, ParsedLexemes, Int), Value l l Placed Placed)
val, Placed (Designator l l Placed Placed)
_) -> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis ((Int, ParsedLexemes, Int), Value l l Placed Placed)
val
         (Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
Nothing, ((Int, ParsedLexemes, Int)
pos', Designator l l Placed Placed
des')) -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, Placed (Designator l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Designator l' l' f' f') -> Expression l l' f' f
Abstract.read ((Int, ParsedLexemes, Int)
pos', Designator l l Placed Placed
des')),
                                             $sel:foldedValue:SynCFExp :: Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
foldedValue= Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. Maybe a
Nothing}
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, AST.FunctionCall Sem
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
fn1 ZipList
  (Sem
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
args1) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
inheritance (AST.FunctionCall Synthesized (Auto ConstantFold) (Designator l l sem sem)
fn ZipList (Synthesized (Auto ConstantFold) (Expression l l sem sem))
args) =
      case (((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Value l l Placed Placed
forall a b. (a, b) -> b
snd (((Int, ParsedLexemes, Int), Value l l Placed Placed)
 -> Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Maybe (Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SynCFDesignator l
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall l.
SynCFDesignator l -> Maybe (Placed (Value l l Placed Placed))
designatorValue (Synthesized
  (Auto ConstantFold)
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Designator
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Designator l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
fn :: SynCFDesignator l), (((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Value l l Placed Placed
forall a b. (a, b) -> b
snd (((Int, ParsedLexemes, Int), Value l l Placed Placed)
 -> Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Maybe (Value l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
 -> Maybe (Value l l Placed Placed))
-> (Synthesized
      (Auto ConstantFold)
      (Expression
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))
    -> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Synthesized
     (Auto ConstantFold)
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Maybe (Value l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SynCFExp l l
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue (SynCFExp l l
 -> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> (Synthesized
      (Auto ConstantFold)
      (Expression
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))
    -> SynCFExp l l)
-> Synthesized
     (Auto ConstantFold)
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> SynCFExp l l
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn (Synthesized
   (Auto ConstantFold)
   (Expression
      l
      l
      (Semantics (Auto ConstantFold))
      (Semantics (Auto ConstantFold)))
 -> Maybe (Value l l Placed Placed))
-> [Synthesized
      (Auto ConstantFold)
      (Expression
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))]
-> [Maybe (Value l l Placed Placed)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ZipList
  (Synthesized
     (Auto ConstantFold)
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
-> [Synthesized
      (Auto ConstantFold)
      (Expression
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))]
forall a. ZipList a -> [a]
getZipList ZipList (Synthesized (Auto ConstantFold) (Expression l l sem sem))
ZipList
  (Synthesized
     (Auto ConstantFold)
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
args)
      of (Just (AST.Builtin Ident
"CAP"), [Just (AST.String Ident
s)])
            | Ident -> Int
Text.length Ident
s Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1, Ident
capital <- Ident -> Ident
Text.toUpper Ident
s -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Ident -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Ident -> Value l l' f' f
Abstract.string Ident
capital)
         (Just (AST.Builtin Ident
"CAP"), [Just (AST.CharCode Int
c)])
            | Int
capital <- Char -> Int
ord (Char -> Char
toUpper (Char -> Char) -> Char -> Char
forall a b. (a -> b) -> a -> b
$ Int -> Char
chr Int
c) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Int -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Int -> Value l l' f' f
Abstract.charCode Int
capital)
         (Just (AST.Builtin Ident
"CHR"), [Just (AST.Integer Integer
code)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Int -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Int -> Value l l' f' f
Abstract.charCode (Int -> Value l l Placed Placed) -> Int -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
code)
         (Just (AST.Builtin Ident
"ORD"), [Just (AST.String Ident
s)])
            | Ident -> Int
Text.length Ident
s Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1, Int
code <- Char -> Int
ord (Ident -> Char
Text.head Ident
s) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer (Integer -> Value l l Placed Placed)
-> Integer -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
code)
         (Just (AST.Builtin Ident
"ORD"), [Just (AST.CharCode Int
code)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer (Integer -> Value l l Placed Placed)
-> Integer -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
code)
         (Just (AST.Builtin Ident
"ABS"), [Just (AST.Integer Integer
i)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer (Integer -> Value l l Placed Placed)
-> Integer -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Integer -> Integer
forall a. Num a => a -> a
abs Integer
i)
         (Just (AST.Builtin Ident
"ABS"), [Just (AST.Real Double
r)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real (Double -> Value l l Placed Placed)
-> Double -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Double -> Double
forall a. Num a => a -> a
abs Double
r)
         (Just (AST.Builtin Ident
"ASH"), [Just (AST.Integer Integer
i), Just (AST.Integer Integer
j)])
            | Integer
shifted <- Integer -> Int -> Integer
forall a. Bits a => a -> Int -> a
shift Integer
i (Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
j) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
shifted)
         (Just (AST.Builtin Ident
"TRUNC"), [Just (AST.Real Double
x)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer (Integer -> Value l l Placed Placed)
-> Integer -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
floor Double
x)
         (Just (AST.Builtin Ident
"FLOAT"), [Just (AST.Integer Integer
x)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real (Double -> Value l l Placed Placed)
-> Double -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
x)
         (Just (AST.Builtin Ident
"FLOAT"), [Just (AST.Real Double
x)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real Double
x)
         (Just (AST.Builtin Ident
"LEN"), [Just (AST.String Ident
s)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer (Integer -> Value l l Placed Placed)
-> Integer -> Value l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ Ident -> Int
Text.length Ident
s)
         (Just (AST.Builtin Ident
"LONG"), [Just (AST.Integer Integer
x)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
x)
         (Just (AST.Builtin Ident
"LONG"), [Just (AST.Real Double
x)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real Double
x)
         (Just (AST.Builtin Ident
"SHORT"), [Just (AST.Integer Integer
x)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
x)
         (Just (AST.Builtin Ident
"SHORT"), [Just (AST.Real Double
x)]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real Double
x)
         (Just (AST.Builtin Ident
"ODD"), [Just (AST.Integer Integer
x)]) ->
            Value l l Placed Placed -> SynCFExp λ l
fromValue (if Integer
x Integer -> Integer -> Integer
forall n. Integral n => n -> n -> n
`mod` Integer
2 Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
1 then Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.true else Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Value l l' f' f
Abstract.false)
         (Just (AST.Builtin Ident
"SIZE"), [Just (AST.Builtin Ident
"INTEGER")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
intSize)
         (Just (AST.Builtin Ident
"SIZE"), [Just (AST.Builtin Ident
"LONGINT")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
intSize)
         (Just (AST.Builtin Ident
"SIZE"), [Just (AST.Builtin Ident
"CARDINAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
intSize)
         (Just (AST.Builtin Ident
"SIZE"), [Just (AST.Builtin Ident
"REAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
doubleSize)
         (Just (AST.Builtin Ident
"SIZE"), [Just (AST.Builtin Ident
"LONGREAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
doubleSize)
         (Just (AST.Builtin Ident
"MAX"), [Just (AST.Builtin Ident
"CHAR")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Int -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Int -> Value l l' f' f
Abstract.charCode Int
0xff)
         (Just (AST.Builtin Ident
"MAX"), [Just (AST.Builtin Ident
"INTEGER")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
maxInteger)
         (Just (AST.Builtin Ident
"MAX"), [Just (AST.Builtin Ident
"LONGINT")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
maxInteger)
         (Just (AST.Builtin Ident
"MAX"), [Just (AST.Builtin Ident
"CARDINAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
maxCardinal)
         (Just (AST.Builtin Ident
"MAX"), [Just (AST.Builtin Ident
"BITSET")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
maxSet)
         (Just (AST.Builtin Ident
"MAX"), [Just (AST.Builtin Ident
"REAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real Double
maxReal)
         (Just (AST.Builtin Ident
"MAX"), [Just (AST.Builtin Ident
"LONGREAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real Double
maxReal)
         (Just (AST.Builtin Ident
"MIN"), [Just (AST.Builtin Ident
"CHAR")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Int -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Int -> Value l l' f' f
Abstract.charCode Int
0)
         (Just (AST.Builtin Ident
"MIN"), [Just (AST.Builtin Ident
"INTEGER")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
minInteger)
         (Just (AST.Builtin Ident
"MIN"), [Just (AST.Builtin Ident
"LONGINT")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
minInteger)
         (Just (AST.Builtin Ident
"MIN"), [Just (AST.Builtin Ident
"CARDINAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
0)
         (Just (AST.Builtin Ident
"MIN"), [Just (AST.Builtin Ident
"BITSET")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Integer -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Integer -> Value l l' f' f
Abstract.integer Integer
minSet)
         (Just (AST.Builtin Ident
"MIN"), [Just (AST.Builtin Ident
"REAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real Double
minReal)
         (Just (AST.Builtin Ident
"MIN"), [Just (AST.Builtin Ident
"LONGREAL")]) -> Value l l Placed Placed -> SynCFExp λ l
fromValue (Double -> Value l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
Double -> Value l l' f' f
Abstract.real Double
minReal)
         (Maybe (Value l l Placed Placed),
 [Maybe (Value l l Placed Placed)])
_ -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, Placed (Designator l l Placed Placed)
-> [((Int, ParsedLexemes, Int), Expression l l Placed Placed)]
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Designator l' l' f' f')
-> [f (Expression l' l' f' f')] -> Expression l l' f' f
Abstract.functionCall (Mapped Placed (Designator l l Placed Placed)
-> Placed (Designator l l Placed Placed)
forall k (f :: k -> *) (a :: k). Mapped f a -> f a
getMapped (Mapped Placed (Designator l l Placed Placed)
 -> Placed (Designator l l Placed Placed))
-> Mapped Placed (Designator l l Placed Placed)
-> Placed (Designator l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ SynCFDesignator l -> Mapped Placed (Designator l l Placed Placed)
forall l.
SynCFDesignator l -> Mapped Placed (Designator l l Placed Placed)
folded (Synthesized
  (Auto ConstantFold)
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Designator
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized (Auto ConstantFold) (Designator l l sem sem)
Synthesized
  (Auto ConstantFold)
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
fn :: SynCFDesignator l))
                                                                  (SynCFExp l l
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' (SynCFExp l l
 -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed))
-> (Synthesized
      (Auto ConstantFold)
      (Expression
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))
    -> SynCFExp l l)
-> Synthesized
     (Auto ConstantFold)
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> ((Int, ParsedLexemes, Int), Expression l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthesized
  (Auto ConstantFold)
  (Expression
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> SynCFExp l l
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn (Synthesized
   (Auto ConstantFold)
   (Expression
      l
      l
      (Semantics (Auto ConstantFold))
      (Semantics (Auto ConstantFold)))
 -> ((Int, ParsedLexemes, Int), Expression l l Placed Placed))
-> [Synthesized
      (Auto ConstantFold)
      (Expression
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))]
-> [((Int, ParsedLexemes, Int), Expression l l Placed Placed)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ZipList
  (Synthesized
     (Auto ConstantFold)
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
-> [Synthesized
      (Auto ConstantFold)
      (Expression
         l
         l
         (Semantics (Auto ConstantFold))
         (Semantics (Auto ConstantFold)))]
forall a. ZipList a -> [a]
getZipList ZipList (Synthesized (Auto ConstantFold) (Expression l l sem sem))
ZipList
  (Synthesized
     (Auto ConstantFold)
     (Expression
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold))))
args)),
                       $sel:foldedValue:SynCFExp :: Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
foldedValue= Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. Maybe a
Nothing}
      where fromValue :: Value l l Placed Placed -> SynCFExp λ l
fromValue Value l l Placed Placed
v = ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis ((Int, ParsedLexemes, Int)
pos, Value l l Placed Placed
v)
   synthesis Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, Expression
  λ l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))
_) Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem)
_ (AST.Literal Synthesized (Auto ConstantFold) (Value l l sem sem)
val) =
      SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Expression λ l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Value l' l' f' f') -> Expression l l' f' f
Abstract.literal (((Int, ParsedLexemes, Int), Value l l Placed Placed)
 -> Expression λ l Placed Placed)
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Expression λ l Placed Placed
forall a b. (a -> b) -> a -> b
$ Mapped Placed (Value l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall k (f :: k -> *) (a :: k). Mapped f a -> f a
getMapped (Mapped Placed (Value l l Placed Placed)
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Mapped Placed (Value l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ SynCF' (Value l l) -> Mapped Placed (Value l l Placed Placed)
forall (node :: (* -> *) -> (* -> *) -> *).
SynCF' node -> Mapped Placed (node Placed Placed)
folded' (SynCF' (Value l l) -> Mapped Placed (Value l l Placed Placed))
-> SynCF' (Value l l) -> Mapped Placed (Value l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (Value
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Value
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized
  (Auto ConstantFold)
  (Value
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
Synthesized (Auto ConstantFold) (Value l l sem sem)
val),
               $sel:foldedValue:SynCFExp :: Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
foldedValue= ((Int, ParsedLexemes, Int), Value l l Placed Placed)
-> Maybe ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a. a -> Maybe a
Just (Mapped Placed (Value l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall k (f :: k -> *) (a :: k). Mapped f a -> f a
getMapped (Mapped Placed (Value l l Placed Placed)
 -> ((Int, ParsedLexemes, Int), Value l l Placed Placed))
-> Mapped Placed (Value l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Value l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ SynCF' (Value l l) -> Mapped Placed (Value l l Placed Placed)
forall (node :: (* -> *) -> (* -> *) -> *).
SynCF' node -> Mapped Placed (node Placed Placed)
folded' (SynCF' (Value l l) -> Mapped Placed (Value l l Placed Placed))
-> SynCF' (Value l l) -> Mapped Placed (Value l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Synthesized
  (Auto ConstantFold)
  (Value
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
-> Atts
     (Synthesized (Auto ConstantFold))
     (Value
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall t a. Synthesized t a -> Atts (Synthesized t) a
syn Synthesized
  (Auto ConstantFold)
  (Value
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
Synthesized (Auto ConstantFold) (Value l l sem sem)
val)}

maxCardinal, maxInteger, minInteger, maxInt32, minInt32, maxSet, minSet :: Integer
maxCardinal :: Integer
maxCardinal = Integer
2 Integer -> Integer -> Integer
forall n. Num n => n -> n -> n
* Integer
maxInteger Integer -> Integer -> Integer
forall n. Num n => n -> n -> n
+ Integer
1
maxInteger :: Integer
maxInteger = Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int
forall a. Bounded a => a
maxBound :: Int)
minInteger :: Integer
minInteger = Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int
forall a. Bounded a => a
minBound :: Int)
maxInt32 :: Integer
maxInt32 = Int32 -> Integer
forall a. Integral a => a -> Integer
toInteger (Int32
forall a. Bounded a => a
maxBound :: Int32)
minInt32 :: Integer
minInt32 = Int32 -> Integer
forall a. Integral a => a -> Integer
toInteger (Int32
forall a. Bounded a => a
minBound :: Int32)
maxSet :: Integer
maxSet = Integer
63
minSet :: Integer
minSet = Integer
0

doubleSize, floatSize, intSize, int32Size :: Integer
doubleSize :: Integer
doubleSize = Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Double -> Int
forall a. Storable a => a -> Int
sizeOf (Double
0 :: Double))
floatSize :: Integer
floatSize = Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Float -> Int
forall a. Storable a => a -> Int
sizeOf (Float
0 :: Float))
intSize :: Integer
intSize = Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Int
forall a. Storable a => a -> Int
sizeOf (Int
0 :: Int))
int32Size :: Integer
int32Size = Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int32 -> Int
forall a. Storable a => a -> Int
sizeOf (Int32
0 :: Int32))

maxReal, minReal :: Double
maxReal :: Double
maxReal = Integer -> Int -> Double
forall a. RealFloat a => Integer -> Int -> a
encodeFloat (Double -> Integer
forall a. RealFloat a => a -> Integer
floatRadix Double
x Integer -> Integer -> Integer
forall n. Num n => n -> n -> n
- Integer
1) ((Int, Int) -> Int
forall a b. (a, b) -> b
snd (Double -> (Int, Int)
forall a. RealFloat a => a -> (Int, Int)
floatRange Double
x) Int -> Int -> Int
forall n. Num n => n -> n -> n
- Int
1)
   where x :: Double
x = Double
0 :: Double
minReal :: Double
minReal = Integer -> Int -> Double
forall a. RealFloat a => Integer -> Int -> a
encodeFloat (Double -> Integer
forall a. RealFloat a => a -> Integer
floatRadix Double
x Integer -> Integer -> Integer
forall n. Num n => n -> n -> n
- Integer
1) ((Int, Int) -> Int
forall a b. (a, b) -> a
fst (Double -> (Int, Int)
forall a. RealFloat a => a -> (Int, Int)
floatRange Double
x))
   where x :: Double
x = Double
0 :: Double

foldBinaryArithmetic :: forall λ l f. (f ~ Placed, Abstract.Value l ~ AST.Value l, Abstract.Wirthy λ,
                                  Pretty (Abstract.Value l l Identity Identity)) =>
                        (Int, ParsedLexemes, Int)
                     -> (f (Abstract.Expression l l f f) -> f (Abstract.Expression l l f f) -> Abstract.Expression λ l f f)
                     -> (forall n. Num n => n -> n -> n)
                     -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l
foldBinaryArithmetic :: (Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Num n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryArithmetic pos :: (Int, ParsedLexemes, Int)
pos@(Int
start, ParsedLexemes
ls, Int
end) f (Expression l l f f)
-> f (Expression l l f f) -> Expression λ l f f
node forall n. Num n => n -> n -> n
op SynCFExp l l
l SynCFExp l l
r =
   case Maybe (Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Placed (Value l l f f)
-> Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
foldValues (Placed (Value l l f f)
 -> Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
-> Maybe (Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SynCFExp l l -> Maybe (Placed (Value l l Placed Placed))
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue SynCFExp l l
l Maybe (Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
-> Maybe (Maybe (Placed (Value l l f f)))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SynCFExp l l -> Maybe (Placed (Value l l Placed Placed))
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue SynCFExp l l
r)
   of Just Placed (Value l l f f)
v -> Placed (Value l l Placed Placed) -> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis Placed (Value l l f f)
Placed (Value l l Placed Placed)
v
      Maybe (Placed (Value l l f f))
Nothing -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, f (Expression l l f f)
-> f (Expression l l f f) -> Expression λ l f f
node (SynCFExp l l -> Placed (Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' SynCFExp l l
l) (SynCFExp l l -> Placed (Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' SynCFExp l l
r)),
                          $sel:foldedValue:SynCFExp :: Maybe (Placed (Value l l Placed Placed))
foldedValue= Maybe (Placed (Value l l Placed Placed))
forall a. Maybe a
Nothing}
   where foldValues :: Placed (AST.Value l l f f) -> Placed (AST.Value l l f f) -> Maybe (Placed (AST.Value l l f f))
         foldBareValues :: AST.Value l l f f -> AST.Value l l f f -> Maybe (AST.Value l l f f)
         foldValues :: Placed (Value l l f f)
-> Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
foldValues ((Int, ParsedLexemes, Int)
_, Value l l f f
l') ((Int
_, ParsedLexemes
ls', Int
_), Value l l f f
r') = (,) (Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end) (Value l l f f -> Placed (Value l l f f))
-> Maybe (Value l l f f) -> Maybe (Placed (Value l l f f))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value l l f f -> Value l l f f -> Maybe (Value l l f f)
foldBareValues Value l l f f
l' Value l l f f
r'
         foldBareValues :: Value l l f f -> Value l l f f -> Maybe (Value l l f f)
foldBareValues (AST.Integer Integer
l') (AST.Integer Integer
r') = Value l l f f -> Maybe (Value l l f f)
forall a. a -> Maybe a
Just (Integer -> Value l l f f
forall λ l (f' :: * -> *) (f :: * -> *). Integer -> Value λ l f' f
AST.Integer (Integer -> Value l l f f) -> Integer -> Value l l f f
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall n. Num n => n -> n -> n
op Integer
l' Integer
r')
         foldBareValues (AST.Real Double
l')    (AST.Real Double
r')    = Value l l f f -> Maybe (Value l l f f)
forall a. a -> Maybe a
Just (Double -> Value l l f f
forall λ l (f' :: * -> *) (f :: * -> *). Double -> Value λ l f' f
AST.Real (Double -> Value l l f f) -> Double -> Value l l f f
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall n. Num n => n -> n -> n
op Double
l' Double
r')
         foldBareValues (AST.Integer Integer
l') (AST.Real Double
r')    = Value l l f f -> Maybe (Value l l f f)
forall a. a -> Maybe a
Just (Double -> Value l l f f
forall λ l (f' :: * -> *) (f :: * -> *). Double -> Value λ l f' f
AST.Real (Double -> Value l l f f) -> Double -> Value l l f f
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall n. Num n => n -> n -> n
op (Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
l') Double
r')
         foldBareValues (AST.Real Double
l')    (AST.Integer Integer
r') = Value l l f f -> Maybe (Value l l f f)
forall a. a -> Maybe a
Just (Double -> Value l l f f
forall λ l (f' :: * -> *) (f :: * -> *). Double -> Value λ l f' f
AST.Real (Double -> Value l l f f) -> Double -> Value l l f f
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall n. Num n => n -> n -> n
op Double
l' (Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
r'))
         foldBareValues Value l l f f
_ Value l l f f
_ = Maybe (Value l l f f)
forall a. Maybe a
Nothing

foldBinaryFractional :: forall λ l f. (f ~ Placed, Abstract.Value l ~ AST.Value l, Abstract.Wirthy λ,
                                  Pretty (Abstract.Value l l Identity Identity)) =>
                        (Int, ParsedLexemes, Int)
                     -> (f (Abstract.Expression l l f f) -> f (Abstract.Expression l l f f) -> Abstract.Expression λ l f f)
                     -> (forall n. Fractional n => n -> n -> n)
                     -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l
foldBinaryFractional :: (Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Fractional n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryFractional pos :: (Int, ParsedLexemes, Int)
pos@(Int
start, ParsedLexemes
ls, Int
end) f (Expression l l f f)
-> f (Expression l l f f) -> Expression λ l f f
node forall n. Fractional n => n -> n -> n
op SynCFExp l l
l SynCFExp l l
r =
   case Maybe (Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Placed (Value l l f f)
-> Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
foldValues (Placed (Value l l f f)
 -> Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
-> Maybe (Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SynCFExp l l -> Maybe (Placed (Value l l Placed Placed))
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue SynCFExp l l
l Maybe (Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
-> Maybe (Maybe (Placed (Value l l f f)))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SynCFExp l l -> Maybe (Placed (Value l l Placed Placed))
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue SynCFExp l l
r)
   of Just Placed (Value l l f f)
v -> Placed (Value l l Placed Placed) -> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis Placed (Value l l f f)
Placed (Value l l Placed Placed)
v
      Maybe (Placed (Value l l f f))
Nothing -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, f (Expression l l f f)
-> f (Expression l l f f) -> Expression λ l f f
node (SynCFExp l l -> Placed (Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' SynCFExp l l
l) (SynCFExp l l -> Placed (Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' SynCFExp l l
r)),
                          $sel:foldedValue:SynCFExp :: Maybe (Placed (Value l l Placed Placed))
foldedValue= Maybe (Placed (Value l l Placed Placed))
forall a. Maybe a
Nothing}
   where foldValues :: Placed (AST.Value l l f f) -> Placed (AST.Value l l f f) -> Maybe (Placed (AST.Value l l f f))
         foldValues :: Placed (Value l l f f)
-> Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
foldValues ((Int, ParsedLexemes, Int)
_, AST.Real Double
l') ((Int
_, ParsedLexemes
ls', Int
_), AST.Real Double
r') = Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
forall a. a -> Maybe a
Just ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end),
                                                                        Double -> Value l l f f
forall λ l (f' :: * -> *) (f :: * -> *). Double -> Value λ l f' f
AST.Real (Double -> Value l l f f) -> Double -> Value l l f f
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall n. Fractional n => n -> n -> n
op Double
l' Double
r')
         foldValues Placed (Value l l f f)
_ Placed (Value l l f f)
_ = Maybe (Placed (Value l l f f))
forall a. Maybe a
Nothing

foldBinaryInteger :: forall λ l f. (f ~ Placed, Abstract.Value l ~ AST.Value l, Abstract.Wirthy λ,
                               Pretty (Abstract.Value l l Identity Identity)) =>
                        (Int, ParsedLexemes, Int)
                     -> (f (Abstract.Expression l l f f) -> f (Abstract.Expression l l f f) -> Abstract.Expression λ l f f)
                     -> (forall n. Integral n => n -> n -> n)
                     -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l
foldBinaryInteger :: (Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (forall n. Integral n => n -> n -> n)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryInteger pos :: (Int, ParsedLexemes, Int)
pos@(Int
start, ParsedLexemes
ls, Int
end) f (Expression l l f f)
-> f (Expression l l f f) -> Expression λ l f f
node forall n. Integral n => n -> n -> n
op SynCFExp l l
l SynCFExp l l
r =
   case Maybe (Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Placed (Value l l f f)
-> Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
foldValues (Placed (Value l l f f)
 -> Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
-> Maybe (Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SynCFExp l l -> Maybe (Placed (Value l l Placed Placed))
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue SynCFExp l l
l Maybe (Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
-> Maybe (Maybe (Placed (Value l l f f)))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SynCFExp l l -> Maybe (Placed (Value l l Placed Placed))
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue SynCFExp l l
r)
   of Just Placed (Value l l f f)
v -> Placed (Value l l Placed Placed) -> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis Placed (Value l l f f)
Placed (Value l l Placed Placed)
v
      Maybe (Placed (Value l l f f))
Nothing -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, f (Expression l l f f)
-> f (Expression l l f f) -> Expression λ l f f
node (SynCFExp l l -> Placed (Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' SynCFExp l l
l) (SynCFExp l l -> Placed (Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' SynCFExp l l
r)),
                          $sel:foldedValue:SynCFExp :: Maybe (Placed (Value l l Placed Placed))
foldedValue= Maybe (Placed (Value l l Placed Placed))
forall a. Maybe a
Nothing}
   where foldValues :: Placed (AST.Value l l f f) -> Placed (AST.Value l l f f) -> Maybe (Placed (AST.Value l l f f))
         foldValues :: Placed (Value l l f f)
-> Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
foldValues ((Int, ParsedLexemes, Int)
_, AST.Integer Integer
l') ((Int
_, ParsedLexemes
ls', Int
_), AST.Integer Integer
r') = Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
forall a. a -> Maybe a
Just ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end),
                                                                              Integer -> Value l l f f
forall λ l (f' :: * -> *) (f :: * -> *). Integer -> Value λ l f' f
AST.Integer (Integer -> Value l l f f) -> Integer -> Value l l f f
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall n. Integral n => n -> n -> n
op Integer
l' Integer
r')
         foldValues Placed (Value l l f f)
_ Placed (Value l l f f)
_ = Maybe (Placed (Value l l f f))
forall a. Maybe a
Nothing

foldBinaryBoolean :: forall λ l f. (f ~ Placed, Abstract.Value l ~ AST.Value l, Abstract.Wirthy λ,
                               Pretty (Abstract.Value l l Identity Identity)) =>
                     (Int, ParsedLexemes, Int)
                  -> (f (Abstract.Expression l l f f) -> f (Abstract.Expression l l f f) -> Abstract.Expression λ l f f)
                  -> (Bool -> Bool -> Bool)
                  -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l
foldBinaryBoolean :: (Int, ParsedLexemes, Int)
-> (f (Expression l l f f)
    -> f (Expression l l f f) -> Expression λ l f f)
-> (Bool -> Bool -> Bool)
-> SynCFExp l l
-> SynCFExp l l
-> SynCFExp λ l
foldBinaryBoolean pos :: (Int, ParsedLexemes, Int)
pos@(Int
start, ParsedLexemes
ls, Int
end) f (Expression l l f f)
-> f (Expression l l f f) -> Expression λ l f f
node Bool -> Bool -> Bool
op SynCFExp l l
l SynCFExp l l
r =
   case Maybe (Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Placed (Value l l f f)
-> Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
foldValues (Placed (Value l l f f)
 -> Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
-> Maybe (Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SynCFExp l l -> Maybe (Placed (Value l l Placed Placed))
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue SynCFExp l l
l Maybe (Placed (Value l l f f) -> Maybe (Placed (Value l l f f)))
-> Maybe (Placed (Value l l f f))
-> Maybe (Maybe (Placed (Value l l f f)))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SynCFExp l l -> Maybe (Placed (Value l l Placed Placed))
forall λ l.
SynCFExp λ l -> Maybe (Placed (Value l l Placed Placed))
foldedValue SynCFExp l l
r)
   of Just Placed (Value l l f f)
v -> Placed (Value l l Placed Placed) -> SynCFExp λ l
forall λ l.
(Wirthy λ, Functor (Map Placed Identity) (Value l l),
 Pretty (Value l l Identity Identity)) =>
Placed (Value l l Placed Placed) -> SynCFExp λ l
Oberon.literalSynthesis Placed (Value l l f f)
Placed (Value l l Placed Placed)
v
      Maybe (Placed (Value l l f f))
Nothing -> SynCFExp :: forall λ l.
Mapped Placed (Expression λ l Placed Placed)
-> Maybe (Placed (Value l l Placed Placed)) -> SynCFExp λ l
SynCFExp{$sel:folded:SynCFExp :: Mapped Placed (Expression λ l Placed Placed)
folded= ((Int, ParsedLexemes, Int), Expression λ l Placed Placed)
-> Mapped Placed (Expression λ l Placed Placed)
forall k (f :: k -> *) (a :: k). f a -> Mapped f a
Mapped ((Int, ParsedLexemes, Int)
pos, f (Expression l l f f)
-> f (Expression l l f f) -> Expression λ l f f
node (SynCFExp l l -> Placed (Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' SynCFExp l l
l) (SynCFExp l l -> Placed (Expression l l Placed Placed)
forall λ l. SynCFExp λ l -> Placed (Expression λ l Placed Placed)
foldedExp' SynCFExp l l
r)),
                          $sel:foldedValue:SynCFExp :: Maybe (Placed (Value l l Placed Placed))
foldedValue= Maybe (Placed (Value l l Placed Placed))
forall a. Maybe a
Nothing}
   where foldValues :: Placed (AST.Value l l f f) -> Placed (AST.Value l l f f) -> Maybe (Placed (AST.Value l l f f))
         foldValues :: Placed (Value l l f f)
-> Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
foldValues ((Int, ParsedLexemes, Int)
_, AST.Boolean Bool
l') ((Int
_, ParsedLexemes
ls', Int
_), AST.Boolean Bool
r') = Placed (Value l l f f) -> Maybe (Placed (Value l l f f))
forall a. a -> Maybe a
Just ((Int
start, ParsedLexemes -> ParsedLexemes -> ParsedLexemes
anyWhitespace ParsedLexemes
ls ParsedLexemes
ls', Int
end),
                                                                              Bool -> Value l l f f
forall λ l (f' :: * -> *) (f :: * -> *). Bool -> Value λ l f' f
AST.Boolean (Bool -> Value l l f f) -> Bool -> Value l l f f
forall a b. (a -> b) -> a -> b
$ Bool -> Bool -> Bool
op Bool
l' Bool
r')
         foldValues Placed (Value l l f f)
_ Placed (Value l l f f)
_ = Maybe (Placed (Value l l f f))
forall a. Maybe a
Nothing

instance (Abstract.Modula2 l, Ord (Abstract.QualIdent l), v ~ Abstract.Value l l Placed Placed,
          Atts (Inherited (Auto ConstantFold)) (Abstract.Expression l l Sem Sem) ~ InhCF l,
          Atts (Inherited (Auto ConstantFold)) (Abstract.Designator l l Sem Sem) ~ InhCF l,
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Expression l l Sem Sem) ~ SynCFExp λ l,
          Atts (Synthesized (Auto ConstantFold)) (Abstract.Designator l l Sem Sem) ~ SynCFDesignator l) =>
         SynthesizedField "designatorValue" (Maybe (Placed v)) (Auto ConstantFold) (AST.Designator l l) Sem Placed where
   synthesizedField :: Proxy "designatorValue"
-> Auto ConstantFold
-> Placed
     (Designator
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Atts (Inherited (Auto ConstantFold)) (Designator l l sem sem)
-> Designator l l sem (Synthesized (Auto ConstantFold))
-> Maybe (Placed v)
synthesizedField Proxy "designatorValue"
_ Auto ConstantFold
_ ((Int, ParsedLexemes, Int)
pos, AST.Variable QualIdent l
q) Atts (Inherited (Auto ConstantFold)) (Designator l l sem sem)
inheritance Designator l l sem (Synthesized (Auto ConstantFold))
_ = (,) (Int, ParsedLexemes, Int)
pos (v -> Placed v) -> Maybe v -> Maybe (Placed v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Maybe v) -> Maybe v
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (QualIdent l -> Map (QualIdent l) (Maybe v) -> Maybe (Maybe v)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup QualIdent l
q (Map (QualIdent l) (Maybe v) -> Maybe (Maybe v))
-> Map (QualIdent l) (Maybe v) -> Maybe (Maybe v)
forall a b. (a -> b) -> a -> b
$ InhCF l -> Environment l
forall l. InhCF l -> Environment l
env Atts (Inherited (Auto ConstantFold)) (Designator l l sem sem)
InhCF l
inheritance)
   synthesizedField Proxy "designatorValue"
_ Auto ConstantFold
_ Placed
  (Designator
     l
     l
     (Semantics (Auto ConstantFold))
     (Semantics (Auto ConstantFold)))
_ Atts (Inherited (Auto ConstantFold)) (Designator l l sem sem)
_ Designator l l sem (Synthesized (Auto ConstantFold))
_ = Maybe (Placed v)
forall a. Maybe a
Nothing

-- * More boring Transformation.Functor instances, TH candidates
instance Ord (Abstract.QualIdent l) => Transformation.At (Auto ConstantFold) (Modules l Sem Sem) where
   $ :: Auto ConstantFold
-> Domain
     (Auto ConstantFold)
     (Modules
        l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold)))
-> Codomain
     (Auto ConstantFold)
     (Modules
        l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold)))
($) = (forall a. ((Int, ParsedLexemes, Int), a) -> a)
-> Auto ConstantFold
-> ((Int, ParsedLexemes, Int),
    Modules
      l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold)))
-> Semantics
     (Auto ConstantFold)
     (Modules
        l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold)))
forall (q :: * -> *) t x (g :: (* -> *) -> (* -> *) -> *)
       (p :: * -> *).
(q ~ Semantics t, x ~ g q q, Apply (g q), Attribution t g q p) =>
(forall a. p a -> a) -> t -> p x -> q x
AG.applyDefault forall a. ((Int, ParsedLexemes, Int), a) -> a
forall a b. (a, b) -> b
snd

-- * Unsafe Rank2 AST instances

$(do l <- varT  <$> newName "l"
     mconcat <$> mapM (\g-> Transformation.Full.TH.deriveUpFunctor (conT ''Auto `appT` conT ''ConstantFold) $ conT g `appT` l `appT` l)
        [''AST.Type, ''AST.FieldList,
         ''AST.ProcedureHeading,
         ''AST.Expression, ''AST.Designator,
         ''AST.Statement, ''AST.Variant])

$(do let sem = [t|Semantics (Auto ConstantFold)|]
     let inst g = [d| instance Attribution (Auto ConstantFold) ($g l l) Sem Placed =>
                               Transformation.At (Auto ConstantFold) ($g l l $sem $sem)
                         where ($) = AG.applyDefault snd |]
     mconcat <$> mapM (inst . conT)
        [''AST.Module, ''AST.ProcedureHeading, ''AST.Type, ''AST.FieldList,
         ''AST.Statement, ''AST.Expression, ''AST.Designator, ''AST.Variant])

$(do full <- varT  <$> newName "full"
     l <- varT  <$> newName "l"
     Transformation.Full.TH.deriveUpFunctor [t| (Auto ConstantFold) |] [t| AST.Declaration $full $l $l |])

instance Attribution (Auto ConstantFold) (AST.Declaration full l l) Sem Placed
      => Transformation.At (Auto ConstantFold) (AST.Declaration full l l Sem Sem) where
   $ :: Auto ConstantFold
-> Domain
     (Auto ConstantFold)
     (Declaration
        full
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
-> Codomain
     (Auto ConstantFold)
     (Declaration
        full
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
($) = (forall a. ((Int, ParsedLexemes, Int), a) -> a)
-> Auto ConstantFold
-> ((Int, ParsedLexemes, Int),
    Declaration
      full
      l
      l
      (Semantics (Auto ConstantFold))
      (Semantics (Auto ConstantFold)))
-> Semantics
     (Auto ConstantFold)
     (Declaration
        full
        l
        l
        (Semantics (Auto ConstantFold))
        (Semantics (Auto ConstantFold)))
forall (q :: * -> *) t x (g :: (* -> *) -> (* -> *) -> *)
       (p :: * -> *).
(q ~ Semantics t, x ~ g q q, Apply (g q), Attribution t g q p) =>
(forall a. p a -> a) -> t -> p x -> q x
AG.applyDefault forall a. ((Int, ParsedLexemes, Int), a) -> a
forall a b. (a, b) -> b
snd