code
stringlengths 5
1.03M
| repo_name
stringlengths 5
90
| path
stringlengths 4
158
| license
stringclasses 15
values | size
int64 5
1.03M
| n_ast_errors
int64 0
53.9k
| ast_max_depth
int64 2
4.17k
| n_whitespaces
int64 0
365k
| n_ast_nodes
int64 3
317k
| n_ast_terminals
int64 1
171k
| n_ast_nonterminals
int64 1
146k
| loc
int64 -1
37.3k
| cycloplexity
int64 -1
1.31k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
{-# LANGUAGE ExistentialQuantification #-}
module Actor where
import Data.Identifiable
import Belief (Beliefs)
import qualified Belief as B
import Health
import Knowledge (Knowledge)
import qualified Knowledge as K
import Terrain
import Entity.Map
import Point
data Actor = Actor
{ actorId :: ActorId
, actorSym :: Char
, actorKnow :: (Knowledge Terrain)
, actorBelief :: (Beliefs Actor)
, actorHealth :: Health
}
data ActorId = PlayerId | MonsterId Integer
type ActorMap = EntityMap Actor
player :: Identifier Actor
player = mkIdentifier $
Actor PlayerId '@' K.empty B.empty (mkHealth 0 0)
getPlayer :: ActorMap -> (Actor, Point)
getPlayer am = get am player
teach :: Actor -> [(Point, Terrain)] -> Actor
teach (Actor i char knowledge belief h) info =
Actor i char (K.learnAll knowledge info) belief h
instance Identifiable Actor where
identify (Actor PlayerId _ _ _ _) = -1
identify (Actor (MonsterId i) _ _ _ _) = i
instance Mob Actor where
glyph (Actor _ sym _ _ _) = sym
class Mob a where
glyph :: a -> Char
| bhickey/catamad | src/Actor.hs | gpl-3.0 | 1,046 | 0 | 10 | 203 | 367 | 203 | 164 | 34 | 1 |
-- TabCode - A parser for the Tabcode lute tablature language
--
-- Copyright (C) 2015-2017 Richard Lewis
-- Author: Richard Lewis <[email protected]>
-- This file is part of TabCode
-- TabCode is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- TabCode is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with TabCode. If not, see <http://www.gnu.org/licenses/>.
module ParseTests where
import Distribution.TestSuite
import qualified Data.Vector as V
import TabCode.Types
import TabCode.Options (TCOptions(..), ParseMode(..), Structure(..), XmlIds(..))
import TabCode.Parser (parseTabcode)
tryParsePhrase :: String -> [TabWord] -> Result
tryParsePhrase tc phrase =
case (parseTabcode parsingOptions tc) of
Right (TabCode _ wrds) -> check wrds phrase
Left err -> Fail $ show err
where
parsingOptions = TCOptions
{ parseMode = Strict
, structure = BarLines
, xmlIds = WithXmlIds }
check ws expected
| V.length ws == 0 =
Error $ "Could not parse " ++ tc ++ " as " ++ (show expected)
| otherwise =
if (V.toList ws) == expected
then Pass
else Fail $ "For \"" ++ tc ++ "\", expected " ++ (show expected) ++ "; got " ++ (show $ V.toList ws)
tryParseWord :: String -> TabWord -> Result
tryParseWord tc tw = tryParsePhrase tc [tw]
mkParseTest :: String -> TabWord -> TestInstance
mkParseTest tc tw = TestInstance
{ run = return $ Finished $ tryParseWord tc tw
, name = show tc
, tags = []
, options = []
, setOption = \_ _ -> Right $ mkParseTest tc tw
}
mkParsePhraseTest :: String -> [TabWord] -> TestInstance
mkParsePhraseTest tc phrase = TestInstance
{ run = return $ Finished $ tryParsePhrase tc phrase
, name = show tc
, tags = []
, options = []
, setOption = \_ _ -> Right $ mkParsePhraseTest tc phrase
}
tryParseInvalidWord :: String -> Result
tryParseInvalidWord tc =
case parseTabcode (TCOptions { parseMode = Strict, structure = BarLines, xmlIds = WithXmlIds }) tc of
Right (TabCode _ wrds) -> Fail $ show wrds
Left _ -> Pass
mkInvalidTest :: String -> TestInstance
mkInvalidTest tc = TestInstance
{ run = return $ Finished $ tryParseInvalidWord tc
, name = show $ tc ++ " [invalid]"
, tags = []
, options = []
, setOption = \_ _ -> Right $ mkInvalidTest tc
}
tests :: IO [Test]
tests = return $ meterSigns
++ rests
++ barLines
++ simpleChords
++ chordsWithBass
++ failChords
++ articulations
++ fingerings
++ ornaments
++ comments
++ structuredComments
++ phrases
meterSigns :: [Test]
meterSigns =
[ Test $ mkParseTest "M(O.)\n" (Meter 1 1 (SingleMeterSign PerfectMajor) Nothing)
, Test $ mkParseTest "M(O)\n" (Meter 1 1 (SingleMeterSign PerfectMinor) Nothing)
, Test $ mkParseTest "M(C.)\n" (Meter 1 1 (SingleMeterSign ImperfectMajor) Nothing)
, Test $ mkParseTest "M(C)\n" (Meter 1 1 (SingleMeterSign ImperfectMinor) Nothing)
, Test $ mkParseTest "M(O/.)\n" (Meter 1 1 (SingleMeterSign HalfPerfectMajor) Nothing)
, Test $ mkParseTest "M(O/)\n" (Meter 1 1 (SingleMeterSign HalfPerfectMinor) Nothing)
, Test $ mkParseTest "M(C/.)\n" (Meter 1 1 (SingleMeterSign HalfImperfectMajor) Nothing)
, Test $ mkParseTest "M(C/)\n" (Meter 1 1 (SingleMeterSign HalfImperfectMinor) Nothing)
, Test $ mkParseTest "M(D.)\n" (Meter 1 1 (SingleMeterSign HalfImperfectMajor) Nothing)
, Test $ mkParseTest "M(D)\n" (Meter 1 1 (SingleMeterSign HalfImperfectMinor) Nothing)
, Test $ mkParseTest "M(3)\n" (Meter 1 1 (SingleMeterSign (Beats 3)) Nothing)
, Test $ mkParseTest "M(4:4)\n" (Meter 1 1 (VerticalMeterSign (Beats 4) (Beats 4)) Nothing)
, Test $ mkParseTest "M(4;4)\n" (Meter 1 1 (HorizontalMeterSign (Beats 4) (Beats 4)) Nothing)
]
rests :: [Test]
rests =
[ Test $ mkParseTest "F\n" (Rest 1 1 (RhythmSign Fermata Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "B\n" (Rest 1 1 (RhythmSign Breve Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "W\n" (Rest 1 1 (RhythmSign Semibreve Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "W.\n" (Rest 1 1 (RhythmSign Semibreve Simple Dot Nothing) Nothing)
, Test $ mkParseTest "W3\n" (Rest 1 1 (RhythmSign Semibreve Compound NoDot Nothing) Nothing)
, Test $ mkParseTest "H\n" (Rest 1 1 (RhythmSign Minim Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "H.\n" (Rest 1 1 (RhythmSign Minim Simple Dot Nothing) Nothing)
, Test $ mkParseTest "H3\n" (Rest 1 1 (RhythmSign Minim Compound NoDot Nothing) Nothing)
, Test $ mkParseTest "Q\n" (Rest 1 1 (RhythmSign Crotchet Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "Q.\n" (Rest 1 1 (RhythmSign Crotchet Simple Dot Nothing) Nothing)
, Test $ mkParseTest "Q3\n" (Rest 1 1 (RhythmSign Crotchet Compound NoDot Nothing) Nothing)
, Test $ mkParseTest "E\n" (Rest 1 1 (RhythmSign Quaver Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "E.\n" (Rest 1 1 (RhythmSign Quaver Simple Dot Nothing) Nothing)
, Test $ mkParseTest "E3\n" (Rest 1 1 (RhythmSign Quaver Compound NoDot Nothing) Nothing)
, Test $ mkParseTest "S\n" (Rest 1 1 (RhythmSign Semiquaver Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "S.\n" (Rest 1 1 (RhythmSign Semiquaver Simple Dot Nothing) Nothing)
, Test $ mkParseTest "S3\n" (Rest 1 1 (RhythmSign Semiquaver Compound NoDot Nothing) Nothing)
, Test $ mkParseTest "T\n" (Rest 1 1 (RhythmSign Demisemiquaver Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "T.\n" (Rest 1 1 (RhythmSign Demisemiquaver Simple Dot Nothing) Nothing)
, Test $ mkParseTest "T3\n" (Rest 1 1 (RhythmSign Demisemiquaver Compound NoDot Nothing) Nothing)
, Test $ mkParseTest "Y\n" (Rest 1 1 (RhythmSign Hemidemisemiquaver Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "Y.\n" (Rest 1 1 (RhythmSign Hemidemisemiquaver Simple Dot Nothing) Nothing)
, Test $ mkParseTest "Y3\n" (Rest 1 1 (RhythmSign Hemidemisemiquaver Compound NoDot Nothing) Nothing)
, Test $ mkParseTest "Z\n" (Rest 1 1 (RhythmSign Semihemidemisemiquaver Simple NoDot Nothing) Nothing)
, Test $ mkParseTest "Z.\n" (Rest 1 1 (RhythmSign Semihemidemisemiquaver Simple Dot Nothing) Nothing)
, Test $ mkParseTest "Z3\n" (Rest 1 1 (RhythmSign Semihemidemisemiquaver Compound NoDot Nothing) Nothing)
]
barLines :: [Test]
barLines =
[ Test $ mkParseTest "|\n" (BarLine 1 1 (SingleBar Nothing Nothing NotDashed Counting) Nothing)
, Test $ mkParseTest "||\n" (BarLine 1 1 (DoubleBar Nothing Nothing NotDashed Counting) Nothing)
, Test $ mkParseTest ":|\n" (BarLine 1 1 (SingleBar (Just RepeatLeft) Nothing NotDashed Counting) Nothing)
, Test $ mkParseTest ":||\n" (BarLine 1 1 (DoubleBar (Just RepeatLeft) Nothing NotDashed Counting) Nothing)
, Test $ mkParseTest "|:\n" (BarLine 1 1 (SingleBar (Just RepeatRight) Nothing NotDashed Counting) Nothing)
, Test $ mkParseTest "||:\n" (BarLine 1 1 (DoubleBar (Just RepeatRight) Nothing NotDashed Counting) Nothing)
, Test $ mkParseTest ":|:\n" (BarLine 1 1 (SingleBar (Just RepeatBoth) Nothing NotDashed Counting) Nothing)
, Test $ mkParseTest ":||:\n" (BarLine 1 1 (DoubleBar (Just RepeatBoth) Nothing NotDashed Counting) Nothing)
, Test $ mkParseTest "|=\n" (BarLine 1 1 (SingleBar Nothing Nothing Dashed Counting) Nothing)
, Test $ mkParseTest "||=\n" (BarLine 1 1 (DoubleBar Nothing Nothing Dashed Counting) Nothing)
, Test $ mkParseTest ":|=\n" (BarLine 1 1 (SingleBar (Just RepeatLeft) Nothing Dashed Counting) Nothing)
, Test $ mkParseTest ":||=\n" (BarLine 1 1 (DoubleBar (Just RepeatLeft) Nothing Dashed Counting) Nothing)
, Test $ mkParseTest "|:=\n" (BarLine 1 1 (SingleBar (Just RepeatRight) Nothing Dashed Counting) Nothing)
, Test $ mkParseTest "||:=\n" (BarLine 1 1 (DoubleBar (Just RepeatRight) Nothing Dashed Counting) Nothing)
, Test $ mkParseTest ":|:=\n" (BarLine 1 1 (SingleBar (Just RepeatBoth) Nothing Dashed Counting) Nothing)
, Test $ mkParseTest ":||:=\n" (BarLine 1 1 (DoubleBar (Just RepeatBoth) Nothing Dashed Counting) Nothing)
, Test $ mkParseTest "|0\n" (BarLine 1 1 (SingleBar Nothing Nothing NotDashed NotCounting) Nothing)
, Test $ mkParseTest "||0\n" (BarLine 1 1 (DoubleBar Nothing Nothing NotDashed NotCounting) Nothing)
, Test $ mkParseTest ":|0\n" (BarLine 1 1 (SingleBar (Just RepeatLeft) Nothing NotDashed NotCounting) Nothing)
, Test $ mkParseTest ":||0\n" (BarLine 1 1 (DoubleBar (Just RepeatLeft) Nothing NotDashed NotCounting) Nothing)
, Test $ mkParseTest "|:0\n" (BarLine 1 1 (SingleBar (Just RepeatRight) Nothing NotDashed NotCounting) Nothing)
, Test $ mkParseTest "||:0\n" (BarLine 1 1 (DoubleBar (Just RepeatRight) Nothing NotDashed NotCounting) Nothing)
, Test $ mkParseTest ":|:0\n" (BarLine 1 1 (SingleBar (Just RepeatBoth) Nothing NotDashed NotCounting) Nothing)
, Test $ mkParseTest ":||:0\n" (BarLine 1 1 (DoubleBar (Just RepeatBoth) Nothing NotDashed NotCounting) Nothing)
, Test $ mkParseTest "|(T=:\\R)\n" (BarLine 1 1 (SingleBar Nothing (Just Reprise) NotDashed Counting) Nothing)
, Test $ mkParseTest "||(T=:\\R)\n" (BarLine 1 1 (DoubleBar Nothing (Just Reprise) NotDashed Counting) Nothing)
, Test $ mkParseTest "|(T+:\\1)\n" (BarLine 1 1 (SingleBar Nothing (Just $ NthTime 1) NotDashed Counting) Nothing)
, Test $ mkParseTest "||(T+:\\1)\n" (BarLine 1 1 (DoubleBar Nothing (Just $ NthTime 1) NotDashed Counting) Nothing)
]
simpleChords :: [Test]
simpleChords =
[ Test $ mkParseTest "c1\n" (Chord 1 1 Nothing [Note One C (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "c1a2\n" (Chord 1 1 Nothing [ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note Two A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Qc1\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple NoDot Nothing)) [Note One C (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Q.c1\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing)) [Note One C (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Q3c1\n" (Chord 1 1 (Just (RhythmSign Crotchet Compound NoDot Nothing)) [Note One C (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Qc1a2\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple NoDot Nothing)) [ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note Two A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
]
chordsWithBass :: [Test]
chordsWithBass =
[ Test $ mkParseTest "Xa\n" (Chord 1 1 Nothing [Note (Bass 1) A (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Xa/\n" (Chord 1 1 Nothing [Note (Bass 2) A (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Xb//\n" (Chord 1 1 Nothing [Note (Bass 3) B (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "X1\n" (Chord 1 1 Nothing [Note (Bass 1) A (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "X4\n" (Chord 1 1 Nothing [Note (Bass 4) A (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "c1Xa\n" (Chord 1 1 Nothing [ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 1) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1Xa/\n" (Chord 1 1 Nothing [ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 2) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1Xb//\n" (Chord 1 1 Nothing [ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 3) B (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1X1\n" (Chord 1 1 Nothing [ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 1) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1X4\n" (Chord 1 1 Nothing [ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 4) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Q.Xa\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[Note (Bass 1) A (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Q.Xa/\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[Note (Bass 2) A (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Q.Xb//\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[Note (Bass 3) B (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Q.X1\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[Note (Bass 1) A (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Q.X4\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[Note (Bass 4) A (Nothing, Nothing) Nothing Nothing Nothing] Nothing)
, Test $ mkParseTest "Q.c1Xa\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 1) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Q.c1Xa/\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 2) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Q.c1Xb//\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 3) B (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Q.c1X1\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 1) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Q.c1X4\n" (Chord 1 1 (Just (RhythmSign Crotchet Simple Dot Nothing))
[ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note (Bass 4) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
]
failChords :: [Test]
failChords =
[ Test $ mkInvalidTest "a1b1\n"
, Test $ mkInvalidTest "a1a2a1\n"
, Test $ mkInvalidTest "Qa1b1\n"
, Test $ mkInvalidTest "Qa1a2a1\n"
, Test $ mkInvalidTest "Q.a1b1\n"
, Test $ mkInvalidTest "Q.a1a2a1\n"
, Test $ mkInvalidTest "o1\n"
, Test $ mkInvalidTest "a1\no1\n"
, Test $ mkInvalidTest "o1\na1\n"
, Test $ mkInvalidTest "So1\n"
, Test $ mkInvalidTest "Sa1\no1\n"
, Test $ mkInvalidTest "So1\na1\n"
, Test $ mkInvalidTest "E.p1\n"
]
articulations :: [Test]
articulations =
[ Test $ mkParseTest "b3(E)d4\n" (Chord 1 1 Nothing [ Note Three B (Nothing, Nothing) Nothing (Just Ensemble) Nothing
, Note Four D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Hc1c2d3(E)d6\n" (Chord 1 1 (Just (RhythmSign Minim Simple NoDot Nothing))
[ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note Two C (Nothing, Nothing) Nothing Nothing Nothing
, Note Three D (Nothing, Nothing) Nothing (Just Ensemble) Nothing
, Note Six D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(E)X4" (Chord 1 1 Nothing [ Note One C (Nothing, Nothing) Nothing (Just Ensemble) Nothing
, Note (Bass 4) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b3(S)d4\n" (Chord 1 1 Nothing [ Note Three B (Nothing, Nothing) Nothing (Just $ Separee Nothing Nothing) Nothing
, Note Four D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Hc1c2d3(S)d6\n" (Chord 1 1 (Just (RhythmSign Minim Simple NoDot Nothing))
[ Note One C (Nothing, Nothing) Nothing Nothing Nothing
, Note Two C (Nothing, Nothing) Nothing Nothing Nothing
, Note Three D (Nothing, Nothing) Nothing (Just $ Separee Nothing Nothing) Nothing
, Note Six D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(S)X4" (Chord 1 1 Nothing [ Note One C (Nothing, Nothing) Nothing (Just $ Separee Nothing Nothing) Nothing
, Note (Bass 4) A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b3(Sd)d4\n" (Chord 1 1 Nothing [ Note Three B (Nothing, Nothing) Nothing (Just $ Separee (Just SepareeDown) Nothing) Nothing
, Note Four D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b3(Su)d4\n" (Chord 1 1 Nothing [ Note Three B (Nothing, Nothing) Nothing (Just $ Separee (Just SepareeUp) Nothing) Nothing
, Note Four D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b3(Sd:l)d4\n" (Chord 1 1 Nothing [ Note Three B (Nothing, Nothing) Nothing (Just $ Separee (Just SepareeDown) (Just SepareeLeft)) Nothing
, Note Four D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b3(Su:r)d4\n" (Chord 1 1 Nothing [ Note Three B (Nothing, Nothing) Nothing (Just $ Separee (Just SepareeUp) (Just SepareeRight)) Nothing
, Note Four D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "Hc1(E)c2d3(S)d6\n" (Chord 1 1 (Just (RhythmSign Minim Simple NoDot Nothing))
[ Note One C (Nothing, Nothing) Nothing (Just Ensemble) Nothing
, Note Two C (Nothing, Nothing) Nothing Nothing Nothing
, Note Three D (Nothing, Nothing) Nothing (Just $ Separee Nothing Nothing) Nothing
, Note Six D (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkInvalidTest "b3(E)(S)d4\n"
, Test $ mkInvalidTest "b3(S)(E)d4\n"
, Test $ mkInvalidTest "b3(E)(Su)d4\n"
, Test $ mkInvalidTest "b3(Su)(E)d4\n"
]
fingerings :: [Test]
fingerings =
[ Test $ mkParseTest "c1(Fr...:7)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerThree (Just PosBelow), Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(F...)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerThree Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(F...:6)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerThree (Just PosBelowLeft), Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(F2:6)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringLeft FingerTwo (Just PosBelowLeft), Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(F2)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringLeft FingerTwo Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(Fl2:6)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringLeft FingerTwo (Just PosBelowLeft), Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(Fr2:6)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerTwo (Just PosBelowLeft), Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(Fr2)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerTwo Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1.\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerOne Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1:\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerTwo Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1!\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight Thumb Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1\"\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerTwo Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(Fl2)!\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringLeft FingerTwo Nothing, Just $ FingeringRight Thumb Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(Fl2)\"\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringLeft FingerTwo Nothing, Just $ FingeringRight FingerTwo Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1!(Fl2)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight Thumb Nothing, Just $ FingeringLeft FingerTwo Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1\"(Fl2)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight FingerTwo Nothing, Just $ FingeringLeft FingerTwo Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "c1(Fr!)(Fl2)\n" (Chord 1 1 Nothing [ Note One C (Just $ FingeringRight Thumb Nothing, Just $ FingeringLeft FingerTwo Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkInvalidTest "c1(Fl..:7)\n"
, Test $ mkInvalidTest "c1(Fr...:9)\n"
, Test $ mkInvalidTest "c1(F.....)\n"
, Test $ mkInvalidTest "c1(F5)\n"
, Test $ mkInvalidTest "c1(Fx1)\n"
, Test $ mkInvalidTest "c1!.\n"
, Test $ mkInvalidTest "c1\":\n"
]
ornaments :: [Test]
ornaments =
[ Test $ mkParseTest "b2(Oa)\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnA Nothing Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2(Oa1)\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnA (Just 1) Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2(Oa:1)\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnA Nothing (Just PosAboveLeft)) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2(Oa2:5)\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnA (Just 2) (Just PosRight)) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2,\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnA (Just 1) Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2(C)\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnB Nothing Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2u\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnC (Just 1) Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2<\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnC (Just 2) Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2#\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnE Nothing Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2x\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnF Nothing Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2~\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnH Nothing Nothing) Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2(Oa)a3\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnA Nothing Nothing) Nothing Nothing
, Note Three A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2,a3\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnA (Just 1) Nothing) Nothing Nothing
, Note Three A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2(C)a3\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnB Nothing Nothing) Nothing Nothing
, Note Three A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2ua3\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnC (Just 1) Nothing) Nothing Nothing
, Note Three A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2<a3\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnC (Just 2) Nothing) Nothing Nothing
, Note Three A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2#a3\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnE Nothing Nothing) Nothing Nothing
, Note Three A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2xa3\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnF Nothing Nothing) Nothing Nothing
, Note Three A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkParseTest "b2~a3\n" (Chord 1 1 Nothing [ Note Two B (Nothing, Nothing) (Just $ OrnH Nothing Nothing) Nothing Nothing
, Note Three A (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, Test $ mkInvalidTest "b2(On)\n"
, Test $ mkInvalidTest "b2(Oa)(Ob)\n"
, Test $ mkInvalidTest "b2(Oa),\n"
, Test $ mkInvalidTest "b2,u\n"
]
comments :: [Test]
comments =
[ Test $ mkParseTest "{foo bar}\n" (CommentWord 1 1 (Comment "foo bar"))
, Test $ mkParseTest "{foo {bar}\n" (CommentWord 1 1 (Comment "foo {bar"))
, Test $ mkParseTest "{Qc1a2}" (CommentWord 1 1 (Comment "Qc1a2"))
, Test $ mkParseTest "{}" (CommentWord 1 1 (Comment ""))
, Test $ mkParseTest "{\n}" (CommentWord 1 1 (Comment "\n"))
, Test $ mkParseTest "{foo\nbar}" (CommentWord 1 1 (Comment "foo\nbar"))
, Test $ mkParseTest "Q.{foo}" (Rest 1 1 (RhythmSign Crotchet Simple Dot Nothing) (Just $ Comment "foo"))
, Test $ mkParseTest "|{foo}" (BarLine 1 1 (SingleBar Nothing Nothing NotDashed Counting) (Just $ Comment "foo"))
, Test $ mkParseTest "M(3){foo}" (Meter 1 1 (SingleMeterSign (Beats 3)) (Just $ Comment "foo"))
, Test $ mkParseTest "a1c3{foo}" (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] (Just $ Comment "foo"))
, Test $ mkParseTest "a1c3 {foo}" (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] (Just $ Comment "foo"))
, Test $ mkParsePhraseTest "a1c3\n{foo}" [ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (CommentWord 2 1 (Comment "foo")) ]
, Test $ mkParseTest "{^}{foo}" (SystemBreak 1 1 (Just $ Comment "foo"))
, Test $ mkParseTest "{>}{^}{foo}" (PageBreak 1 1 (Just $ Comment "foo"))
]
structuredComments :: [Test]
structuredComments =
[ Test $ mkParseTest "{^}\n" (SystemBreak 1 1 Nothing)
, Test $ mkParseTest "{>}{^}\n" (PageBreak 1 1 Nothing)
]
phrases :: [Test]
phrases =
[ Test $ mkParsePhraseTest "a1c3\na1c3"
[ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (Chord 2 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing) ]
, Test $ mkParsePhraseTest "a1c3 a1c3"
[ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (Chord 1 6 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing) ]
, Test $ mkParsePhraseTest "a1c3 a1c3 {foo}"
[ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (Chord 1 6 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] (Just $ Comment "foo")) ]
, Test $ mkParsePhraseTest "a1c3 a1c3{foo}"
[ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (Chord 1 6 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] (Just $ Comment "foo")) ]
, Test $ mkParsePhraseTest "a1c3\na1c3 {foo}"
[ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (Chord 2 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] (Just $ Comment "foo")) ]
, Test $ mkParsePhraseTest "a1c3 Q {foo}"
[ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (Rest 1 6 (RhythmSign Crotchet Simple NoDot Nothing) (Just $ Comment "foo")) ]
, Test $ mkParsePhraseTest "a1c3 | {foo}"
[ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (BarLine 1 6 (SingleBar Nothing Nothing NotDashed Counting) (Just $ Comment "foo")) ]
, Test $ mkParsePhraseTest "a1c3 M(O) {foo}"
[ (Chord 1 1 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing)
, (Meter 1 6 (SingleMeterSign PerfectMinor) (Just $ Comment "foo")) ]
, Test $ mkParsePhraseTest "M(O.) {foo} a1c3"
[ (Meter 1 1 (SingleMeterSign PerfectMajor) (Just $ Comment "foo"))
, (Chord 1 13 Nothing [ Note One A (Nothing, Nothing) Nothing Nothing Nothing
, Note Three C (Nothing, Nothing) Nothing Nothing Nothing ] Nothing) ]
]
| TransformingMusicology/tabcode-haskell | tests/ParseTests.hs | gpl-3.0 | 31,680 | 0 | 16 | 8,011 | 10,917 | 5,658 | 5,259 | 366 | 3 |
{--
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
Not all numbers produce palindromes so quickly. For example,
349 + 943 = 1292,
1292 + 2921 = 4213
4213 + 3124 = 7337
That is, 349 took three iterations to arrive at a palindrome.
Although no one has proved it yet, it is thought that some numbers, like 196, never produce a palindrome. A number that never forms a palindrome through the reverse and add process is called a Lychrel number. Due to the theoretical nature of these numbers, and for the purpose of this problem, we shall assume that a number is Lychrel until proven otherwise. In addition you are given that for every number below ten-thousand, it will either (i) become a palindrome in less than fifty iterations, or, (ii) no one, with all the computing power that exists, has managed so far to map it to a palindrome. In fact, 10677 is the first number to be shown to require over fifty iterations before producing a palindrome: 4668731596684224866951378664 (53 iterations, 28-digits).
Surprisingly, there are palindromic numbers that are themselves Lychrel numbers; the first example is 4994.
How many Lychrel numbers are there below ten-thousand?
NOTE: Wording was modified slightly on 24 April 2007 to emphasise the theoretical nature of Lychrel numbers.
--}
import Data.List
digits = reverse . map (`mod` 10) . takeWhile (> 0) . iterate (`div` 10)
(*|) a b = a * 10 + b
undigits xs = foldl' (*|) 0 xs
is_palindrome a = x == (reverse x)
where x = digits a
-- do the lychrel process
lychrel num = num + b
where b = undigits $ reverse $ digits num
-- tail is to avoid testing num itself (it could be palindromic)
is_lychrel num = null $ dropWhile (not . is_palindrome) $ take 49 $ tail $ iterate lychrel num
main = print $ length $ filter is_lychrel [1..9999]
| goalieca/haskelling | 055.hs | gpl-3.0 | 1,898 | 0 | 11 | 427 | 211 | 112 | 99 | 10 | 1 |
split x = (x, x) | hmemcpy/milewski-ctfp-pdf | src/content/3.7/code/haskell/snippet30.hs | gpl-3.0 | 16 | 0 | 5 | 4 | 15 | 8 | 7 | 1 | 1 |
{-# LANGUAGE Rank2Types, GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Helium.ModuleSystem.ExtractImportDecls where
import Helium.Syntax.UHA_Syntax
import Helium.Syntax.UHA_Utils
import Lvm.Common.Id
import qualified Lvm.Core.Expr as Core
import qualified Lvm.Core.Module as Core
import Helium.Utils.Utils (internalError)
import Control.Monad.Identity (Identity)
import qualified Control.Monad.Identity
-- Alternative -------------------------------------------------
-- wrapper
data Inh_Alternative = Inh_Alternative { }
data Syn_Alternative = Syn_Alternative { self_Syn_Alternative :: (Alternative) }
{-# INLINABLE wrap_Alternative #-}
wrap_Alternative :: T_Alternative -> Inh_Alternative -> (Syn_Alternative )
wrap_Alternative (T_Alternative act) (Inh_Alternative ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg1 = T_Alternative_vIn1
(T_Alternative_vOut1 _lhsOself) <- return (inv_Alternative_s2 sem arg1)
return (Syn_Alternative _lhsOself)
)
-- cata
{-# NOINLINE sem_Alternative #-}
sem_Alternative :: Alternative -> T_Alternative
sem_Alternative ( Alternative_Hole range_ id_ ) = sem_Alternative_Hole ( sem_Range range_ ) id_
sem_Alternative ( Alternative_Feedback range_ feedback_ alternative_ ) = sem_Alternative_Feedback ( sem_Range range_ ) feedback_ ( sem_Alternative alternative_ )
sem_Alternative ( Alternative_Alternative range_ pattern_ righthandside_ ) = sem_Alternative_Alternative ( sem_Range range_ ) ( sem_Pattern pattern_ ) ( sem_RightHandSide righthandside_ )
sem_Alternative ( Alternative_Empty range_ ) = sem_Alternative_Empty ( sem_Range range_ )
-- semantic domain
newtype T_Alternative = T_Alternative {
attach_T_Alternative :: Identity (T_Alternative_s2 )
}
newtype T_Alternative_s2 = C_Alternative_s2 {
inv_Alternative_s2 :: (T_Alternative_v1 )
}
data T_Alternative_s3 = C_Alternative_s3
type T_Alternative_v1 = (T_Alternative_vIn1 ) -> (T_Alternative_vOut1 )
data T_Alternative_vIn1 = T_Alternative_vIn1
data T_Alternative_vOut1 = T_Alternative_vOut1 (Alternative)
{-# NOINLINE sem_Alternative_Hole #-}
sem_Alternative_Hole :: T_Range -> (Integer) -> T_Alternative
sem_Alternative_Hole arg_range_ arg_id_ = T_Alternative (return st2) where
{-# NOINLINE st2 #-}
st2 = let
v1 :: T_Alternative_v1
v1 = \ (T_Alternative_vIn1 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule0 _rangeIself arg_id_
_lhsOself :: Alternative
_lhsOself = rule1 _self
__result_ = T_Alternative_vOut1 _lhsOself
in __result_ )
in C_Alternative_s2 v1
{-# INLINE rule0 #-}
rule0 = \ ((_rangeIself) :: Range) id_ ->
Alternative_Hole _rangeIself id_
{-# INLINE rule1 #-}
rule1 = \ _self ->
_self
{-# NOINLINE sem_Alternative_Feedback #-}
sem_Alternative_Feedback :: T_Range -> (String) -> T_Alternative -> T_Alternative
sem_Alternative_Feedback arg_range_ arg_feedback_ arg_alternative_ = T_Alternative (return st2) where
{-# NOINLINE st2 #-}
st2 = let
v1 :: T_Alternative_v1
v1 = \ (T_Alternative_vIn1 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_alternativeX2 = Control.Monad.Identity.runIdentity (attach_T_Alternative (arg_alternative_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Alternative_vOut1 _alternativeIself) = inv_Alternative_s2 _alternativeX2 (T_Alternative_vIn1 )
_self = rule2 _alternativeIself _rangeIself arg_feedback_
_lhsOself :: Alternative
_lhsOself = rule3 _self
__result_ = T_Alternative_vOut1 _lhsOself
in __result_ )
in C_Alternative_s2 v1
{-# INLINE rule2 #-}
rule2 = \ ((_alternativeIself) :: Alternative) ((_rangeIself) :: Range) feedback_ ->
Alternative_Feedback _rangeIself feedback_ _alternativeIself
{-# INLINE rule3 #-}
rule3 = \ _self ->
_self
{-# NOINLINE sem_Alternative_Alternative #-}
sem_Alternative_Alternative :: T_Range -> T_Pattern -> T_RightHandSide -> T_Alternative
sem_Alternative_Alternative arg_range_ arg_pattern_ arg_righthandside_ = T_Alternative (return st2) where
{-# NOINLINE st2 #-}
st2 = let
v1 :: T_Alternative_v1
v1 = \ (T_Alternative_vIn1 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_))
_righthandsideX149 = Control.Monad.Identity.runIdentity (attach_T_RightHandSide (arg_righthandside_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Pattern_vOut118 _patternIself) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 )
(T_RightHandSide_vOut148 _righthandsideIself) = inv_RightHandSide_s149 _righthandsideX149 (T_RightHandSide_vIn148 )
_self = rule4 _patternIself _rangeIself _righthandsideIself
_lhsOself :: Alternative
_lhsOself = rule5 _self
__result_ = T_Alternative_vOut1 _lhsOself
in __result_ )
in C_Alternative_s2 v1
{-# INLINE rule4 #-}
rule4 = \ ((_patternIself) :: Pattern) ((_rangeIself) :: Range) ((_righthandsideIself) :: RightHandSide) ->
Alternative_Alternative _rangeIself _patternIself _righthandsideIself
{-# INLINE rule5 #-}
rule5 = \ _self ->
_self
{-# NOINLINE sem_Alternative_Empty #-}
sem_Alternative_Empty :: T_Range -> T_Alternative
sem_Alternative_Empty arg_range_ = T_Alternative (return st2) where
{-# NOINLINE st2 #-}
st2 = let
v1 :: T_Alternative_v1
v1 = \ (T_Alternative_vIn1 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule6 _rangeIself
_lhsOself :: Alternative
_lhsOself = rule7 _self
__result_ = T_Alternative_vOut1 _lhsOself
in __result_ )
in C_Alternative_s2 v1
{-# INLINE rule6 #-}
rule6 = \ ((_rangeIself) :: Range) ->
Alternative_Empty _rangeIself
{-# INLINE rule7 #-}
rule7 = \ _self ->
_self
-- Alternatives ------------------------------------------------
-- wrapper
data Inh_Alternatives = Inh_Alternatives { }
data Syn_Alternatives = Syn_Alternatives { self_Syn_Alternatives :: (Alternatives) }
{-# INLINABLE wrap_Alternatives #-}
wrap_Alternatives :: T_Alternatives -> Inh_Alternatives -> (Syn_Alternatives )
wrap_Alternatives (T_Alternatives act) (Inh_Alternatives ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg4 = T_Alternatives_vIn4
(T_Alternatives_vOut4 _lhsOself) <- return (inv_Alternatives_s5 sem arg4)
return (Syn_Alternatives _lhsOself)
)
-- cata
{-# NOINLINE sem_Alternatives #-}
sem_Alternatives :: Alternatives -> T_Alternatives
sem_Alternatives list = Prelude.foldr sem_Alternatives_Cons sem_Alternatives_Nil (Prelude.map sem_Alternative list)
-- semantic domain
newtype T_Alternatives = T_Alternatives {
attach_T_Alternatives :: Identity (T_Alternatives_s5 )
}
newtype T_Alternatives_s5 = C_Alternatives_s5 {
inv_Alternatives_s5 :: (T_Alternatives_v4 )
}
data T_Alternatives_s6 = C_Alternatives_s6
type T_Alternatives_v4 = (T_Alternatives_vIn4 ) -> (T_Alternatives_vOut4 )
data T_Alternatives_vIn4 = T_Alternatives_vIn4
data T_Alternatives_vOut4 = T_Alternatives_vOut4 (Alternatives)
{-# NOINLINE sem_Alternatives_Cons #-}
sem_Alternatives_Cons :: T_Alternative -> T_Alternatives -> T_Alternatives
sem_Alternatives_Cons arg_hd_ arg_tl_ = T_Alternatives (return st5) where
{-# NOINLINE st5 #-}
st5 = let
v4 :: T_Alternatives_v4
v4 = \ (T_Alternatives_vIn4 ) -> ( let
_hdX2 = Control.Monad.Identity.runIdentity (attach_T_Alternative (arg_hd_))
_tlX5 = Control.Monad.Identity.runIdentity (attach_T_Alternatives (arg_tl_))
(T_Alternative_vOut1 _hdIself) = inv_Alternative_s2 _hdX2 (T_Alternative_vIn1 )
(T_Alternatives_vOut4 _tlIself) = inv_Alternatives_s5 _tlX5 (T_Alternatives_vIn4 )
_self = rule8 _hdIself _tlIself
_lhsOself :: Alternatives
_lhsOself = rule9 _self
__result_ = T_Alternatives_vOut4 _lhsOself
in __result_ )
in C_Alternatives_s5 v4
{-# INLINE rule8 #-}
rule8 = \ ((_hdIself) :: Alternative) ((_tlIself) :: Alternatives) ->
(:) _hdIself _tlIself
{-# INLINE rule9 #-}
rule9 = \ _self ->
_self
{-# NOINLINE sem_Alternatives_Nil #-}
sem_Alternatives_Nil :: T_Alternatives
sem_Alternatives_Nil = T_Alternatives (return st5) where
{-# NOINLINE st5 #-}
st5 = let
v4 :: T_Alternatives_v4
v4 = \ (T_Alternatives_vIn4 ) -> ( let
_self = rule10 ()
_lhsOself :: Alternatives
_lhsOself = rule11 _self
__result_ = T_Alternatives_vOut4 _lhsOself
in __result_ )
in C_Alternatives_s5 v4
{-# INLINE rule10 #-}
rule10 = \ (_ :: ()) ->
[]
{-# INLINE rule11 #-}
rule11 = \ _self ->
_self
-- AnnotatedType -----------------------------------------------
-- wrapper
data Inh_AnnotatedType = Inh_AnnotatedType { }
data Syn_AnnotatedType = Syn_AnnotatedType { self_Syn_AnnotatedType :: (AnnotatedType) }
{-# INLINABLE wrap_AnnotatedType #-}
wrap_AnnotatedType :: T_AnnotatedType -> Inh_AnnotatedType -> (Syn_AnnotatedType )
wrap_AnnotatedType (T_AnnotatedType act) (Inh_AnnotatedType ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg7 = T_AnnotatedType_vIn7
(T_AnnotatedType_vOut7 _lhsOself) <- return (inv_AnnotatedType_s8 sem arg7)
return (Syn_AnnotatedType _lhsOself)
)
-- cata
{-# INLINE sem_AnnotatedType #-}
sem_AnnotatedType :: AnnotatedType -> T_AnnotatedType
sem_AnnotatedType ( AnnotatedType_AnnotatedType range_ strict_ type_ ) = sem_AnnotatedType_AnnotatedType ( sem_Range range_ ) strict_ ( sem_Type type_ )
-- semantic domain
newtype T_AnnotatedType = T_AnnotatedType {
attach_T_AnnotatedType :: Identity (T_AnnotatedType_s8 )
}
newtype T_AnnotatedType_s8 = C_AnnotatedType_s8 {
inv_AnnotatedType_s8 :: (T_AnnotatedType_v7 )
}
data T_AnnotatedType_s9 = C_AnnotatedType_s9
type T_AnnotatedType_v7 = (T_AnnotatedType_vIn7 ) -> (T_AnnotatedType_vOut7 )
data T_AnnotatedType_vIn7 = T_AnnotatedType_vIn7
data T_AnnotatedType_vOut7 = T_AnnotatedType_vOut7 (AnnotatedType)
{-# NOINLINE sem_AnnotatedType_AnnotatedType #-}
sem_AnnotatedType_AnnotatedType :: T_Range -> (Bool) -> T_Type -> T_AnnotatedType
sem_AnnotatedType_AnnotatedType arg_range_ arg_strict_ arg_type_ = T_AnnotatedType (return st8) where
{-# NOINLINE st8 #-}
st8 = let
v7 :: T_AnnotatedType_v7
v7 = \ (T_AnnotatedType_vIn7 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Type_vOut163 _typeIself) = inv_Type_s164 _typeX164 (T_Type_vIn163 )
_self = rule12 _rangeIself _typeIself arg_strict_
_lhsOself :: AnnotatedType
_lhsOself = rule13 _self
__result_ = T_AnnotatedType_vOut7 _lhsOself
in __result_ )
in C_AnnotatedType_s8 v7
{-# INLINE rule12 #-}
rule12 = \ ((_rangeIself) :: Range) ((_typeIself) :: Type) strict_ ->
AnnotatedType_AnnotatedType _rangeIself strict_ _typeIself
{-# INLINE rule13 #-}
rule13 = \ _self ->
_self
-- AnnotatedTypes ----------------------------------------------
-- wrapper
data Inh_AnnotatedTypes = Inh_AnnotatedTypes { }
data Syn_AnnotatedTypes = Syn_AnnotatedTypes { self_Syn_AnnotatedTypes :: (AnnotatedTypes) }
{-# INLINABLE wrap_AnnotatedTypes #-}
wrap_AnnotatedTypes :: T_AnnotatedTypes -> Inh_AnnotatedTypes -> (Syn_AnnotatedTypes )
wrap_AnnotatedTypes (T_AnnotatedTypes act) (Inh_AnnotatedTypes ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg10 = T_AnnotatedTypes_vIn10
(T_AnnotatedTypes_vOut10 _lhsOself) <- return (inv_AnnotatedTypes_s11 sem arg10)
return (Syn_AnnotatedTypes _lhsOself)
)
-- cata
{-# NOINLINE sem_AnnotatedTypes #-}
sem_AnnotatedTypes :: AnnotatedTypes -> T_AnnotatedTypes
sem_AnnotatedTypes list = Prelude.foldr sem_AnnotatedTypes_Cons sem_AnnotatedTypes_Nil (Prelude.map sem_AnnotatedType list)
-- semantic domain
newtype T_AnnotatedTypes = T_AnnotatedTypes {
attach_T_AnnotatedTypes :: Identity (T_AnnotatedTypes_s11 )
}
newtype T_AnnotatedTypes_s11 = C_AnnotatedTypes_s11 {
inv_AnnotatedTypes_s11 :: (T_AnnotatedTypes_v10 )
}
data T_AnnotatedTypes_s12 = C_AnnotatedTypes_s12
type T_AnnotatedTypes_v10 = (T_AnnotatedTypes_vIn10 ) -> (T_AnnotatedTypes_vOut10 )
data T_AnnotatedTypes_vIn10 = T_AnnotatedTypes_vIn10
data T_AnnotatedTypes_vOut10 = T_AnnotatedTypes_vOut10 (AnnotatedTypes)
{-# NOINLINE sem_AnnotatedTypes_Cons #-}
sem_AnnotatedTypes_Cons :: T_AnnotatedType -> T_AnnotatedTypes -> T_AnnotatedTypes
sem_AnnotatedTypes_Cons arg_hd_ arg_tl_ = T_AnnotatedTypes (return st11) where
{-# NOINLINE st11 #-}
st11 = let
v10 :: T_AnnotatedTypes_v10
v10 = \ (T_AnnotatedTypes_vIn10 ) -> ( let
_hdX8 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedType (arg_hd_))
_tlX11 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedTypes (arg_tl_))
(T_AnnotatedType_vOut7 _hdIself) = inv_AnnotatedType_s8 _hdX8 (T_AnnotatedType_vIn7 )
(T_AnnotatedTypes_vOut10 _tlIself) = inv_AnnotatedTypes_s11 _tlX11 (T_AnnotatedTypes_vIn10 )
_self = rule14 _hdIself _tlIself
_lhsOself :: AnnotatedTypes
_lhsOself = rule15 _self
__result_ = T_AnnotatedTypes_vOut10 _lhsOself
in __result_ )
in C_AnnotatedTypes_s11 v10
{-# INLINE rule14 #-}
rule14 = \ ((_hdIself) :: AnnotatedType) ((_tlIself) :: AnnotatedTypes) ->
(:) _hdIself _tlIself
{-# INLINE rule15 #-}
rule15 = \ _self ->
_self
{-# NOINLINE sem_AnnotatedTypes_Nil #-}
sem_AnnotatedTypes_Nil :: T_AnnotatedTypes
sem_AnnotatedTypes_Nil = T_AnnotatedTypes (return st11) where
{-# NOINLINE st11 #-}
st11 = let
v10 :: T_AnnotatedTypes_v10
v10 = \ (T_AnnotatedTypes_vIn10 ) -> ( let
_self = rule16 ()
_lhsOself :: AnnotatedTypes
_lhsOself = rule17 _self
__result_ = T_AnnotatedTypes_vOut10 _lhsOself
in __result_ )
in C_AnnotatedTypes_s11 v10
{-# INLINE rule16 #-}
rule16 = \ (_ :: ()) ->
[]
{-# INLINE rule17 #-}
rule17 = \ _self ->
_self
-- Body --------------------------------------------------------
-- wrapper
data Inh_Body = Inh_Body { }
data Syn_Body = Syn_Body { coreImportDecls_Syn_Body :: ( [(Core.CoreDecl,[Id])] ), self_Syn_Body :: (Body) }
{-# INLINABLE wrap_Body #-}
wrap_Body :: T_Body -> Inh_Body -> (Syn_Body )
wrap_Body (T_Body act) (Inh_Body ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg13 = T_Body_vIn13
(T_Body_vOut13 _lhsOcoreImportDecls _lhsOself) <- return (inv_Body_s14 sem arg13)
return (Syn_Body _lhsOcoreImportDecls _lhsOself)
)
-- cata
{-# NOINLINE sem_Body #-}
sem_Body :: Body -> T_Body
sem_Body ( Body_Hole range_ id_ ) = sem_Body_Hole ( sem_Range range_ ) id_
sem_Body ( Body_Body range_ importdeclarations_ declarations_ ) = sem_Body_Body ( sem_Range range_ ) ( sem_ImportDeclarations importdeclarations_ ) ( sem_Declarations declarations_ )
-- semantic domain
newtype T_Body = T_Body {
attach_T_Body :: Identity (T_Body_s14 )
}
newtype T_Body_s14 = C_Body_s14 {
inv_Body_s14 :: (T_Body_v13 )
}
data T_Body_s15 = C_Body_s15
type T_Body_v13 = (T_Body_vIn13 ) -> (T_Body_vOut13 )
data T_Body_vIn13 = T_Body_vIn13
data T_Body_vOut13 = T_Body_vOut13 ( [(Core.CoreDecl,[Id])] ) (Body)
{-# NOINLINE sem_Body_Hole #-}
sem_Body_Hole :: T_Range -> (Integer) -> T_Body
sem_Body_Hole arg_range_ arg_id_ = T_Body (return st14) where
{-# NOINLINE st14 #-}
st14 = let
v13 :: T_Body_v13
v13 = \ (T_Body_vIn13 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_lhsOcoreImportDecls :: [(Core.CoreDecl,[Id])]
_lhsOcoreImportDecls = rule18 ()
_self = rule19 _rangeIself arg_id_
_lhsOself :: Body
_lhsOself = rule20 _self
__result_ = T_Body_vOut13 _lhsOcoreImportDecls _lhsOself
in __result_ )
in C_Body_s14 v13
{-# INLINE rule18 #-}
rule18 = \ (_ :: ()) ->
[]
{-# INLINE rule19 #-}
rule19 = \ ((_rangeIself) :: Range) id_ ->
Body_Hole _rangeIself id_
{-# INLINE rule20 #-}
rule20 = \ _self ->
_self
{-# NOINLINE sem_Body_Body #-}
sem_Body_Body :: T_Range -> T_ImportDeclarations -> T_Declarations -> T_Body
sem_Body_Body arg_range_ arg_importdeclarations_ arg_declarations_ = T_Body (return st14) where
{-# NOINLINE st14 #-}
st14 = let
v13 :: T_Body_v13
v13 = \ (T_Body_vIn13 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_importdeclarationsX74 = Control.Monad.Identity.runIdentity (attach_T_ImportDeclarations (arg_importdeclarations_))
_declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_ImportDeclarations_vOut73 _importdeclarationsIcoreImportDecls _importdeclarationsIself) = inv_ImportDeclarations_s74 _importdeclarationsX74 (T_ImportDeclarations_vIn73 )
(T_Declarations_vOut31 _declarationsIself) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 )
_lhsOcoreImportDecls :: [(Core.CoreDecl,[Id])]
_lhsOcoreImportDecls = rule21 _importdeclarationsIcoreImportDecls
_self = rule22 _declarationsIself _importdeclarationsIself _rangeIself
_lhsOself :: Body
_lhsOself = rule23 _self
__result_ = T_Body_vOut13 _lhsOcoreImportDecls _lhsOself
in __result_ )
in C_Body_s14 v13
{-# INLINE rule21 #-}
rule21 = \ ((_importdeclarationsIcoreImportDecls) :: [(Core.CoreDecl,[Id])] ) ->
_importdeclarationsIcoreImportDecls
{-# INLINE rule22 #-}
rule22 = \ ((_declarationsIself) :: Declarations) ((_importdeclarationsIself) :: ImportDeclarations) ((_rangeIself) :: Range) ->
Body_Body _rangeIself _importdeclarationsIself _declarationsIself
{-# INLINE rule23 #-}
rule23 = \ _self ->
_self
-- Constructor -------------------------------------------------
-- wrapper
data Inh_Constructor = Inh_Constructor { }
data Syn_Constructor = Syn_Constructor { self_Syn_Constructor :: (Constructor) }
{-# INLINABLE wrap_Constructor #-}
wrap_Constructor :: T_Constructor -> Inh_Constructor -> (Syn_Constructor )
wrap_Constructor (T_Constructor act) (Inh_Constructor ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg16 = T_Constructor_vIn16
(T_Constructor_vOut16 _lhsOself) <- return (inv_Constructor_s17 sem arg16)
return (Syn_Constructor _lhsOself)
)
-- cata
{-# NOINLINE sem_Constructor #-}
sem_Constructor :: Constructor -> T_Constructor
sem_Constructor ( Constructor_Constructor range_ constructor_ types_ ) = sem_Constructor_Constructor ( sem_Range range_ ) ( sem_Name constructor_ ) ( sem_AnnotatedTypes types_ )
sem_Constructor ( Constructor_Infix range_ leftType_ constructorOperator_ rightType_ ) = sem_Constructor_Infix ( sem_Range range_ ) ( sem_AnnotatedType leftType_ ) ( sem_Name constructorOperator_ ) ( sem_AnnotatedType rightType_ )
sem_Constructor ( Constructor_Record range_ constructor_ fieldDeclarations_ ) = sem_Constructor_Record ( sem_Range range_ ) ( sem_Name constructor_ ) ( sem_FieldDeclarations fieldDeclarations_ )
-- semantic domain
newtype T_Constructor = T_Constructor {
attach_T_Constructor :: Identity (T_Constructor_s17 )
}
newtype T_Constructor_s17 = C_Constructor_s17 {
inv_Constructor_s17 :: (T_Constructor_v16 )
}
data T_Constructor_s18 = C_Constructor_s18
type T_Constructor_v16 = (T_Constructor_vIn16 ) -> (T_Constructor_vOut16 )
data T_Constructor_vIn16 = T_Constructor_vIn16
data T_Constructor_vOut16 = T_Constructor_vOut16 (Constructor)
{-# NOINLINE sem_Constructor_Constructor #-}
sem_Constructor_Constructor :: T_Range -> T_Name -> T_AnnotatedTypes -> T_Constructor
sem_Constructor_Constructor arg_range_ arg_constructor_ arg_types_ = T_Constructor (return st17) where
{-# NOINLINE st17 #-}
st17 = let
v16 :: T_Constructor_v16
v16 = \ (T_Constructor_vIn16 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_constructorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_constructor_))
_typesX11 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedTypes (arg_types_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _constructorIself) = inv_Name_s113 _constructorX113 (T_Name_vIn112 )
(T_AnnotatedTypes_vOut10 _typesIself) = inv_AnnotatedTypes_s11 _typesX11 (T_AnnotatedTypes_vIn10 )
_self = rule24 _constructorIself _rangeIself _typesIself
_lhsOself :: Constructor
_lhsOself = rule25 _self
__result_ = T_Constructor_vOut16 _lhsOself
in __result_ )
in C_Constructor_s17 v16
{-# INLINE rule24 #-}
rule24 = \ ((_constructorIself) :: Name) ((_rangeIself) :: Range) ((_typesIself) :: AnnotatedTypes) ->
Constructor_Constructor _rangeIself _constructorIself _typesIself
{-# INLINE rule25 #-}
rule25 = \ _self ->
_self
{-# NOINLINE sem_Constructor_Infix #-}
sem_Constructor_Infix :: T_Range -> T_AnnotatedType -> T_Name -> T_AnnotatedType -> T_Constructor
sem_Constructor_Infix arg_range_ arg_leftType_ arg_constructorOperator_ arg_rightType_ = T_Constructor (return st17) where
{-# NOINLINE st17 #-}
st17 = let
v16 :: T_Constructor_v16
v16 = \ (T_Constructor_vIn16 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_leftTypeX8 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedType (arg_leftType_))
_constructorOperatorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_constructorOperator_))
_rightTypeX8 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedType (arg_rightType_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_AnnotatedType_vOut7 _leftTypeIself) = inv_AnnotatedType_s8 _leftTypeX8 (T_AnnotatedType_vIn7 )
(T_Name_vOut112 _constructorOperatorIself) = inv_Name_s113 _constructorOperatorX113 (T_Name_vIn112 )
(T_AnnotatedType_vOut7 _rightTypeIself) = inv_AnnotatedType_s8 _rightTypeX8 (T_AnnotatedType_vIn7 )
_self = rule26 _constructorOperatorIself _leftTypeIself _rangeIself _rightTypeIself
_lhsOself :: Constructor
_lhsOself = rule27 _self
__result_ = T_Constructor_vOut16 _lhsOself
in __result_ )
in C_Constructor_s17 v16
{-# INLINE rule26 #-}
rule26 = \ ((_constructorOperatorIself) :: Name) ((_leftTypeIself) :: AnnotatedType) ((_rangeIself) :: Range) ((_rightTypeIself) :: AnnotatedType) ->
Constructor_Infix _rangeIself _leftTypeIself _constructorOperatorIself _rightTypeIself
{-# INLINE rule27 #-}
rule27 = \ _self ->
_self
{-# NOINLINE sem_Constructor_Record #-}
sem_Constructor_Record :: T_Range -> T_Name -> T_FieldDeclarations -> T_Constructor
sem_Constructor_Record arg_range_ arg_constructor_ arg_fieldDeclarations_ = T_Constructor (return st17) where
{-# NOINLINE st17 #-}
st17 = let
v16 :: T_Constructor_v16
v16 = \ (T_Constructor_vIn16 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_constructorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_constructor_))
_fieldDeclarationsX50 = Control.Monad.Identity.runIdentity (attach_T_FieldDeclarations (arg_fieldDeclarations_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _constructorIself) = inv_Name_s113 _constructorX113 (T_Name_vIn112 )
(T_FieldDeclarations_vOut49 _fieldDeclarationsIself) = inv_FieldDeclarations_s50 _fieldDeclarationsX50 (T_FieldDeclarations_vIn49 )
_self = rule28 _constructorIself _fieldDeclarationsIself _rangeIself
_lhsOself :: Constructor
_lhsOself = rule29 _self
__result_ = T_Constructor_vOut16 _lhsOself
in __result_ )
in C_Constructor_s17 v16
{-# INLINE rule28 #-}
rule28 = \ ((_constructorIself) :: Name) ((_fieldDeclarationsIself) :: FieldDeclarations) ((_rangeIself) :: Range) ->
Constructor_Record _rangeIself _constructorIself _fieldDeclarationsIself
{-# INLINE rule29 #-}
rule29 = \ _self ->
_self
-- Constructors ------------------------------------------------
-- wrapper
data Inh_Constructors = Inh_Constructors { }
data Syn_Constructors = Syn_Constructors { self_Syn_Constructors :: (Constructors) }
{-# INLINABLE wrap_Constructors #-}
wrap_Constructors :: T_Constructors -> Inh_Constructors -> (Syn_Constructors )
wrap_Constructors (T_Constructors act) (Inh_Constructors ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg19 = T_Constructors_vIn19
(T_Constructors_vOut19 _lhsOself) <- return (inv_Constructors_s20 sem arg19)
return (Syn_Constructors _lhsOself)
)
-- cata
{-# NOINLINE sem_Constructors #-}
sem_Constructors :: Constructors -> T_Constructors
sem_Constructors list = Prelude.foldr sem_Constructors_Cons sem_Constructors_Nil (Prelude.map sem_Constructor list)
-- semantic domain
newtype T_Constructors = T_Constructors {
attach_T_Constructors :: Identity (T_Constructors_s20 )
}
newtype T_Constructors_s20 = C_Constructors_s20 {
inv_Constructors_s20 :: (T_Constructors_v19 )
}
data T_Constructors_s21 = C_Constructors_s21
type T_Constructors_v19 = (T_Constructors_vIn19 ) -> (T_Constructors_vOut19 )
data T_Constructors_vIn19 = T_Constructors_vIn19
data T_Constructors_vOut19 = T_Constructors_vOut19 (Constructors)
{-# NOINLINE sem_Constructors_Cons #-}
sem_Constructors_Cons :: T_Constructor -> T_Constructors -> T_Constructors
sem_Constructors_Cons arg_hd_ arg_tl_ = T_Constructors (return st20) where
{-# NOINLINE st20 #-}
st20 = let
v19 :: T_Constructors_v19
v19 = \ (T_Constructors_vIn19 ) -> ( let
_hdX17 = Control.Monad.Identity.runIdentity (attach_T_Constructor (arg_hd_))
_tlX20 = Control.Monad.Identity.runIdentity (attach_T_Constructors (arg_tl_))
(T_Constructor_vOut16 _hdIself) = inv_Constructor_s17 _hdX17 (T_Constructor_vIn16 )
(T_Constructors_vOut19 _tlIself) = inv_Constructors_s20 _tlX20 (T_Constructors_vIn19 )
_self = rule30 _hdIself _tlIself
_lhsOself :: Constructors
_lhsOself = rule31 _self
__result_ = T_Constructors_vOut19 _lhsOself
in __result_ )
in C_Constructors_s20 v19
{-# INLINE rule30 #-}
rule30 = \ ((_hdIself) :: Constructor) ((_tlIself) :: Constructors) ->
(:) _hdIself _tlIself
{-# INLINE rule31 #-}
rule31 = \ _self ->
_self
{-# NOINLINE sem_Constructors_Nil #-}
sem_Constructors_Nil :: T_Constructors
sem_Constructors_Nil = T_Constructors (return st20) where
{-# NOINLINE st20 #-}
st20 = let
v19 :: T_Constructors_v19
v19 = \ (T_Constructors_vIn19 ) -> ( let
_self = rule32 ()
_lhsOself :: Constructors
_lhsOself = rule33 _self
__result_ = T_Constructors_vOut19 _lhsOself
in __result_ )
in C_Constructors_s20 v19
{-# INLINE rule32 #-}
rule32 = \ (_ :: ()) ->
[]
{-# INLINE rule33 #-}
rule33 = \ _self ->
_self
-- ContextItem -------------------------------------------------
-- wrapper
data Inh_ContextItem = Inh_ContextItem { }
data Syn_ContextItem = Syn_ContextItem { self_Syn_ContextItem :: (ContextItem) }
{-# INLINABLE wrap_ContextItem #-}
wrap_ContextItem :: T_ContextItem -> Inh_ContextItem -> (Syn_ContextItem )
wrap_ContextItem (T_ContextItem act) (Inh_ContextItem ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg22 = T_ContextItem_vIn22
(T_ContextItem_vOut22 _lhsOself) <- return (inv_ContextItem_s23 sem arg22)
return (Syn_ContextItem _lhsOself)
)
-- cata
{-# NOINLINE sem_ContextItem #-}
sem_ContextItem :: ContextItem -> T_ContextItem
sem_ContextItem ( ContextItem_ContextItem range_ name_ types_ ) = sem_ContextItem_ContextItem ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Types types_ )
-- semantic domain
newtype T_ContextItem = T_ContextItem {
attach_T_ContextItem :: Identity (T_ContextItem_s23 )
}
newtype T_ContextItem_s23 = C_ContextItem_s23 {
inv_ContextItem_s23 :: (T_ContextItem_v22 )
}
data T_ContextItem_s24 = C_ContextItem_s24
type T_ContextItem_v22 = (T_ContextItem_vIn22 ) -> (T_ContextItem_vOut22 )
data T_ContextItem_vIn22 = T_ContextItem_vIn22
data T_ContextItem_vOut22 = T_ContextItem_vOut22 (ContextItem)
{-# NOINLINE sem_ContextItem_ContextItem #-}
sem_ContextItem_ContextItem :: T_Range -> T_Name -> T_Types -> T_ContextItem
sem_ContextItem_ContextItem arg_range_ arg_name_ arg_types_ = T_ContextItem (return st23) where
{-# NOINLINE st23 #-}
st23 = let
v22 :: T_ContextItem_v22
v22 = \ (T_ContextItem_vIn22 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_typesX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_types_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Types_vOut166 _typesIself) = inv_Types_s167 _typesX167 (T_Types_vIn166 )
_self = rule34 _nameIself _rangeIself _typesIself
_lhsOself :: ContextItem
_lhsOself = rule35 _self
__result_ = T_ContextItem_vOut22 _lhsOself
in __result_ )
in C_ContextItem_s23 v22
{-# INLINE rule34 #-}
rule34 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ((_typesIself) :: Types) ->
ContextItem_ContextItem _rangeIself _nameIself _typesIself
{-# INLINE rule35 #-}
rule35 = \ _self ->
_self
-- ContextItems ------------------------------------------------
-- wrapper
data Inh_ContextItems = Inh_ContextItems { }
data Syn_ContextItems = Syn_ContextItems { self_Syn_ContextItems :: (ContextItems) }
{-# INLINABLE wrap_ContextItems #-}
wrap_ContextItems :: T_ContextItems -> Inh_ContextItems -> (Syn_ContextItems )
wrap_ContextItems (T_ContextItems act) (Inh_ContextItems ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg25 = T_ContextItems_vIn25
(T_ContextItems_vOut25 _lhsOself) <- return (inv_ContextItems_s26 sem arg25)
return (Syn_ContextItems _lhsOself)
)
-- cata
{-# NOINLINE sem_ContextItems #-}
sem_ContextItems :: ContextItems -> T_ContextItems
sem_ContextItems list = Prelude.foldr sem_ContextItems_Cons sem_ContextItems_Nil (Prelude.map sem_ContextItem list)
-- semantic domain
newtype T_ContextItems = T_ContextItems {
attach_T_ContextItems :: Identity (T_ContextItems_s26 )
}
newtype T_ContextItems_s26 = C_ContextItems_s26 {
inv_ContextItems_s26 :: (T_ContextItems_v25 )
}
data T_ContextItems_s27 = C_ContextItems_s27
type T_ContextItems_v25 = (T_ContextItems_vIn25 ) -> (T_ContextItems_vOut25 )
data T_ContextItems_vIn25 = T_ContextItems_vIn25
data T_ContextItems_vOut25 = T_ContextItems_vOut25 (ContextItems)
{-# NOINLINE sem_ContextItems_Cons #-}
sem_ContextItems_Cons :: T_ContextItem -> T_ContextItems -> T_ContextItems
sem_ContextItems_Cons arg_hd_ arg_tl_ = T_ContextItems (return st26) where
{-# NOINLINE st26 #-}
st26 = let
v25 :: T_ContextItems_v25
v25 = \ (T_ContextItems_vIn25 ) -> ( let
_hdX23 = Control.Monad.Identity.runIdentity (attach_T_ContextItem (arg_hd_))
_tlX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_tl_))
(T_ContextItem_vOut22 _hdIself) = inv_ContextItem_s23 _hdX23 (T_ContextItem_vIn22 )
(T_ContextItems_vOut25 _tlIself) = inv_ContextItems_s26 _tlX26 (T_ContextItems_vIn25 )
_self = rule36 _hdIself _tlIself
_lhsOself :: ContextItems
_lhsOself = rule37 _self
__result_ = T_ContextItems_vOut25 _lhsOself
in __result_ )
in C_ContextItems_s26 v25
{-# INLINE rule36 #-}
rule36 = \ ((_hdIself) :: ContextItem) ((_tlIself) :: ContextItems) ->
(:) _hdIself _tlIself
{-# INLINE rule37 #-}
rule37 = \ _self ->
_self
{-# NOINLINE sem_ContextItems_Nil #-}
sem_ContextItems_Nil :: T_ContextItems
sem_ContextItems_Nil = T_ContextItems (return st26) where
{-# NOINLINE st26 #-}
st26 = let
v25 :: T_ContextItems_v25
v25 = \ (T_ContextItems_vIn25 ) -> ( let
_self = rule38 ()
_lhsOself :: ContextItems
_lhsOself = rule39 _self
__result_ = T_ContextItems_vOut25 _lhsOself
in __result_ )
in C_ContextItems_s26 v25
{-# INLINE rule38 #-}
rule38 = \ (_ :: ()) ->
[]
{-# INLINE rule39 #-}
rule39 = \ _self ->
_self
-- Declaration -------------------------------------------------
-- wrapper
data Inh_Declaration = Inh_Declaration { }
data Syn_Declaration = Syn_Declaration { self_Syn_Declaration :: (Declaration) }
{-# INLINABLE wrap_Declaration #-}
wrap_Declaration :: T_Declaration -> Inh_Declaration -> (Syn_Declaration )
wrap_Declaration (T_Declaration act) (Inh_Declaration ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg28 = T_Declaration_vIn28
(T_Declaration_vOut28 _lhsOself) <- return (inv_Declaration_s29 sem arg28)
return (Syn_Declaration _lhsOself)
)
-- cata
{-# NOINLINE sem_Declaration #-}
sem_Declaration :: Declaration -> T_Declaration
sem_Declaration ( Declaration_Hole range_ id_ ) = sem_Declaration_Hole ( sem_Range range_ ) id_
sem_Declaration ( Declaration_Type range_ simpletype_ type_ ) = sem_Declaration_Type ( sem_Range range_ ) ( sem_SimpleType simpletype_ ) ( sem_Type type_ )
sem_Declaration ( Declaration_Data range_ context_ simpletype_ constructors_ derivings_ ) = sem_Declaration_Data ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_SimpleType simpletype_ ) ( sem_Constructors constructors_ ) ( sem_Names derivings_ )
sem_Declaration ( Declaration_Newtype range_ context_ simpletype_ constructor_ derivings_ ) = sem_Declaration_Newtype ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_SimpleType simpletype_ ) ( sem_Constructor constructor_ ) ( sem_Names derivings_ )
sem_Declaration ( Declaration_Class range_ context_ simpletype_ where_ ) = sem_Declaration_Class ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_SimpleType simpletype_ ) ( sem_MaybeDeclarations where_ )
sem_Declaration ( Declaration_Instance range_ context_ name_ types_ where_ ) = sem_Declaration_Instance ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_Name name_ ) ( sem_Types types_ ) ( sem_MaybeDeclarations where_ )
sem_Declaration ( Declaration_Default range_ types_ ) = sem_Declaration_Default ( sem_Range range_ ) ( sem_Types types_ )
sem_Declaration ( Declaration_FunctionBindings range_ bindings_ ) = sem_Declaration_FunctionBindings ( sem_Range range_ ) ( sem_FunctionBindings bindings_ )
sem_Declaration ( Declaration_PatternBinding range_ pattern_ righthandside_ ) = sem_Declaration_PatternBinding ( sem_Range range_ ) ( sem_Pattern pattern_ ) ( sem_RightHandSide righthandside_ )
sem_Declaration ( Declaration_TypeSignature range_ names_ type_ ) = sem_Declaration_TypeSignature ( sem_Range range_ ) ( sem_Names names_ ) ( sem_Type type_ )
sem_Declaration ( Declaration_Fixity range_ fixity_ priority_ operators_ ) = sem_Declaration_Fixity ( sem_Range range_ ) ( sem_Fixity fixity_ ) ( sem_MaybeInt priority_ ) ( sem_Names operators_ )
sem_Declaration ( Declaration_Empty range_ ) = sem_Declaration_Empty ( sem_Range range_ )
-- semantic domain
newtype T_Declaration = T_Declaration {
attach_T_Declaration :: Identity (T_Declaration_s29 )
}
newtype T_Declaration_s29 = C_Declaration_s29 {
inv_Declaration_s29 :: (T_Declaration_v28 )
}
data T_Declaration_s30 = C_Declaration_s30
type T_Declaration_v28 = (T_Declaration_vIn28 ) -> (T_Declaration_vOut28 )
data T_Declaration_vIn28 = T_Declaration_vIn28
data T_Declaration_vOut28 = T_Declaration_vOut28 (Declaration)
{-# NOINLINE sem_Declaration_Hole #-}
sem_Declaration_Hole :: T_Range -> (Integer) -> T_Declaration
sem_Declaration_Hole arg_range_ arg_id_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule40 _rangeIself arg_id_
_lhsOself :: Declaration
_lhsOself = rule41 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule40 #-}
rule40 = \ ((_rangeIself) :: Range) id_ ->
Declaration_Hole _rangeIself id_
{-# INLINE rule41 #-}
rule41 = \ _self ->
_self
{-# NOINLINE sem_Declaration_Type #-}
sem_Declaration_Type :: T_Range -> T_SimpleType -> T_Type -> T_Declaration
sem_Declaration_Type arg_range_ arg_simpletype_ arg_type_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_simpletypeX152 = Control.Monad.Identity.runIdentity (attach_T_SimpleType (arg_simpletype_))
_typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_SimpleType_vOut151 _simpletypeIself) = inv_SimpleType_s152 _simpletypeX152 (T_SimpleType_vIn151 )
(T_Type_vOut163 _typeIself) = inv_Type_s164 _typeX164 (T_Type_vIn163 )
_self = rule42 _rangeIself _simpletypeIself _typeIself
_lhsOself :: Declaration
_lhsOself = rule43 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule42 #-}
rule42 = \ ((_rangeIself) :: Range) ((_simpletypeIself) :: SimpleType) ((_typeIself) :: Type) ->
Declaration_Type _rangeIself _simpletypeIself _typeIself
{-# INLINE rule43 #-}
rule43 = \ _self ->
_self
{-# NOINLINE sem_Declaration_Data #-}
sem_Declaration_Data :: T_Range -> T_ContextItems -> T_SimpleType -> T_Constructors -> T_Names -> T_Declaration
sem_Declaration_Data arg_range_ arg_context_ arg_simpletype_ arg_constructors_ arg_derivings_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_))
_simpletypeX152 = Control.Monad.Identity.runIdentity (attach_T_SimpleType (arg_simpletype_))
_constructorsX20 = Control.Monad.Identity.runIdentity (attach_T_Constructors (arg_constructors_))
_derivingsX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_derivings_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_ContextItems_vOut25 _contextIself) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 )
(T_SimpleType_vOut151 _simpletypeIself) = inv_SimpleType_s152 _simpletypeX152 (T_SimpleType_vIn151 )
(T_Constructors_vOut19 _constructorsIself) = inv_Constructors_s20 _constructorsX20 (T_Constructors_vIn19 )
(T_Names_vOut115 _derivingsInames _derivingsIself) = inv_Names_s116 _derivingsX116 (T_Names_vIn115 )
_self = rule44 _constructorsIself _contextIself _derivingsIself _rangeIself _simpletypeIself
_lhsOself :: Declaration
_lhsOself = rule45 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule44 #-}
rule44 = \ ((_constructorsIself) :: Constructors) ((_contextIself) :: ContextItems) ((_derivingsIself) :: Names) ((_rangeIself) :: Range) ((_simpletypeIself) :: SimpleType) ->
Declaration_Data _rangeIself _contextIself _simpletypeIself _constructorsIself _derivingsIself
{-# INLINE rule45 #-}
rule45 = \ _self ->
_self
{-# NOINLINE sem_Declaration_Newtype #-}
sem_Declaration_Newtype :: T_Range -> T_ContextItems -> T_SimpleType -> T_Constructor -> T_Names -> T_Declaration
sem_Declaration_Newtype arg_range_ arg_context_ arg_simpletype_ arg_constructor_ arg_derivings_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_))
_simpletypeX152 = Control.Monad.Identity.runIdentity (attach_T_SimpleType (arg_simpletype_))
_constructorX17 = Control.Monad.Identity.runIdentity (attach_T_Constructor (arg_constructor_))
_derivingsX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_derivings_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_ContextItems_vOut25 _contextIself) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 )
(T_SimpleType_vOut151 _simpletypeIself) = inv_SimpleType_s152 _simpletypeX152 (T_SimpleType_vIn151 )
(T_Constructor_vOut16 _constructorIself) = inv_Constructor_s17 _constructorX17 (T_Constructor_vIn16 )
(T_Names_vOut115 _derivingsInames _derivingsIself) = inv_Names_s116 _derivingsX116 (T_Names_vIn115 )
_self = rule46 _constructorIself _contextIself _derivingsIself _rangeIself _simpletypeIself
_lhsOself :: Declaration
_lhsOself = rule47 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule46 #-}
rule46 = \ ((_constructorIself) :: Constructor) ((_contextIself) :: ContextItems) ((_derivingsIself) :: Names) ((_rangeIself) :: Range) ((_simpletypeIself) :: SimpleType) ->
Declaration_Newtype _rangeIself _contextIself _simpletypeIself _constructorIself _derivingsIself
{-# INLINE rule47 #-}
rule47 = \ _self ->
_self
{-# NOINLINE sem_Declaration_Class #-}
sem_Declaration_Class :: T_Range -> T_ContextItems -> T_SimpleType -> T_MaybeDeclarations -> T_Declaration
sem_Declaration_Class arg_range_ arg_context_ arg_simpletype_ arg_where_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_))
_simpletypeX152 = Control.Monad.Identity.runIdentity (attach_T_SimpleType (arg_simpletype_))
_whereX89 = Control.Monad.Identity.runIdentity (attach_T_MaybeDeclarations (arg_where_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_ContextItems_vOut25 _contextIself) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 )
(T_SimpleType_vOut151 _simpletypeIself) = inv_SimpleType_s152 _simpletypeX152 (T_SimpleType_vIn151 )
(T_MaybeDeclarations_vOut88 _whereIself) = inv_MaybeDeclarations_s89 _whereX89 (T_MaybeDeclarations_vIn88 )
_self = rule48 _contextIself _rangeIself _simpletypeIself _whereIself
_lhsOself :: Declaration
_lhsOself = rule49 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule48 #-}
rule48 = \ ((_contextIself) :: ContextItems) ((_rangeIself) :: Range) ((_simpletypeIself) :: SimpleType) ((_whereIself) :: MaybeDeclarations) ->
Declaration_Class _rangeIself _contextIself _simpletypeIself _whereIself
{-# INLINE rule49 #-}
rule49 = \ _self ->
_self
{-# NOINLINE sem_Declaration_Instance #-}
sem_Declaration_Instance :: T_Range -> T_ContextItems -> T_Name -> T_Types -> T_MaybeDeclarations -> T_Declaration
sem_Declaration_Instance arg_range_ arg_context_ arg_name_ arg_types_ arg_where_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_typesX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_types_))
_whereX89 = Control.Monad.Identity.runIdentity (attach_T_MaybeDeclarations (arg_where_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_ContextItems_vOut25 _contextIself) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Types_vOut166 _typesIself) = inv_Types_s167 _typesX167 (T_Types_vIn166 )
(T_MaybeDeclarations_vOut88 _whereIself) = inv_MaybeDeclarations_s89 _whereX89 (T_MaybeDeclarations_vIn88 )
_self = rule50 _contextIself _nameIself _rangeIself _typesIself _whereIself
_lhsOself :: Declaration
_lhsOself = rule51 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule50 #-}
rule50 = \ ((_contextIself) :: ContextItems) ((_nameIself) :: Name) ((_rangeIself) :: Range) ((_typesIself) :: Types) ((_whereIself) :: MaybeDeclarations) ->
Declaration_Instance _rangeIself _contextIself _nameIself _typesIself _whereIself
{-# INLINE rule51 #-}
rule51 = \ _self ->
_self
{-# NOINLINE sem_Declaration_Default #-}
sem_Declaration_Default :: T_Range -> T_Types -> T_Declaration
sem_Declaration_Default arg_range_ arg_types_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_typesX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_types_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Types_vOut166 _typesIself) = inv_Types_s167 _typesX167 (T_Types_vIn166 )
_self = rule52 _rangeIself _typesIself
_lhsOself :: Declaration
_lhsOself = rule53 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule52 #-}
rule52 = \ ((_rangeIself) :: Range) ((_typesIself) :: Types) ->
Declaration_Default _rangeIself _typesIself
{-# INLINE rule53 #-}
rule53 = \ _self ->
_self
{-# NOINLINE sem_Declaration_FunctionBindings #-}
sem_Declaration_FunctionBindings :: T_Range -> T_FunctionBindings -> T_Declaration
sem_Declaration_FunctionBindings arg_range_ arg_bindings_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_bindingsX59 = Control.Monad.Identity.runIdentity (attach_T_FunctionBindings (arg_bindings_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_FunctionBindings_vOut58 _bindingsIname _bindingsIself) = inv_FunctionBindings_s59 _bindingsX59 (T_FunctionBindings_vIn58 )
_self = rule54 _bindingsIself _rangeIself
_lhsOself :: Declaration
_lhsOself = rule55 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule54 #-}
rule54 = \ ((_bindingsIself) :: FunctionBindings) ((_rangeIself) :: Range) ->
Declaration_FunctionBindings _rangeIself _bindingsIself
{-# INLINE rule55 #-}
rule55 = \ _self ->
_self
{-# NOINLINE sem_Declaration_PatternBinding #-}
sem_Declaration_PatternBinding :: T_Range -> T_Pattern -> T_RightHandSide -> T_Declaration
sem_Declaration_PatternBinding arg_range_ arg_pattern_ arg_righthandside_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_))
_righthandsideX149 = Control.Monad.Identity.runIdentity (attach_T_RightHandSide (arg_righthandside_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Pattern_vOut118 _patternIself) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 )
(T_RightHandSide_vOut148 _righthandsideIself) = inv_RightHandSide_s149 _righthandsideX149 (T_RightHandSide_vIn148 )
_self = rule56 _patternIself _rangeIself _righthandsideIself
_lhsOself :: Declaration
_lhsOself = rule57 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule56 #-}
rule56 = \ ((_patternIself) :: Pattern) ((_rangeIself) :: Range) ((_righthandsideIself) :: RightHandSide) ->
Declaration_PatternBinding _rangeIself _patternIself _righthandsideIself
{-# INLINE rule57 #-}
rule57 = \ _self ->
_self
{-# NOINLINE sem_Declaration_TypeSignature #-}
sem_Declaration_TypeSignature :: T_Range -> T_Names -> T_Type -> T_Declaration
sem_Declaration_TypeSignature arg_range_ arg_names_ arg_type_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_namesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_names_))
_typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Names_vOut115 _namesInames _namesIself) = inv_Names_s116 _namesX116 (T_Names_vIn115 )
(T_Type_vOut163 _typeIself) = inv_Type_s164 _typeX164 (T_Type_vIn163 )
_self = rule58 _namesIself _rangeIself _typeIself
_lhsOself :: Declaration
_lhsOself = rule59 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule58 #-}
rule58 = \ ((_namesIself) :: Names) ((_rangeIself) :: Range) ((_typeIself) :: Type) ->
Declaration_TypeSignature _rangeIself _namesIself _typeIself
{-# INLINE rule59 #-}
rule59 = \ _self ->
_self
{-# NOINLINE sem_Declaration_Fixity #-}
sem_Declaration_Fixity :: T_Range -> T_Fixity -> T_MaybeInt -> T_Names -> T_Declaration
sem_Declaration_Fixity arg_range_ arg_fixity_ arg_priority_ arg_operators_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_fixityX53 = Control.Monad.Identity.runIdentity (attach_T_Fixity (arg_fixity_))
_priorityX101 = Control.Monad.Identity.runIdentity (attach_T_MaybeInt (arg_priority_))
_operatorsX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_operators_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Fixity_vOut52 _fixityIself) = inv_Fixity_s53 _fixityX53 (T_Fixity_vIn52 )
(T_MaybeInt_vOut100 _priorityIself) = inv_MaybeInt_s101 _priorityX101 (T_MaybeInt_vIn100 )
(T_Names_vOut115 _operatorsInames _operatorsIself) = inv_Names_s116 _operatorsX116 (T_Names_vIn115 )
_self = rule60 _fixityIself _operatorsIself _priorityIself _rangeIself
_lhsOself :: Declaration
_lhsOself = rule61 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule60 #-}
rule60 = \ ((_fixityIself) :: Fixity) ((_operatorsIself) :: Names) ((_priorityIself) :: MaybeInt) ((_rangeIself) :: Range) ->
Declaration_Fixity _rangeIself _fixityIself _priorityIself _operatorsIself
{-# INLINE rule61 #-}
rule61 = \ _self ->
_self
{-# NOINLINE sem_Declaration_Empty #-}
sem_Declaration_Empty :: T_Range -> T_Declaration
sem_Declaration_Empty arg_range_ = T_Declaration (return st29) where
{-# NOINLINE st29 #-}
st29 = let
v28 :: T_Declaration_v28
v28 = \ (T_Declaration_vIn28 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule62 _rangeIself
_lhsOself :: Declaration
_lhsOself = rule63 _self
__result_ = T_Declaration_vOut28 _lhsOself
in __result_ )
in C_Declaration_s29 v28
{-# INLINE rule62 #-}
rule62 = \ ((_rangeIself) :: Range) ->
Declaration_Empty _rangeIself
{-# INLINE rule63 #-}
rule63 = \ _self ->
_self
-- Declarations ------------------------------------------------
-- wrapper
data Inh_Declarations = Inh_Declarations { }
data Syn_Declarations = Syn_Declarations { self_Syn_Declarations :: (Declarations) }
{-# INLINABLE wrap_Declarations #-}
wrap_Declarations :: T_Declarations -> Inh_Declarations -> (Syn_Declarations )
wrap_Declarations (T_Declarations act) (Inh_Declarations ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg31 = T_Declarations_vIn31
(T_Declarations_vOut31 _lhsOself) <- return (inv_Declarations_s32 sem arg31)
return (Syn_Declarations _lhsOself)
)
-- cata
{-# NOINLINE sem_Declarations #-}
sem_Declarations :: Declarations -> T_Declarations
sem_Declarations list = Prelude.foldr sem_Declarations_Cons sem_Declarations_Nil (Prelude.map sem_Declaration list)
-- semantic domain
newtype T_Declarations = T_Declarations {
attach_T_Declarations :: Identity (T_Declarations_s32 )
}
newtype T_Declarations_s32 = C_Declarations_s32 {
inv_Declarations_s32 :: (T_Declarations_v31 )
}
data T_Declarations_s33 = C_Declarations_s33
type T_Declarations_v31 = (T_Declarations_vIn31 ) -> (T_Declarations_vOut31 )
data T_Declarations_vIn31 = T_Declarations_vIn31
data T_Declarations_vOut31 = T_Declarations_vOut31 (Declarations)
{-# NOINLINE sem_Declarations_Cons #-}
sem_Declarations_Cons :: T_Declaration -> T_Declarations -> T_Declarations
sem_Declarations_Cons arg_hd_ arg_tl_ = T_Declarations (return st32) where
{-# NOINLINE st32 #-}
st32 = let
v31 :: T_Declarations_v31
v31 = \ (T_Declarations_vIn31 ) -> ( let
_hdX29 = Control.Monad.Identity.runIdentity (attach_T_Declaration (arg_hd_))
_tlX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_tl_))
(T_Declaration_vOut28 _hdIself) = inv_Declaration_s29 _hdX29 (T_Declaration_vIn28 )
(T_Declarations_vOut31 _tlIself) = inv_Declarations_s32 _tlX32 (T_Declarations_vIn31 )
_self = rule64 _hdIself _tlIself
_lhsOself :: Declarations
_lhsOself = rule65 _self
__result_ = T_Declarations_vOut31 _lhsOself
in __result_ )
in C_Declarations_s32 v31
{-# INLINE rule64 #-}
rule64 = \ ((_hdIself) :: Declaration) ((_tlIself) :: Declarations) ->
(:) _hdIself _tlIself
{-# INLINE rule65 #-}
rule65 = \ _self ->
_self
{-# NOINLINE sem_Declarations_Nil #-}
sem_Declarations_Nil :: T_Declarations
sem_Declarations_Nil = T_Declarations (return st32) where
{-# NOINLINE st32 #-}
st32 = let
v31 :: T_Declarations_v31
v31 = \ (T_Declarations_vIn31 ) -> ( let
_self = rule66 ()
_lhsOself :: Declarations
_lhsOself = rule67 _self
__result_ = T_Declarations_vOut31 _lhsOself
in __result_ )
in C_Declarations_s32 v31
{-# INLINE rule66 #-}
rule66 = \ (_ :: ()) ->
[]
{-# INLINE rule67 #-}
rule67 = \ _self ->
_self
-- Export ------------------------------------------------------
-- wrapper
data Inh_Export = Inh_Export { }
data Syn_Export = Syn_Export { self_Syn_Export :: (Export) }
{-# INLINABLE wrap_Export #-}
wrap_Export :: T_Export -> Inh_Export -> (Syn_Export )
wrap_Export (T_Export act) (Inh_Export ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg34 = T_Export_vIn34
(T_Export_vOut34 _lhsOself) <- return (inv_Export_s35 sem arg34)
return (Syn_Export _lhsOself)
)
-- cata
{-# NOINLINE sem_Export #-}
sem_Export :: Export -> T_Export
sem_Export ( Export_Variable range_ name_ ) = sem_Export_Variable ( sem_Range range_ ) ( sem_Name name_ )
sem_Export ( Export_TypeOrClass range_ name_ names_ ) = sem_Export_TypeOrClass ( sem_Range range_ ) ( sem_Name name_ ) ( sem_MaybeNames names_ )
sem_Export ( Export_TypeOrClassComplete range_ name_ ) = sem_Export_TypeOrClassComplete ( sem_Range range_ ) ( sem_Name name_ )
sem_Export ( Export_Module range_ name_ ) = sem_Export_Module ( sem_Range range_ ) ( sem_Name name_ )
-- semantic domain
newtype T_Export = T_Export {
attach_T_Export :: Identity (T_Export_s35 )
}
newtype T_Export_s35 = C_Export_s35 {
inv_Export_s35 :: (T_Export_v34 )
}
data T_Export_s36 = C_Export_s36
type T_Export_v34 = (T_Export_vIn34 ) -> (T_Export_vOut34 )
data T_Export_vIn34 = T_Export_vIn34
data T_Export_vOut34 = T_Export_vOut34 (Export)
{-# NOINLINE sem_Export_Variable #-}
sem_Export_Variable :: T_Range -> T_Name -> T_Export
sem_Export_Variable arg_range_ arg_name_ = T_Export (return st35) where
{-# NOINLINE st35 #-}
st35 = let
v34 :: T_Export_v34
v34 = \ (T_Export_vIn34 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_self = rule68 _nameIself _rangeIself
_lhsOself :: Export
_lhsOself = rule69 _self
__result_ = T_Export_vOut34 _lhsOself
in __result_ )
in C_Export_s35 v34
{-# INLINE rule68 #-}
rule68 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Export_Variable _rangeIself _nameIself
{-# INLINE rule69 #-}
rule69 = \ _self ->
_self
{-# NOINLINE sem_Export_TypeOrClass #-}
sem_Export_TypeOrClass :: T_Range -> T_Name -> T_MaybeNames -> T_Export
sem_Export_TypeOrClass arg_range_ arg_name_ arg_names_ = T_Export (return st35) where
{-# NOINLINE st35 #-}
st35 = let
v34 :: T_Export_v34
v34 = \ (T_Export_vIn34 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_namesX107 = Control.Monad.Identity.runIdentity (attach_T_MaybeNames (arg_names_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_MaybeNames_vOut106 _namesInames _namesIself) = inv_MaybeNames_s107 _namesX107 (T_MaybeNames_vIn106 )
_self = rule70 _nameIself _namesIself _rangeIself
_lhsOself :: Export
_lhsOself = rule71 _self
__result_ = T_Export_vOut34 _lhsOself
in __result_ )
in C_Export_s35 v34
{-# INLINE rule70 #-}
rule70 = \ ((_nameIself) :: Name) ((_namesIself) :: MaybeNames) ((_rangeIself) :: Range) ->
Export_TypeOrClass _rangeIself _nameIself _namesIself
{-# INLINE rule71 #-}
rule71 = \ _self ->
_self
{-# NOINLINE sem_Export_TypeOrClassComplete #-}
sem_Export_TypeOrClassComplete :: T_Range -> T_Name -> T_Export
sem_Export_TypeOrClassComplete arg_range_ arg_name_ = T_Export (return st35) where
{-# NOINLINE st35 #-}
st35 = let
v34 :: T_Export_v34
v34 = \ (T_Export_vIn34 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_self = rule72 _nameIself _rangeIself
_lhsOself :: Export
_lhsOself = rule73 _self
__result_ = T_Export_vOut34 _lhsOself
in __result_ )
in C_Export_s35 v34
{-# INLINE rule72 #-}
rule72 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Export_TypeOrClassComplete _rangeIself _nameIself
{-# INLINE rule73 #-}
rule73 = \ _self ->
_self
{-# NOINLINE sem_Export_Module #-}
sem_Export_Module :: T_Range -> T_Name -> T_Export
sem_Export_Module arg_range_ arg_name_ = T_Export (return st35) where
{-# NOINLINE st35 #-}
st35 = let
v34 :: T_Export_v34
v34 = \ (T_Export_vIn34 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_self = rule74 _nameIself _rangeIself
_lhsOself :: Export
_lhsOself = rule75 _self
__result_ = T_Export_vOut34 _lhsOself
in __result_ )
in C_Export_s35 v34
{-# INLINE rule74 #-}
rule74 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Export_Module _rangeIself _nameIself
{-# INLINE rule75 #-}
rule75 = \ _self ->
_self
-- Exports -----------------------------------------------------
-- wrapper
data Inh_Exports = Inh_Exports { }
data Syn_Exports = Syn_Exports { self_Syn_Exports :: (Exports) }
{-# INLINABLE wrap_Exports #-}
wrap_Exports :: T_Exports -> Inh_Exports -> (Syn_Exports )
wrap_Exports (T_Exports act) (Inh_Exports ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg37 = T_Exports_vIn37
(T_Exports_vOut37 _lhsOself) <- return (inv_Exports_s38 sem arg37)
return (Syn_Exports _lhsOself)
)
-- cata
{-# NOINLINE sem_Exports #-}
sem_Exports :: Exports -> T_Exports
sem_Exports list = Prelude.foldr sem_Exports_Cons sem_Exports_Nil (Prelude.map sem_Export list)
-- semantic domain
newtype T_Exports = T_Exports {
attach_T_Exports :: Identity (T_Exports_s38 )
}
newtype T_Exports_s38 = C_Exports_s38 {
inv_Exports_s38 :: (T_Exports_v37 )
}
data T_Exports_s39 = C_Exports_s39
type T_Exports_v37 = (T_Exports_vIn37 ) -> (T_Exports_vOut37 )
data T_Exports_vIn37 = T_Exports_vIn37
data T_Exports_vOut37 = T_Exports_vOut37 (Exports)
{-# NOINLINE sem_Exports_Cons #-}
sem_Exports_Cons :: T_Export -> T_Exports -> T_Exports
sem_Exports_Cons arg_hd_ arg_tl_ = T_Exports (return st38) where
{-# NOINLINE st38 #-}
st38 = let
v37 :: T_Exports_v37
v37 = \ (T_Exports_vIn37 ) -> ( let
_hdX35 = Control.Monad.Identity.runIdentity (attach_T_Export (arg_hd_))
_tlX38 = Control.Monad.Identity.runIdentity (attach_T_Exports (arg_tl_))
(T_Export_vOut34 _hdIself) = inv_Export_s35 _hdX35 (T_Export_vIn34 )
(T_Exports_vOut37 _tlIself) = inv_Exports_s38 _tlX38 (T_Exports_vIn37 )
_self = rule76 _hdIself _tlIself
_lhsOself :: Exports
_lhsOself = rule77 _self
__result_ = T_Exports_vOut37 _lhsOself
in __result_ )
in C_Exports_s38 v37
{-# INLINE rule76 #-}
rule76 = \ ((_hdIself) :: Export) ((_tlIself) :: Exports) ->
(:) _hdIself _tlIself
{-# INLINE rule77 #-}
rule77 = \ _self ->
_self
{-# NOINLINE sem_Exports_Nil #-}
sem_Exports_Nil :: T_Exports
sem_Exports_Nil = T_Exports (return st38) where
{-# NOINLINE st38 #-}
st38 = let
v37 :: T_Exports_v37
v37 = \ (T_Exports_vIn37 ) -> ( let
_self = rule78 ()
_lhsOself :: Exports
_lhsOself = rule79 _self
__result_ = T_Exports_vOut37 _lhsOself
in __result_ )
in C_Exports_s38 v37
{-# INLINE rule78 #-}
rule78 = \ (_ :: ()) ->
[]
{-# INLINE rule79 #-}
rule79 = \ _self ->
_self
-- Expression --------------------------------------------------
-- wrapper
data Inh_Expression = Inh_Expression { }
data Syn_Expression = Syn_Expression { self_Syn_Expression :: (Expression) }
{-# INLINABLE wrap_Expression #-}
wrap_Expression :: T_Expression -> Inh_Expression -> (Syn_Expression )
wrap_Expression (T_Expression act) (Inh_Expression ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg40 = T_Expression_vIn40
(T_Expression_vOut40 _lhsOself) <- return (inv_Expression_s41 sem arg40)
return (Syn_Expression _lhsOself)
)
-- cata
{-# NOINLINE sem_Expression #-}
sem_Expression :: Expression -> T_Expression
sem_Expression ( Expression_Hole range_ id_ ) = sem_Expression_Hole ( sem_Range range_ ) id_
sem_Expression ( Expression_Feedback range_ feedback_ expression_ ) = sem_Expression_Feedback ( sem_Range range_ ) feedback_ ( sem_Expression expression_ )
sem_Expression ( Expression_MustUse range_ expression_ ) = sem_Expression_MustUse ( sem_Range range_ ) ( sem_Expression expression_ )
sem_Expression ( Expression_Literal range_ literal_ ) = sem_Expression_Literal ( sem_Range range_ ) ( sem_Literal literal_ )
sem_Expression ( Expression_Variable range_ name_ ) = sem_Expression_Variable ( sem_Range range_ ) ( sem_Name name_ )
sem_Expression ( Expression_Constructor range_ name_ ) = sem_Expression_Constructor ( sem_Range range_ ) ( sem_Name name_ )
sem_Expression ( Expression_Parenthesized range_ expression_ ) = sem_Expression_Parenthesized ( sem_Range range_ ) ( sem_Expression expression_ )
sem_Expression ( Expression_NormalApplication range_ function_ arguments_ ) = sem_Expression_NormalApplication ( sem_Range range_ ) ( sem_Expression function_ ) ( sem_Expressions arguments_ )
sem_Expression ( Expression_InfixApplication range_ leftExpression_ operator_ rightExpression_ ) = sem_Expression_InfixApplication ( sem_Range range_ ) ( sem_MaybeExpression leftExpression_ ) ( sem_Expression operator_ ) ( sem_MaybeExpression rightExpression_ )
sem_Expression ( Expression_If range_ guardExpression_ thenExpression_ elseExpression_ ) = sem_Expression_If ( sem_Range range_ ) ( sem_Expression guardExpression_ ) ( sem_Expression thenExpression_ ) ( sem_Expression elseExpression_ )
sem_Expression ( Expression_Lambda range_ patterns_ expression_ ) = sem_Expression_Lambda ( sem_Range range_ ) ( sem_Patterns patterns_ ) ( sem_Expression expression_ )
sem_Expression ( Expression_Case range_ expression_ alternatives_ ) = sem_Expression_Case ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_Alternatives alternatives_ )
sem_Expression ( Expression_Let range_ declarations_ expression_ ) = sem_Expression_Let ( sem_Range range_ ) ( sem_Declarations declarations_ ) ( sem_Expression expression_ )
sem_Expression ( Expression_Do range_ statements_ ) = sem_Expression_Do ( sem_Range range_ ) ( sem_Statements statements_ )
sem_Expression ( Expression_List range_ expressions_ ) = sem_Expression_List ( sem_Range range_ ) ( sem_Expressions expressions_ )
sem_Expression ( Expression_Tuple range_ expressions_ ) = sem_Expression_Tuple ( sem_Range range_ ) ( sem_Expressions expressions_ )
sem_Expression ( Expression_Comprehension range_ expression_ qualifiers_ ) = sem_Expression_Comprehension ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_Qualifiers qualifiers_ )
sem_Expression ( Expression_Typed range_ expression_ type_ ) = sem_Expression_Typed ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_Type type_ )
sem_Expression ( Expression_RecordConstruction range_ name_ recordExpressionBindings_ ) = sem_Expression_RecordConstruction ( sem_Range range_ ) ( sem_Name name_ ) ( sem_RecordExpressionBindings recordExpressionBindings_ )
sem_Expression ( Expression_RecordUpdate range_ expression_ recordExpressionBindings_ ) = sem_Expression_RecordUpdate ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_RecordExpressionBindings recordExpressionBindings_ )
sem_Expression ( Expression_Enum range_ from_ then_ to_ ) = sem_Expression_Enum ( sem_Range range_ ) ( sem_Expression from_ ) ( sem_MaybeExpression then_ ) ( sem_MaybeExpression to_ )
sem_Expression ( Expression_Negate range_ expression_ ) = sem_Expression_Negate ( sem_Range range_ ) ( sem_Expression expression_ )
sem_Expression ( Expression_NegateFloat range_ expression_ ) = sem_Expression_NegateFloat ( sem_Range range_ ) ( sem_Expression expression_ )
-- semantic domain
newtype T_Expression = T_Expression {
attach_T_Expression :: Identity (T_Expression_s41 )
}
newtype T_Expression_s41 = C_Expression_s41 {
inv_Expression_s41 :: (T_Expression_v40 )
}
data T_Expression_s42 = C_Expression_s42
type T_Expression_v40 = (T_Expression_vIn40 ) -> (T_Expression_vOut40 )
data T_Expression_vIn40 = T_Expression_vIn40
data T_Expression_vOut40 = T_Expression_vOut40 (Expression)
{-# NOINLINE sem_Expression_Hole #-}
sem_Expression_Hole :: T_Range -> (Integer) -> T_Expression
sem_Expression_Hole arg_range_ arg_id_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule80 _rangeIself arg_id_
_lhsOself :: Expression
_lhsOself = rule81 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule80 #-}
rule80 = \ ((_rangeIself) :: Range) id_ ->
Expression_Hole _rangeIself id_
{-# INLINE rule81 #-}
rule81 = \ _self ->
_self
{-# NOINLINE sem_Expression_Feedback #-}
sem_Expression_Feedback :: T_Range -> (String) -> T_Expression -> T_Expression
sem_Expression_Feedback arg_range_ arg_feedback_ arg_expression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule82 _expressionIself _rangeIself arg_feedback_
_lhsOself :: Expression
_lhsOself = rule83 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule82 #-}
rule82 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) feedback_ ->
Expression_Feedback _rangeIself feedback_ _expressionIself
{-# INLINE rule83 #-}
rule83 = \ _self ->
_self
{-# NOINLINE sem_Expression_MustUse #-}
sem_Expression_MustUse :: T_Range -> T_Expression -> T_Expression
sem_Expression_MustUse arg_range_ arg_expression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule84 _expressionIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule85 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule84 #-}
rule84 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ->
Expression_MustUse _rangeIself _expressionIself
{-# INLINE rule85 #-}
rule85 = \ _self ->
_self
{-# NOINLINE sem_Expression_Literal #-}
sem_Expression_Literal :: T_Range -> T_Literal -> T_Expression
sem_Expression_Literal arg_range_ arg_literal_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Literal_vOut85 _literalIself) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 )
_self = rule86 _literalIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule87 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule86 #-}
rule86 = \ ((_literalIself) :: Literal) ((_rangeIself) :: Range) ->
Expression_Literal _rangeIself _literalIself
{-# INLINE rule87 #-}
rule87 = \ _self ->
_self
{-# NOINLINE sem_Expression_Variable #-}
sem_Expression_Variable :: T_Range -> T_Name -> T_Expression
sem_Expression_Variable arg_range_ arg_name_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_self = rule88 _nameIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule89 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule88 #-}
rule88 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Expression_Variable _rangeIself _nameIself
{-# INLINE rule89 #-}
rule89 = \ _self ->
_self
{-# NOINLINE sem_Expression_Constructor #-}
sem_Expression_Constructor :: T_Range -> T_Name -> T_Expression
sem_Expression_Constructor arg_range_ arg_name_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_self = rule90 _nameIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule91 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule90 #-}
rule90 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Expression_Constructor _rangeIself _nameIself
{-# INLINE rule91 #-}
rule91 = \ _self ->
_self
{-# NOINLINE sem_Expression_Parenthesized #-}
sem_Expression_Parenthesized :: T_Range -> T_Expression -> T_Expression
sem_Expression_Parenthesized arg_range_ arg_expression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule92 _expressionIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule93 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule92 #-}
rule92 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ->
Expression_Parenthesized _rangeIself _expressionIself
{-# INLINE rule93 #-}
rule93 = \ _self ->
_self
{-# NOINLINE sem_Expression_NormalApplication #-}
sem_Expression_NormalApplication :: T_Range -> T_Expression -> T_Expressions -> T_Expression
sem_Expression_NormalApplication arg_range_ arg_function_ arg_arguments_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_functionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_function_))
_argumentsX44 = Control.Monad.Identity.runIdentity (attach_T_Expressions (arg_arguments_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _functionIself) = inv_Expression_s41 _functionX41 (T_Expression_vIn40 )
(T_Expressions_vOut43 _argumentsIself) = inv_Expressions_s44 _argumentsX44 (T_Expressions_vIn43 )
_self = rule94 _argumentsIself _functionIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule95 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule94 #-}
rule94 = \ ((_argumentsIself) :: Expressions) ((_functionIself) :: Expression) ((_rangeIself) :: Range) ->
Expression_NormalApplication _rangeIself _functionIself _argumentsIself
{-# INLINE rule95 #-}
rule95 = \ _self ->
_self
{-# NOINLINE sem_Expression_InfixApplication #-}
sem_Expression_InfixApplication :: T_Range -> T_MaybeExpression -> T_Expression -> T_MaybeExpression -> T_Expression
sem_Expression_InfixApplication arg_range_ arg_leftExpression_ arg_operator_ arg_rightExpression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_leftExpressionX95 = Control.Monad.Identity.runIdentity (attach_T_MaybeExpression (arg_leftExpression_))
_operatorX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_operator_))
_rightExpressionX95 = Control.Monad.Identity.runIdentity (attach_T_MaybeExpression (arg_rightExpression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_MaybeExpression_vOut94 _leftExpressionIself) = inv_MaybeExpression_s95 _leftExpressionX95 (T_MaybeExpression_vIn94 )
(T_Expression_vOut40 _operatorIself) = inv_Expression_s41 _operatorX41 (T_Expression_vIn40 )
(T_MaybeExpression_vOut94 _rightExpressionIself) = inv_MaybeExpression_s95 _rightExpressionX95 (T_MaybeExpression_vIn94 )
_self = rule96 _leftExpressionIself _operatorIself _rangeIself _rightExpressionIself
_lhsOself :: Expression
_lhsOself = rule97 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule96 #-}
rule96 = \ ((_leftExpressionIself) :: MaybeExpression) ((_operatorIself) :: Expression) ((_rangeIself) :: Range) ((_rightExpressionIself) :: MaybeExpression) ->
Expression_InfixApplication _rangeIself _leftExpressionIself _operatorIself _rightExpressionIself
{-# INLINE rule97 #-}
rule97 = \ _self ->
_self
{-# NOINLINE sem_Expression_If #-}
sem_Expression_If :: T_Range -> T_Expression -> T_Expression -> T_Expression -> T_Expression
sem_Expression_If arg_range_ arg_guardExpression_ arg_thenExpression_ arg_elseExpression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_guardExpressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_guardExpression_))
_thenExpressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_thenExpression_))
_elseExpressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_elseExpression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _guardExpressionIself) = inv_Expression_s41 _guardExpressionX41 (T_Expression_vIn40 )
(T_Expression_vOut40 _thenExpressionIself) = inv_Expression_s41 _thenExpressionX41 (T_Expression_vIn40 )
(T_Expression_vOut40 _elseExpressionIself) = inv_Expression_s41 _elseExpressionX41 (T_Expression_vIn40 )
_self = rule98 _elseExpressionIself _guardExpressionIself _rangeIself _thenExpressionIself
_lhsOself :: Expression
_lhsOself = rule99 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule98 #-}
rule98 = \ ((_elseExpressionIself) :: Expression) ((_guardExpressionIself) :: Expression) ((_rangeIself) :: Range) ((_thenExpressionIself) :: Expression) ->
Expression_If _rangeIself _guardExpressionIself _thenExpressionIself _elseExpressionIself
{-# INLINE rule99 #-}
rule99 = \ _self ->
_self
{-# NOINLINE sem_Expression_Lambda #-}
sem_Expression_Lambda :: T_Range -> T_Patterns -> T_Expression -> T_Expression
sem_Expression_Lambda arg_range_ arg_patterns_ arg_expression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Patterns_vOut121 _patternsIself) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule100 _expressionIself _patternsIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule101 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule100 #-}
rule100 = \ ((_expressionIself) :: Expression) ((_patternsIself) :: Patterns) ((_rangeIself) :: Range) ->
Expression_Lambda _rangeIself _patternsIself _expressionIself
{-# INLINE rule101 #-}
rule101 = \ _self ->
_self
{-# NOINLINE sem_Expression_Case #-}
sem_Expression_Case :: T_Range -> T_Expression -> T_Alternatives -> T_Expression
sem_Expression_Case arg_range_ arg_expression_ arg_alternatives_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
_alternativesX5 = Control.Monad.Identity.runIdentity (attach_T_Alternatives (arg_alternatives_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
(T_Alternatives_vOut4 _alternativesIself) = inv_Alternatives_s5 _alternativesX5 (T_Alternatives_vIn4 )
_self = rule102 _alternativesIself _expressionIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule103 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule102 #-}
rule102 = \ ((_alternativesIself) :: Alternatives) ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ->
Expression_Case _rangeIself _expressionIself _alternativesIself
{-# INLINE rule103 #-}
rule103 = \ _self ->
_self
{-# NOINLINE sem_Expression_Let #-}
sem_Expression_Let :: T_Range -> T_Declarations -> T_Expression -> T_Expression
sem_Expression_Let arg_range_ arg_declarations_ arg_expression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Declarations_vOut31 _declarationsIself) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule104 _declarationsIself _expressionIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule105 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule104 #-}
rule104 = \ ((_declarationsIself) :: Declarations) ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ->
Expression_Let _rangeIself _declarationsIself _expressionIself
{-# INLINE rule105 #-}
rule105 = \ _self ->
_self
{-# NOINLINE sem_Expression_Do #-}
sem_Expression_Do :: T_Range -> T_Statements -> T_Expression
sem_Expression_Do arg_range_ arg_statements_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_statementsX158 = Control.Monad.Identity.runIdentity (attach_T_Statements (arg_statements_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Statements_vOut157 _statementsIself) = inv_Statements_s158 _statementsX158 (T_Statements_vIn157 )
_self = rule106 _rangeIself _statementsIself
_lhsOself :: Expression
_lhsOself = rule107 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule106 #-}
rule106 = \ ((_rangeIself) :: Range) ((_statementsIself) :: Statements) ->
Expression_Do _rangeIself _statementsIself
{-# INLINE rule107 #-}
rule107 = \ _self ->
_self
{-# NOINLINE sem_Expression_List #-}
sem_Expression_List :: T_Range -> T_Expressions -> T_Expression
sem_Expression_List arg_range_ arg_expressions_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionsX44 = Control.Monad.Identity.runIdentity (attach_T_Expressions (arg_expressions_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expressions_vOut43 _expressionsIself) = inv_Expressions_s44 _expressionsX44 (T_Expressions_vIn43 )
_self = rule108 _expressionsIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule109 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule108 #-}
rule108 = \ ((_expressionsIself) :: Expressions) ((_rangeIself) :: Range) ->
Expression_List _rangeIself _expressionsIself
{-# INLINE rule109 #-}
rule109 = \ _self ->
_self
{-# NOINLINE sem_Expression_Tuple #-}
sem_Expression_Tuple :: T_Range -> T_Expressions -> T_Expression
sem_Expression_Tuple arg_range_ arg_expressions_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionsX44 = Control.Monad.Identity.runIdentity (attach_T_Expressions (arg_expressions_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expressions_vOut43 _expressionsIself) = inv_Expressions_s44 _expressionsX44 (T_Expressions_vIn43 )
_self = rule110 _expressionsIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule111 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule110 #-}
rule110 = \ ((_expressionsIself) :: Expressions) ((_rangeIself) :: Range) ->
Expression_Tuple _rangeIself _expressionsIself
{-# INLINE rule111 #-}
rule111 = \ _self ->
_self
{-# NOINLINE sem_Expression_Comprehension #-}
sem_Expression_Comprehension :: T_Range -> T_Expression -> T_Qualifiers -> T_Expression
sem_Expression_Comprehension arg_range_ arg_expression_ arg_qualifiers_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
_qualifiersX131 = Control.Monad.Identity.runIdentity (attach_T_Qualifiers (arg_qualifiers_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
(T_Qualifiers_vOut130 _qualifiersIself) = inv_Qualifiers_s131 _qualifiersX131 (T_Qualifiers_vIn130 )
_self = rule112 _expressionIself _qualifiersIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule113 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule112 #-}
rule112 = \ ((_expressionIself) :: Expression) ((_qualifiersIself) :: Qualifiers) ((_rangeIself) :: Range) ->
Expression_Comprehension _rangeIself _expressionIself _qualifiersIself
{-# INLINE rule113 #-}
rule113 = \ _self ->
_self
{-# NOINLINE sem_Expression_Typed #-}
sem_Expression_Typed :: T_Range -> T_Expression -> T_Type -> T_Expression
sem_Expression_Typed arg_range_ arg_expression_ arg_type_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
_typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
(T_Type_vOut163 _typeIself) = inv_Type_s164 _typeX164 (T_Type_vIn163 )
_self = rule114 _expressionIself _rangeIself _typeIself
_lhsOself :: Expression
_lhsOself = rule115 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule114 #-}
rule114 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ((_typeIself) :: Type) ->
Expression_Typed _rangeIself _expressionIself _typeIself
{-# INLINE rule115 #-}
rule115 = \ _self ->
_self
{-# NOINLINE sem_Expression_RecordConstruction #-}
sem_Expression_RecordConstruction :: T_Range -> T_Name -> T_RecordExpressionBindings -> T_Expression
sem_Expression_RecordConstruction arg_range_ arg_name_ arg_recordExpressionBindings_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_recordExpressionBindingsX140 = Control.Monad.Identity.runIdentity (attach_T_RecordExpressionBindings (arg_recordExpressionBindings_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_RecordExpressionBindings_vOut139 _recordExpressionBindingsIself) = inv_RecordExpressionBindings_s140 _recordExpressionBindingsX140 (T_RecordExpressionBindings_vIn139 )
_self = rule116 _nameIself _rangeIself _recordExpressionBindingsIself
_lhsOself :: Expression
_lhsOself = rule117 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule116 #-}
rule116 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ((_recordExpressionBindingsIself) :: RecordExpressionBindings) ->
Expression_RecordConstruction _rangeIself _nameIself _recordExpressionBindingsIself
{-# INLINE rule117 #-}
rule117 = \ _self ->
_self
{-# NOINLINE sem_Expression_RecordUpdate #-}
sem_Expression_RecordUpdate :: T_Range -> T_Expression -> T_RecordExpressionBindings -> T_Expression
sem_Expression_RecordUpdate arg_range_ arg_expression_ arg_recordExpressionBindings_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
_recordExpressionBindingsX140 = Control.Monad.Identity.runIdentity (attach_T_RecordExpressionBindings (arg_recordExpressionBindings_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
(T_RecordExpressionBindings_vOut139 _recordExpressionBindingsIself) = inv_RecordExpressionBindings_s140 _recordExpressionBindingsX140 (T_RecordExpressionBindings_vIn139 )
_self = rule118 _expressionIself _rangeIself _recordExpressionBindingsIself
_lhsOself :: Expression
_lhsOself = rule119 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule118 #-}
rule118 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ((_recordExpressionBindingsIself) :: RecordExpressionBindings) ->
Expression_RecordUpdate _rangeIself _expressionIself _recordExpressionBindingsIself
{-# INLINE rule119 #-}
rule119 = \ _self ->
_self
{-# NOINLINE sem_Expression_Enum #-}
sem_Expression_Enum :: T_Range -> T_Expression -> T_MaybeExpression -> T_MaybeExpression -> T_Expression
sem_Expression_Enum arg_range_ arg_from_ arg_then_ arg_to_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_fromX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_from_))
_thenX95 = Control.Monad.Identity.runIdentity (attach_T_MaybeExpression (arg_then_))
_toX95 = Control.Monad.Identity.runIdentity (attach_T_MaybeExpression (arg_to_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _fromIself) = inv_Expression_s41 _fromX41 (T_Expression_vIn40 )
(T_MaybeExpression_vOut94 _thenIself) = inv_MaybeExpression_s95 _thenX95 (T_MaybeExpression_vIn94 )
(T_MaybeExpression_vOut94 _toIself) = inv_MaybeExpression_s95 _toX95 (T_MaybeExpression_vIn94 )
_self = rule120 _fromIself _rangeIself _thenIself _toIself
_lhsOself :: Expression
_lhsOself = rule121 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule120 #-}
rule120 = \ ((_fromIself) :: Expression) ((_rangeIself) :: Range) ((_thenIself) :: MaybeExpression) ((_toIself) :: MaybeExpression) ->
Expression_Enum _rangeIself _fromIself _thenIself _toIself
{-# INLINE rule121 #-}
rule121 = \ _self ->
_self
{-# NOINLINE sem_Expression_Negate #-}
sem_Expression_Negate :: T_Range -> T_Expression -> T_Expression
sem_Expression_Negate arg_range_ arg_expression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule122 _expressionIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule123 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule122 #-}
rule122 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ->
Expression_Negate _rangeIself _expressionIself
{-# INLINE rule123 #-}
rule123 = \ _self ->
_self
{-# NOINLINE sem_Expression_NegateFloat #-}
sem_Expression_NegateFloat :: T_Range -> T_Expression -> T_Expression
sem_Expression_NegateFloat arg_range_ arg_expression_ = T_Expression (return st41) where
{-# NOINLINE st41 #-}
st41 = let
v40 :: T_Expression_v40
v40 = \ (T_Expression_vIn40 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule124 _expressionIself _rangeIself
_lhsOself :: Expression
_lhsOself = rule125 _self
__result_ = T_Expression_vOut40 _lhsOself
in __result_ )
in C_Expression_s41 v40
{-# INLINE rule124 #-}
rule124 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ->
Expression_NegateFloat _rangeIself _expressionIself
{-# INLINE rule125 #-}
rule125 = \ _self ->
_self
-- Expressions -------------------------------------------------
-- wrapper
data Inh_Expressions = Inh_Expressions { }
data Syn_Expressions = Syn_Expressions { self_Syn_Expressions :: (Expressions) }
{-# INLINABLE wrap_Expressions #-}
wrap_Expressions :: T_Expressions -> Inh_Expressions -> (Syn_Expressions )
wrap_Expressions (T_Expressions act) (Inh_Expressions ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg43 = T_Expressions_vIn43
(T_Expressions_vOut43 _lhsOself) <- return (inv_Expressions_s44 sem arg43)
return (Syn_Expressions _lhsOself)
)
-- cata
{-# NOINLINE sem_Expressions #-}
sem_Expressions :: Expressions -> T_Expressions
sem_Expressions list = Prelude.foldr sem_Expressions_Cons sem_Expressions_Nil (Prelude.map sem_Expression list)
-- semantic domain
newtype T_Expressions = T_Expressions {
attach_T_Expressions :: Identity (T_Expressions_s44 )
}
newtype T_Expressions_s44 = C_Expressions_s44 {
inv_Expressions_s44 :: (T_Expressions_v43 )
}
data T_Expressions_s45 = C_Expressions_s45
type T_Expressions_v43 = (T_Expressions_vIn43 ) -> (T_Expressions_vOut43 )
data T_Expressions_vIn43 = T_Expressions_vIn43
data T_Expressions_vOut43 = T_Expressions_vOut43 (Expressions)
{-# NOINLINE sem_Expressions_Cons #-}
sem_Expressions_Cons :: T_Expression -> T_Expressions -> T_Expressions
sem_Expressions_Cons arg_hd_ arg_tl_ = T_Expressions (return st44) where
{-# NOINLINE st44 #-}
st44 = let
v43 :: T_Expressions_v43
v43 = \ (T_Expressions_vIn43 ) -> ( let
_hdX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_hd_))
_tlX44 = Control.Monad.Identity.runIdentity (attach_T_Expressions (arg_tl_))
(T_Expression_vOut40 _hdIself) = inv_Expression_s41 _hdX41 (T_Expression_vIn40 )
(T_Expressions_vOut43 _tlIself) = inv_Expressions_s44 _tlX44 (T_Expressions_vIn43 )
_self = rule126 _hdIself _tlIself
_lhsOself :: Expressions
_lhsOself = rule127 _self
__result_ = T_Expressions_vOut43 _lhsOself
in __result_ )
in C_Expressions_s44 v43
{-# INLINE rule126 #-}
rule126 = \ ((_hdIself) :: Expression) ((_tlIself) :: Expressions) ->
(:) _hdIself _tlIself
{-# INLINE rule127 #-}
rule127 = \ _self ->
_self
{-# NOINLINE sem_Expressions_Nil #-}
sem_Expressions_Nil :: T_Expressions
sem_Expressions_Nil = T_Expressions (return st44) where
{-# NOINLINE st44 #-}
st44 = let
v43 :: T_Expressions_v43
v43 = \ (T_Expressions_vIn43 ) -> ( let
_self = rule128 ()
_lhsOself :: Expressions
_lhsOself = rule129 _self
__result_ = T_Expressions_vOut43 _lhsOself
in __result_ )
in C_Expressions_s44 v43
{-# INLINE rule128 #-}
rule128 = \ (_ :: ()) ->
[]
{-# INLINE rule129 #-}
rule129 = \ _self ->
_self
-- FieldDeclaration --------------------------------------------
-- wrapper
data Inh_FieldDeclaration = Inh_FieldDeclaration { }
data Syn_FieldDeclaration = Syn_FieldDeclaration { self_Syn_FieldDeclaration :: (FieldDeclaration) }
{-# INLINABLE wrap_FieldDeclaration #-}
wrap_FieldDeclaration :: T_FieldDeclaration -> Inh_FieldDeclaration -> (Syn_FieldDeclaration )
wrap_FieldDeclaration (T_FieldDeclaration act) (Inh_FieldDeclaration ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg46 = T_FieldDeclaration_vIn46
(T_FieldDeclaration_vOut46 _lhsOself) <- return (inv_FieldDeclaration_s47 sem arg46)
return (Syn_FieldDeclaration _lhsOself)
)
-- cata
{-# INLINE sem_FieldDeclaration #-}
sem_FieldDeclaration :: FieldDeclaration -> T_FieldDeclaration
sem_FieldDeclaration ( FieldDeclaration_FieldDeclaration range_ names_ type_ ) = sem_FieldDeclaration_FieldDeclaration ( sem_Range range_ ) ( sem_Names names_ ) ( sem_AnnotatedType type_ )
-- semantic domain
newtype T_FieldDeclaration = T_FieldDeclaration {
attach_T_FieldDeclaration :: Identity (T_FieldDeclaration_s47 )
}
newtype T_FieldDeclaration_s47 = C_FieldDeclaration_s47 {
inv_FieldDeclaration_s47 :: (T_FieldDeclaration_v46 )
}
data T_FieldDeclaration_s48 = C_FieldDeclaration_s48
type T_FieldDeclaration_v46 = (T_FieldDeclaration_vIn46 ) -> (T_FieldDeclaration_vOut46 )
data T_FieldDeclaration_vIn46 = T_FieldDeclaration_vIn46
data T_FieldDeclaration_vOut46 = T_FieldDeclaration_vOut46 (FieldDeclaration)
{-# NOINLINE sem_FieldDeclaration_FieldDeclaration #-}
sem_FieldDeclaration_FieldDeclaration :: T_Range -> T_Names -> T_AnnotatedType -> T_FieldDeclaration
sem_FieldDeclaration_FieldDeclaration arg_range_ arg_names_ arg_type_ = T_FieldDeclaration (return st47) where
{-# NOINLINE st47 #-}
st47 = let
v46 :: T_FieldDeclaration_v46
v46 = \ (T_FieldDeclaration_vIn46 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_namesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_names_))
_typeX8 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedType (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Names_vOut115 _namesInames _namesIself) = inv_Names_s116 _namesX116 (T_Names_vIn115 )
(T_AnnotatedType_vOut7 _typeIself) = inv_AnnotatedType_s8 _typeX8 (T_AnnotatedType_vIn7 )
_self = rule130 _namesIself _rangeIself _typeIself
_lhsOself :: FieldDeclaration
_lhsOself = rule131 _self
__result_ = T_FieldDeclaration_vOut46 _lhsOself
in __result_ )
in C_FieldDeclaration_s47 v46
{-# INLINE rule130 #-}
rule130 = \ ((_namesIself) :: Names) ((_rangeIself) :: Range) ((_typeIself) :: AnnotatedType) ->
FieldDeclaration_FieldDeclaration _rangeIself _namesIself _typeIself
{-# INLINE rule131 #-}
rule131 = \ _self ->
_self
-- FieldDeclarations -------------------------------------------
-- wrapper
data Inh_FieldDeclarations = Inh_FieldDeclarations { }
data Syn_FieldDeclarations = Syn_FieldDeclarations { self_Syn_FieldDeclarations :: (FieldDeclarations) }
{-# INLINABLE wrap_FieldDeclarations #-}
wrap_FieldDeclarations :: T_FieldDeclarations -> Inh_FieldDeclarations -> (Syn_FieldDeclarations )
wrap_FieldDeclarations (T_FieldDeclarations act) (Inh_FieldDeclarations ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg49 = T_FieldDeclarations_vIn49
(T_FieldDeclarations_vOut49 _lhsOself) <- return (inv_FieldDeclarations_s50 sem arg49)
return (Syn_FieldDeclarations _lhsOself)
)
-- cata
{-# NOINLINE sem_FieldDeclarations #-}
sem_FieldDeclarations :: FieldDeclarations -> T_FieldDeclarations
sem_FieldDeclarations list = Prelude.foldr sem_FieldDeclarations_Cons sem_FieldDeclarations_Nil (Prelude.map sem_FieldDeclaration list)
-- semantic domain
newtype T_FieldDeclarations = T_FieldDeclarations {
attach_T_FieldDeclarations :: Identity (T_FieldDeclarations_s50 )
}
newtype T_FieldDeclarations_s50 = C_FieldDeclarations_s50 {
inv_FieldDeclarations_s50 :: (T_FieldDeclarations_v49 )
}
data T_FieldDeclarations_s51 = C_FieldDeclarations_s51
type T_FieldDeclarations_v49 = (T_FieldDeclarations_vIn49 ) -> (T_FieldDeclarations_vOut49 )
data T_FieldDeclarations_vIn49 = T_FieldDeclarations_vIn49
data T_FieldDeclarations_vOut49 = T_FieldDeclarations_vOut49 (FieldDeclarations)
{-# NOINLINE sem_FieldDeclarations_Cons #-}
sem_FieldDeclarations_Cons :: T_FieldDeclaration -> T_FieldDeclarations -> T_FieldDeclarations
sem_FieldDeclarations_Cons arg_hd_ arg_tl_ = T_FieldDeclarations (return st50) where
{-# NOINLINE st50 #-}
st50 = let
v49 :: T_FieldDeclarations_v49
v49 = \ (T_FieldDeclarations_vIn49 ) -> ( let
_hdX47 = Control.Monad.Identity.runIdentity (attach_T_FieldDeclaration (arg_hd_))
_tlX50 = Control.Monad.Identity.runIdentity (attach_T_FieldDeclarations (arg_tl_))
(T_FieldDeclaration_vOut46 _hdIself) = inv_FieldDeclaration_s47 _hdX47 (T_FieldDeclaration_vIn46 )
(T_FieldDeclarations_vOut49 _tlIself) = inv_FieldDeclarations_s50 _tlX50 (T_FieldDeclarations_vIn49 )
_self = rule132 _hdIself _tlIself
_lhsOself :: FieldDeclarations
_lhsOself = rule133 _self
__result_ = T_FieldDeclarations_vOut49 _lhsOself
in __result_ )
in C_FieldDeclarations_s50 v49
{-# INLINE rule132 #-}
rule132 = \ ((_hdIself) :: FieldDeclaration) ((_tlIself) :: FieldDeclarations) ->
(:) _hdIself _tlIself
{-# INLINE rule133 #-}
rule133 = \ _self ->
_self
{-# NOINLINE sem_FieldDeclarations_Nil #-}
sem_FieldDeclarations_Nil :: T_FieldDeclarations
sem_FieldDeclarations_Nil = T_FieldDeclarations (return st50) where
{-# NOINLINE st50 #-}
st50 = let
v49 :: T_FieldDeclarations_v49
v49 = \ (T_FieldDeclarations_vIn49 ) -> ( let
_self = rule134 ()
_lhsOself :: FieldDeclarations
_lhsOself = rule135 _self
__result_ = T_FieldDeclarations_vOut49 _lhsOself
in __result_ )
in C_FieldDeclarations_s50 v49
{-# INLINE rule134 #-}
rule134 = \ (_ :: ()) ->
[]
{-# INLINE rule135 #-}
rule135 = \ _self ->
_self
-- Fixity ------------------------------------------------------
-- wrapper
data Inh_Fixity = Inh_Fixity { }
data Syn_Fixity = Syn_Fixity { self_Syn_Fixity :: (Fixity) }
{-# INLINABLE wrap_Fixity #-}
wrap_Fixity :: T_Fixity -> Inh_Fixity -> (Syn_Fixity )
wrap_Fixity (T_Fixity act) (Inh_Fixity ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg52 = T_Fixity_vIn52
(T_Fixity_vOut52 _lhsOself) <- return (inv_Fixity_s53 sem arg52)
return (Syn_Fixity _lhsOself)
)
-- cata
{-# NOINLINE sem_Fixity #-}
sem_Fixity :: Fixity -> T_Fixity
sem_Fixity ( Fixity_Infixl range_ ) = sem_Fixity_Infixl ( sem_Range range_ )
sem_Fixity ( Fixity_Infixr range_ ) = sem_Fixity_Infixr ( sem_Range range_ )
sem_Fixity ( Fixity_Infix range_ ) = sem_Fixity_Infix ( sem_Range range_ )
-- semantic domain
newtype T_Fixity = T_Fixity {
attach_T_Fixity :: Identity (T_Fixity_s53 )
}
newtype T_Fixity_s53 = C_Fixity_s53 {
inv_Fixity_s53 :: (T_Fixity_v52 )
}
data T_Fixity_s54 = C_Fixity_s54
type T_Fixity_v52 = (T_Fixity_vIn52 ) -> (T_Fixity_vOut52 )
data T_Fixity_vIn52 = T_Fixity_vIn52
data T_Fixity_vOut52 = T_Fixity_vOut52 (Fixity)
{-# NOINLINE sem_Fixity_Infixl #-}
sem_Fixity_Infixl :: T_Range -> T_Fixity
sem_Fixity_Infixl arg_range_ = T_Fixity (return st53) where
{-# NOINLINE st53 #-}
st53 = let
v52 :: T_Fixity_v52
v52 = \ (T_Fixity_vIn52 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule136 _rangeIself
_lhsOself :: Fixity
_lhsOself = rule137 _self
__result_ = T_Fixity_vOut52 _lhsOself
in __result_ )
in C_Fixity_s53 v52
{-# INLINE rule136 #-}
rule136 = \ ((_rangeIself) :: Range) ->
Fixity_Infixl _rangeIself
{-# INLINE rule137 #-}
rule137 = \ _self ->
_self
{-# NOINLINE sem_Fixity_Infixr #-}
sem_Fixity_Infixr :: T_Range -> T_Fixity
sem_Fixity_Infixr arg_range_ = T_Fixity (return st53) where
{-# NOINLINE st53 #-}
st53 = let
v52 :: T_Fixity_v52
v52 = \ (T_Fixity_vIn52 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule138 _rangeIself
_lhsOself :: Fixity
_lhsOself = rule139 _self
__result_ = T_Fixity_vOut52 _lhsOself
in __result_ )
in C_Fixity_s53 v52
{-# INLINE rule138 #-}
rule138 = \ ((_rangeIself) :: Range) ->
Fixity_Infixr _rangeIself
{-# INLINE rule139 #-}
rule139 = \ _self ->
_self
{-# NOINLINE sem_Fixity_Infix #-}
sem_Fixity_Infix :: T_Range -> T_Fixity
sem_Fixity_Infix arg_range_ = T_Fixity (return st53) where
{-# NOINLINE st53 #-}
st53 = let
v52 :: T_Fixity_v52
v52 = \ (T_Fixity_vIn52 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule140 _rangeIself
_lhsOself :: Fixity
_lhsOself = rule141 _self
__result_ = T_Fixity_vOut52 _lhsOself
in __result_ )
in C_Fixity_s53 v52
{-# INLINE rule140 #-}
rule140 = \ ((_rangeIself) :: Range) ->
Fixity_Infix _rangeIself
{-# INLINE rule141 #-}
rule141 = \ _self ->
_self
-- FunctionBinding ---------------------------------------------
-- wrapper
data Inh_FunctionBinding = Inh_FunctionBinding { }
data Syn_FunctionBinding = Syn_FunctionBinding { name_Syn_FunctionBinding :: (Name), self_Syn_FunctionBinding :: (FunctionBinding) }
{-# INLINABLE wrap_FunctionBinding #-}
wrap_FunctionBinding :: T_FunctionBinding -> Inh_FunctionBinding -> (Syn_FunctionBinding )
wrap_FunctionBinding (T_FunctionBinding act) (Inh_FunctionBinding ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg55 = T_FunctionBinding_vIn55
(T_FunctionBinding_vOut55 _lhsOname _lhsOself) <- return (inv_FunctionBinding_s56 sem arg55)
return (Syn_FunctionBinding _lhsOname _lhsOself)
)
-- cata
{-# NOINLINE sem_FunctionBinding #-}
sem_FunctionBinding :: FunctionBinding -> T_FunctionBinding
sem_FunctionBinding ( FunctionBinding_Hole range_ id_ ) = sem_FunctionBinding_Hole ( sem_Range range_ ) id_
sem_FunctionBinding ( FunctionBinding_Feedback range_ feedback_ functionBinding_ ) = sem_FunctionBinding_Feedback ( sem_Range range_ ) feedback_ ( sem_FunctionBinding functionBinding_ )
sem_FunctionBinding ( FunctionBinding_FunctionBinding range_ lefthandside_ righthandside_ ) = sem_FunctionBinding_FunctionBinding ( sem_Range range_ ) ( sem_LeftHandSide lefthandside_ ) ( sem_RightHandSide righthandside_ )
-- semantic domain
newtype T_FunctionBinding = T_FunctionBinding {
attach_T_FunctionBinding :: Identity (T_FunctionBinding_s56 )
}
newtype T_FunctionBinding_s56 = C_FunctionBinding_s56 {
inv_FunctionBinding_s56 :: (T_FunctionBinding_v55 )
}
data T_FunctionBinding_s57 = C_FunctionBinding_s57
type T_FunctionBinding_v55 = (T_FunctionBinding_vIn55 ) -> (T_FunctionBinding_vOut55 )
data T_FunctionBinding_vIn55 = T_FunctionBinding_vIn55
data T_FunctionBinding_vOut55 = T_FunctionBinding_vOut55 (Name) (FunctionBinding)
{-# NOINLINE sem_FunctionBinding_Hole #-}
sem_FunctionBinding_Hole :: T_Range -> (Integer) -> T_FunctionBinding
sem_FunctionBinding_Hole arg_range_ arg_id_ = T_FunctionBinding (return st56) where
{-# NOINLINE st56 #-}
st56 = let
v55 :: T_FunctionBinding_v55
v55 = \ (T_FunctionBinding_vIn55 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_lhsOname :: Name
_lhsOname = rule142 ()
_self = rule143 _rangeIself arg_id_
_lhsOself :: FunctionBinding
_lhsOself = rule144 _self
__result_ = T_FunctionBinding_vOut55 _lhsOname _lhsOself
in __result_ )
in C_FunctionBinding_s56 v55
{-# INLINE rule142 #-}
rule142 = \ (_ :: ()) ->
internalError "ToCoreName.ag" "n/a" "hole FunctionBindings"
{-# INLINE rule143 #-}
rule143 = \ ((_rangeIself) :: Range) id_ ->
FunctionBinding_Hole _rangeIself id_
{-# INLINE rule144 #-}
rule144 = \ _self ->
_self
{-# NOINLINE sem_FunctionBinding_Feedback #-}
sem_FunctionBinding_Feedback :: T_Range -> (String) -> T_FunctionBinding -> T_FunctionBinding
sem_FunctionBinding_Feedback arg_range_ arg_feedback_ arg_functionBinding_ = T_FunctionBinding (return st56) where
{-# NOINLINE st56 #-}
st56 = let
v55 :: T_FunctionBinding_v55
v55 = \ (T_FunctionBinding_vIn55 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_functionBindingX56 = Control.Monad.Identity.runIdentity (attach_T_FunctionBinding (arg_functionBinding_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_FunctionBinding_vOut55 _functionBindingIname _functionBindingIself) = inv_FunctionBinding_s56 _functionBindingX56 (T_FunctionBinding_vIn55 )
_self = rule145 _functionBindingIself _rangeIself arg_feedback_
_lhsOself :: FunctionBinding
_lhsOself = rule146 _self
_lhsOname :: Name
_lhsOname = rule147 _functionBindingIname
__result_ = T_FunctionBinding_vOut55 _lhsOname _lhsOself
in __result_ )
in C_FunctionBinding_s56 v55
{-# INLINE rule145 #-}
rule145 = \ ((_functionBindingIself) :: FunctionBinding) ((_rangeIself) :: Range) feedback_ ->
FunctionBinding_Feedback _rangeIself feedback_ _functionBindingIself
{-# INLINE rule146 #-}
rule146 = \ _self ->
_self
{-# INLINE rule147 #-}
rule147 = \ ((_functionBindingIname) :: Name) ->
_functionBindingIname
{-# NOINLINE sem_FunctionBinding_FunctionBinding #-}
sem_FunctionBinding_FunctionBinding :: T_Range -> T_LeftHandSide -> T_RightHandSide -> T_FunctionBinding
sem_FunctionBinding_FunctionBinding arg_range_ arg_lefthandside_ arg_righthandside_ = T_FunctionBinding (return st56) where
{-# NOINLINE st56 #-}
st56 = let
v55 :: T_FunctionBinding_v55
v55 = \ (T_FunctionBinding_vIn55 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_lefthandsideX83 = Control.Monad.Identity.runIdentity (attach_T_LeftHandSide (arg_lefthandside_))
_righthandsideX149 = Control.Monad.Identity.runIdentity (attach_T_RightHandSide (arg_righthandside_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_LeftHandSide_vOut82 _lefthandsideIname _lefthandsideIself) = inv_LeftHandSide_s83 _lefthandsideX83 (T_LeftHandSide_vIn82 )
(T_RightHandSide_vOut148 _righthandsideIself) = inv_RightHandSide_s149 _righthandsideX149 (T_RightHandSide_vIn148 )
_self = rule148 _lefthandsideIself _rangeIself _righthandsideIself
_lhsOself :: FunctionBinding
_lhsOself = rule149 _self
_lhsOname :: Name
_lhsOname = rule150 _lefthandsideIname
__result_ = T_FunctionBinding_vOut55 _lhsOname _lhsOself
in __result_ )
in C_FunctionBinding_s56 v55
{-# INLINE rule148 #-}
rule148 = \ ((_lefthandsideIself) :: LeftHandSide) ((_rangeIself) :: Range) ((_righthandsideIself) :: RightHandSide) ->
FunctionBinding_FunctionBinding _rangeIself _lefthandsideIself _righthandsideIself
{-# INLINE rule149 #-}
rule149 = \ _self ->
_self
{-# INLINE rule150 #-}
rule150 = \ ((_lefthandsideIname) :: Name) ->
_lefthandsideIname
-- FunctionBindings --------------------------------------------
-- wrapper
data Inh_FunctionBindings = Inh_FunctionBindings { }
data Syn_FunctionBindings = Syn_FunctionBindings { name_Syn_FunctionBindings :: (Name), self_Syn_FunctionBindings :: (FunctionBindings) }
{-# INLINABLE wrap_FunctionBindings #-}
wrap_FunctionBindings :: T_FunctionBindings -> Inh_FunctionBindings -> (Syn_FunctionBindings )
wrap_FunctionBindings (T_FunctionBindings act) (Inh_FunctionBindings ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg58 = T_FunctionBindings_vIn58
(T_FunctionBindings_vOut58 _lhsOname _lhsOself) <- return (inv_FunctionBindings_s59 sem arg58)
return (Syn_FunctionBindings _lhsOname _lhsOself)
)
-- cata
{-# NOINLINE sem_FunctionBindings #-}
sem_FunctionBindings :: FunctionBindings -> T_FunctionBindings
sem_FunctionBindings list = Prelude.foldr sem_FunctionBindings_Cons sem_FunctionBindings_Nil (Prelude.map sem_FunctionBinding list)
-- semantic domain
newtype T_FunctionBindings = T_FunctionBindings {
attach_T_FunctionBindings :: Identity (T_FunctionBindings_s59 )
}
newtype T_FunctionBindings_s59 = C_FunctionBindings_s59 {
inv_FunctionBindings_s59 :: (T_FunctionBindings_v58 )
}
data T_FunctionBindings_s60 = C_FunctionBindings_s60
type T_FunctionBindings_v58 = (T_FunctionBindings_vIn58 ) -> (T_FunctionBindings_vOut58 )
data T_FunctionBindings_vIn58 = T_FunctionBindings_vIn58
data T_FunctionBindings_vOut58 = T_FunctionBindings_vOut58 (Name) (FunctionBindings)
{-# NOINLINE sem_FunctionBindings_Cons #-}
sem_FunctionBindings_Cons :: T_FunctionBinding -> T_FunctionBindings -> T_FunctionBindings
sem_FunctionBindings_Cons arg_hd_ arg_tl_ = T_FunctionBindings (return st59) where
{-# NOINLINE st59 #-}
st59 = let
v58 :: T_FunctionBindings_v58
v58 = \ (T_FunctionBindings_vIn58 ) -> ( let
_hdX56 = Control.Monad.Identity.runIdentity (attach_T_FunctionBinding (arg_hd_))
_tlX59 = Control.Monad.Identity.runIdentity (attach_T_FunctionBindings (arg_tl_))
(T_FunctionBinding_vOut55 _hdIname _hdIself) = inv_FunctionBinding_s56 _hdX56 (T_FunctionBinding_vIn55 )
(T_FunctionBindings_vOut58 _tlIname _tlIself) = inv_FunctionBindings_s59 _tlX59 (T_FunctionBindings_vIn58 )
_lhsOname :: Name
_lhsOname = rule151 _hdIname
_self = rule152 _hdIself _tlIself
_lhsOself :: FunctionBindings
_lhsOself = rule153 _self
__result_ = T_FunctionBindings_vOut58 _lhsOname _lhsOself
in __result_ )
in C_FunctionBindings_s59 v58
{-# INLINE rule151 #-}
rule151 = \ ((_hdIname) :: Name) ->
_hdIname
{-# INLINE rule152 #-}
rule152 = \ ((_hdIself) :: FunctionBinding) ((_tlIself) :: FunctionBindings) ->
(:) _hdIself _tlIself
{-# INLINE rule153 #-}
rule153 = \ _self ->
_self
{-# NOINLINE sem_FunctionBindings_Nil #-}
sem_FunctionBindings_Nil :: T_FunctionBindings
sem_FunctionBindings_Nil = T_FunctionBindings (return st59) where
{-# NOINLINE st59 #-}
st59 = let
v58 :: T_FunctionBindings_v58
v58 = \ (T_FunctionBindings_vIn58 ) -> ( let
_lhsOname :: Name
_lhsOname = rule154 ()
_self = rule155 ()
_lhsOself :: FunctionBindings
_lhsOself = rule156 _self
__result_ = T_FunctionBindings_vOut58 _lhsOname _lhsOself
in __result_ )
in C_FunctionBindings_s59 v58
{-# INLINE rule154 #-}
rule154 = \ (_ :: ()) ->
internalError "ToCoreName.ag" "n/a" "empty FunctionBindings"
{-# INLINE rule155 #-}
rule155 = \ (_ :: ()) ->
[]
{-# INLINE rule156 #-}
rule156 = \ _self ->
_self
-- GuardedExpression -------------------------------------------
-- wrapper
data Inh_GuardedExpression = Inh_GuardedExpression { }
data Syn_GuardedExpression = Syn_GuardedExpression { self_Syn_GuardedExpression :: (GuardedExpression) }
{-# INLINABLE wrap_GuardedExpression #-}
wrap_GuardedExpression :: T_GuardedExpression -> Inh_GuardedExpression -> (Syn_GuardedExpression )
wrap_GuardedExpression (T_GuardedExpression act) (Inh_GuardedExpression ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg61 = T_GuardedExpression_vIn61
(T_GuardedExpression_vOut61 _lhsOself) <- return (inv_GuardedExpression_s62 sem arg61)
return (Syn_GuardedExpression _lhsOself)
)
-- cata
{-# NOINLINE sem_GuardedExpression #-}
sem_GuardedExpression :: GuardedExpression -> T_GuardedExpression
sem_GuardedExpression ( GuardedExpression_GuardedExpression range_ guard_ expression_ ) = sem_GuardedExpression_GuardedExpression ( sem_Range range_ ) ( sem_Expression guard_ ) ( sem_Expression expression_ )
-- semantic domain
newtype T_GuardedExpression = T_GuardedExpression {
attach_T_GuardedExpression :: Identity (T_GuardedExpression_s62 )
}
newtype T_GuardedExpression_s62 = C_GuardedExpression_s62 {
inv_GuardedExpression_s62 :: (T_GuardedExpression_v61 )
}
data T_GuardedExpression_s63 = C_GuardedExpression_s63
type T_GuardedExpression_v61 = (T_GuardedExpression_vIn61 ) -> (T_GuardedExpression_vOut61 )
data T_GuardedExpression_vIn61 = T_GuardedExpression_vIn61
data T_GuardedExpression_vOut61 = T_GuardedExpression_vOut61 (GuardedExpression)
{-# NOINLINE sem_GuardedExpression_GuardedExpression #-}
sem_GuardedExpression_GuardedExpression :: T_Range -> T_Expression -> T_Expression -> T_GuardedExpression
sem_GuardedExpression_GuardedExpression arg_range_ arg_guard_ arg_expression_ = T_GuardedExpression (return st62) where
{-# NOINLINE st62 #-}
st62 = let
v61 :: T_GuardedExpression_v61
v61 = \ (T_GuardedExpression_vIn61 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_guardX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_guard_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _guardIself) = inv_Expression_s41 _guardX41 (T_Expression_vIn40 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule157 _expressionIself _guardIself _rangeIself
_lhsOself :: GuardedExpression
_lhsOself = rule158 _self
__result_ = T_GuardedExpression_vOut61 _lhsOself
in __result_ )
in C_GuardedExpression_s62 v61
{-# INLINE rule157 #-}
rule157 = \ ((_expressionIself) :: Expression) ((_guardIself) :: Expression) ((_rangeIself) :: Range) ->
GuardedExpression_GuardedExpression _rangeIself _guardIself _expressionIself
{-# INLINE rule158 #-}
rule158 = \ _self ->
_self
-- GuardedExpressions ------------------------------------------
-- wrapper
data Inh_GuardedExpressions = Inh_GuardedExpressions { }
data Syn_GuardedExpressions = Syn_GuardedExpressions { self_Syn_GuardedExpressions :: (GuardedExpressions) }
{-# INLINABLE wrap_GuardedExpressions #-}
wrap_GuardedExpressions :: T_GuardedExpressions -> Inh_GuardedExpressions -> (Syn_GuardedExpressions )
wrap_GuardedExpressions (T_GuardedExpressions act) (Inh_GuardedExpressions ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg64 = T_GuardedExpressions_vIn64
(T_GuardedExpressions_vOut64 _lhsOself) <- return (inv_GuardedExpressions_s65 sem arg64)
return (Syn_GuardedExpressions _lhsOself)
)
-- cata
{-# NOINLINE sem_GuardedExpressions #-}
sem_GuardedExpressions :: GuardedExpressions -> T_GuardedExpressions
sem_GuardedExpressions list = Prelude.foldr sem_GuardedExpressions_Cons sem_GuardedExpressions_Nil (Prelude.map sem_GuardedExpression list)
-- semantic domain
newtype T_GuardedExpressions = T_GuardedExpressions {
attach_T_GuardedExpressions :: Identity (T_GuardedExpressions_s65 )
}
newtype T_GuardedExpressions_s65 = C_GuardedExpressions_s65 {
inv_GuardedExpressions_s65 :: (T_GuardedExpressions_v64 )
}
data T_GuardedExpressions_s66 = C_GuardedExpressions_s66
type T_GuardedExpressions_v64 = (T_GuardedExpressions_vIn64 ) -> (T_GuardedExpressions_vOut64 )
data T_GuardedExpressions_vIn64 = T_GuardedExpressions_vIn64
data T_GuardedExpressions_vOut64 = T_GuardedExpressions_vOut64 (GuardedExpressions)
{-# NOINLINE sem_GuardedExpressions_Cons #-}
sem_GuardedExpressions_Cons :: T_GuardedExpression -> T_GuardedExpressions -> T_GuardedExpressions
sem_GuardedExpressions_Cons arg_hd_ arg_tl_ = T_GuardedExpressions (return st65) where
{-# NOINLINE st65 #-}
st65 = let
v64 :: T_GuardedExpressions_v64
v64 = \ (T_GuardedExpressions_vIn64 ) -> ( let
_hdX62 = Control.Monad.Identity.runIdentity (attach_T_GuardedExpression (arg_hd_))
_tlX65 = Control.Monad.Identity.runIdentity (attach_T_GuardedExpressions (arg_tl_))
(T_GuardedExpression_vOut61 _hdIself) = inv_GuardedExpression_s62 _hdX62 (T_GuardedExpression_vIn61 )
(T_GuardedExpressions_vOut64 _tlIself) = inv_GuardedExpressions_s65 _tlX65 (T_GuardedExpressions_vIn64 )
_self = rule159 _hdIself _tlIself
_lhsOself :: GuardedExpressions
_lhsOself = rule160 _self
__result_ = T_GuardedExpressions_vOut64 _lhsOself
in __result_ )
in C_GuardedExpressions_s65 v64
{-# INLINE rule159 #-}
rule159 = \ ((_hdIself) :: GuardedExpression) ((_tlIself) :: GuardedExpressions) ->
(:) _hdIself _tlIself
{-# INLINE rule160 #-}
rule160 = \ _self ->
_self
{-# NOINLINE sem_GuardedExpressions_Nil #-}
sem_GuardedExpressions_Nil :: T_GuardedExpressions
sem_GuardedExpressions_Nil = T_GuardedExpressions (return st65) where
{-# NOINLINE st65 #-}
st65 = let
v64 :: T_GuardedExpressions_v64
v64 = \ (T_GuardedExpressions_vIn64 ) -> ( let
_self = rule161 ()
_lhsOself :: GuardedExpressions
_lhsOself = rule162 _self
__result_ = T_GuardedExpressions_vOut64 _lhsOself
in __result_ )
in C_GuardedExpressions_s65 v64
{-# INLINE rule161 #-}
rule161 = \ (_ :: ()) ->
[]
{-# INLINE rule162 #-}
rule162 = \ _self ->
_self
-- Import ------------------------------------------------------
-- wrapper
data Inh_Import = Inh_Import { }
data Syn_Import = Syn_Import { imps_Syn_Import :: ([Id]), self_Syn_Import :: (Import) }
{-# INLINABLE wrap_Import #-}
wrap_Import :: T_Import -> Inh_Import -> (Syn_Import )
wrap_Import (T_Import act) (Inh_Import ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg67 = T_Import_vIn67
(T_Import_vOut67 _lhsOimps _lhsOself) <- return (inv_Import_s68 sem arg67)
return (Syn_Import _lhsOimps _lhsOself)
)
-- cata
{-# NOINLINE sem_Import #-}
sem_Import :: Import -> T_Import
sem_Import ( Import_Variable range_ name_ ) = sem_Import_Variable ( sem_Range range_ ) ( sem_Name name_ )
sem_Import ( Import_TypeOrClass range_ name_ names_ ) = sem_Import_TypeOrClass ( sem_Range range_ ) ( sem_Name name_ ) ( sem_MaybeNames names_ )
sem_Import ( Import_TypeOrClassComplete range_ name_ ) = sem_Import_TypeOrClassComplete ( sem_Range range_ ) ( sem_Name name_ )
-- semantic domain
newtype T_Import = T_Import {
attach_T_Import :: Identity (T_Import_s68 )
}
newtype T_Import_s68 = C_Import_s68 {
inv_Import_s68 :: (T_Import_v67 )
}
data T_Import_s69 = C_Import_s69
type T_Import_v67 = (T_Import_vIn67 ) -> (T_Import_vOut67 )
data T_Import_vIn67 = T_Import_vIn67
data T_Import_vOut67 = T_Import_vOut67 ([Id]) (Import)
{-# NOINLINE sem_Import_Variable #-}
sem_Import_Variable :: T_Range -> T_Name -> T_Import
sem_Import_Variable arg_range_ arg_name_ = T_Import (return st68) where
{-# NOINLINE st68 #-}
st68 = let
v67 :: T_Import_v67
v67 = \ (T_Import_vIn67 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_lhsOimps :: [Id]
_lhsOimps = rule163 _nameIself
_self = rule164 _nameIself _rangeIself
_lhsOself :: Import
_lhsOself = rule165 _self
__result_ = T_Import_vOut67 _lhsOimps _lhsOself
in __result_ )
in C_Import_s68 v67
{-# INLINE rule163 #-}
rule163 = \ ((_nameIself) :: Name) ->
[idFromName _nameIself]
{-# INLINE rule164 #-}
rule164 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Import_Variable _rangeIself _nameIself
{-# INLINE rule165 #-}
rule165 = \ _self ->
_self
{-# NOINLINE sem_Import_TypeOrClass #-}
sem_Import_TypeOrClass :: T_Range -> T_Name -> T_MaybeNames -> T_Import
sem_Import_TypeOrClass arg_range_ arg_name_ arg_names_ = T_Import (return st68) where
{-# NOINLINE st68 #-}
st68 = let
v67 :: T_Import_v67
v67 = \ (T_Import_vIn67 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_namesX107 = Control.Monad.Identity.runIdentity (attach_T_MaybeNames (arg_names_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_MaybeNames_vOut106 _namesInames _namesIself) = inv_MaybeNames_s107 _namesX107 (T_MaybeNames_vIn106 )
_lhsOimps :: [Id]
_lhsOimps = rule166 ()
_self = rule167 _nameIself _namesIself _rangeIself
_lhsOself :: Import
_lhsOself = rule168 _self
__result_ = T_Import_vOut67 _lhsOimps _lhsOself
in __result_ )
in C_Import_s68 v67
{-# INLINE rule166 #-}
rule166 = \ (_ :: ()) ->
internalError "ExtractImportDecls.ag" "ImportSpecification.Import" "only variables can be hidden"
{-# INLINE rule167 #-}
rule167 = \ ((_nameIself) :: Name) ((_namesIself) :: MaybeNames) ((_rangeIself) :: Range) ->
Import_TypeOrClass _rangeIself _nameIself _namesIself
{-# INLINE rule168 #-}
rule168 = \ _self ->
_self
{-# NOINLINE sem_Import_TypeOrClassComplete #-}
sem_Import_TypeOrClassComplete :: T_Range -> T_Name -> T_Import
sem_Import_TypeOrClassComplete arg_range_ arg_name_ = T_Import (return st68) where
{-# NOINLINE st68 #-}
st68 = let
v67 :: T_Import_v67
v67 = \ (T_Import_vIn67 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_lhsOimps :: [Id]
_lhsOimps = rule169 ()
_self = rule170 _nameIself _rangeIself
_lhsOself :: Import
_lhsOself = rule171 _self
__result_ = T_Import_vOut67 _lhsOimps _lhsOself
in __result_ )
in C_Import_s68 v67
{-# INLINE rule169 #-}
rule169 = \ (_ :: ()) ->
internalError "ExtractImportDecls.ag" "ImportSpecification.Import" "only variables can be hidden"
{-# INLINE rule170 #-}
rule170 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Import_TypeOrClassComplete _rangeIself _nameIself
{-# INLINE rule171 #-}
rule171 = \ _self ->
_self
-- ImportDeclaration -------------------------------------------
-- wrapper
data Inh_ImportDeclaration = Inh_ImportDeclaration { }
data Syn_ImportDeclaration = Syn_ImportDeclaration { coreImportDecls_Syn_ImportDeclaration :: ( [(Core.CoreDecl,[Id])] ), self_Syn_ImportDeclaration :: (ImportDeclaration) }
{-# INLINABLE wrap_ImportDeclaration #-}
wrap_ImportDeclaration :: T_ImportDeclaration -> Inh_ImportDeclaration -> (Syn_ImportDeclaration )
wrap_ImportDeclaration (T_ImportDeclaration act) (Inh_ImportDeclaration ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg70 = T_ImportDeclaration_vIn70
(T_ImportDeclaration_vOut70 _lhsOcoreImportDecls _lhsOself) <- return (inv_ImportDeclaration_s71 sem arg70)
return (Syn_ImportDeclaration _lhsOcoreImportDecls _lhsOself)
)
-- cata
{-# NOINLINE sem_ImportDeclaration #-}
sem_ImportDeclaration :: ImportDeclaration -> T_ImportDeclaration
sem_ImportDeclaration ( ImportDeclaration_Import range_ qualified_ name_ asname_ importspecification_ ) = sem_ImportDeclaration_Import ( sem_Range range_ ) qualified_ ( sem_Name name_ ) ( sem_MaybeName asname_ ) ( sem_MaybeImportSpecification importspecification_ )
sem_ImportDeclaration ( ImportDeclaration_Empty range_ ) = sem_ImportDeclaration_Empty ( sem_Range range_ )
-- semantic domain
newtype T_ImportDeclaration = T_ImportDeclaration {
attach_T_ImportDeclaration :: Identity (T_ImportDeclaration_s71 )
}
newtype T_ImportDeclaration_s71 = C_ImportDeclaration_s71 {
inv_ImportDeclaration_s71 :: (T_ImportDeclaration_v70 )
}
data T_ImportDeclaration_s72 = C_ImportDeclaration_s72
type T_ImportDeclaration_v70 = (T_ImportDeclaration_vIn70 ) -> (T_ImportDeclaration_vOut70 )
data T_ImportDeclaration_vIn70 = T_ImportDeclaration_vIn70
data T_ImportDeclaration_vOut70 = T_ImportDeclaration_vOut70 ( [(Core.CoreDecl,[Id])] ) (ImportDeclaration)
{-# NOINLINE sem_ImportDeclaration_Import #-}
sem_ImportDeclaration_Import :: T_Range -> (Bool) -> T_Name -> T_MaybeName -> T_MaybeImportSpecification -> T_ImportDeclaration
sem_ImportDeclaration_Import arg_range_ arg_qualified_ arg_name_ arg_asname_ arg_importspecification_ = T_ImportDeclaration (return st71) where
{-# NOINLINE st71 #-}
st71 = let
v70 :: T_ImportDeclaration_v70
v70 = \ (T_ImportDeclaration_vIn70 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_asnameX104 = Control.Monad.Identity.runIdentity (attach_T_MaybeName (arg_asname_))
_importspecificationX98 = Control.Monad.Identity.runIdentity (attach_T_MaybeImportSpecification (arg_importspecification_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_MaybeName_vOut103 _asnameIisNothing _asnameIname _asnameIself) = inv_MaybeName_s104 _asnameX104 (T_MaybeName_vIn103 )
(T_MaybeImportSpecification_vOut97 _importspecificationIimps _importspecificationIself) = inv_MaybeImportSpecification_s98 _importspecificationX98 (T_MaybeImportSpecification_vIn97 )
_lhsOcoreImportDecls :: [(Core.CoreDecl,[Id])]
_lhsOcoreImportDecls = rule172 _hidings _importDecls
_importDecls = rule173 _asnameIisNothing _nameIself arg_qualified_
_hidings = rule174 _importspecificationIimps
_self = rule175 _asnameIself _importspecificationIself _nameIself _rangeIself arg_qualified_
_lhsOself :: ImportDeclaration
_lhsOself = rule176 _self
__result_ = T_ImportDeclaration_vOut70 _lhsOcoreImportDecls _lhsOself
in __result_ )
in C_ImportDeclaration_s71 v70
{-# INLINE rule172 #-}
rule172 = \ _hidings _importDecls ->
[(_importDecls ,_hidings )]
{-# INLINE rule173 #-}
rule173 = \ ((_asnameIisNothing) :: Bool) ((_nameIself) :: Name) qualified_ ->
if qualified_ || not _asnameIisNothing then
internalError "ExtractImportDecls.ag" "ImportDeclaration.Import" "qualified and as-imports not supported yet"
else
Core.DeclImport
{ Core.declName = idFromName _nameIself
, Core.declAccess =
Core.Imported
{ Core.accessPublic = False
, Core.importModule = idFromName _nameIself
, Core.importName = dummyId
, Core.importKind = Core.DeclKindModule
, Core.importMajorVer = 0
, Core.importMinorVer = 0
}
, Core.declCustoms = []
}
{-# INLINE rule174 #-}
rule174 = \ ((_importspecificationIimps) :: [Id]) ->
_importspecificationIimps
{-# INLINE rule175 #-}
rule175 = \ ((_asnameIself) :: MaybeName) ((_importspecificationIself) :: MaybeImportSpecification) ((_nameIself) :: Name) ((_rangeIself) :: Range) qualified_ ->
ImportDeclaration_Import _rangeIself qualified_ _nameIself _asnameIself _importspecificationIself
{-# INLINE rule176 #-}
rule176 = \ _self ->
_self
{-# NOINLINE sem_ImportDeclaration_Empty #-}
sem_ImportDeclaration_Empty :: T_Range -> T_ImportDeclaration
sem_ImportDeclaration_Empty arg_range_ = T_ImportDeclaration (return st71) where
{-# NOINLINE st71 #-}
st71 = let
v70 :: T_ImportDeclaration_v70
v70 = \ (T_ImportDeclaration_vIn70 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_lhsOcoreImportDecls :: [(Core.CoreDecl,[Id])]
_lhsOcoreImportDecls = rule177 ()
_self = rule178 _rangeIself
_lhsOself :: ImportDeclaration
_lhsOself = rule179 _self
__result_ = T_ImportDeclaration_vOut70 _lhsOcoreImportDecls _lhsOself
in __result_ )
in C_ImportDeclaration_s71 v70
{-# INLINE rule177 #-}
rule177 = \ (_ :: ()) ->
[]
{-# INLINE rule178 #-}
rule178 = \ ((_rangeIself) :: Range) ->
ImportDeclaration_Empty _rangeIself
{-# INLINE rule179 #-}
rule179 = \ _self ->
_self
-- ImportDeclarations ------------------------------------------
-- wrapper
data Inh_ImportDeclarations = Inh_ImportDeclarations { }
data Syn_ImportDeclarations = Syn_ImportDeclarations { coreImportDecls_Syn_ImportDeclarations :: ( [(Core.CoreDecl,[Id])] ), self_Syn_ImportDeclarations :: (ImportDeclarations) }
{-# INLINABLE wrap_ImportDeclarations #-}
wrap_ImportDeclarations :: T_ImportDeclarations -> Inh_ImportDeclarations -> (Syn_ImportDeclarations )
wrap_ImportDeclarations (T_ImportDeclarations act) (Inh_ImportDeclarations ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg73 = T_ImportDeclarations_vIn73
(T_ImportDeclarations_vOut73 _lhsOcoreImportDecls _lhsOself) <- return (inv_ImportDeclarations_s74 sem arg73)
return (Syn_ImportDeclarations _lhsOcoreImportDecls _lhsOself)
)
-- cata
{-# NOINLINE sem_ImportDeclarations #-}
sem_ImportDeclarations :: ImportDeclarations -> T_ImportDeclarations
sem_ImportDeclarations list = Prelude.foldr sem_ImportDeclarations_Cons sem_ImportDeclarations_Nil (Prelude.map sem_ImportDeclaration list)
-- semantic domain
newtype T_ImportDeclarations = T_ImportDeclarations {
attach_T_ImportDeclarations :: Identity (T_ImportDeclarations_s74 )
}
newtype T_ImportDeclarations_s74 = C_ImportDeclarations_s74 {
inv_ImportDeclarations_s74 :: (T_ImportDeclarations_v73 )
}
data T_ImportDeclarations_s75 = C_ImportDeclarations_s75
type T_ImportDeclarations_v73 = (T_ImportDeclarations_vIn73 ) -> (T_ImportDeclarations_vOut73 )
data T_ImportDeclarations_vIn73 = T_ImportDeclarations_vIn73
data T_ImportDeclarations_vOut73 = T_ImportDeclarations_vOut73 ( [(Core.CoreDecl,[Id])] ) (ImportDeclarations)
{-# NOINLINE sem_ImportDeclarations_Cons #-}
sem_ImportDeclarations_Cons :: T_ImportDeclaration -> T_ImportDeclarations -> T_ImportDeclarations
sem_ImportDeclarations_Cons arg_hd_ arg_tl_ = T_ImportDeclarations (return st74) where
{-# NOINLINE st74 #-}
st74 = let
v73 :: T_ImportDeclarations_v73
v73 = \ (T_ImportDeclarations_vIn73 ) -> ( let
_hdX71 = Control.Monad.Identity.runIdentity (attach_T_ImportDeclaration (arg_hd_))
_tlX74 = Control.Monad.Identity.runIdentity (attach_T_ImportDeclarations (arg_tl_))
(T_ImportDeclaration_vOut70 _hdIcoreImportDecls _hdIself) = inv_ImportDeclaration_s71 _hdX71 (T_ImportDeclaration_vIn70 )
(T_ImportDeclarations_vOut73 _tlIcoreImportDecls _tlIself) = inv_ImportDeclarations_s74 _tlX74 (T_ImportDeclarations_vIn73 )
_lhsOcoreImportDecls :: [(Core.CoreDecl,[Id])]
_lhsOcoreImportDecls = rule180 _hdIcoreImportDecls _tlIcoreImportDecls
_self = rule181 _hdIself _tlIself
_lhsOself :: ImportDeclarations
_lhsOself = rule182 _self
__result_ = T_ImportDeclarations_vOut73 _lhsOcoreImportDecls _lhsOself
in __result_ )
in C_ImportDeclarations_s74 v73
{-# INLINE rule180 #-}
rule180 = \ ((_hdIcoreImportDecls) :: [(Core.CoreDecl,[Id])] ) ((_tlIcoreImportDecls) :: [(Core.CoreDecl,[Id])] ) ->
_hdIcoreImportDecls ++ _tlIcoreImportDecls
{-# INLINE rule181 #-}
rule181 = \ ((_hdIself) :: ImportDeclaration) ((_tlIself) :: ImportDeclarations) ->
(:) _hdIself _tlIself
{-# INLINE rule182 #-}
rule182 = \ _self ->
_self
{-# NOINLINE sem_ImportDeclarations_Nil #-}
sem_ImportDeclarations_Nil :: T_ImportDeclarations
sem_ImportDeclarations_Nil = T_ImportDeclarations (return st74) where
{-# NOINLINE st74 #-}
st74 = let
v73 :: T_ImportDeclarations_v73
v73 = \ (T_ImportDeclarations_vIn73 ) -> ( let
_lhsOcoreImportDecls :: [(Core.CoreDecl,[Id])]
_lhsOcoreImportDecls = rule183 ()
_self = rule184 ()
_lhsOself :: ImportDeclarations
_lhsOself = rule185 _self
__result_ = T_ImportDeclarations_vOut73 _lhsOcoreImportDecls _lhsOself
in __result_ )
in C_ImportDeclarations_s74 v73
{-# INLINE rule183 #-}
rule183 = \ (_ :: ()) ->
[]
{-# INLINE rule184 #-}
rule184 = \ (_ :: ()) ->
[]
{-# INLINE rule185 #-}
rule185 = \ _self ->
_self
-- ImportSpecification -----------------------------------------
-- wrapper
data Inh_ImportSpecification = Inh_ImportSpecification { }
data Syn_ImportSpecification = Syn_ImportSpecification { imps_Syn_ImportSpecification :: ([Id]), self_Syn_ImportSpecification :: (ImportSpecification) }
{-# INLINABLE wrap_ImportSpecification #-}
wrap_ImportSpecification :: T_ImportSpecification -> Inh_ImportSpecification -> (Syn_ImportSpecification )
wrap_ImportSpecification (T_ImportSpecification act) (Inh_ImportSpecification ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg76 = T_ImportSpecification_vIn76
(T_ImportSpecification_vOut76 _lhsOimps _lhsOself) <- return (inv_ImportSpecification_s77 sem arg76)
return (Syn_ImportSpecification _lhsOimps _lhsOself)
)
-- cata
{-# INLINE sem_ImportSpecification #-}
sem_ImportSpecification :: ImportSpecification -> T_ImportSpecification
sem_ImportSpecification ( ImportSpecification_Import range_ hiding_ imports_ ) = sem_ImportSpecification_Import ( sem_Range range_ ) hiding_ ( sem_Imports imports_ )
-- semantic domain
newtype T_ImportSpecification = T_ImportSpecification {
attach_T_ImportSpecification :: Identity (T_ImportSpecification_s77 )
}
newtype T_ImportSpecification_s77 = C_ImportSpecification_s77 {
inv_ImportSpecification_s77 :: (T_ImportSpecification_v76 )
}
data T_ImportSpecification_s78 = C_ImportSpecification_s78
type T_ImportSpecification_v76 = (T_ImportSpecification_vIn76 ) -> (T_ImportSpecification_vOut76 )
data T_ImportSpecification_vIn76 = T_ImportSpecification_vIn76
data T_ImportSpecification_vOut76 = T_ImportSpecification_vOut76 ([Id]) (ImportSpecification)
{-# NOINLINE sem_ImportSpecification_Import #-}
sem_ImportSpecification_Import :: T_Range -> (Bool) -> T_Imports -> T_ImportSpecification
sem_ImportSpecification_Import arg_range_ arg_hiding_ arg_imports_ = T_ImportSpecification (return st77) where
{-# NOINLINE st77 #-}
st77 = let
v76 :: T_ImportSpecification_v76
v76 = \ (T_ImportSpecification_vIn76 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_importsX80 = Control.Monad.Identity.runIdentity (attach_T_Imports (arg_imports_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Imports_vOut79 _importsIimps _importsIself) = inv_Imports_s80 _importsX80 (T_Imports_vIn79 )
_lhsOimps :: [Id]
_lhsOimps = rule186 _importsIimps arg_hiding_
_self = rule187 _importsIself _rangeIself arg_hiding_
_lhsOself :: ImportSpecification
_lhsOself = rule188 _self
__result_ = T_ImportSpecification_vOut76 _lhsOimps _lhsOself
in __result_ )
in C_ImportSpecification_s77 v76
{-# INLINE rule186 #-}
rule186 = \ ((_importsIimps) :: [Id]) hiding_ ->
if not hiding_ then
internalError "ExtractImportDecls.ag" "ImportSpecification.Import" "import lists are not supported"
else
_importsIimps
{-# INLINE rule187 #-}
rule187 = \ ((_importsIself) :: Imports) ((_rangeIself) :: Range) hiding_ ->
ImportSpecification_Import _rangeIself hiding_ _importsIself
{-# INLINE rule188 #-}
rule188 = \ _self ->
_self
-- Imports -----------------------------------------------------
-- wrapper
data Inh_Imports = Inh_Imports { }
data Syn_Imports = Syn_Imports { imps_Syn_Imports :: ([Id]), self_Syn_Imports :: (Imports) }
{-# INLINABLE wrap_Imports #-}
wrap_Imports :: T_Imports -> Inh_Imports -> (Syn_Imports )
wrap_Imports (T_Imports act) (Inh_Imports ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg79 = T_Imports_vIn79
(T_Imports_vOut79 _lhsOimps _lhsOself) <- return (inv_Imports_s80 sem arg79)
return (Syn_Imports _lhsOimps _lhsOself)
)
-- cata
{-# NOINLINE sem_Imports #-}
sem_Imports :: Imports -> T_Imports
sem_Imports list = Prelude.foldr sem_Imports_Cons sem_Imports_Nil (Prelude.map sem_Import list)
-- semantic domain
newtype T_Imports = T_Imports {
attach_T_Imports :: Identity (T_Imports_s80 )
}
newtype T_Imports_s80 = C_Imports_s80 {
inv_Imports_s80 :: (T_Imports_v79 )
}
data T_Imports_s81 = C_Imports_s81
type T_Imports_v79 = (T_Imports_vIn79 ) -> (T_Imports_vOut79 )
data T_Imports_vIn79 = T_Imports_vIn79
data T_Imports_vOut79 = T_Imports_vOut79 ([Id]) (Imports)
{-# NOINLINE sem_Imports_Cons #-}
sem_Imports_Cons :: T_Import -> T_Imports -> T_Imports
sem_Imports_Cons arg_hd_ arg_tl_ = T_Imports (return st80) where
{-# NOINLINE st80 #-}
st80 = let
v79 :: T_Imports_v79
v79 = \ (T_Imports_vIn79 ) -> ( let
_hdX68 = Control.Monad.Identity.runIdentity (attach_T_Import (arg_hd_))
_tlX80 = Control.Monad.Identity.runIdentity (attach_T_Imports (arg_tl_))
(T_Import_vOut67 _hdIimps _hdIself) = inv_Import_s68 _hdX68 (T_Import_vIn67 )
(T_Imports_vOut79 _tlIimps _tlIself) = inv_Imports_s80 _tlX80 (T_Imports_vIn79 )
_lhsOimps :: [Id]
_lhsOimps = rule189 _hdIimps _tlIimps
_self = rule190 _hdIself _tlIself
_lhsOself :: Imports
_lhsOself = rule191 _self
__result_ = T_Imports_vOut79 _lhsOimps _lhsOself
in __result_ )
in C_Imports_s80 v79
{-# INLINE rule189 #-}
rule189 = \ ((_hdIimps) :: [Id]) ((_tlIimps) :: [Id]) ->
_hdIimps ++ _tlIimps
{-# INLINE rule190 #-}
rule190 = \ ((_hdIself) :: Import) ((_tlIself) :: Imports) ->
(:) _hdIself _tlIself
{-# INLINE rule191 #-}
rule191 = \ _self ->
_self
{-# NOINLINE sem_Imports_Nil #-}
sem_Imports_Nil :: T_Imports
sem_Imports_Nil = T_Imports (return st80) where
{-# NOINLINE st80 #-}
st80 = let
v79 :: T_Imports_v79
v79 = \ (T_Imports_vIn79 ) -> ( let
_lhsOimps :: [Id]
_lhsOimps = rule192 ()
_self = rule193 ()
_lhsOself :: Imports
_lhsOself = rule194 _self
__result_ = T_Imports_vOut79 _lhsOimps _lhsOself
in __result_ )
in C_Imports_s80 v79
{-# INLINE rule192 #-}
rule192 = \ (_ :: ()) ->
[]
{-# INLINE rule193 #-}
rule193 = \ (_ :: ()) ->
[]
{-# INLINE rule194 #-}
rule194 = \ _self ->
_self
-- LeftHandSide ------------------------------------------------
-- wrapper
data Inh_LeftHandSide = Inh_LeftHandSide { }
data Syn_LeftHandSide = Syn_LeftHandSide { name_Syn_LeftHandSide :: (Name), self_Syn_LeftHandSide :: (LeftHandSide) }
{-# INLINABLE wrap_LeftHandSide #-}
wrap_LeftHandSide :: T_LeftHandSide -> Inh_LeftHandSide -> (Syn_LeftHandSide )
wrap_LeftHandSide (T_LeftHandSide act) (Inh_LeftHandSide ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg82 = T_LeftHandSide_vIn82
(T_LeftHandSide_vOut82 _lhsOname _lhsOself) <- return (inv_LeftHandSide_s83 sem arg82)
return (Syn_LeftHandSide _lhsOname _lhsOself)
)
-- cata
{-# NOINLINE sem_LeftHandSide #-}
sem_LeftHandSide :: LeftHandSide -> T_LeftHandSide
sem_LeftHandSide ( LeftHandSide_Function range_ name_ patterns_ ) = sem_LeftHandSide_Function ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Patterns patterns_ )
sem_LeftHandSide ( LeftHandSide_Infix range_ leftPattern_ operator_ rightPattern_ ) = sem_LeftHandSide_Infix ( sem_Range range_ ) ( sem_Pattern leftPattern_ ) ( sem_Name operator_ ) ( sem_Pattern rightPattern_ )
sem_LeftHandSide ( LeftHandSide_Parenthesized range_ lefthandside_ patterns_ ) = sem_LeftHandSide_Parenthesized ( sem_Range range_ ) ( sem_LeftHandSide lefthandside_ ) ( sem_Patterns patterns_ )
-- semantic domain
newtype T_LeftHandSide = T_LeftHandSide {
attach_T_LeftHandSide :: Identity (T_LeftHandSide_s83 )
}
newtype T_LeftHandSide_s83 = C_LeftHandSide_s83 {
inv_LeftHandSide_s83 :: (T_LeftHandSide_v82 )
}
data T_LeftHandSide_s84 = C_LeftHandSide_s84
type T_LeftHandSide_v82 = (T_LeftHandSide_vIn82 ) -> (T_LeftHandSide_vOut82 )
data T_LeftHandSide_vIn82 = T_LeftHandSide_vIn82
data T_LeftHandSide_vOut82 = T_LeftHandSide_vOut82 (Name) (LeftHandSide)
{-# NOINLINE sem_LeftHandSide_Function #-}
sem_LeftHandSide_Function :: T_Range -> T_Name -> T_Patterns -> T_LeftHandSide
sem_LeftHandSide_Function arg_range_ arg_name_ arg_patterns_ = T_LeftHandSide (return st83) where
{-# NOINLINE st83 #-}
st83 = let
v82 :: T_LeftHandSide_v82
v82 = \ (T_LeftHandSide_vIn82 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Patterns_vOut121 _patternsIself) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 )
_lhsOname :: Name
_lhsOname = rule195 _nameIself
_self = rule196 _nameIself _patternsIself _rangeIself
_lhsOself :: LeftHandSide
_lhsOself = rule197 _self
__result_ = T_LeftHandSide_vOut82 _lhsOname _lhsOself
in __result_ )
in C_LeftHandSide_s83 v82
{-# INLINE rule195 #-}
rule195 = \ ((_nameIself) :: Name) ->
_nameIself
{-# INLINE rule196 #-}
rule196 = \ ((_nameIself) :: Name) ((_patternsIself) :: Patterns) ((_rangeIself) :: Range) ->
LeftHandSide_Function _rangeIself _nameIself _patternsIself
{-# INLINE rule197 #-}
rule197 = \ _self ->
_self
{-# NOINLINE sem_LeftHandSide_Infix #-}
sem_LeftHandSide_Infix :: T_Range -> T_Pattern -> T_Name -> T_Pattern -> T_LeftHandSide
sem_LeftHandSide_Infix arg_range_ arg_leftPattern_ arg_operator_ arg_rightPattern_ = T_LeftHandSide (return st83) where
{-# NOINLINE st83 #-}
st83 = let
v82 :: T_LeftHandSide_v82
v82 = \ (T_LeftHandSide_vIn82 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_leftPatternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_leftPattern_))
_operatorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_operator_))
_rightPatternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_rightPattern_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Pattern_vOut118 _leftPatternIself) = inv_Pattern_s119 _leftPatternX119 (T_Pattern_vIn118 )
(T_Name_vOut112 _operatorIself) = inv_Name_s113 _operatorX113 (T_Name_vIn112 )
(T_Pattern_vOut118 _rightPatternIself) = inv_Pattern_s119 _rightPatternX119 (T_Pattern_vIn118 )
_lhsOname :: Name
_lhsOname = rule198 _operatorIself
_self = rule199 _leftPatternIself _operatorIself _rangeIself _rightPatternIself
_lhsOself :: LeftHandSide
_lhsOself = rule200 _self
__result_ = T_LeftHandSide_vOut82 _lhsOname _lhsOself
in __result_ )
in C_LeftHandSide_s83 v82
{-# INLINE rule198 #-}
rule198 = \ ((_operatorIself) :: Name) ->
_operatorIself
{-# INLINE rule199 #-}
rule199 = \ ((_leftPatternIself) :: Pattern) ((_operatorIself) :: Name) ((_rangeIself) :: Range) ((_rightPatternIself) :: Pattern) ->
LeftHandSide_Infix _rangeIself _leftPatternIself _operatorIself _rightPatternIself
{-# INLINE rule200 #-}
rule200 = \ _self ->
_self
{-# NOINLINE sem_LeftHandSide_Parenthesized #-}
sem_LeftHandSide_Parenthesized :: T_Range -> T_LeftHandSide -> T_Patterns -> T_LeftHandSide
sem_LeftHandSide_Parenthesized arg_range_ arg_lefthandside_ arg_patterns_ = T_LeftHandSide (return st83) where
{-# NOINLINE st83 #-}
st83 = let
v82 :: T_LeftHandSide_v82
v82 = \ (T_LeftHandSide_vIn82 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_lefthandsideX83 = Control.Monad.Identity.runIdentity (attach_T_LeftHandSide (arg_lefthandside_))
_patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_LeftHandSide_vOut82 _lefthandsideIname _lefthandsideIself) = inv_LeftHandSide_s83 _lefthandsideX83 (T_LeftHandSide_vIn82 )
(T_Patterns_vOut121 _patternsIself) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 )
_self = rule201 _lefthandsideIself _patternsIself _rangeIself
_lhsOself :: LeftHandSide
_lhsOself = rule202 _self
_lhsOname :: Name
_lhsOname = rule203 _lefthandsideIname
__result_ = T_LeftHandSide_vOut82 _lhsOname _lhsOself
in __result_ )
in C_LeftHandSide_s83 v82
{-# INLINE rule201 #-}
rule201 = \ ((_lefthandsideIself) :: LeftHandSide) ((_patternsIself) :: Patterns) ((_rangeIself) :: Range) ->
LeftHandSide_Parenthesized _rangeIself _lefthandsideIself _patternsIself
{-# INLINE rule202 #-}
rule202 = \ _self ->
_self
{-# INLINE rule203 #-}
rule203 = \ ((_lefthandsideIname) :: Name) ->
_lefthandsideIname
-- Literal -----------------------------------------------------
-- wrapper
data Inh_Literal = Inh_Literal { }
data Syn_Literal = Syn_Literal { self_Syn_Literal :: (Literal) }
{-# INLINABLE wrap_Literal #-}
wrap_Literal :: T_Literal -> Inh_Literal -> (Syn_Literal )
wrap_Literal (T_Literal act) (Inh_Literal ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg85 = T_Literal_vIn85
(T_Literal_vOut85 _lhsOself) <- return (inv_Literal_s86 sem arg85)
return (Syn_Literal _lhsOself)
)
-- cata
{-# NOINLINE sem_Literal #-}
sem_Literal :: Literal -> T_Literal
sem_Literal ( Literal_Int range_ value_ ) = sem_Literal_Int ( sem_Range range_ ) value_
sem_Literal ( Literal_Char range_ value_ ) = sem_Literal_Char ( sem_Range range_ ) value_
sem_Literal ( Literal_Float range_ value_ ) = sem_Literal_Float ( sem_Range range_ ) value_
sem_Literal ( Literal_String range_ value_ ) = sem_Literal_String ( sem_Range range_ ) value_
-- semantic domain
newtype T_Literal = T_Literal {
attach_T_Literal :: Identity (T_Literal_s86 )
}
newtype T_Literal_s86 = C_Literal_s86 {
inv_Literal_s86 :: (T_Literal_v85 )
}
data T_Literal_s87 = C_Literal_s87
type T_Literal_v85 = (T_Literal_vIn85 ) -> (T_Literal_vOut85 )
data T_Literal_vIn85 = T_Literal_vIn85
data T_Literal_vOut85 = T_Literal_vOut85 (Literal)
{-# NOINLINE sem_Literal_Int #-}
sem_Literal_Int :: T_Range -> (String) -> T_Literal
sem_Literal_Int arg_range_ arg_value_ = T_Literal (return st86) where
{-# NOINLINE st86 #-}
st86 = let
v85 :: T_Literal_v85
v85 = \ (T_Literal_vIn85 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule204 _rangeIself arg_value_
_lhsOself :: Literal
_lhsOself = rule205 _self
__result_ = T_Literal_vOut85 _lhsOself
in __result_ )
in C_Literal_s86 v85
{-# INLINE rule204 #-}
rule204 = \ ((_rangeIself) :: Range) value_ ->
Literal_Int _rangeIself value_
{-# INLINE rule205 #-}
rule205 = \ _self ->
_self
{-# NOINLINE sem_Literal_Char #-}
sem_Literal_Char :: T_Range -> (String) -> T_Literal
sem_Literal_Char arg_range_ arg_value_ = T_Literal (return st86) where
{-# NOINLINE st86 #-}
st86 = let
v85 :: T_Literal_v85
v85 = \ (T_Literal_vIn85 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule206 _rangeIself arg_value_
_lhsOself :: Literal
_lhsOself = rule207 _self
__result_ = T_Literal_vOut85 _lhsOself
in __result_ )
in C_Literal_s86 v85
{-# INLINE rule206 #-}
rule206 = \ ((_rangeIself) :: Range) value_ ->
Literal_Char _rangeIself value_
{-# INLINE rule207 #-}
rule207 = \ _self ->
_self
{-# NOINLINE sem_Literal_Float #-}
sem_Literal_Float :: T_Range -> (String) -> T_Literal
sem_Literal_Float arg_range_ arg_value_ = T_Literal (return st86) where
{-# NOINLINE st86 #-}
st86 = let
v85 :: T_Literal_v85
v85 = \ (T_Literal_vIn85 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule208 _rangeIself arg_value_
_lhsOself :: Literal
_lhsOself = rule209 _self
__result_ = T_Literal_vOut85 _lhsOself
in __result_ )
in C_Literal_s86 v85
{-# INLINE rule208 #-}
rule208 = \ ((_rangeIself) :: Range) value_ ->
Literal_Float _rangeIself value_
{-# INLINE rule209 #-}
rule209 = \ _self ->
_self
{-# NOINLINE sem_Literal_String #-}
sem_Literal_String :: T_Range -> (String) -> T_Literal
sem_Literal_String arg_range_ arg_value_ = T_Literal (return st86) where
{-# NOINLINE st86 #-}
st86 = let
v85 :: T_Literal_v85
v85 = \ (T_Literal_vIn85 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule210 _rangeIself arg_value_
_lhsOself :: Literal
_lhsOself = rule211 _self
__result_ = T_Literal_vOut85 _lhsOself
in __result_ )
in C_Literal_s86 v85
{-# INLINE rule210 #-}
rule210 = \ ((_rangeIself) :: Range) value_ ->
Literal_String _rangeIself value_
{-# INLINE rule211 #-}
rule211 = \ _self ->
_self
-- MaybeDeclarations -------------------------------------------
-- wrapper
data Inh_MaybeDeclarations = Inh_MaybeDeclarations { }
data Syn_MaybeDeclarations = Syn_MaybeDeclarations { self_Syn_MaybeDeclarations :: (MaybeDeclarations) }
{-# INLINABLE wrap_MaybeDeclarations #-}
wrap_MaybeDeclarations :: T_MaybeDeclarations -> Inh_MaybeDeclarations -> (Syn_MaybeDeclarations )
wrap_MaybeDeclarations (T_MaybeDeclarations act) (Inh_MaybeDeclarations ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg88 = T_MaybeDeclarations_vIn88
(T_MaybeDeclarations_vOut88 _lhsOself) <- return (inv_MaybeDeclarations_s89 sem arg88)
return (Syn_MaybeDeclarations _lhsOself)
)
-- cata
{-# NOINLINE sem_MaybeDeclarations #-}
sem_MaybeDeclarations :: MaybeDeclarations -> T_MaybeDeclarations
sem_MaybeDeclarations ( MaybeDeclarations_Nothing ) = sem_MaybeDeclarations_Nothing
sem_MaybeDeclarations ( MaybeDeclarations_Just declarations_ ) = sem_MaybeDeclarations_Just ( sem_Declarations declarations_ )
-- semantic domain
newtype T_MaybeDeclarations = T_MaybeDeclarations {
attach_T_MaybeDeclarations :: Identity (T_MaybeDeclarations_s89 )
}
newtype T_MaybeDeclarations_s89 = C_MaybeDeclarations_s89 {
inv_MaybeDeclarations_s89 :: (T_MaybeDeclarations_v88 )
}
data T_MaybeDeclarations_s90 = C_MaybeDeclarations_s90
type T_MaybeDeclarations_v88 = (T_MaybeDeclarations_vIn88 ) -> (T_MaybeDeclarations_vOut88 )
data T_MaybeDeclarations_vIn88 = T_MaybeDeclarations_vIn88
data T_MaybeDeclarations_vOut88 = T_MaybeDeclarations_vOut88 (MaybeDeclarations)
{-# NOINLINE sem_MaybeDeclarations_Nothing #-}
sem_MaybeDeclarations_Nothing :: T_MaybeDeclarations
sem_MaybeDeclarations_Nothing = T_MaybeDeclarations (return st89) where
{-# NOINLINE st89 #-}
st89 = let
v88 :: T_MaybeDeclarations_v88
v88 = \ (T_MaybeDeclarations_vIn88 ) -> ( let
_self = rule212 ()
_lhsOself :: MaybeDeclarations
_lhsOself = rule213 _self
__result_ = T_MaybeDeclarations_vOut88 _lhsOself
in __result_ )
in C_MaybeDeclarations_s89 v88
{-# INLINE rule212 #-}
rule212 = \ (_ :: ()) ->
MaybeDeclarations_Nothing
{-# INLINE rule213 #-}
rule213 = \ _self ->
_self
{-# NOINLINE sem_MaybeDeclarations_Just #-}
sem_MaybeDeclarations_Just :: T_Declarations -> T_MaybeDeclarations
sem_MaybeDeclarations_Just arg_declarations_ = T_MaybeDeclarations (return st89) where
{-# NOINLINE st89 #-}
st89 = let
v88 :: T_MaybeDeclarations_v88
v88 = \ (T_MaybeDeclarations_vIn88 ) -> ( let
_declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_))
(T_Declarations_vOut31 _declarationsIself) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 )
_self = rule214 _declarationsIself
_lhsOself :: MaybeDeclarations
_lhsOself = rule215 _self
__result_ = T_MaybeDeclarations_vOut88 _lhsOself
in __result_ )
in C_MaybeDeclarations_s89 v88
{-# INLINE rule214 #-}
rule214 = \ ((_declarationsIself) :: Declarations) ->
MaybeDeclarations_Just _declarationsIself
{-# INLINE rule215 #-}
rule215 = \ _self ->
_self
-- MaybeExports ------------------------------------------------
-- wrapper
data Inh_MaybeExports = Inh_MaybeExports { }
data Syn_MaybeExports = Syn_MaybeExports { self_Syn_MaybeExports :: (MaybeExports) }
{-# INLINABLE wrap_MaybeExports #-}
wrap_MaybeExports :: T_MaybeExports -> Inh_MaybeExports -> (Syn_MaybeExports )
wrap_MaybeExports (T_MaybeExports act) (Inh_MaybeExports ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg91 = T_MaybeExports_vIn91
(T_MaybeExports_vOut91 _lhsOself) <- return (inv_MaybeExports_s92 sem arg91)
return (Syn_MaybeExports _lhsOself)
)
-- cata
{-# NOINLINE sem_MaybeExports #-}
sem_MaybeExports :: MaybeExports -> T_MaybeExports
sem_MaybeExports ( MaybeExports_Nothing ) = sem_MaybeExports_Nothing
sem_MaybeExports ( MaybeExports_Just exports_ ) = sem_MaybeExports_Just ( sem_Exports exports_ )
-- semantic domain
newtype T_MaybeExports = T_MaybeExports {
attach_T_MaybeExports :: Identity (T_MaybeExports_s92 )
}
newtype T_MaybeExports_s92 = C_MaybeExports_s92 {
inv_MaybeExports_s92 :: (T_MaybeExports_v91 )
}
data T_MaybeExports_s93 = C_MaybeExports_s93
type T_MaybeExports_v91 = (T_MaybeExports_vIn91 ) -> (T_MaybeExports_vOut91 )
data T_MaybeExports_vIn91 = T_MaybeExports_vIn91
data T_MaybeExports_vOut91 = T_MaybeExports_vOut91 (MaybeExports)
{-# NOINLINE sem_MaybeExports_Nothing #-}
sem_MaybeExports_Nothing :: T_MaybeExports
sem_MaybeExports_Nothing = T_MaybeExports (return st92) where
{-# NOINLINE st92 #-}
st92 = let
v91 :: T_MaybeExports_v91
v91 = \ (T_MaybeExports_vIn91 ) -> ( let
_self = rule216 ()
_lhsOself :: MaybeExports
_lhsOself = rule217 _self
__result_ = T_MaybeExports_vOut91 _lhsOself
in __result_ )
in C_MaybeExports_s92 v91
{-# INLINE rule216 #-}
rule216 = \ (_ :: ()) ->
MaybeExports_Nothing
{-# INLINE rule217 #-}
rule217 = \ _self ->
_self
{-# NOINLINE sem_MaybeExports_Just #-}
sem_MaybeExports_Just :: T_Exports -> T_MaybeExports
sem_MaybeExports_Just arg_exports_ = T_MaybeExports (return st92) where
{-# NOINLINE st92 #-}
st92 = let
v91 :: T_MaybeExports_v91
v91 = \ (T_MaybeExports_vIn91 ) -> ( let
_exportsX38 = Control.Monad.Identity.runIdentity (attach_T_Exports (arg_exports_))
(T_Exports_vOut37 _exportsIself) = inv_Exports_s38 _exportsX38 (T_Exports_vIn37 )
_self = rule218 _exportsIself
_lhsOself :: MaybeExports
_lhsOself = rule219 _self
__result_ = T_MaybeExports_vOut91 _lhsOself
in __result_ )
in C_MaybeExports_s92 v91
{-# INLINE rule218 #-}
rule218 = \ ((_exportsIself) :: Exports) ->
MaybeExports_Just _exportsIself
{-# INLINE rule219 #-}
rule219 = \ _self ->
_self
-- MaybeExpression ---------------------------------------------
-- wrapper
data Inh_MaybeExpression = Inh_MaybeExpression { }
data Syn_MaybeExpression = Syn_MaybeExpression { self_Syn_MaybeExpression :: (MaybeExpression) }
{-# INLINABLE wrap_MaybeExpression #-}
wrap_MaybeExpression :: T_MaybeExpression -> Inh_MaybeExpression -> (Syn_MaybeExpression )
wrap_MaybeExpression (T_MaybeExpression act) (Inh_MaybeExpression ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg94 = T_MaybeExpression_vIn94
(T_MaybeExpression_vOut94 _lhsOself) <- return (inv_MaybeExpression_s95 sem arg94)
return (Syn_MaybeExpression _lhsOself)
)
-- cata
{-# NOINLINE sem_MaybeExpression #-}
sem_MaybeExpression :: MaybeExpression -> T_MaybeExpression
sem_MaybeExpression ( MaybeExpression_Nothing ) = sem_MaybeExpression_Nothing
sem_MaybeExpression ( MaybeExpression_Just expression_ ) = sem_MaybeExpression_Just ( sem_Expression expression_ )
-- semantic domain
newtype T_MaybeExpression = T_MaybeExpression {
attach_T_MaybeExpression :: Identity (T_MaybeExpression_s95 )
}
newtype T_MaybeExpression_s95 = C_MaybeExpression_s95 {
inv_MaybeExpression_s95 :: (T_MaybeExpression_v94 )
}
data T_MaybeExpression_s96 = C_MaybeExpression_s96
type T_MaybeExpression_v94 = (T_MaybeExpression_vIn94 ) -> (T_MaybeExpression_vOut94 )
data T_MaybeExpression_vIn94 = T_MaybeExpression_vIn94
data T_MaybeExpression_vOut94 = T_MaybeExpression_vOut94 (MaybeExpression)
{-# NOINLINE sem_MaybeExpression_Nothing #-}
sem_MaybeExpression_Nothing :: T_MaybeExpression
sem_MaybeExpression_Nothing = T_MaybeExpression (return st95) where
{-# NOINLINE st95 #-}
st95 = let
v94 :: T_MaybeExpression_v94
v94 = \ (T_MaybeExpression_vIn94 ) -> ( let
_self = rule220 ()
_lhsOself :: MaybeExpression
_lhsOself = rule221 _self
__result_ = T_MaybeExpression_vOut94 _lhsOself
in __result_ )
in C_MaybeExpression_s95 v94
{-# INLINE rule220 #-}
rule220 = \ (_ :: ()) ->
MaybeExpression_Nothing
{-# INLINE rule221 #-}
rule221 = \ _self ->
_self
{-# NOINLINE sem_MaybeExpression_Just #-}
sem_MaybeExpression_Just :: T_Expression -> T_MaybeExpression
sem_MaybeExpression_Just arg_expression_ = T_MaybeExpression (return st95) where
{-# NOINLINE st95 #-}
st95 = let
v94 :: T_MaybeExpression_v94
v94 = \ (T_MaybeExpression_vIn94 ) -> ( let
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule222 _expressionIself
_lhsOself :: MaybeExpression
_lhsOself = rule223 _self
__result_ = T_MaybeExpression_vOut94 _lhsOself
in __result_ )
in C_MaybeExpression_s95 v94
{-# INLINE rule222 #-}
rule222 = \ ((_expressionIself) :: Expression) ->
MaybeExpression_Just _expressionIself
{-# INLINE rule223 #-}
rule223 = \ _self ->
_self
-- MaybeImportSpecification ------------------------------------
-- wrapper
data Inh_MaybeImportSpecification = Inh_MaybeImportSpecification { }
data Syn_MaybeImportSpecification = Syn_MaybeImportSpecification { imps_Syn_MaybeImportSpecification :: ([Id]), self_Syn_MaybeImportSpecification :: (MaybeImportSpecification) }
{-# INLINABLE wrap_MaybeImportSpecification #-}
wrap_MaybeImportSpecification :: T_MaybeImportSpecification -> Inh_MaybeImportSpecification -> (Syn_MaybeImportSpecification )
wrap_MaybeImportSpecification (T_MaybeImportSpecification act) (Inh_MaybeImportSpecification ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg97 = T_MaybeImportSpecification_vIn97
(T_MaybeImportSpecification_vOut97 _lhsOimps _lhsOself) <- return (inv_MaybeImportSpecification_s98 sem arg97)
return (Syn_MaybeImportSpecification _lhsOimps _lhsOself)
)
-- cata
{-# NOINLINE sem_MaybeImportSpecification #-}
sem_MaybeImportSpecification :: MaybeImportSpecification -> T_MaybeImportSpecification
sem_MaybeImportSpecification ( MaybeImportSpecification_Nothing ) = sem_MaybeImportSpecification_Nothing
sem_MaybeImportSpecification ( MaybeImportSpecification_Just importspecification_ ) = sem_MaybeImportSpecification_Just ( sem_ImportSpecification importspecification_ )
-- semantic domain
newtype T_MaybeImportSpecification = T_MaybeImportSpecification {
attach_T_MaybeImportSpecification :: Identity (T_MaybeImportSpecification_s98 )
}
newtype T_MaybeImportSpecification_s98 = C_MaybeImportSpecification_s98 {
inv_MaybeImportSpecification_s98 :: (T_MaybeImportSpecification_v97 )
}
data T_MaybeImportSpecification_s99 = C_MaybeImportSpecification_s99
type T_MaybeImportSpecification_v97 = (T_MaybeImportSpecification_vIn97 ) -> (T_MaybeImportSpecification_vOut97 )
data T_MaybeImportSpecification_vIn97 = T_MaybeImportSpecification_vIn97
data T_MaybeImportSpecification_vOut97 = T_MaybeImportSpecification_vOut97 ([Id]) (MaybeImportSpecification)
{-# NOINLINE sem_MaybeImportSpecification_Nothing #-}
sem_MaybeImportSpecification_Nothing :: T_MaybeImportSpecification
sem_MaybeImportSpecification_Nothing = T_MaybeImportSpecification (return st98) where
{-# NOINLINE st98 #-}
st98 = let
v97 :: T_MaybeImportSpecification_v97
v97 = \ (T_MaybeImportSpecification_vIn97 ) -> ( let
_lhsOimps :: [Id]
_lhsOimps = rule224 ()
_self = rule225 ()
_lhsOself :: MaybeImportSpecification
_lhsOself = rule226 _self
__result_ = T_MaybeImportSpecification_vOut97 _lhsOimps _lhsOself
in __result_ )
in C_MaybeImportSpecification_s98 v97
{-# INLINE rule224 #-}
rule224 = \ (_ :: ()) ->
[]
{-# INLINE rule225 #-}
rule225 = \ (_ :: ()) ->
MaybeImportSpecification_Nothing
{-# INLINE rule226 #-}
rule226 = \ _self ->
_self
{-# NOINLINE sem_MaybeImportSpecification_Just #-}
sem_MaybeImportSpecification_Just :: T_ImportSpecification -> T_MaybeImportSpecification
sem_MaybeImportSpecification_Just arg_importspecification_ = T_MaybeImportSpecification (return st98) where
{-# NOINLINE st98 #-}
st98 = let
v97 :: T_MaybeImportSpecification_v97
v97 = \ (T_MaybeImportSpecification_vIn97 ) -> ( let
_importspecificationX77 = Control.Monad.Identity.runIdentity (attach_T_ImportSpecification (arg_importspecification_))
(T_ImportSpecification_vOut76 _importspecificationIimps _importspecificationIself) = inv_ImportSpecification_s77 _importspecificationX77 (T_ImportSpecification_vIn76 )
_lhsOimps :: [Id]
_lhsOimps = rule227 _importspecificationIimps
_self = rule228 _importspecificationIself
_lhsOself :: MaybeImportSpecification
_lhsOself = rule229 _self
__result_ = T_MaybeImportSpecification_vOut97 _lhsOimps _lhsOself
in __result_ )
in C_MaybeImportSpecification_s98 v97
{-# INLINE rule227 #-}
rule227 = \ ((_importspecificationIimps) :: [Id]) ->
_importspecificationIimps
{-# INLINE rule228 #-}
rule228 = \ ((_importspecificationIself) :: ImportSpecification) ->
MaybeImportSpecification_Just _importspecificationIself
{-# INLINE rule229 #-}
rule229 = \ _self ->
_self
-- MaybeInt ----------------------------------------------------
-- wrapper
data Inh_MaybeInt = Inh_MaybeInt { }
data Syn_MaybeInt = Syn_MaybeInt { self_Syn_MaybeInt :: (MaybeInt) }
{-# INLINABLE wrap_MaybeInt #-}
wrap_MaybeInt :: T_MaybeInt -> Inh_MaybeInt -> (Syn_MaybeInt )
wrap_MaybeInt (T_MaybeInt act) (Inh_MaybeInt ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg100 = T_MaybeInt_vIn100
(T_MaybeInt_vOut100 _lhsOself) <- return (inv_MaybeInt_s101 sem arg100)
return (Syn_MaybeInt _lhsOself)
)
-- cata
{-# NOINLINE sem_MaybeInt #-}
sem_MaybeInt :: MaybeInt -> T_MaybeInt
sem_MaybeInt ( MaybeInt_Nothing ) = sem_MaybeInt_Nothing
sem_MaybeInt ( MaybeInt_Just int_ ) = sem_MaybeInt_Just int_
-- semantic domain
newtype T_MaybeInt = T_MaybeInt {
attach_T_MaybeInt :: Identity (T_MaybeInt_s101 )
}
newtype T_MaybeInt_s101 = C_MaybeInt_s101 {
inv_MaybeInt_s101 :: (T_MaybeInt_v100 )
}
data T_MaybeInt_s102 = C_MaybeInt_s102
type T_MaybeInt_v100 = (T_MaybeInt_vIn100 ) -> (T_MaybeInt_vOut100 )
data T_MaybeInt_vIn100 = T_MaybeInt_vIn100
data T_MaybeInt_vOut100 = T_MaybeInt_vOut100 (MaybeInt)
{-# NOINLINE sem_MaybeInt_Nothing #-}
sem_MaybeInt_Nothing :: T_MaybeInt
sem_MaybeInt_Nothing = T_MaybeInt (return st101) where
{-# NOINLINE st101 #-}
st101 = let
v100 :: T_MaybeInt_v100
v100 = \ (T_MaybeInt_vIn100 ) -> ( let
_self = rule230 ()
_lhsOself :: MaybeInt
_lhsOself = rule231 _self
__result_ = T_MaybeInt_vOut100 _lhsOself
in __result_ )
in C_MaybeInt_s101 v100
{-# INLINE rule230 #-}
rule230 = \ (_ :: ()) ->
MaybeInt_Nothing
{-# INLINE rule231 #-}
rule231 = \ _self ->
_self
{-# NOINLINE sem_MaybeInt_Just #-}
sem_MaybeInt_Just :: (Int) -> T_MaybeInt
sem_MaybeInt_Just arg_int_ = T_MaybeInt (return st101) where
{-# NOINLINE st101 #-}
st101 = let
v100 :: T_MaybeInt_v100
v100 = \ (T_MaybeInt_vIn100 ) -> ( let
_self = rule232 arg_int_
_lhsOself :: MaybeInt
_lhsOself = rule233 _self
__result_ = T_MaybeInt_vOut100 _lhsOself
in __result_ )
in C_MaybeInt_s101 v100
{-# INLINE rule232 #-}
rule232 = \ int_ ->
MaybeInt_Just int_
{-# INLINE rule233 #-}
rule233 = \ _self ->
_self
-- MaybeName ---------------------------------------------------
-- wrapper
data Inh_MaybeName = Inh_MaybeName { }
data Syn_MaybeName = Syn_MaybeName { isNothing_Syn_MaybeName :: (Bool), name_Syn_MaybeName :: ( Maybe Name ), self_Syn_MaybeName :: (MaybeName) }
{-# INLINABLE wrap_MaybeName #-}
wrap_MaybeName :: T_MaybeName -> Inh_MaybeName -> (Syn_MaybeName )
wrap_MaybeName (T_MaybeName act) (Inh_MaybeName ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg103 = T_MaybeName_vIn103
(T_MaybeName_vOut103 _lhsOisNothing _lhsOname _lhsOself) <- return (inv_MaybeName_s104 sem arg103)
return (Syn_MaybeName _lhsOisNothing _lhsOname _lhsOself)
)
-- cata
{-# NOINLINE sem_MaybeName #-}
sem_MaybeName :: MaybeName -> T_MaybeName
sem_MaybeName ( MaybeName_Nothing ) = sem_MaybeName_Nothing
sem_MaybeName ( MaybeName_Just name_ ) = sem_MaybeName_Just ( sem_Name name_ )
-- semantic domain
newtype T_MaybeName = T_MaybeName {
attach_T_MaybeName :: Identity (T_MaybeName_s104 )
}
newtype T_MaybeName_s104 = C_MaybeName_s104 {
inv_MaybeName_s104 :: (T_MaybeName_v103 )
}
data T_MaybeName_s105 = C_MaybeName_s105
type T_MaybeName_v103 = (T_MaybeName_vIn103 ) -> (T_MaybeName_vOut103 )
data T_MaybeName_vIn103 = T_MaybeName_vIn103
data T_MaybeName_vOut103 = T_MaybeName_vOut103 (Bool) ( Maybe Name ) (MaybeName)
{-# NOINLINE sem_MaybeName_Nothing #-}
sem_MaybeName_Nothing :: T_MaybeName
sem_MaybeName_Nothing = T_MaybeName (return st104) where
{-# NOINLINE st104 #-}
st104 = let
v103 :: T_MaybeName_v103
v103 = \ (T_MaybeName_vIn103 ) -> ( let
_lhsOisNothing :: Bool
_lhsOisNothing = rule234 ()
_lhsOname :: Maybe Name
_lhsOname = rule235 ()
_self = rule236 ()
_lhsOself :: MaybeName
_lhsOself = rule237 _self
__result_ = T_MaybeName_vOut103 _lhsOisNothing _lhsOname _lhsOself
in __result_ )
in C_MaybeName_s104 v103
{-# INLINE rule234 #-}
rule234 = \ (_ :: ()) ->
True
{-# INLINE rule235 #-}
rule235 = \ (_ :: ()) ->
Nothing
{-# INLINE rule236 #-}
rule236 = \ (_ :: ()) ->
MaybeName_Nothing
{-# INLINE rule237 #-}
rule237 = \ _self ->
_self
{-# NOINLINE sem_MaybeName_Just #-}
sem_MaybeName_Just :: T_Name -> T_MaybeName
sem_MaybeName_Just arg_name_ = T_MaybeName (return st104) where
{-# NOINLINE st104 #-}
st104 = let
v103 :: T_MaybeName_v103
v103 = \ (T_MaybeName_vIn103 ) -> ( let
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_lhsOisNothing :: Bool
_lhsOisNothing = rule238 ()
_lhsOname :: Maybe Name
_lhsOname = rule239 _nameIself
_self = rule240 _nameIself
_lhsOself :: MaybeName
_lhsOself = rule241 _self
__result_ = T_MaybeName_vOut103 _lhsOisNothing _lhsOname _lhsOself
in __result_ )
in C_MaybeName_s104 v103
{-# INLINE rule238 #-}
rule238 = \ (_ :: ()) ->
False
{-# INLINE rule239 #-}
rule239 = \ ((_nameIself) :: Name) ->
Just _nameIself
{-# INLINE rule240 #-}
rule240 = \ ((_nameIself) :: Name) ->
MaybeName_Just _nameIself
{-# INLINE rule241 #-}
rule241 = \ _self ->
_self
-- MaybeNames --------------------------------------------------
-- wrapper
data Inh_MaybeNames = Inh_MaybeNames { }
data Syn_MaybeNames = Syn_MaybeNames { names_Syn_MaybeNames :: ( Maybe [Name] ), self_Syn_MaybeNames :: (MaybeNames) }
{-# INLINABLE wrap_MaybeNames #-}
wrap_MaybeNames :: T_MaybeNames -> Inh_MaybeNames -> (Syn_MaybeNames )
wrap_MaybeNames (T_MaybeNames act) (Inh_MaybeNames ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg106 = T_MaybeNames_vIn106
(T_MaybeNames_vOut106 _lhsOnames _lhsOself) <- return (inv_MaybeNames_s107 sem arg106)
return (Syn_MaybeNames _lhsOnames _lhsOself)
)
-- cata
{-# NOINLINE sem_MaybeNames #-}
sem_MaybeNames :: MaybeNames -> T_MaybeNames
sem_MaybeNames ( MaybeNames_Nothing ) = sem_MaybeNames_Nothing
sem_MaybeNames ( MaybeNames_Just names_ ) = sem_MaybeNames_Just ( sem_Names names_ )
-- semantic domain
newtype T_MaybeNames = T_MaybeNames {
attach_T_MaybeNames :: Identity (T_MaybeNames_s107 )
}
newtype T_MaybeNames_s107 = C_MaybeNames_s107 {
inv_MaybeNames_s107 :: (T_MaybeNames_v106 )
}
data T_MaybeNames_s108 = C_MaybeNames_s108
type T_MaybeNames_v106 = (T_MaybeNames_vIn106 ) -> (T_MaybeNames_vOut106 )
data T_MaybeNames_vIn106 = T_MaybeNames_vIn106
data T_MaybeNames_vOut106 = T_MaybeNames_vOut106 ( Maybe [Name] ) (MaybeNames)
{-# NOINLINE sem_MaybeNames_Nothing #-}
sem_MaybeNames_Nothing :: T_MaybeNames
sem_MaybeNames_Nothing = T_MaybeNames (return st107) where
{-# NOINLINE st107 #-}
st107 = let
v106 :: T_MaybeNames_v106
v106 = \ (T_MaybeNames_vIn106 ) -> ( let
_lhsOnames :: Maybe [Name]
_lhsOnames = rule242 ()
_self = rule243 ()
_lhsOself :: MaybeNames
_lhsOself = rule244 _self
__result_ = T_MaybeNames_vOut106 _lhsOnames _lhsOself
in __result_ )
in C_MaybeNames_s107 v106
{-# INLINE rule242 #-}
rule242 = \ (_ :: ()) ->
Nothing
{-# INLINE rule243 #-}
rule243 = \ (_ :: ()) ->
MaybeNames_Nothing
{-# INLINE rule244 #-}
rule244 = \ _self ->
_self
{-# NOINLINE sem_MaybeNames_Just #-}
sem_MaybeNames_Just :: T_Names -> T_MaybeNames
sem_MaybeNames_Just arg_names_ = T_MaybeNames (return st107) where
{-# NOINLINE st107 #-}
st107 = let
v106 :: T_MaybeNames_v106
v106 = \ (T_MaybeNames_vIn106 ) -> ( let
_namesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_names_))
(T_Names_vOut115 _namesInames _namesIself) = inv_Names_s116 _namesX116 (T_Names_vIn115 )
_lhsOnames :: Maybe [Name]
_lhsOnames = rule245 _namesInames
_self = rule246 _namesIself
_lhsOself :: MaybeNames
_lhsOself = rule247 _self
__result_ = T_MaybeNames_vOut106 _lhsOnames _lhsOself
in __result_ )
in C_MaybeNames_s107 v106
{-# INLINE rule245 #-}
rule245 = \ ((_namesInames) :: [Name]) ->
Just _namesInames
{-# INLINE rule246 #-}
rule246 = \ ((_namesIself) :: Names) ->
MaybeNames_Just _namesIself
{-# INLINE rule247 #-}
rule247 = \ _self ->
_self
-- Module ------------------------------------------------------
-- wrapper
data Inh_Module = Inh_Module { }
data Syn_Module = Syn_Module { coreImportDecls_Syn_Module :: ( [(Core.CoreDecl,[Id])] ), self_Syn_Module :: (Module) }
{-# INLINABLE wrap_Module #-}
wrap_Module :: T_Module -> Inh_Module -> (Syn_Module )
wrap_Module (T_Module act) (Inh_Module ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg109 = T_Module_vIn109
(T_Module_vOut109 _lhsOcoreImportDecls _lhsOself) <- return (inv_Module_s110 sem arg109)
return (Syn_Module _lhsOcoreImportDecls _lhsOself)
)
-- cata
{-# INLINE sem_Module #-}
sem_Module :: Module -> T_Module
sem_Module ( Module_Module range_ name_ exports_ body_ ) = sem_Module_Module ( sem_Range range_ ) ( sem_MaybeName name_ ) ( sem_MaybeExports exports_ ) ( sem_Body body_ )
-- semantic domain
newtype T_Module = T_Module {
attach_T_Module :: Identity (T_Module_s110 )
}
newtype T_Module_s110 = C_Module_s110 {
inv_Module_s110 :: (T_Module_v109 )
}
data T_Module_s111 = C_Module_s111
type T_Module_v109 = (T_Module_vIn109 ) -> (T_Module_vOut109 )
data T_Module_vIn109 = T_Module_vIn109
data T_Module_vOut109 = T_Module_vOut109 ( [(Core.CoreDecl,[Id])] ) (Module)
{-# NOINLINE sem_Module_Module #-}
sem_Module_Module :: T_Range -> T_MaybeName -> T_MaybeExports -> T_Body -> T_Module
sem_Module_Module arg_range_ arg_name_ arg_exports_ arg_body_ = T_Module (return st110) where
{-# NOINLINE st110 #-}
st110 = let
v109 :: T_Module_v109
v109 = \ (T_Module_vIn109 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX104 = Control.Monad.Identity.runIdentity (attach_T_MaybeName (arg_name_))
_exportsX92 = Control.Monad.Identity.runIdentity (attach_T_MaybeExports (arg_exports_))
_bodyX14 = Control.Monad.Identity.runIdentity (attach_T_Body (arg_body_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_MaybeName_vOut103 _nameIisNothing _nameIname _nameIself) = inv_MaybeName_s104 _nameX104 (T_MaybeName_vIn103 )
(T_MaybeExports_vOut91 _exportsIself) = inv_MaybeExports_s92 _exportsX92 (T_MaybeExports_vIn91 )
(T_Body_vOut13 _bodyIcoreImportDecls _bodyIself) = inv_Body_s14 _bodyX14 (T_Body_vIn13 )
_self = rule248 _bodyIself _exportsIself _nameIself _rangeIself
_lhsOself :: Module
_lhsOself = rule249 _self
_lhsOcoreImportDecls :: [(Core.CoreDecl,[Id])]
_lhsOcoreImportDecls = rule250 _bodyIcoreImportDecls
__result_ = T_Module_vOut109 _lhsOcoreImportDecls _lhsOself
in __result_ )
in C_Module_s110 v109
{-# INLINE rule248 #-}
rule248 = \ ((_bodyIself) :: Body) ((_exportsIself) :: MaybeExports) ((_nameIself) :: MaybeName) ((_rangeIself) :: Range) ->
Module_Module _rangeIself _nameIself _exportsIself _bodyIself
{-# INLINE rule249 #-}
rule249 = \ _self ->
_self
{-# INLINE rule250 #-}
rule250 = \ ((_bodyIcoreImportDecls) :: [(Core.CoreDecl,[Id])] ) ->
_bodyIcoreImportDecls
-- Name --------------------------------------------------------
-- wrapper
data Inh_Name = Inh_Name { }
data Syn_Name = Syn_Name { self_Syn_Name :: (Name) }
{-# INLINABLE wrap_Name #-}
wrap_Name :: T_Name -> Inh_Name -> (Syn_Name )
wrap_Name (T_Name act) (Inh_Name ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg112 = T_Name_vIn112
(T_Name_vOut112 _lhsOself) <- return (inv_Name_s113 sem arg112)
return (Syn_Name _lhsOself)
)
-- cata
{-# NOINLINE sem_Name #-}
sem_Name :: Name -> T_Name
sem_Name ( Name_Identifier range_ module_ name_ ) = sem_Name_Identifier ( sem_Range range_ ) ( sem_Strings module_ ) name_
sem_Name ( Name_Operator range_ module_ name_ ) = sem_Name_Operator ( sem_Range range_ ) ( sem_Strings module_ ) name_
sem_Name ( Name_Special range_ module_ name_ ) = sem_Name_Special ( sem_Range range_ ) ( sem_Strings module_ ) name_
-- semantic domain
newtype T_Name = T_Name {
attach_T_Name :: Identity (T_Name_s113 )
}
newtype T_Name_s113 = C_Name_s113 {
inv_Name_s113 :: (T_Name_v112 )
}
data T_Name_s114 = C_Name_s114
type T_Name_v112 = (T_Name_vIn112 ) -> (T_Name_vOut112 )
data T_Name_vIn112 = T_Name_vIn112
data T_Name_vOut112 = T_Name_vOut112 (Name)
{-# NOINLINE sem_Name_Identifier #-}
sem_Name_Identifier :: T_Range -> T_Strings -> (String) -> T_Name
sem_Name_Identifier arg_range_ arg_module_ arg_name_ = T_Name (return st113) where
{-# NOINLINE st113 #-}
st113 = let
v112 :: T_Name_v112
v112 = \ (T_Name_vIn112 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_moduleX161 = Control.Monad.Identity.runIdentity (attach_T_Strings (arg_module_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Strings_vOut160 _moduleIself) = inv_Strings_s161 _moduleX161 (T_Strings_vIn160 )
_self = rule251 _moduleIself _rangeIself arg_name_
_lhsOself :: Name
_lhsOself = rule252 _self
__result_ = T_Name_vOut112 _lhsOself
in __result_ )
in C_Name_s113 v112
{-# INLINE rule251 #-}
rule251 = \ ((_moduleIself) :: Strings) ((_rangeIself) :: Range) name_ ->
Name_Identifier _rangeIself _moduleIself name_
{-# INLINE rule252 #-}
rule252 = \ _self ->
_self
{-# NOINLINE sem_Name_Operator #-}
sem_Name_Operator :: T_Range -> T_Strings -> (String) -> T_Name
sem_Name_Operator arg_range_ arg_module_ arg_name_ = T_Name (return st113) where
{-# NOINLINE st113 #-}
st113 = let
v112 :: T_Name_v112
v112 = \ (T_Name_vIn112 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_moduleX161 = Control.Monad.Identity.runIdentity (attach_T_Strings (arg_module_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Strings_vOut160 _moduleIself) = inv_Strings_s161 _moduleX161 (T_Strings_vIn160 )
_self = rule253 _moduleIself _rangeIself arg_name_
_lhsOself :: Name
_lhsOself = rule254 _self
__result_ = T_Name_vOut112 _lhsOself
in __result_ )
in C_Name_s113 v112
{-# INLINE rule253 #-}
rule253 = \ ((_moduleIself) :: Strings) ((_rangeIself) :: Range) name_ ->
Name_Operator _rangeIself _moduleIself name_
{-# INLINE rule254 #-}
rule254 = \ _self ->
_self
{-# NOINLINE sem_Name_Special #-}
sem_Name_Special :: T_Range -> T_Strings -> (String) -> T_Name
sem_Name_Special arg_range_ arg_module_ arg_name_ = T_Name (return st113) where
{-# NOINLINE st113 #-}
st113 = let
v112 :: T_Name_v112
v112 = \ (T_Name_vIn112 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_moduleX161 = Control.Monad.Identity.runIdentity (attach_T_Strings (arg_module_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Strings_vOut160 _moduleIself) = inv_Strings_s161 _moduleX161 (T_Strings_vIn160 )
_self = rule255 _moduleIself _rangeIself arg_name_
_lhsOself :: Name
_lhsOself = rule256 _self
__result_ = T_Name_vOut112 _lhsOself
in __result_ )
in C_Name_s113 v112
{-# INLINE rule255 #-}
rule255 = \ ((_moduleIself) :: Strings) ((_rangeIself) :: Range) name_ ->
Name_Special _rangeIself _moduleIself name_
{-# INLINE rule256 #-}
rule256 = \ _self ->
_self
-- Names -------------------------------------------------------
-- wrapper
data Inh_Names = Inh_Names { }
data Syn_Names = Syn_Names { names_Syn_Names :: ([Name]), self_Syn_Names :: (Names) }
{-# INLINABLE wrap_Names #-}
wrap_Names :: T_Names -> Inh_Names -> (Syn_Names )
wrap_Names (T_Names act) (Inh_Names ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg115 = T_Names_vIn115
(T_Names_vOut115 _lhsOnames _lhsOself) <- return (inv_Names_s116 sem arg115)
return (Syn_Names _lhsOnames _lhsOself)
)
-- cata
{-# NOINLINE sem_Names #-}
sem_Names :: Names -> T_Names
sem_Names list = Prelude.foldr sem_Names_Cons sem_Names_Nil (Prelude.map sem_Name list)
-- semantic domain
newtype T_Names = T_Names {
attach_T_Names :: Identity (T_Names_s116 )
}
newtype T_Names_s116 = C_Names_s116 {
inv_Names_s116 :: (T_Names_v115 )
}
data T_Names_s117 = C_Names_s117
type T_Names_v115 = (T_Names_vIn115 ) -> (T_Names_vOut115 )
data T_Names_vIn115 = T_Names_vIn115
data T_Names_vOut115 = T_Names_vOut115 ([Name]) (Names)
{-# NOINLINE sem_Names_Cons #-}
sem_Names_Cons :: T_Name -> T_Names -> T_Names
sem_Names_Cons arg_hd_ arg_tl_ = T_Names (return st116) where
{-# NOINLINE st116 #-}
st116 = let
v115 :: T_Names_v115
v115 = \ (T_Names_vIn115 ) -> ( let
_hdX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_hd_))
_tlX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_tl_))
(T_Name_vOut112 _hdIself) = inv_Name_s113 _hdX113 (T_Name_vIn112 )
(T_Names_vOut115 _tlInames _tlIself) = inv_Names_s116 _tlX116 (T_Names_vIn115 )
_lhsOnames :: [Name]
_lhsOnames = rule257 _hdIself _tlInames
_self = rule258 _hdIself _tlIself
_lhsOself :: Names
_lhsOself = rule259 _self
__result_ = T_Names_vOut115 _lhsOnames _lhsOself
in __result_ )
in C_Names_s116 v115
{-# INLINE rule257 #-}
rule257 = \ ((_hdIself) :: Name) ((_tlInames) :: [Name]) ->
_hdIself : _tlInames
{-# INLINE rule258 #-}
rule258 = \ ((_hdIself) :: Name) ((_tlIself) :: Names) ->
(:) _hdIself _tlIself
{-# INLINE rule259 #-}
rule259 = \ _self ->
_self
{-# NOINLINE sem_Names_Nil #-}
sem_Names_Nil :: T_Names
sem_Names_Nil = T_Names (return st116) where
{-# NOINLINE st116 #-}
st116 = let
v115 :: T_Names_v115
v115 = \ (T_Names_vIn115 ) -> ( let
_lhsOnames :: [Name]
_lhsOnames = rule260 ()
_self = rule261 ()
_lhsOself :: Names
_lhsOself = rule262 _self
__result_ = T_Names_vOut115 _lhsOnames _lhsOself
in __result_ )
in C_Names_s116 v115
{-# INLINE rule260 #-}
rule260 = \ (_ :: ()) ->
[]
{-# INLINE rule261 #-}
rule261 = \ (_ :: ()) ->
[]
{-# INLINE rule262 #-}
rule262 = \ _self ->
_self
-- Pattern -----------------------------------------------------
-- wrapper
data Inh_Pattern = Inh_Pattern { }
data Syn_Pattern = Syn_Pattern { self_Syn_Pattern :: (Pattern) }
{-# INLINABLE wrap_Pattern #-}
wrap_Pattern :: T_Pattern -> Inh_Pattern -> (Syn_Pattern )
wrap_Pattern (T_Pattern act) (Inh_Pattern ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg118 = T_Pattern_vIn118
(T_Pattern_vOut118 _lhsOself) <- return (inv_Pattern_s119 sem arg118)
return (Syn_Pattern _lhsOself)
)
-- cata
{-# NOINLINE sem_Pattern #-}
sem_Pattern :: Pattern -> T_Pattern
sem_Pattern ( Pattern_Hole range_ id_ ) = sem_Pattern_Hole ( sem_Range range_ ) id_
sem_Pattern ( Pattern_Literal range_ literal_ ) = sem_Pattern_Literal ( sem_Range range_ ) ( sem_Literal literal_ )
sem_Pattern ( Pattern_Variable range_ name_ ) = sem_Pattern_Variable ( sem_Range range_ ) ( sem_Name name_ )
sem_Pattern ( Pattern_Constructor range_ name_ patterns_ ) = sem_Pattern_Constructor ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Patterns patterns_ )
sem_Pattern ( Pattern_Parenthesized range_ pattern_ ) = sem_Pattern_Parenthesized ( sem_Range range_ ) ( sem_Pattern pattern_ )
sem_Pattern ( Pattern_InfixConstructor range_ leftPattern_ constructorOperator_ rightPattern_ ) = sem_Pattern_InfixConstructor ( sem_Range range_ ) ( sem_Pattern leftPattern_ ) ( sem_Name constructorOperator_ ) ( sem_Pattern rightPattern_ )
sem_Pattern ( Pattern_List range_ patterns_ ) = sem_Pattern_List ( sem_Range range_ ) ( sem_Patterns patterns_ )
sem_Pattern ( Pattern_Tuple range_ patterns_ ) = sem_Pattern_Tuple ( sem_Range range_ ) ( sem_Patterns patterns_ )
sem_Pattern ( Pattern_Record range_ name_ recordPatternBindings_ ) = sem_Pattern_Record ( sem_Range range_ ) ( sem_Name name_ ) ( sem_RecordPatternBindings recordPatternBindings_ )
sem_Pattern ( Pattern_Negate range_ literal_ ) = sem_Pattern_Negate ( sem_Range range_ ) ( sem_Literal literal_ )
sem_Pattern ( Pattern_As range_ name_ pattern_ ) = sem_Pattern_As ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Pattern pattern_ )
sem_Pattern ( Pattern_Wildcard range_ ) = sem_Pattern_Wildcard ( sem_Range range_ )
sem_Pattern ( Pattern_Irrefutable range_ pattern_ ) = sem_Pattern_Irrefutable ( sem_Range range_ ) ( sem_Pattern pattern_ )
sem_Pattern ( Pattern_Successor range_ name_ literal_ ) = sem_Pattern_Successor ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Literal literal_ )
sem_Pattern ( Pattern_NegateFloat range_ literal_ ) = sem_Pattern_NegateFloat ( sem_Range range_ ) ( sem_Literal literal_ )
-- semantic domain
newtype T_Pattern = T_Pattern {
attach_T_Pattern :: Identity (T_Pattern_s119 )
}
newtype T_Pattern_s119 = C_Pattern_s119 {
inv_Pattern_s119 :: (T_Pattern_v118 )
}
data T_Pattern_s120 = C_Pattern_s120
type T_Pattern_v118 = (T_Pattern_vIn118 ) -> (T_Pattern_vOut118 )
data T_Pattern_vIn118 = T_Pattern_vIn118
data T_Pattern_vOut118 = T_Pattern_vOut118 (Pattern)
{-# NOINLINE sem_Pattern_Hole #-}
sem_Pattern_Hole :: T_Range -> (Integer) -> T_Pattern
sem_Pattern_Hole arg_range_ arg_id_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule263 _rangeIself arg_id_
_lhsOself :: Pattern
_lhsOself = rule264 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule263 #-}
rule263 = \ ((_rangeIself) :: Range) id_ ->
Pattern_Hole _rangeIself id_
{-# INLINE rule264 #-}
rule264 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Literal #-}
sem_Pattern_Literal :: T_Range -> T_Literal -> T_Pattern
sem_Pattern_Literal arg_range_ arg_literal_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Literal_vOut85 _literalIself) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 )
_self = rule265 _literalIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule266 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule265 #-}
rule265 = \ ((_literalIself) :: Literal) ((_rangeIself) :: Range) ->
Pattern_Literal _rangeIself _literalIself
{-# INLINE rule266 #-}
rule266 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Variable #-}
sem_Pattern_Variable :: T_Range -> T_Name -> T_Pattern
sem_Pattern_Variable arg_range_ arg_name_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_self = rule267 _nameIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule268 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule267 #-}
rule267 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Pattern_Variable _rangeIself _nameIself
{-# INLINE rule268 #-}
rule268 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Constructor #-}
sem_Pattern_Constructor :: T_Range -> T_Name -> T_Patterns -> T_Pattern
sem_Pattern_Constructor arg_range_ arg_name_ arg_patterns_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Patterns_vOut121 _patternsIself) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 )
_self = rule269 _nameIself _patternsIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule270 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule269 #-}
rule269 = \ ((_nameIself) :: Name) ((_patternsIself) :: Patterns) ((_rangeIself) :: Range) ->
Pattern_Constructor _rangeIself _nameIself _patternsIself
{-# INLINE rule270 #-}
rule270 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Parenthesized #-}
sem_Pattern_Parenthesized :: T_Range -> T_Pattern -> T_Pattern
sem_Pattern_Parenthesized arg_range_ arg_pattern_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Pattern_vOut118 _patternIself) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 )
_self = rule271 _patternIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule272 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule271 #-}
rule271 = \ ((_patternIself) :: Pattern) ((_rangeIself) :: Range) ->
Pattern_Parenthesized _rangeIself _patternIself
{-# INLINE rule272 #-}
rule272 = \ _self ->
_self
{-# NOINLINE sem_Pattern_InfixConstructor #-}
sem_Pattern_InfixConstructor :: T_Range -> T_Pattern -> T_Name -> T_Pattern -> T_Pattern
sem_Pattern_InfixConstructor arg_range_ arg_leftPattern_ arg_constructorOperator_ arg_rightPattern_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_leftPatternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_leftPattern_))
_constructorOperatorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_constructorOperator_))
_rightPatternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_rightPattern_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Pattern_vOut118 _leftPatternIself) = inv_Pattern_s119 _leftPatternX119 (T_Pattern_vIn118 )
(T_Name_vOut112 _constructorOperatorIself) = inv_Name_s113 _constructorOperatorX113 (T_Name_vIn112 )
(T_Pattern_vOut118 _rightPatternIself) = inv_Pattern_s119 _rightPatternX119 (T_Pattern_vIn118 )
_self = rule273 _constructorOperatorIself _leftPatternIself _rangeIself _rightPatternIself
_lhsOself :: Pattern
_lhsOself = rule274 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule273 #-}
rule273 = \ ((_constructorOperatorIself) :: Name) ((_leftPatternIself) :: Pattern) ((_rangeIself) :: Range) ((_rightPatternIself) :: Pattern) ->
Pattern_InfixConstructor _rangeIself _leftPatternIself _constructorOperatorIself _rightPatternIself
{-# INLINE rule274 #-}
rule274 = \ _self ->
_self
{-# NOINLINE sem_Pattern_List #-}
sem_Pattern_List :: T_Range -> T_Patterns -> T_Pattern
sem_Pattern_List arg_range_ arg_patterns_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Patterns_vOut121 _patternsIself) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 )
_self = rule275 _patternsIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule276 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule275 #-}
rule275 = \ ((_patternsIself) :: Patterns) ((_rangeIself) :: Range) ->
Pattern_List _rangeIself _patternsIself
{-# INLINE rule276 #-}
rule276 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Tuple #-}
sem_Pattern_Tuple :: T_Range -> T_Patterns -> T_Pattern
sem_Pattern_Tuple arg_range_ arg_patterns_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Patterns_vOut121 _patternsIself) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 )
_self = rule277 _patternsIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule278 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule277 #-}
rule277 = \ ((_patternsIself) :: Patterns) ((_rangeIself) :: Range) ->
Pattern_Tuple _rangeIself _patternsIself
{-# INLINE rule278 #-}
rule278 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Record #-}
sem_Pattern_Record :: T_Range -> T_Name -> T_RecordPatternBindings -> T_Pattern
sem_Pattern_Record arg_range_ arg_name_ arg_recordPatternBindings_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_recordPatternBindingsX146 = Control.Monad.Identity.runIdentity (attach_T_RecordPatternBindings (arg_recordPatternBindings_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_RecordPatternBindings_vOut145 _recordPatternBindingsIself) = inv_RecordPatternBindings_s146 _recordPatternBindingsX146 (T_RecordPatternBindings_vIn145 )
_self = rule279 _nameIself _rangeIself _recordPatternBindingsIself
_lhsOself :: Pattern
_lhsOself = rule280 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule279 #-}
rule279 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ((_recordPatternBindingsIself) :: RecordPatternBindings) ->
Pattern_Record _rangeIself _nameIself _recordPatternBindingsIself
{-# INLINE rule280 #-}
rule280 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Negate #-}
sem_Pattern_Negate :: T_Range -> T_Literal -> T_Pattern
sem_Pattern_Negate arg_range_ arg_literal_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Literal_vOut85 _literalIself) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 )
_self = rule281 _literalIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule282 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule281 #-}
rule281 = \ ((_literalIself) :: Literal) ((_rangeIself) :: Range) ->
Pattern_Negate _rangeIself _literalIself
{-# INLINE rule282 #-}
rule282 = \ _self ->
_self
{-# NOINLINE sem_Pattern_As #-}
sem_Pattern_As :: T_Range -> T_Name -> T_Pattern -> T_Pattern
sem_Pattern_As arg_range_ arg_name_ arg_pattern_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Pattern_vOut118 _patternIself) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 )
_self = rule283 _nameIself _patternIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule284 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule283 #-}
rule283 = \ ((_nameIself) :: Name) ((_patternIself) :: Pattern) ((_rangeIself) :: Range) ->
Pattern_As _rangeIself _nameIself _patternIself
{-# INLINE rule284 #-}
rule284 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Wildcard #-}
sem_Pattern_Wildcard :: T_Range -> T_Pattern
sem_Pattern_Wildcard arg_range_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule285 _rangeIself
_lhsOself :: Pattern
_lhsOself = rule286 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule285 #-}
rule285 = \ ((_rangeIself) :: Range) ->
Pattern_Wildcard _rangeIself
{-# INLINE rule286 #-}
rule286 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Irrefutable #-}
sem_Pattern_Irrefutable :: T_Range -> T_Pattern -> T_Pattern
sem_Pattern_Irrefutable arg_range_ arg_pattern_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Pattern_vOut118 _patternIself) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 )
_self = rule287 _patternIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule288 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule287 #-}
rule287 = \ ((_patternIself) :: Pattern) ((_rangeIself) :: Range) ->
Pattern_Irrefutable _rangeIself _patternIself
{-# INLINE rule288 #-}
rule288 = \ _self ->
_self
{-# NOINLINE sem_Pattern_Successor #-}
sem_Pattern_Successor :: T_Range -> T_Name -> T_Literal -> T_Pattern
sem_Pattern_Successor arg_range_ arg_name_ arg_literal_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Literal_vOut85 _literalIself) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 )
_self = rule289 _literalIself _nameIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule290 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule289 #-}
rule289 = \ ((_literalIself) :: Literal) ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Pattern_Successor _rangeIself _nameIself _literalIself
{-# INLINE rule290 #-}
rule290 = \ _self ->
_self
{-# NOINLINE sem_Pattern_NegateFloat #-}
sem_Pattern_NegateFloat :: T_Range -> T_Literal -> T_Pattern
sem_Pattern_NegateFloat arg_range_ arg_literal_ = T_Pattern (return st119) where
{-# NOINLINE st119 #-}
st119 = let
v118 :: T_Pattern_v118
v118 = \ (T_Pattern_vIn118 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Literal_vOut85 _literalIself) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 )
_self = rule291 _literalIself _rangeIself
_lhsOself :: Pattern
_lhsOself = rule292 _self
__result_ = T_Pattern_vOut118 _lhsOself
in __result_ )
in C_Pattern_s119 v118
{-# INLINE rule291 #-}
rule291 = \ ((_literalIself) :: Literal) ((_rangeIself) :: Range) ->
Pattern_NegateFloat _rangeIself _literalIself
{-# INLINE rule292 #-}
rule292 = \ _self ->
_self
-- Patterns ----------------------------------------------------
-- wrapper
data Inh_Patterns = Inh_Patterns { }
data Syn_Patterns = Syn_Patterns { self_Syn_Patterns :: (Patterns) }
{-# INLINABLE wrap_Patterns #-}
wrap_Patterns :: T_Patterns -> Inh_Patterns -> (Syn_Patterns )
wrap_Patterns (T_Patterns act) (Inh_Patterns ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg121 = T_Patterns_vIn121
(T_Patterns_vOut121 _lhsOself) <- return (inv_Patterns_s122 sem arg121)
return (Syn_Patterns _lhsOself)
)
-- cata
{-# NOINLINE sem_Patterns #-}
sem_Patterns :: Patterns -> T_Patterns
sem_Patterns list = Prelude.foldr sem_Patterns_Cons sem_Patterns_Nil (Prelude.map sem_Pattern list)
-- semantic domain
newtype T_Patterns = T_Patterns {
attach_T_Patterns :: Identity (T_Patterns_s122 )
}
newtype T_Patterns_s122 = C_Patterns_s122 {
inv_Patterns_s122 :: (T_Patterns_v121 )
}
data T_Patterns_s123 = C_Patterns_s123
type T_Patterns_v121 = (T_Patterns_vIn121 ) -> (T_Patterns_vOut121 )
data T_Patterns_vIn121 = T_Patterns_vIn121
data T_Patterns_vOut121 = T_Patterns_vOut121 (Patterns)
{-# NOINLINE sem_Patterns_Cons #-}
sem_Patterns_Cons :: T_Pattern -> T_Patterns -> T_Patterns
sem_Patterns_Cons arg_hd_ arg_tl_ = T_Patterns (return st122) where
{-# NOINLINE st122 #-}
st122 = let
v121 :: T_Patterns_v121
v121 = \ (T_Patterns_vIn121 ) -> ( let
_hdX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_hd_))
_tlX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_tl_))
(T_Pattern_vOut118 _hdIself) = inv_Pattern_s119 _hdX119 (T_Pattern_vIn118 )
(T_Patterns_vOut121 _tlIself) = inv_Patterns_s122 _tlX122 (T_Patterns_vIn121 )
_self = rule293 _hdIself _tlIself
_lhsOself :: Patterns
_lhsOself = rule294 _self
__result_ = T_Patterns_vOut121 _lhsOself
in __result_ )
in C_Patterns_s122 v121
{-# INLINE rule293 #-}
rule293 = \ ((_hdIself) :: Pattern) ((_tlIself) :: Patterns) ->
(:) _hdIself _tlIself
{-# INLINE rule294 #-}
rule294 = \ _self ->
_self
{-# NOINLINE sem_Patterns_Nil #-}
sem_Patterns_Nil :: T_Patterns
sem_Patterns_Nil = T_Patterns (return st122) where
{-# NOINLINE st122 #-}
st122 = let
v121 :: T_Patterns_v121
v121 = \ (T_Patterns_vIn121 ) -> ( let
_self = rule295 ()
_lhsOself :: Patterns
_lhsOself = rule296 _self
__result_ = T_Patterns_vOut121 _lhsOself
in __result_ )
in C_Patterns_s122 v121
{-# INLINE rule295 #-}
rule295 = \ (_ :: ()) ->
[]
{-# INLINE rule296 #-}
rule296 = \ _self ->
_self
-- Position ----------------------------------------------------
-- wrapper
data Inh_Position = Inh_Position { }
data Syn_Position = Syn_Position { self_Syn_Position :: (Position) }
{-# INLINABLE wrap_Position #-}
wrap_Position :: T_Position -> Inh_Position -> (Syn_Position )
wrap_Position (T_Position act) (Inh_Position ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg124 = T_Position_vIn124
(T_Position_vOut124 _lhsOself) <- return (inv_Position_s125 sem arg124)
return (Syn_Position _lhsOself)
)
-- cata
{-# NOINLINE sem_Position #-}
sem_Position :: Position -> T_Position
sem_Position ( Position_Position filename_ line_ column_ ) = sem_Position_Position filename_ line_ column_
sem_Position ( Position_Unknown ) = sem_Position_Unknown
-- semantic domain
newtype T_Position = T_Position {
attach_T_Position :: Identity (T_Position_s125 )
}
newtype T_Position_s125 = C_Position_s125 {
inv_Position_s125 :: (T_Position_v124 )
}
data T_Position_s126 = C_Position_s126
type T_Position_v124 = (T_Position_vIn124 ) -> (T_Position_vOut124 )
data T_Position_vIn124 = T_Position_vIn124
data T_Position_vOut124 = T_Position_vOut124 (Position)
{-# NOINLINE sem_Position_Position #-}
sem_Position_Position :: (String) -> (Int) -> (Int) -> T_Position
sem_Position_Position arg_filename_ arg_line_ arg_column_ = T_Position (return st125) where
{-# NOINLINE st125 #-}
st125 = let
v124 :: T_Position_v124
v124 = \ (T_Position_vIn124 ) -> ( let
_self = rule297 arg_column_ arg_filename_ arg_line_
_lhsOself :: Position
_lhsOself = rule298 _self
__result_ = T_Position_vOut124 _lhsOself
in __result_ )
in C_Position_s125 v124
{-# INLINE rule297 #-}
rule297 = \ column_ filename_ line_ ->
Position_Position filename_ line_ column_
{-# INLINE rule298 #-}
rule298 = \ _self ->
_self
{-# NOINLINE sem_Position_Unknown #-}
sem_Position_Unknown :: T_Position
sem_Position_Unknown = T_Position (return st125) where
{-# NOINLINE st125 #-}
st125 = let
v124 :: T_Position_v124
v124 = \ (T_Position_vIn124 ) -> ( let
_self = rule299 ()
_lhsOself :: Position
_lhsOself = rule300 _self
__result_ = T_Position_vOut124 _lhsOself
in __result_ )
in C_Position_s125 v124
{-# INLINE rule299 #-}
rule299 = \ (_ :: ()) ->
Position_Unknown
{-# INLINE rule300 #-}
rule300 = \ _self ->
_self
-- Qualifier ---------------------------------------------------
-- wrapper
data Inh_Qualifier = Inh_Qualifier { }
data Syn_Qualifier = Syn_Qualifier { self_Syn_Qualifier :: (Qualifier) }
{-# INLINABLE wrap_Qualifier #-}
wrap_Qualifier :: T_Qualifier -> Inh_Qualifier -> (Syn_Qualifier )
wrap_Qualifier (T_Qualifier act) (Inh_Qualifier ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg127 = T_Qualifier_vIn127
(T_Qualifier_vOut127 _lhsOself) <- return (inv_Qualifier_s128 sem arg127)
return (Syn_Qualifier _lhsOself)
)
-- cata
{-# NOINLINE sem_Qualifier #-}
sem_Qualifier :: Qualifier -> T_Qualifier
sem_Qualifier ( Qualifier_Guard range_ guard_ ) = sem_Qualifier_Guard ( sem_Range range_ ) ( sem_Expression guard_ )
sem_Qualifier ( Qualifier_Let range_ declarations_ ) = sem_Qualifier_Let ( sem_Range range_ ) ( sem_Declarations declarations_ )
sem_Qualifier ( Qualifier_Generator range_ pattern_ expression_ ) = sem_Qualifier_Generator ( sem_Range range_ ) ( sem_Pattern pattern_ ) ( sem_Expression expression_ )
sem_Qualifier ( Qualifier_Empty range_ ) = sem_Qualifier_Empty ( sem_Range range_ )
-- semantic domain
newtype T_Qualifier = T_Qualifier {
attach_T_Qualifier :: Identity (T_Qualifier_s128 )
}
newtype T_Qualifier_s128 = C_Qualifier_s128 {
inv_Qualifier_s128 :: (T_Qualifier_v127 )
}
data T_Qualifier_s129 = C_Qualifier_s129
type T_Qualifier_v127 = (T_Qualifier_vIn127 ) -> (T_Qualifier_vOut127 )
data T_Qualifier_vIn127 = T_Qualifier_vIn127
data T_Qualifier_vOut127 = T_Qualifier_vOut127 (Qualifier)
{-# NOINLINE sem_Qualifier_Guard #-}
sem_Qualifier_Guard :: T_Range -> T_Expression -> T_Qualifier
sem_Qualifier_Guard arg_range_ arg_guard_ = T_Qualifier (return st128) where
{-# NOINLINE st128 #-}
st128 = let
v127 :: T_Qualifier_v127
v127 = \ (T_Qualifier_vIn127 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_guardX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_guard_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _guardIself) = inv_Expression_s41 _guardX41 (T_Expression_vIn40 )
_self = rule301 _guardIself _rangeIself
_lhsOself :: Qualifier
_lhsOself = rule302 _self
__result_ = T_Qualifier_vOut127 _lhsOself
in __result_ )
in C_Qualifier_s128 v127
{-# INLINE rule301 #-}
rule301 = \ ((_guardIself) :: Expression) ((_rangeIself) :: Range) ->
Qualifier_Guard _rangeIself _guardIself
{-# INLINE rule302 #-}
rule302 = \ _self ->
_self
{-# NOINLINE sem_Qualifier_Let #-}
sem_Qualifier_Let :: T_Range -> T_Declarations -> T_Qualifier
sem_Qualifier_Let arg_range_ arg_declarations_ = T_Qualifier (return st128) where
{-# NOINLINE st128 #-}
st128 = let
v127 :: T_Qualifier_v127
v127 = \ (T_Qualifier_vIn127 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Declarations_vOut31 _declarationsIself) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 )
_self = rule303 _declarationsIself _rangeIself
_lhsOself :: Qualifier
_lhsOself = rule304 _self
__result_ = T_Qualifier_vOut127 _lhsOself
in __result_ )
in C_Qualifier_s128 v127
{-# INLINE rule303 #-}
rule303 = \ ((_declarationsIself) :: Declarations) ((_rangeIself) :: Range) ->
Qualifier_Let _rangeIself _declarationsIself
{-# INLINE rule304 #-}
rule304 = \ _self ->
_self
{-# NOINLINE sem_Qualifier_Generator #-}
sem_Qualifier_Generator :: T_Range -> T_Pattern -> T_Expression -> T_Qualifier
sem_Qualifier_Generator arg_range_ arg_pattern_ arg_expression_ = T_Qualifier (return st128) where
{-# NOINLINE st128 #-}
st128 = let
v127 :: T_Qualifier_v127
v127 = \ (T_Qualifier_vIn127 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Pattern_vOut118 _patternIself) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule305 _expressionIself _patternIself _rangeIself
_lhsOself :: Qualifier
_lhsOself = rule306 _self
__result_ = T_Qualifier_vOut127 _lhsOself
in __result_ )
in C_Qualifier_s128 v127
{-# INLINE rule305 #-}
rule305 = \ ((_expressionIself) :: Expression) ((_patternIself) :: Pattern) ((_rangeIself) :: Range) ->
Qualifier_Generator _rangeIself _patternIself _expressionIself
{-# INLINE rule306 #-}
rule306 = \ _self ->
_self
{-# NOINLINE sem_Qualifier_Empty #-}
sem_Qualifier_Empty :: T_Range -> T_Qualifier
sem_Qualifier_Empty arg_range_ = T_Qualifier (return st128) where
{-# NOINLINE st128 #-}
st128 = let
v127 :: T_Qualifier_v127
v127 = \ (T_Qualifier_vIn127 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule307 _rangeIself
_lhsOself :: Qualifier
_lhsOself = rule308 _self
__result_ = T_Qualifier_vOut127 _lhsOself
in __result_ )
in C_Qualifier_s128 v127
{-# INLINE rule307 #-}
rule307 = \ ((_rangeIself) :: Range) ->
Qualifier_Empty _rangeIself
{-# INLINE rule308 #-}
rule308 = \ _self ->
_self
-- Qualifiers --------------------------------------------------
-- wrapper
data Inh_Qualifiers = Inh_Qualifiers { }
data Syn_Qualifiers = Syn_Qualifiers { self_Syn_Qualifiers :: (Qualifiers) }
{-# INLINABLE wrap_Qualifiers #-}
wrap_Qualifiers :: T_Qualifiers -> Inh_Qualifiers -> (Syn_Qualifiers )
wrap_Qualifiers (T_Qualifiers act) (Inh_Qualifiers ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg130 = T_Qualifiers_vIn130
(T_Qualifiers_vOut130 _lhsOself) <- return (inv_Qualifiers_s131 sem arg130)
return (Syn_Qualifiers _lhsOself)
)
-- cata
{-# NOINLINE sem_Qualifiers #-}
sem_Qualifiers :: Qualifiers -> T_Qualifiers
sem_Qualifiers list = Prelude.foldr sem_Qualifiers_Cons sem_Qualifiers_Nil (Prelude.map sem_Qualifier list)
-- semantic domain
newtype T_Qualifiers = T_Qualifiers {
attach_T_Qualifiers :: Identity (T_Qualifiers_s131 )
}
newtype T_Qualifiers_s131 = C_Qualifiers_s131 {
inv_Qualifiers_s131 :: (T_Qualifiers_v130 )
}
data T_Qualifiers_s132 = C_Qualifiers_s132
type T_Qualifiers_v130 = (T_Qualifiers_vIn130 ) -> (T_Qualifiers_vOut130 )
data T_Qualifiers_vIn130 = T_Qualifiers_vIn130
data T_Qualifiers_vOut130 = T_Qualifiers_vOut130 (Qualifiers)
{-# NOINLINE sem_Qualifiers_Cons #-}
sem_Qualifiers_Cons :: T_Qualifier -> T_Qualifiers -> T_Qualifiers
sem_Qualifiers_Cons arg_hd_ arg_tl_ = T_Qualifiers (return st131) where
{-# NOINLINE st131 #-}
st131 = let
v130 :: T_Qualifiers_v130
v130 = \ (T_Qualifiers_vIn130 ) -> ( let
_hdX128 = Control.Monad.Identity.runIdentity (attach_T_Qualifier (arg_hd_))
_tlX131 = Control.Monad.Identity.runIdentity (attach_T_Qualifiers (arg_tl_))
(T_Qualifier_vOut127 _hdIself) = inv_Qualifier_s128 _hdX128 (T_Qualifier_vIn127 )
(T_Qualifiers_vOut130 _tlIself) = inv_Qualifiers_s131 _tlX131 (T_Qualifiers_vIn130 )
_self = rule309 _hdIself _tlIself
_lhsOself :: Qualifiers
_lhsOself = rule310 _self
__result_ = T_Qualifiers_vOut130 _lhsOself
in __result_ )
in C_Qualifiers_s131 v130
{-# INLINE rule309 #-}
rule309 = \ ((_hdIself) :: Qualifier) ((_tlIself) :: Qualifiers) ->
(:) _hdIself _tlIself
{-# INLINE rule310 #-}
rule310 = \ _self ->
_self
{-# NOINLINE sem_Qualifiers_Nil #-}
sem_Qualifiers_Nil :: T_Qualifiers
sem_Qualifiers_Nil = T_Qualifiers (return st131) where
{-# NOINLINE st131 #-}
st131 = let
v130 :: T_Qualifiers_v130
v130 = \ (T_Qualifiers_vIn130 ) -> ( let
_self = rule311 ()
_lhsOself :: Qualifiers
_lhsOself = rule312 _self
__result_ = T_Qualifiers_vOut130 _lhsOself
in __result_ )
in C_Qualifiers_s131 v130
{-# INLINE rule311 #-}
rule311 = \ (_ :: ()) ->
[]
{-# INLINE rule312 #-}
rule312 = \ _self ->
_self
-- Range -------------------------------------------------------
-- wrapper
data Inh_Range = Inh_Range { }
data Syn_Range = Syn_Range { self_Syn_Range :: (Range) }
{-# INLINABLE wrap_Range #-}
wrap_Range :: T_Range -> Inh_Range -> (Syn_Range )
wrap_Range (T_Range act) (Inh_Range ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg133 = T_Range_vIn133
(T_Range_vOut133 _lhsOself) <- return (inv_Range_s134 sem arg133)
return (Syn_Range _lhsOself)
)
-- cata
{-# INLINE sem_Range #-}
sem_Range :: Range -> T_Range
sem_Range ( Range_Range start_ stop_ ) = sem_Range_Range ( sem_Position start_ ) ( sem_Position stop_ )
-- semantic domain
newtype T_Range = T_Range {
attach_T_Range :: Identity (T_Range_s134 )
}
newtype T_Range_s134 = C_Range_s134 {
inv_Range_s134 :: (T_Range_v133 )
}
data T_Range_s135 = C_Range_s135
type T_Range_v133 = (T_Range_vIn133 ) -> (T_Range_vOut133 )
data T_Range_vIn133 = T_Range_vIn133
data T_Range_vOut133 = T_Range_vOut133 (Range)
{-# NOINLINE sem_Range_Range #-}
sem_Range_Range :: T_Position -> T_Position -> T_Range
sem_Range_Range arg_start_ arg_stop_ = T_Range (return st134) where
{-# NOINLINE st134 #-}
st134 = let
v133 :: T_Range_v133
v133 = \ (T_Range_vIn133 ) -> ( let
_startX125 = Control.Monad.Identity.runIdentity (attach_T_Position (arg_start_))
_stopX125 = Control.Monad.Identity.runIdentity (attach_T_Position (arg_stop_))
(T_Position_vOut124 _startIself) = inv_Position_s125 _startX125 (T_Position_vIn124 )
(T_Position_vOut124 _stopIself) = inv_Position_s125 _stopX125 (T_Position_vIn124 )
_self = rule313 _startIself _stopIself
_lhsOself :: Range
_lhsOself = rule314 _self
__result_ = T_Range_vOut133 _lhsOself
in __result_ )
in C_Range_s134 v133
{-# INLINE rule313 #-}
rule313 = \ ((_startIself) :: Position) ((_stopIself) :: Position) ->
Range_Range _startIself _stopIself
{-# INLINE rule314 #-}
rule314 = \ _self ->
_self
-- RecordExpressionBinding -------------------------------------
-- wrapper
data Inh_RecordExpressionBinding = Inh_RecordExpressionBinding { }
data Syn_RecordExpressionBinding = Syn_RecordExpressionBinding { self_Syn_RecordExpressionBinding :: (RecordExpressionBinding) }
{-# INLINABLE wrap_RecordExpressionBinding #-}
wrap_RecordExpressionBinding :: T_RecordExpressionBinding -> Inh_RecordExpressionBinding -> (Syn_RecordExpressionBinding )
wrap_RecordExpressionBinding (T_RecordExpressionBinding act) (Inh_RecordExpressionBinding ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg136 = T_RecordExpressionBinding_vIn136
(T_RecordExpressionBinding_vOut136 _lhsOself) <- return (inv_RecordExpressionBinding_s137 sem arg136)
return (Syn_RecordExpressionBinding _lhsOself)
)
-- cata
{-# NOINLINE sem_RecordExpressionBinding #-}
sem_RecordExpressionBinding :: RecordExpressionBinding -> T_RecordExpressionBinding
sem_RecordExpressionBinding ( RecordExpressionBinding_RecordExpressionBinding range_ name_ expression_ ) = sem_RecordExpressionBinding_RecordExpressionBinding ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Expression expression_ )
-- semantic domain
newtype T_RecordExpressionBinding = T_RecordExpressionBinding {
attach_T_RecordExpressionBinding :: Identity (T_RecordExpressionBinding_s137 )
}
newtype T_RecordExpressionBinding_s137 = C_RecordExpressionBinding_s137 {
inv_RecordExpressionBinding_s137 :: (T_RecordExpressionBinding_v136 )
}
data T_RecordExpressionBinding_s138 = C_RecordExpressionBinding_s138
type T_RecordExpressionBinding_v136 = (T_RecordExpressionBinding_vIn136 ) -> (T_RecordExpressionBinding_vOut136 )
data T_RecordExpressionBinding_vIn136 = T_RecordExpressionBinding_vIn136
data T_RecordExpressionBinding_vOut136 = T_RecordExpressionBinding_vOut136 (RecordExpressionBinding)
{-# NOINLINE sem_RecordExpressionBinding_RecordExpressionBinding #-}
sem_RecordExpressionBinding_RecordExpressionBinding :: T_Range -> T_Name -> T_Expression -> T_RecordExpressionBinding
sem_RecordExpressionBinding_RecordExpressionBinding arg_range_ arg_name_ arg_expression_ = T_RecordExpressionBinding (return st137) where
{-# NOINLINE st137 #-}
st137 = let
v136 :: T_RecordExpressionBinding_v136
v136 = \ (T_RecordExpressionBinding_vIn136 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule315 _expressionIself _nameIself _rangeIself
_lhsOself :: RecordExpressionBinding
_lhsOself = rule316 _self
__result_ = T_RecordExpressionBinding_vOut136 _lhsOself
in __result_ )
in C_RecordExpressionBinding_s137 v136
{-# INLINE rule315 #-}
rule315 = \ ((_expressionIself) :: Expression) ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
RecordExpressionBinding_RecordExpressionBinding _rangeIself _nameIself _expressionIself
{-# INLINE rule316 #-}
rule316 = \ _self ->
_self
-- RecordExpressionBindings ------------------------------------
-- wrapper
data Inh_RecordExpressionBindings = Inh_RecordExpressionBindings { }
data Syn_RecordExpressionBindings = Syn_RecordExpressionBindings { self_Syn_RecordExpressionBindings :: (RecordExpressionBindings) }
{-# INLINABLE wrap_RecordExpressionBindings #-}
wrap_RecordExpressionBindings :: T_RecordExpressionBindings -> Inh_RecordExpressionBindings -> (Syn_RecordExpressionBindings )
wrap_RecordExpressionBindings (T_RecordExpressionBindings act) (Inh_RecordExpressionBindings ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg139 = T_RecordExpressionBindings_vIn139
(T_RecordExpressionBindings_vOut139 _lhsOself) <- return (inv_RecordExpressionBindings_s140 sem arg139)
return (Syn_RecordExpressionBindings _lhsOself)
)
-- cata
{-# NOINLINE sem_RecordExpressionBindings #-}
sem_RecordExpressionBindings :: RecordExpressionBindings -> T_RecordExpressionBindings
sem_RecordExpressionBindings list = Prelude.foldr sem_RecordExpressionBindings_Cons sem_RecordExpressionBindings_Nil (Prelude.map sem_RecordExpressionBinding list)
-- semantic domain
newtype T_RecordExpressionBindings = T_RecordExpressionBindings {
attach_T_RecordExpressionBindings :: Identity (T_RecordExpressionBindings_s140 )
}
newtype T_RecordExpressionBindings_s140 = C_RecordExpressionBindings_s140 {
inv_RecordExpressionBindings_s140 :: (T_RecordExpressionBindings_v139 )
}
data T_RecordExpressionBindings_s141 = C_RecordExpressionBindings_s141
type T_RecordExpressionBindings_v139 = (T_RecordExpressionBindings_vIn139 ) -> (T_RecordExpressionBindings_vOut139 )
data T_RecordExpressionBindings_vIn139 = T_RecordExpressionBindings_vIn139
data T_RecordExpressionBindings_vOut139 = T_RecordExpressionBindings_vOut139 (RecordExpressionBindings)
{-# NOINLINE sem_RecordExpressionBindings_Cons #-}
sem_RecordExpressionBindings_Cons :: T_RecordExpressionBinding -> T_RecordExpressionBindings -> T_RecordExpressionBindings
sem_RecordExpressionBindings_Cons arg_hd_ arg_tl_ = T_RecordExpressionBindings (return st140) where
{-# NOINLINE st140 #-}
st140 = let
v139 :: T_RecordExpressionBindings_v139
v139 = \ (T_RecordExpressionBindings_vIn139 ) -> ( let
_hdX137 = Control.Monad.Identity.runIdentity (attach_T_RecordExpressionBinding (arg_hd_))
_tlX140 = Control.Monad.Identity.runIdentity (attach_T_RecordExpressionBindings (arg_tl_))
(T_RecordExpressionBinding_vOut136 _hdIself) = inv_RecordExpressionBinding_s137 _hdX137 (T_RecordExpressionBinding_vIn136 )
(T_RecordExpressionBindings_vOut139 _tlIself) = inv_RecordExpressionBindings_s140 _tlX140 (T_RecordExpressionBindings_vIn139 )
_self = rule317 _hdIself _tlIself
_lhsOself :: RecordExpressionBindings
_lhsOself = rule318 _self
__result_ = T_RecordExpressionBindings_vOut139 _lhsOself
in __result_ )
in C_RecordExpressionBindings_s140 v139
{-# INLINE rule317 #-}
rule317 = \ ((_hdIself) :: RecordExpressionBinding) ((_tlIself) :: RecordExpressionBindings) ->
(:) _hdIself _tlIself
{-# INLINE rule318 #-}
rule318 = \ _self ->
_self
{-# NOINLINE sem_RecordExpressionBindings_Nil #-}
sem_RecordExpressionBindings_Nil :: T_RecordExpressionBindings
sem_RecordExpressionBindings_Nil = T_RecordExpressionBindings (return st140) where
{-# NOINLINE st140 #-}
st140 = let
v139 :: T_RecordExpressionBindings_v139
v139 = \ (T_RecordExpressionBindings_vIn139 ) -> ( let
_self = rule319 ()
_lhsOself :: RecordExpressionBindings
_lhsOself = rule320 _self
__result_ = T_RecordExpressionBindings_vOut139 _lhsOself
in __result_ )
in C_RecordExpressionBindings_s140 v139
{-# INLINE rule319 #-}
rule319 = \ (_ :: ()) ->
[]
{-# INLINE rule320 #-}
rule320 = \ _self ->
_self
-- RecordPatternBinding ----------------------------------------
-- wrapper
data Inh_RecordPatternBinding = Inh_RecordPatternBinding { }
data Syn_RecordPatternBinding = Syn_RecordPatternBinding { self_Syn_RecordPatternBinding :: (RecordPatternBinding) }
{-# INLINABLE wrap_RecordPatternBinding #-}
wrap_RecordPatternBinding :: T_RecordPatternBinding -> Inh_RecordPatternBinding -> (Syn_RecordPatternBinding )
wrap_RecordPatternBinding (T_RecordPatternBinding act) (Inh_RecordPatternBinding ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg142 = T_RecordPatternBinding_vIn142
(T_RecordPatternBinding_vOut142 _lhsOself) <- return (inv_RecordPatternBinding_s143 sem arg142)
return (Syn_RecordPatternBinding _lhsOself)
)
-- cata
{-# NOINLINE sem_RecordPatternBinding #-}
sem_RecordPatternBinding :: RecordPatternBinding -> T_RecordPatternBinding
sem_RecordPatternBinding ( RecordPatternBinding_RecordPatternBinding range_ name_ pattern_ ) = sem_RecordPatternBinding_RecordPatternBinding ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Pattern pattern_ )
-- semantic domain
newtype T_RecordPatternBinding = T_RecordPatternBinding {
attach_T_RecordPatternBinding :: Identity (T_RecordPatternBinding_s143 )
}
newtype T_RecordPatternBinding_s143 = C_RecordPatternBinding_s143 {
inv_RecordPatternBinding_s143 :: (T_RecordPatternBinding_v142 )
}
data T_RecordPatternBinding_s144 = C_RecordPatternBinding_s144
type T_RecordPatternBinding_v142 = (T_RecordPatternBinding_vIn142 ) -> (T_RecordPatternBinding_vOut142 )
data T_RecordPatternBinding_vIn142 = T_RecordPatternBinding_vIn142
data T_RecordPatternBinding_vOut142 = T_RecordPatternBinding_vOut142 (RecordPatternBinding)
{-# NOINLINE sem_RecordPatternBinding_RecordPatternBinding #-}
sem_RecordPatternBinding_RecordPatternBinding :: T_Range -> T_Name -> T_Pattern -> T_RecordPatternBinding
sem_RecordPatternBinding_RecordPatternBinding arg_range_ arg_name_ arg_pattern_ = T_RecordPatternBinding (return st143) where
{-# NOINLINE st143 #-}
st143 = let
v142 :: T_RecordPatternBinding_v142
v142 = \ (T_RecordPatternBinding_vIn142 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Pattern_vOut118 _patternIself) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 )
_self = rule321 _nameIself _patternIself _rangeIself
_lhsOself :: RecordPatternBinding
_lhsOself = rule322 _self
__result_ = T_RecordPatternBinding_vOut142 _lhsOself
in __result_ )
in C_RecordPatternBinding_s143 v142
{-# INLINE rule321 #-}
rule321 = \ ((_nameIself) :: Name) ((_patternIself) :: Pattern) ((_rangeIself) :: Range) ->
RecordPatternBinding_RecordPatternBinding _rangeIself _nameIself _patternIself
{-# INLINE rule322 #-}
rule322 = \ _self ->
_self
-- RecordPatternBindings ---------------------------------------
-- wrapper
data Inh_RecordPatternBindings = Inh_RecordPatternBindings { }
data Syn_RecordPatternBindings = Syn_RecordPatternBindings { self_Syn_RecordPatternBindings :: (RecordPatternBindings) }
{-# INLINABLE wrap_RecordPatternBindings #-}
wrap_RecordPatternBindings :: T_RecordPatternBindings -> Inh_RecordPatternBindings -> (Syn_RecordPatternBindings )
wrap_RecordPatternBindings (T_RecordPatternBindings act) (Inh_RecordPatternBindings ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg145 = T_RecordPatternBindings_vIn145
(T_RecordPatternBindings_vOut145 _lhsOself) <- return (inv_RecordPatternBindings_s146 sem arg145)
return (Syn_RecordPatternBindings _lhsOself)
)
-- cata
{-# NOINLINE sem_RecordPatternBindings #-}
sem_RecordPatternBindings :: RecordPatternBindings -> T_RecordPatternBindings
sem_RecordPatternBindings list = Prelude.foldr sem_RecordPatternBindings_Cons sem_RecordPatternBindings_Nil (Prelude.map sem_RecordPatternBinding list)
-- semantic domain
newtype T_RecordPatternBindings = T_RecordPatternBindings {
attach_T_RecordPatternBindings :: Identity (T_RecordPatternBindings_s146 )
}
newtype T_RecordPatternBindings_s146 = C_RecordPatternBindings_s146 {
inv_RecordPatternBindings_s146 :: (T_RecordPatternBindings_v145 )
}
data T_RecordPatternBindings_s147 = C_RecordPatternBindings_s147
type T_RecordPatternBindings_v145 = (T_RecordPatternBindings_vIn145 ) -> (T_RecordPatternBindings_vOut145 )
data T_RecordPatternBindings_vIn145 = T_RecordPatternBindings_vIn145
data T_RecordPatternBindings_vOut145 = T_RecordPatternBindings_vOut145 (RecordPatternBindings)
{-# NOINLINE sem_RecordPatternBindings_Cons #-}
sem_RecordPatternBindings_Cons :: T_RecordPatternBinding -> T_RecordPatternBindings -> T_RecordPatternBindings
sem_RecordPatternBindings_Cons arg_hd_ arg_tl_ = T_RecordPatternBindings (return st146) where
{-# NOINLINE st146 #-}
st146 = let
v145 :: T_RecordPatternBindings_v145
v145 = \ (T_RecordPatternBindings_vIn145 ) -> ( let
_hdX143 = Control.Monad.Identity.runIdentity (attach_T_RecordPatternBinding (arg_hd_))
_tlX146 = Control.Monad.Identity.runIdentity (attach_T_RecordPatternBindings (arg_tl_))
(T_RecordPatternBinding_vOut142 _hdIself) = inv_RecordPatternBinding_s143 _hdX143 (T_RecordPatternBinding_vIn142 )
(T_RecordPatternBindings_vOut145 _tlIself) = inv_RecordPatternBindings_s146 _tlX146 (T_RecordPatternBindings_vIn145 )
_self = rule323 _hdIself _tlIself
_lhsOself :: RecordPatternBindings
_lhsOself = rule324 _self
__result_ = T_RecordPatternBindings_vOut145 _lhsOself
in __result_ )
in C_RecordPatternBindings_s146 v145
{-# INLINE rule323 #-}
rule323 = \ ((_hdIself) :: RecordPatternBinding) ((_tlIself) :: RecordPatternBindings) ->
(:) _hdIself _tlIself
{-# INLINE rule324 #-}
rule324 = \ _self ->
_self
{-# NOINLINE sem_RecordPatternBindings_Nil #-}
sem_RecordPatternBindings_Nil :: T_RecordPatternBindings
sem_RecordPatternBindings_Nil = T_RecordPatternBindings (return st146) where
{-# NOINLINE st146 #-}
st146 = let
v145 :: T_RecordPatternBindings_v145
v145 = \ (T_RecordPatternBindings_vIn145 ) -> ( let
_self = rule325 ()
_lhsOself :: RecordPatternBindings
_lhsOself = rule326 _self
__result_ = T_RecordPatternBindings_vOut145 _lhsOself
in __result_ )
in C_RecordPatternBindings_s146 v145
{-# INLINE rule325 #-}
rule325 = \ (_ :: ()) ->
[]
{-# INLINE rule326 #-}
rule326 = \ _self ->
_self
-- RightHandSide -----------------------------------------------
-- wrapper
data Inh_RightHandSide = Inh_RightHandSide { }
data Syn_RightHandSide = Syn_RightHandSide { self_Syn_RightHandSide :: (RightHandSide) }
{-# INLINABLE wrap_RightHandSide #-}
wrap_RightHandSide :: T_RightHandSide -> Inh_RightHandSide -> (Syn_RightHandSide )
wrap_RightHandSide (T_RightHandSide act) (Inh_RightHandSide ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg148 = T_RightHandSide_vIn148
(T_RightHandSide_vOut148 _lhsOself) <- return (inv_RightHandSide_s149 sem arg148)
return (Syn_RightHandSide _lhsOself)
)
-- cata
{-# NOINLINE sem_RightHandSide #-}
sem_RightHandSide :: RightHandSide -> T_RightHandSide
sem_RightHandSide ( RightHandSide_Expression range_ expression_ where_ ) = sem_RightHandSide_Expression ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_MaybeDeclarations where_ )
sem_RightHandSide ( RightHandSide_Guarded range_ guardedexpressions_ where_ ) = sem_RightHandSide_Guarded ( sem_Range range_ ) ( sem_GuardedExpressions guardedexpressions_ ) ( sem_MaybeDeclarations where_ )
-- semantic domain
newtype T_RightHandSide = T_RightHandSide {
attach_T_RightHandSide :: Identity (T_RightHandSide_s149 )
}
newtype T_RightHandSide_s149 = C_RightHandSide_s149 {
inv_RightHandSide_s149 :: (T_RightHandSide_v148 )
}
data T_RightHandSide_s150 = C_RightHandSide_s150
type T_RightHandSide_v148 = (T_RightHandSide_vIn148 ) -> (T_RightHandSide_vOut148 )
data T_RightHandSide_vIn148 = T_RightHandSide_vIn148
data T_RightHandSide_vOut148 = T_RightHandSide_vOut148 (RightHandSide)
{-# NOINLINE sem_RightHandSide_Expression #-}
sem_RightHandSide_Expression :: T_Range -> T_Expression -> T_MaybeDeclarations -> T_RightHandSide
sem_RightHandSide_Expression arg_range_ arg_expression_ arg_where_ = T_RightHandSide (return st149) where
{-# NOINLINE st149 #-}
st149 = let
v148 :: T_RightHandSide_v148
v148 = \ (T_RightHandSide_vIn148 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
_whereX89 = Control.Monad.Identity.runIdentity (attach_T_MaybeDeclarations (arg_where_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
(T_MaybeDeclarations_vOut88 _whereIself) = inv_MaybeDeclarations_s89 _whereX89 (T_MaybeDeclarations_vIn88 )
_self = rule327 _expressionIself _rangeIself _whereIself
_lhsOself :: RightHandSide
_lhsOself = rule328 _self
__result_ = T_RightHandSide_vOut148 _lhsOself
in __result_ )
in C_RightHandSide_s149 v148
{-# INLINE rule327 #-}
rule327 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ((_whereIself) :: MaybeDeclarations) ->
RightHandSide_Expression _rangeIself _expressionIself _whereIself
{-# INLINE rule328 #-}
rule328 = \ _self ->
_self
{-# NOINLINE sem_RightHandSide_Guarded #-}
sem_RightHandSide_Guarded :: T_Range -> T_GuardedExpressions -> T_MaybeDeclarations -> T_RightHandSide
sem_RightHandSide_Guarded arg_range_ arg_guardedexpressions_ arg_where_ = T_RightHandSide (return st149) where
{-# NOINLINE st149 #-}
st149 = let
v148 :: T_RightHandSide_v148
v148 = \ (T_RightHandSide_vIn148 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_guardedexpressionsX65 = Control.Monad.Identity.runIdentity (attach_T_GuardedExpressions (arg_guardedexpressions_))
_whereX89 = Control.Monad.Identity.runIdentity (attach_T_MaybeDeclarations (arg_where_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_GuardedExpressions_vOut64 _guardedexpressionsIself) = inv_GuardedExpressions_s65 _guardedexpressionsX65 (T_GuardedExpressions_vIn64 )
(T_MaybeDeclarations_vOut88 _whereIself) = inv_MaybeDeclarations_s89 _whereX89 (T_MaybeDeclarations_vIn88 )
_self = rule329 _guardedexpressionsIself _rangeIself _whereIself
_lhsOself :: RightHandSide
_lhsOself = rule330 _self
__result_ = T_RightHandSide_vOut148 _lhsOself
in __result_ )
in C_RightHandSide_s149 v148
{-# INLINE rule329 #-}
rule329 = \ ((_guardedexpressionsIself) :: GuardedExpressions) ((_rangeIself) :: Range) ((_whereIself) :: MaybeDeclarations) ->
RightHandSide_Guarded _rangeIself _guardedexpressionsIself _whereIself
{-# INLINE rule330 #-}
rule330 = \ _self ->
_self
-- SimpleType --------------------------------------------------
-- wrapper
data Inh_SimpleType = Inh_SimpleType { }
data Syn_SimpleType = Syn_SimpleType { self_Syn_SimpleType :: (SimpleType) }
{-# INLINABLE wrap_SimpleType #-}
wrap_SimpleType :: T_SimpleType -> Inh_SimpleType -> (Syn_SimpleType )
wrap_SimpleType (T_SimpleType act) (Inh_SimpleType ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg151 = T_SimpleType_vIn151
(T_SimpleType_vOut151 _lhsOself) <- return (inv_SimpleType_s152 sem arg151)
return (Syn_SimpleType _lhsOself)
)
-- cata
{-# INLINE sem_SimpleType #-}
sem_SimpleType :: SimpleType -> T_SimpleType
sem_SimpleType ( SimpleType_SimpleType range_ name_ typevariables_ ) = sem_SimpleType_SimpleType ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Names typevariables_ )
-- semantic domain
newtype T_SimpleType = T_SimpleType {
attach_T_SimpleType :: Identity (T_SimpleType_s152 )
}
newtype T_SimpleType_s152 = C_SimpleType_s152 {
inv_SimpleType_s152 :: (T_SimpleType_v151 )
}
data T_SimpleType_s153 = C_SimpleType_s153
type T_SimpleType_v151 = (T_SimpleType_vIn151 ) -> (T_SimpleType_vOut151 )
data T_SimpleType_vIn151 = T_SimpleType_vIn151
data T_SimpleType_vOut151 = T_SimpleType_vOut151 (SimpleType)
{-# NOINLINE sem_SimpleType_SimpleType #-}
sem_SimpleType_SimpleType :: T_Range -> T_Name -> T_Names -> T_SimpleType
sem_SimpleType_SimpleType arg_range_ arg_name_ arg_typevariables_ = T_SimpleType (return st152) where
{-# NOINLINE st152 #-}
st152 = let
v151 :: T_SimpleType_v151
v151 = \ (T_SimpleType_vIn151 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
_typevariablesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_typevariables_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
(T_Names_vOut115 _typevariablesInames _typevariablesIself) = inv_Names_s116 _typevariablesX116 (T_Names_vIn115 )
_self = rule331 _nameIself _rangeIself _typevariablesIself
_lhsOself :: SimpleType
_lhsOself = rule332 _self
__result_ = T_SimpleType_vOut151 _lhsOself
in __result_ )
in C_SimpleType_s152 v151
{-# INLINE rule331 #-}
rule331 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ((_typevariablesIself) :: Names) ->
SimpleType_SimpleType _rangeIself _nameIself _typevariablesIself
{-# INLINE rule332 #-}
rule332 = \ _self ->
_self
-- Statement ---------------------------------------------------
-- wrapper
data Inh_Statement = Inh_Statement { }
data Syn_Statement = Syn_Statement { self_Syn_Statement :: (Statement) }
{-# INLINABLE wrap_Statement #-}
wrap_Statement :: T_Statement -> Inh_Statement -> (Syn_Statement )
wrap_Statement (T_Statement act) (Inh_Statement ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg154 = T_Statement_vIn154
(T_Statement_vOut154 _lhsOself) <- return (inv_Statement_s155 sem arg154)
return (Syn_Statement _lhsOself)
)
-- cata
{-# NOINLINE sem_Statement #-}
sem_Statement :: Statement -> T_Statement
sem_Statement ( Statement_Expression range_ expression_ ) = sem_Statement_Expression ( sem_Range range_ ) ( sem_Expression expression_ )
sem_Statement ( Statement_Let range_ declarations_ ) = sem_Statement_Let ( sem_Range range_ ) ( sem_Declarations declarations_ )
sem_Statement ( Statement_Generator range_ pattern_ expression_ ) = sem_Statement_Generator ( sem_Range range_ ) ( sem_Pattern pattern_ ) ( sem_Expression expression_ )
sem_Statement ( Statement_Empty range_ ) = sem_Statement_Empty ( sem_Range range_ )
-- semantic domain
newtype T_Statement = T_Statement {
attach_T_Statement :: Identity (T_Statement_s155 )
}
newtype T_Statement_s155 = C_Statement_s155 {
inv_Statement_s155 :: (T_Statement_v154 )
}
data T_Statement_s156 = C_Statement_s156
type T_Statement_v154 = (T_Statement_vIn154 ) -> (T_Statement_vOut154 )
data T_Statement_vIn154 = T_Statement_vIn154
data T_Statement_vOut154 = T_Statement_vOut154 (Statement)
{-# NOINLINE sem_Statement_Expression #-}
sem_Statement_Expression :: T_Range -> T_Expression -> T_Statement
sem_Statement_Expression arg_range_ arg_expression_ = T_Statement (return st155) where
{-# NOINLINE st155 #-}
st155 = let
v154 :: T_Statement_v154
v154 = \ (T_Statement_vIn154 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule333 _expressionIself _rangeIself
_lhsOself :: Statement
_lhsOself = rule334 _self
__result_ = T_Statement_vOut154 _lhsOself
in __result_ )
in C_Statement_s155 v154
{-# INLINE rule333 #-}
rule333 = \ ((_expressionIself) :: Expression) ((_rangeIself) :: Range) ->
Statement_Expression _rangeIself _expressionIself
{-# INLINE rule334 #-}
rule334 = \ _self ->
_self
{-# NOINLINE sem_Statement_Let #-}
sem_Statement_Let :: T_Range -> T_Declarations -> T_Statement
sem_Statement_Let arg_range_ arg_declarations_ = T_Statement (return st155) where
{-# NOINLINE st155 #-}
st155 = let
v154 :: T_Statement_v154
v154 = \ (T_Statement_vIn154 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Declarations_vOut31 _declarationsIself) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 )
_self = rule335 _declarationsIself _rangeIself
_lhsOself :: Statement
_lhsOself = rule336 _self
__result_ = T_Statement_vOut154 _lhsOself
in __result_ )
in C_Statement_s155 v154
{-# INLINE rule335 #-}
rule335 = \ ((_declarationsIself) :: Declarations) ((_rangeIself) :: Range) ->
Statement_Let _rangeIself _declarationsIself
{-# INLINE rule336 #-}
rule336 = \ _self ->
_self
{-# NOINLINE sem_Statement_Generator #-}
sem_Statement_Generator :: T_Range -> T_Pattern -> T_Expression -> T_Statement
sem_Statement_Generator arg_range_ arg_pattern_ arg_expression_ = T_Statement (return st155) where
{-# NOINLINE st155 #-}
st155 = let
v154 :: T_Statement_v154
v154 = \ (T_Statement_vIn154 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_))
_expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Pattern_vOut118 _patternIself) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 )
(T_Expression_vOut40 _expressionIself) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 )
_self = rule337 _expressionIself _patternIself _rangeIself
_lhsOself :: Statement
_lhsOself = rule338 _self
__result_ = T_Statement_vOut154 _lhsOself
in __result_ )
in C_Statement_s155 v154
{-# INLINE rule337 #-}
rule337 = \ ((_expressionIself) :: Expression) ((_patternIself) :: Pattern) ((_rangeIself) :: Range) ->
Statement_Generator _rangeIself _patternIself _expressionIself
{-# INLINE rule338 #-}
rule338 = \ _self ->
_self
{-# NOINLINE sem_Statement_Empty #-}
sem_Statement_Empty :: T_Range -> T_Statement
sem_Statement_Empty arg_range_ = T_Statement (return st155) where
{-# NOINLINE st155 #-}
st155 = let
v154 :: T_Statement_v154
v154 = \ (T_Statement_vIn154 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
_self = rule339 _rangeIself
_lhsOself :: Statement
_lhsOself = rule340 _self
__result_ = T_Statement_vOut154 _lhsOself
in __result_ )
in C_Statement_s155 v154
{-# INLINE rule339 #-}
rule339 = \ ((_rangeIself) :: Range) ->
Statement_Empty _rangeIself
{-# INLINE rule340 #-}
rule340 = \ _self ->
_self
-- Statements --------------------------------------------------
-- wrapper
data Inh_Statements = Inh_Statements { }
data Syn_Statements = Syn_Statements { self_Syn_Statements :: (Statements) }
{-# INLINABLE wrap_Statements #-}
wrap_Statements :: T_Statements -> Inh_Statements -> (Syn_Statements )
wrap_Statements (T_Statements act) (Inh_Statements ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg157 = T_Statements_vIn157
(T_Statements_vOut157 _lhsOself) <- return (inv_Statements_s158 sem arg157)
return (Syn_Statements _lhsOself)
)
-- cata
{-# NOINLINE sem_Statements #-}
sem_Statements :: Statements -> T_Statements
sem_Statements list = Prelude.foldr sem_Statements_Cons sem_Statements_Nil (Prelude.map sem_Statement list)
-- semantic domain
newtype T_Statements = T_Statements {
attach_T_Statements :: Identity (T_Statements_s158 )
}
newtype T_Statements_s158 = C_Statements_s158 {
inv_Statements_s158 :: (T_Statements_v157 )
}
data T_Statements_s159 = C_Statements_s159
type T_Statements_v157 = (T_Statements_vIn157 ) -> (T_Statements_vOut157 )
data T_Statements_vIn157 = T_Statements_vIn157
data T_Statements_vOut157 = T_Statements_vOut157 (Statements)
{-# NOINLINE sem_Statements_Cons #-}
sem_Statements_Cons :: T_Statement -> T_Statements -> T_Statements
sem_Statements_Cons arg_hd_ arg_tl_ = T_Statements (return st158) where
{-# NOINLINE st158 #-}
st158 = let
v157 :: T_Statements_v157
v157 = \ (T_Statements_vIn157 ) -> ( let
_hdX155 = Control.Monad.Identity.runIdentity (attach_T_Statement (arg_hd_))
_tlX158 = Control.Monad.Identity.runIdentity (attach_T_Statements (arg_tl_))
(T_Statement_vOut154 _hdIself) = inv_Statement_s155 _hdX155 (T_Statement_vIn154 )
(T_Statements_vOut157 _tlIself) = inv_Statements_s158 _tlX158 (T_Statements_vIn157 )
_self = rule341 _hdIself _tlIself
_lhsOself :: Statements
_lhsOself = rule342 _self
__result_ = T_Statements_vOut157 _lhsOself
in __result_ )
in C_Statements_s158 v157
{-# INLINE rule341 #-}
rule341 = \ ((_hdIself) :: Statement) ((_tlIself) :: Statements) ->
(:) _hdIself _tlIself
{-# INLINE rule342 #-}
rule342 = \ _self ->
_self
{-# NOINLINE sem_Statements_Nil #-}
sem_Statements_Nil :: T_Statements
sem_Statements_Nil = T_Statements (return st158) where
{-# NOINLINE st158 #-}
st158 = let
v157 :: T_Statements_v157
v157 = \ (T_Statements_vIn157 ) -> ( let
_self = rule343 ()
_lhsOself :: Statements
_lhsOself = rule344 _self
__result_ = T_Statements_vOut157 _lhsOself
in __result_ )
in C_Statements_s158 v157
{-# INLINE rule343 #-}
rule343 = \ (_ :: ()) ->
[]
{-# INLINE rule344 #-}
rule344 = \ _self ->
_self
-- Strings -----------------------------------------------------
-- wrapper
data Inh_Strings = Inh_Strings { }
data Syn_Strings = Syn_Strings { self_Syn_Strings :: (Strings) }
{-# INLINABLE wrap_Strings #-}
wrap_Strings :: T_Strings -> Inh_Strings -> (Syn_Strings )
wrap_Strings (T_Strings act) (Inh_Strings ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg160 = T_Strings_vIn160
(T_Strings_vOut160 _lhsOself) <- return (inv_Strings_s161 sem arg160)
return (Syn_Strings _lhsOself)
)
-- cata
{-# NOINLINE sem_Strings #-}
sem_Strings :: Strings -> T_Strings
sem_Strings list = Prelude.foldr sem_Strings_Cons sem_Strings_Nil list
-- semantic domain
newtype T_Strings = T_Strings {
attach_T_Strings :: Identity (T_Strings_s161 )
}
newtype T_Strings_s161 = C_Strings_s161 {
inv_Strings_s161 :: (T_Strings_v160 )
}
data T_Strings_s162 = C_Strings_s162
type T_Strings_v160 = (T_Strings_vIn160 ) -> (T_Strings_vOut160 )
data T_Strings_vIn160 = T_Strings_vIn160
data T_Strings_vOut160 = T_Strings_vOut160 (Strings)
{-# NOINLINE sem_Strings_Cons #-}
sem_Strings_Cons :: (String) -> T_Strings -> T_Strings
sem_Strings_Cons arg_hd_ arg_tl_ = T_Strings (return st161) where
{-# NOINLINE st161 #-}
st161 = let
v160 :: T_Strings_v160
v160 = \ (T_Strings_vIn160 ) -> ( let
_tlX161 = Control.Monad.Identity.runIdentity (attach_T_Strings (arg_tl_))
(T_Strings_vOut160 _tlIself) = inv_Strings_s161 _tlX161 (T_Strings_vIn160 )
_self = rule345 _tlIself arg_hd_
_lhsOself :: Strings
_lhsOself = rule346 _self
__result_ = T_Strings_vOut160 _lhsOself
in __result_ )
in C_Strings_s161 v160
{-# INLINE rule345 #-}
rule345 = \ ((_tlIself) :: Strings) hd_ ->
(:) hd_ _tlIself
{-# INLINE rule346 #-}
rule346 = \ _self ->
_self
{-# NOINLINE sem_Strings_Nil #-}
sem_Strings_Nil :: T_Strings
sem_Strings_Nil = T_Strings (return st161) where
{-# NOINLINE st161 #-}
st161 = let
v160 :: T_Strings_v160
v160 = \ (T_Strings_vIn160 ) -> ( let
_self = rule347 ()
_lhsOself :: Strings
_lhsOself = rule348 _self
__result_ = T_Strings_vOut160 _lhsOself
in __result_ )
in C_Strings_s161 v160
{-# INLINE rule347 #-}
rule347 = \ (_ :: ()) ->
[]
{-# INLINE rule348 #-}
rule348 = \ _self ->
_self
-- Type --------------------------------------------------------
-- wrapper
data Inh_Type = Inh_Type { }
data Syn_Type = Syn_Type { self_Syn_Type :: (Type) }
{-# INLINABLE wrap_Type #-}
wrap_Type :: T_Type -> Inh_Type -> (Syn_Type )
wrap_Type (T_Type act) (Inh_Type ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg163 = T_Type_vIn163
(T_Type_vOut163 _lhsOself) <- return (inv_Type_s164 sem arg163)
return (Syn_Type _lhsOself)
)
-- cata
{-# NOINLINE sem_Type #-}
sem_Type :: Type -> T_Type
sem_Type ( Type_Application range_ prefix_ function_ arguments_ ) = sem_Type_Application ( sem_Range range_ ) prefix_ ( sem_Type function_ ) ( sem_Types arguments_ )
sem_Type ( Type_Variable range_ name_ ) = sem_Type_Variable ( sem_Range range_ ) ( sem_Name name_ )
sem_Type ( Type_Constructor range_ name_ ) = sem_Type_Constructor ( sem_Range range_ ) ( sem_Name name_ )
sem_Type ( Type_Qualified range_ context_ type_ ) = sem_Type_Qualified ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_Type type_ )
sem_Type ( Type_Forall range_ typevariables_ type_ ) = sem_Type_Forall ( sem_Range range_ ) ( sem_Names typevariables_ ) ( sem_Type type_ )
sem_Type ( Type_Exists range_ typevariables_ type_ ) = sem_Type_Exists ( sem_Range range_ ) ( sem_Names typevariables_ ) ( sem_Type type_ )
sem_Type ( Type_Parenthesized range_ type_ ) = sem_Type_Parenthesized ( sem_Range range_ ) ( sem_Type type_ )
-- semantic domain
newtype T_Type = T_Type {
attach_T_Type :: Identity (T_Type_s164 )
}
newtype T_Type_s164 = C_Type_s164 {
inv_Type_s164 :: (T_Type_v163 )
}
data T_Type_s165 = C_Type_s165
type T_Type_v163 = (T_Type_vIn163 ) -> (T_Type_vOut163 )
data T_Type_vIn163 = T_Type_vIn163
data T_Type_vOut163 = T_Type_vOut163 (Type)
{-# NOINLINE sem_Type_Application #-}
sem_Type_Application :: T_Range -> (Bool) -> T_Type -> T_Types -> T_Type
sem_Type_Application arg_range_ arg_prefix_ arg_function_ arg_arguments_ = T_Type (return st164) where
{-# NOINLINE st164 #-}
st164 = let
v163 :: T_Type_v163
v163 = \ (T_Type_vIn163 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_functionX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_function_))
_argumentsX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_arguments_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Type_vOut163 _functionIself) = inv_Type_s164 _functionX164 (T_Type_vIn163 )
(T_Types_vOut166 _argumentsIself) = inv_Types_s167 _argumentsX167 (T_Types_vIn166 )
_self = rule349 _argumentsIself _functionIself _rangeIself arg_prefix_
_lhsOself :: Type
_lhsOself = rule350 _self
__result_ = T_Type_vOut163 _lhsOself
in __result_ )
in C_Type_s164 v163
{-# INLINE rule349 #-}
rule349 = \ ((_argumentsIself) :: Types) ((_functionIself) :: Type) ((_rangeIself) :: Range) prefix_ ->
Type_Application _rangeIself prefix_ _functionIself _argumentsIself
{-# INLINE rule350 #-}
rule350 = \ _self ->
_self
{-# NOINLINE sem_Type_Variable #-}
sem_Type_Variable :: T_Range -> T_Name -> T_Type
sem_Type_Variable arg_range_ arg_name_ = T_Type (return st164) where
{-# NOINLINE st164 #-}
st164 = let
v163 :: T_Type_v163
v163 = \ (T_Type_vIn163 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_self = rule351 _nameIself _rangeIself
_lhsOself :: Type
_lhsOself = rule352 _self
__result_ = T_Type_vOut163 _lhsOself
in __result_ )
in C_Type_s164 v163
{-# INLINE rule351 #-}
rule351 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Type_Variable _rangeIself _nameIself
{-# INLINE rule352 #-}
rule352 = \ _self ->
_self
{-# NOINLINE sem_Type_Constructor #-}
sem_Type_Constructor :: T_Range -> T_Name -> T_Type
sem_Type_Constructor arg_range_ arg_name_ = T_Type (return st164) where
{-# NOINLINE st164 #-}
st164 = let
v163 :: T_Type_v163
v163 = \ (T_Type_vIn163 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Name_vOut112 _nameIself) = inv_Name_s113 _nameX113 (T_Name_vIn112 )
_self = rule353 _nameIself _rangeIself
_lhsOself :: Type
_lhsOself = rule354 _self
__result_ = T_Type_vOut163 _lhsOself
in __result_ )
in C_Type_s164 v163
{-# INLINE rule353 #-}
rule353 = \ ((_nameIself) :: Name) ((_rangeIself) :: Range) ->
Type_Constructor _rangeIself _nameIself
{-# INLINE rule354 #-}
rule354 = \ _self ->
_self
{-# NOINLINE sem_Type_Qualified #-}
sem_Type_Qualified :: T_Range -> T_ContextItems -> T_Type -> T_Type
sem_Type_Qualified arg_range_ arg_context_ arg_type_ = T_Type (return st164) where
{-# NOINLINE st164 #-}
st164 = let
v163 :: T_Type_v163
v163 = \ (T_Type_vIn163 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_))
_typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_ContextItems_vOut25 _contextIself) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 )
(T_Type_vOut163 _typeIself) = inv_Type_s164 _typeX164 (T_Type_vIn163 )
_self = rule355 _contextIself _rangeIself _typeIself
_lhsOself :: Type
_lhsOself = rule356 _self
__result_ = T_Type_vOut163 _lhsOself
in __result_ )
in C_Type_s164 v163
{-# INLINE rule355 #-}
rule355 = \ ((_contextIself) :: ContextItems) ((_rangeIself) :: Range) ((_typeIself) :: Type) ->
Type_Qualified _rangeIself _contextIself _typeIself
{-# INLINE rule356 #-}
rule356 = \ _self ->
_self
{-# NOINLINE sem_Type_Forall #-}
sem_Type_Forall :: T_Range -> T_Names -> T_Type -> T_Type
sem_Type_Forall arg_range_ arg_typevariables_ arg_type_ = T_Type (return st164) where
{-# NOINLINE st164 #-}
st164 = let
v163 :: T_Type_v163
v163 = \ (T_Type_vIn163 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_typevariablesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_typevariables_))
_typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Names_vOut115 _typevariablesInames _typevariablesIself) = inv_Names_s116 _typevariablesX116 (T_Names_vIn115 )
(T_Type_vOut163 _typeIself) = inv_Type_s164 _typeX164 (T_Type_vIn163 )
_self = rule357 _rangeIself _typeIself _typevariablesIself
_lhsOself :: Type
_lhsOself = rule358 _self
__result_ = T_Type_vOut163 _lhsOself
in __result_ )
in C_Type_s164 v163
{-# INLINE rule357 #-}
rule357 = \ ((_rangeIself) :: Range) ((_typeIself) :: Type) ((_typevariablesIself) :: Names) ->
Type_Forall _rangeIself _typevariablesIself _typeIself
{-# INLINE rule358 #-}
rule358 = \ _self ->
_self
{-# NOINLINE sem_Type_Exists #-}
sem_Type_Exists :: T_Range -> T_Names -> T_Type -> T_Type
sem_Type_Exists arg_range_ arg_typevariables_ arg_type_ = T_Type (return st164) where
{-# NOINLINE st164 #-}
st164 = let
v163 :: T_Type_v163
v163 = \ (T_Type_vIn163 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_typevariablesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_typevariables_))
_typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Names_vOut115 _typevariablesInames _typevariablesIself) = inv_Names_s116 _typevariablesX116 (T_Names_vIn115 )
(T_Type_vOut163 _typeIself) = inv_Type_s164 _typeX164 (T_Type_vIn163 )
_self = rule359 _rangeIself _typeIself _typevariablesIself
_lhsOself :: Type
_lhsOself = rule360 _self
__result_ = T_Type_vOut163 _lhsOself
in __result_ )
in C_Type_s164 v163
{-# INLINE rule359 #-}
rule359 = \ ((_rangeIself) :: Range) ((_typeIself) :: Type) ((_typevariablesIself) :: Names) ->
Type_Exists _rangeIself _typevariablesIself _typeIself
{-# INLINE rule360 #-}
rule360 = \ _self ->
_self
{-# NOINLINE sem_Type_Parenthesized #-}
sem_Type_Parenthesized :: T_Range -> T_Type -> T_Type
sem_Type_Parenthesized arg_range_ arg_type_ = T_Type (return st164) where
{-# NOINLINE st164 #-}
st164 = let
v163 :: T_Type_v163
v163 = \ (T_Type_vIn163 ) -> ( let
_rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_))
_typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_))
(T_Range_vOut133 _rangeIself) = inv_Range_s134 _rangeX134 (T_Range_vIn133 )
(T_Type_vOut163 _typeIself) = inv_Type_s164 _typeX164 (T_Type_vIn163 )
_self = rule361 _rangeIself _typeIself
_lhsOself :: Type
_lhsOself = rule362 _self
__result_ = T_Type_vOut163 _lhsOself
in __result_ )
in C_Type_s164 v163
{-# INLINE rule361 #-}
rule361 = \ ((_rangeIself) :: Range) ((_typeIself) :: Type) ->
Type_Parenthesized _rangeIself _typeIself
{-# INLINE rule362 #-}
rule362 = \ _self ->
_self
-- Types -------------------------------------------------------
-- wrapper
data Inh_Types = Inh_Types { }
data Syn_Types = Syn_Types { self_Syn_Types :: (Types) }
{-# INLINABLE wrap_Types #-}
wrap_Types :: T_Types -> Inh_Types -> (Syn_Types )
wrap_Types (T_Types act) (Inh_Types ) =
Control.Monad.Identity.runIdentity (
do sem <- act
let arg166 = T_Types_vIn166
(T_Types_vOut166 _lhsOself) <- return (inv_Types_s167 sem arg166)
return (Syn_Types _lhsOself)
)
-- cata
{-# NOINLINE sem_Types #-}
sem_Types :: Types -> T_Types
sem_Types list = Prelude.foldr sem_Types_Cons sem_Types_Nil (Prelude.map sem_Type list)
-- semantic domain
newtype T_Types = T_Types {
attach_T_Types :: Identity (T_Types_s167 )
}
newtype T_Types_s167 = C_Types_s167 {
inv_Types_s167 :: (T_Types_v166 )
}
data T_Types_s168 = C_Types_s168
type T_Types_v166 = (T_Types_vIn166 ) -> (T_Types_vOut166 )
data T_Types_vIn166 = T_Types_vIn166
data T_Types_vOut166 = T_Types_vOut166 (Types)
{-# NOINLINE sem_Types_Cons #-}
sem_Types_Cons :: T_Type -> T_Types -> T_Types
sem_Types_Cons arg_hd_ arg_tl_ = T_Types (return st167) where
{-# NOINLINE st167 #-}
st167 = let
v166 :: T_Types_v166
v166 = \ (T_Types_vIn166 ) -> ( let
_hdX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_hd_))
_tlX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_tl_))
(T_Type_vOut163 _hdIself) = inv_Type_s164 _hdX164 (T_Type_vIn163 )
(T_Types_vOut166 _tlIself) = inv_Types_s167 _tlX167 (T_Types_vIn166 )
_self = rule363 _hdIself _tlIself
_lhsOself :: Types
_lhsOself = rule364 _self
__result_ = T_Types_vOut166 _lhsOself
in __result_ )
in C_Types_s167 v166
{-# INLINE rule363 #-}
rule363 = \ ((_hdIself) :: Type) ((_tlIself) :: Types) ->
(:) _hdIself _tlIself
{-# INLINE rule364 #-}
rule364 = \ _self ->
_self
{-# NOINLINE sem_Types_Nil #-}
sem_Types_Nil :: T_Types
sem_Types_Nil = T_Types (return st167) where
{-# NOINLINE st167 #-}
st167 = let
v166 :: T_Types_v166
v166 = \ (T_Types_vIn166 ) -> ( let
_self = rule365 ()
_lhsOself :: Types
_lhsOself = rule366 _self
__result_ = T_Types_vOut166 _lhsOself
in __result_ )
in C_Types_s167 v166
{-# INLINE rule365 #-}
rule365 = \ (_ :: ()) ->
[]
{-# INLINE rule366 #-}
rule366 = \ _self ->
_self
| roberth/uu-helium | src/Helium/ModuleSystem/ExtractImportDecls.hs | gpl-3.0 | 290,106 | 56 | 20 | 64,495 | 58,666 | 31,972 | 26,694 | 5,202 | 2 |
-- file: ch03/Braces.hs
-- Using layout to determine structure
bar = let a =1
b = 2
c = 3
in a + b + c
-- Using explicit structuring (hardly ever used)
foo = let { a = 1; b = 2;
c = 3 }
in a + b +c
| craigem/RealWorldHaskell | ch03/Braces.hs | gpl-3.0 | 240 | 0 | 8 | 94 | 76 | 43 | 33 | 7 | 1 |
{-# LANGUAGE OverloadedStrings #-}
-- Module : System.APT.Options
-- Copyright : (c) 2014 Brendan Hay <[email protected]>
-- License : This Source Code Form is subject to the terms of
-- the Mozilla Public License, v. 2.0.
-- A copy of the MPL can be found in the LICENSE file or
-- you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : experimental
-- Portability : non-portable (GHC extensions)
module System.APT.Options where
import qualified Data.ByteString.Char8 as BS
import Data.ByteString.From (FromByteString(..))
import qualified Data.ByteString.From as From
import Data.Monoid
import Data.Text (Text)
import qualified Data.Text as Text
import GHC.Conc
import Options.Applicative
import System.APT.Types
parseOptions :: Parser a -> IO a
parseOptions p = customExecParser
(prefs $ showHelpOnError <> columns 100)
(info (helper <*> p) $ fullDesc
<> footer ("Concurrency:\n " ++ show numCapabilities))
textOption :: Mod OptionFields String -> Parser Text
textOption = fmap Text.pack . strOption
fromOption :: FromByteString a => Mod OptionFields a -> Parser a
fromOption = nullOption . (eitherReader (From.runParser From.parser . BS.pack) <>)
bucketOption :: Mod OptionFields String -> Parser Bucket
bucketOption = fmap (mk . Text.pack) . strOption
where
mk t =
case Text.split (== '/') t of
[] -> error "Bucket cannot be blank."
(x:[]) -> Bucket x Nothing
(x:xs) -> Bucket x (Just $ Text.intercalate "/" xs)
| brendanhay/apteryx | apteryx/System/APT/Options.hs | mpl-2.0 | 1,706 | 0 | 14 | 436 | 378 | 207 | 171 | 27 | 3 |
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Network.AWS.IAM.GetGroupPolicy
-- Copyright : (c) 2013-2015 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the specified inline policy document that is embedded in the
-- specified group.
--
-- A group can also have managed policies attached to it. To retrieve a
-- managed policy document that is attached to a group, use GetPolicy to
-- determine the policy\'s default version, then use GetPolicyVersion to
-- retrieve the policy document.
--
-- For more information about policies, refer to
-- <http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html Managed Policies and Inline Policies>
-- in the /Using IAM/ guide.
--
-- /See:/ <http://docs.aws.amazon.com/IAM/latest/APIReference/API_GetGroupPolicy.html AWS API Reference> for GetGroupPolicy.
module Network.AWS.IAM.GetGroupPolicy
(
-- * Creating a Request
getGroupPolicy
, GetGroupPolicy
-- * Request Lenses
, ggpGroupName
, ggpPolicyName
-- * Destructuring the Response
, getGroupPolicyResponse
, GetGroupPolicyResponse
-- * Response Lenses
, ggprsResponseStatus
, ggprsGroupName
, ggprsPolicyName
, ggprsPolicyDocument
) where
import Network.AWS.IAM.Types
import Network.AWS.IAM.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
-- | /See:/ 'getGroupPolicy' smart constructor.
data GetGroupPolicy = GetGroupPolicy'
{ _ggpGroupName :: !Text
, _ggpPolicyName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'GetGroupPolicy' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ggpGroupName'
--
-- * 'ggpPolicyName'
getGroupPolicy
:: Text -- ^ 'ggpGroupName'
-> Text -- ^ 'ggpPolicyName'
-> GetGroupPolicy
getGroupPolicy pGroupName_ pPolicyName_ =
GetGroupPolicy'
{ _ggpGroupName = pGroupName_
, _ggpPolicyName = pPolicyName_
}
-- | The name of the group the policy is associated with.
ggpGroupName :: Lens' GetGroupPolicy Text
ggpGroupName = lens _ggpGroupName (\ s a -> s{_ggpGroupName = a});
-- | The name of the policy document to get.
ggpPolicyName :: Lens' GetGroupPolicy Text
ggpPolicyName = lens _ggpPolicyName (\ s a -> s{_ggpPolicyName = a});
instance AWSRequest GetGroupPolicy where
type Rs GetGroupPolicy = GetGroupPolicyResponse
request = postQuery iAM
response
= receiveXMLWrapper "GetGroupPolicyResult"
(\ s h x ->
GetGroupPolicyResponse' <$>
(pure (fromEnum s)) <*> (x .@ "GroupName") <*>
(x .@ "PolicyName")
<*> (x .@ "PolicyDocument"))
instance ToHeaders GetGroupPolicy where
toHeaders = const mempty
instance ToPath GetGroupPolicy where
toPath = const "/"
instance ToQuery GetGroupPolicy where
toQuery GetGroupPolicy'{..}
= mconcat
["Action" =: ("GetGroupPolicy" :: ByteString),
"Version" =: ("2010-05-08" :: ByteString),
"GroupName" =: _ggpGroupName,
"PolicyName" =: _ggpPolicyName]
-- | Contains the response to a successful GetGroupPolicy request.
--
-- /See:/ 'getGroupPolicyResponse' smart constructor.
data GetGroupPolicyResponse = GetGroupPolicyResponse'
{ _ggprsResponseStatus :: !Int
, _ggprsGroupName :: !Text
, _ggprsPolicyName :: !Text
, _ggprsPolicyDocument :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'GetGroupPolicyResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ggprsResponseStatus'
--
-- * 'ggprsGroupName'
--
-- * 'ggprsPolicyName'
--
-- * 'ggprsPolicyDocument'
getGroupPolicyResponse
:: Int -- ^ 'ggprsResponseStatus'
-> Text -- ^ 'ggprsGroupName'
-> Text -- ^ 'ggprsPolicyName'
-> Text -- ^ 'ggprsPolicyDocument'
-> GetGroupPolicyResponse
getGroupPolicyResponse pResponseStatus_ pGroupName_ pPolicyName_ pPolicyDocument_ =
GetGroupPolicyResponse'
{ _ggprsResponseStatus = pResponseStatus_
, _ggprsGroupName = pGroupName_
, _ggprsPolicyName = pPolicyName_
, _ggprsPolicyDocument = pPolicyDocument_
}
-- | The response status code.
ggprsResponseStatus :: Lens' GetGroupPolicyResponse Int
ggprsResponseStatus = lens _ggprsResponseStatus (\ s a -> s{_ggprsResponseStatus = a});
-- | The group the policy is associated with.
ggprsGroupName :: Lens' GetGroupPolicyResponse Text
ggprsGroupName = lens _ggprsGroupName (\ s a -> s{_ggprsGroupName = a});
-- | The name of the policy.
ggprsPolicyName :: Lens' GetGroupPolicyResponse Text
ggprsPolicyName = lens _ggprsPolicyName (\ s a -> s{_ggprsPolicyName = a});
-- | The policy document.
ggprsPolicyDocument :: Lens' GetGroupPolicyResponse Text
ggprsPolicyDocument = lens _ggprsPolicyDocument (\ s a -> s{_ggprsPolicyDocument = a});
| fmapfmapfmap/amazonka | amazonka-iam/gen/Network/AWS/IAM/GetGroupPolicy.hs | mpl-2.0 | 5,626 | 0 | 16 | 1,162 | 780 | 471 | 309 | 100 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- |
-- Module : Network.Google.Resource.Compute.InstanceGroups.Get
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the specified instance group. Get a list of available instance
-- groups by making a list() request.
--
-- /See:/ <https://developers.google.com/compute/docs/reference/latest/ Compute Engine API Reference> for @compute.instanceGroups.get@.
module Network.Google.Resource.Compute.InstanceGroups.Get
(
-- * REST Resource
InstanceGroupsGetResource
-- * Creating a Request
, instanceGroupsGet
, InstanceGroupsGet
-- * Request Lenses
, iggProject
, iggZone
, iggInstanceGroup
) where
import Network.Google.Compute.Types
import Network.Google.Prelude
-- | A resource alias for @compute.instanceGroups.get@ method which the
-- 'InstanceGroupsGet' request conforms to.
type InstanceGroupsGetResource =
"compute" :>
"v1" :>
"projects" :>
Capture "project" Text :>
"zones" :>
Capture "zone" Text :>
"instanceGroups" :>
Capture "instanceGroup" Text :>
QueryParam "alt" AltJSON :> Get '[JSON] InstanceGroup
-- | Returns the specified instance group. Get a list of available instance
-- groups by making a list() request.
--
-- /See:/ 'instanceGroupsGet' smart constructor.
data InstanceGroupsGet = InstanceGroupsGet'
{ _iggProject :: !Text
, _iggZone :: !Text
, _iggInstanceGroup :: !Text
} deriving (Eq,Show,Data,Typeable,Generic)
-- | Creates a value of 'InstanceGroupsGet' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'iggProject'
--
-- * 'iggZone'
--
-- * 'iggInstanceGroup'
instanceGroupsGet
:: Text -- ^ 'iggProject'
-> Text -- ^ 'iggZone'
-> Text -- ^ 'iggInstanceGroup'
-> InstanceGroupsGet
instanceGroupsGet pIggProject_ pIggZone_ pIggInstanceGroup_ =
InstanceGroupsGet'
{ _iggProject = pIggProject_
, _iggZone = pIggZone_
, _iggInstanceGroup = pIggInstanceGroup_
}
-- | Project ID for this request.
iggProject :: Lens' InstanceGroupsGet Text
iggProject
= lens _iggProject (\ s a -> s{_iggProject = a})
-- | The name of the zone where the instance group is located.
iggZone :: Lens' InstanceGroupsGet Text
iggZone = lens _iggZone (\ s a -> s{_iggZone = a})
-- | The name of the instance group.
iggInstanceGroup :: Lens' InstanceGroupsGet Text
iggInstanceGroup
= lens _iggInstanceGroup
(\ s a -> s{_iggInstanceGroup = a})
instance GoogleRequest InstanceGroupsGet where
type Rs InstanceGroupsGet = InstanceGroup
type Scopes InstanceGroupsGet =
'["https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/compute.readonly"]
requestClient InstanceGroupsGet'{..}
= go _iggProject _iggZone _iggInstanceGroup
(Just AltJSON)
computeService
where go
= buildClient
(Proxy :: Proxy InstanceGroupsGetResource)
mempty
| rueshyna/gogol | gogol-compute/gen/Network/Google/Resource/Compute/InstanceGroups/Get.hs | mpl-2.0 | 3,888 | 0 | 16 | 932 | 468 | 280 | 188 | 76 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- |
-- Module : Network.Google.Resource.Games.Players.List
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Get the collection of players for the currently authenticated user.
--
-- /See:/ <https://developers.google.com/games/ Google Play Game Services Reference> for @games.players.list@.
module Network.Google.Resource.Games.Players.List
(
-- * REST Resource
PlayersListResource
-- * Creating a Request
, playersList
, PlayersList
-- * Request Lenses
, plXgafv
, plUploadProtocol
, plAccessToken
, plUploadType
, plCollection
, plLanguage
, plPageToken
, plMaxResults
, plCallback
) where
import Network.Google.Games.Types
import Network.Google.Prelude
-- | A resource alias for @games.players.list@ method which the
-- 'PlayersList' request conforms to.
type PlayersListResource =
"games" :>
"v1" :>
"players" :>
"me" :>
"players" :>
Capture "collection" PlayersListCollection :>
QueryParam "$.xgafv" Xgafv :>
QueryParam "upload_protocol" Text :>
QueryParam "access_token" Text :>
QueryParam "uploadType" Text :>
QueryParam "language" Text :>
QueryParam "pageToken" Text :>
QueryParam "maxResults" (Textual Int32) :>
QueryParam "callback" Text :>
QueryParam "alt" AltJSON :>
Get '[JSON] PlayerListResponse
-- | Get the collection of players for the currently authenticated user.
--
-- /See:/ 'playersList' smart constructor.
data PlayersList =
PlayersList'
{ _plXgafv :: !(Maybe Xgafv)
, _plUploadProtocol :: !(Maybe Text)
, _plAccessToken :: !(Maybe Text)
, _plUploadType :: !(Maybe Text)
, _plCollection :: !PlayersListCollection
, _plLanguage :: !(Maybe Text)
, _plPageToken :: !(Maybe Text)
, _plMaxResults :: !(Maybe (Textual Int32))
, _plCallback :: !(Maybe Text)
}
deriving (Eq, Show, Data, Typeable, Generic)
-- | Creates a value of 'PlayersList' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'plXgafv'
--
-- * 'plUploadProtocol'
--
-- * 'plAccessToken'
--
-- * 'plUploadType'
--
-- * 'plCollection'
--
-- * 'plLanguage'
--
-- * 'plPageToken'
--
-- * 'plMaxResults'
--
-- * 'plCallback'
playersList
:: PlayersListCollection -- ^ 'plCollection'
-> PlayersList
playersList pPlCollection_ =
PlayersList'
{ _plXgafv = Nothing
, _plUploadProtocol = Nothing
, _plAccessToken = Nothing
, _plUploadType = Nothing
, _plCollection = pPlCollection_
, _plLanguage = Nothing
, _plPageToken = Nothing
, _plMaxResults = Nothing
, _plCallback = Nothing
}
-- | V1 error format.
plXgafv :: Lens' PlayersList (Maybe Xgafv)
plXgafv = lens _plXgafv (\ s a -> s{_plXgafv = a})
-- | Upload protocol for media (e.g. \"raw\", \"multipart\").
plUploadProtocol :: Lens' PlayersList (Maybe Text)
plUploadProtocol
= lens _plUploadProtocol
(\ s a -> s{_plUploadProtocol = a})
-- | OAuth access token.
plAccessToken :: Lens' PlayersList (Maybe Text)
plAccessToken
= lens _plAccessToken
(\ s a -> s{_plAccessToken = a})
-- | Legacy upload protocol for media (e.g. \"media\", \"multipart\").
plUploadType :: Lens' PlayersList (Maybe Text)
plUploadType
= lens _plUploadType (\ s a -> s{_plUploadType = a})
-- | Collection of players being retrieved
plCollection :: Lens' PlayersList PlayersListCollection
plCollection
= lens _plCollection (\ s a -> s{_plCollection = a})
-- | The preferred language to use for strings returned by this method.
plLanguage :: Lens' PlayersList (Maybe Text)
plLanguage
= lens _plLanguage (\ s a -> s{_plLanguage = a})
-- | The token returned by the previous request.
plPageToken :: Lens' PlayersList (Maybe Text)
plPageToken
= lens _plPageToken (\ s a -> s{_plPageToken = a})
-- | The maximum number of player resources to return in the response, used
-- for paging. For any response, the actual number of player resources
-- returned may be less than the specified \`maxResults\`.
plMaxResults :: Lens' PlayersList (Maybe Int32)
plMaxResults
= lens _plMaxResults (\ s a -> s{_plMaxResults = a})
. mapping _Coerce
-- | JSONP
plCallback :: Lens' PlayersList (Maybe Text)
plCallback
= lens _plCallback (\ s a -> s{_plCallback = a})
instance GoogleRequest PlayersList where
type Rs PlayersList = PlayerListResponse
type Scopes PlayersList =
'["https://www.googleapis.com/auth/games"]
requestClient PlayersList'{..}
= go _plCollection _plXgafv _plUploadProtocol
_plAccessToken
_plUploadType
_plLanguage
_plPageToken
_plMaxResults
_plCallback
(Just AltJSON)
gamesService
where go
= buildClient (Proxy :: Proxy PlayersListResource)
mempty
| brendanhay/gogol | gogol-games/gen/Network/Google/Resource/Games/Players/List.hs | mpl-2.0 | 5,831 | 0 | 22 | 1,504 | 971 | 559 | 412 | 135 | 1 |
-- Implicit CAD. Copyright (C) 2011, Christopher Olah ([email protected])
-- Copyright (C) 2016 Julia Longtin ([email protected])
-- Released under the GNU AGPLV3+, see LICENSE
-- FIXME: describe why we need this.
{-# LANGUAGE OverloadedStrings #-}
module Graphics.Implicit.Export.NormedTriangleMeshFormats (obj) where
import Prelude(($), map, (+), (.), (*), length, (-), return)
import Graphics.Implicit.Definitions (NormedTriangle(NormedTriangle), NormedTriangleMesh(NormedTriangleMesh), ℝ3)
import Graphics.Implicit.Export.TextBuilderUtils (Text, Builder, toLazyText, (<>), bf, mconcat, buildInt)
-- | Generate a .obj format file from a NormedTriangleMesh
-- see: https://en.wikipedia.org/wiki/Wavefront_.obj_file
obj :: NormedTriangleMesh -> Text
obj (NormedTriangleMesh normedtriangles) = toLazyText $ vertcode <> normcode <> trianglecode
where
-- | A vertex line; v (0.0, 0.0, 1.0) = "v 0.0 0.0 1.0\n"
v :: ℝ3 -> Builder
v (x,y,z) = "v " <> bf x <> " " <> bf y <> " " <> bf z <> "\n"
-- | A normal line; n (0.0, 0.0, 1.0) = "vn 0.0 0.0 1.0\n"
n :: ℝ3 -> Builder
n (x,y,z) = "vn " <> bf x <> " " <> bf y <> " " <> bf z <> "\n"
verts = do
-- | Extract the vertices for each triangle
-- recall that a normed triangle is of the form ((vert, norm), ...)
NormedTriangle ((a,_),(b,_),(c,_)) <- normedtriangles
-- | The vertices from each triangle take up 3 positions in the resulting list
[a,b,c]
norms = do
-- | extract the normals for each triangle
NormedTriangle ((_,a),(_,b),(_,c)) <- normedtriangles
-- | The normals from each triangle take up 3 positions in the resulting list
[a,b,c]
vertcode = mconcat $ map v verts
normcode = mconcat $ map n norms
trianglecode = mconcat $ do
n' <- map ((+1).(*3)) [0,1 .. length normedtriangles -1]
let
vta = buildInt n'
vtb = buildInt (n'+1)
vtc = buildInt (n'+2)
return $ "f " <> vta <> " " <> vtb <> " " <> vtc <> " " <> "\n"
| krakrjak/ImplicitCAD | Graphics/Implicit/Export/NormedTriangleMeshFormats.hs | agpl-3.0 | 2,174 | 3 | 17 | 607 | 543 | 315 | 228 | 26 | 1 |
module Libaddutil.Collision
where
import Libaddutil.Primitives
boxIntersect :: Area -> Area -> Bool
boxIntersect ((x1,y1,z1),(x2,y2,z2)) ((x3,y3,z3),(x4,y4,z4)) =
if x2 < x3 || y2 < y3 || z2 < z3 ||
x1 > x4 || y1 > y4 || z1 > z4 then False else True
{- ((x1 > x3 && x1 < x4) || (x2 > x3 && x2 < x4) &&
(y1 > y3 && y1 < y4) || (y2 > y3 && y2 < y4) &&
(z1 < z3 && 41 < z4) || (z2 > z3 && z2 < z4))
-}
| anttisalonen/freekick | haskell/addutil/Libaddutil/Collision.hs | agpl-3.0 | 470 | 0 | 16 | 164 | 135 | 79 | 56 | 6 | 2 |
module Akarui.FOL.PrettyPrint
( PrettyPrint(..)
) where
import qualified Data.Text as T
import Akarui.FOL.Symbols
class PrettyPrint t where
prettyPrint :: Symbols -> t -> T.Text
| PhDP/Manticore | Akarui/FOL/PrettyPrint.hs | apache-2.0 | 182 | 0 | 9 | 28 | 54 | 33 | 21 | 6 | 0 |
module Lambda.Deconstruct
(
-- * Convenient polymorphic deconstruction
app
, lam
, var
-- * Combinator
, (|>)
, (<!>)
-- ** From "Control.Applicative"
, Alternative
, (<|>)
)
where
import Control.Applicative
(
Alternative
, empty
, (<|>)
)
import Data.Maybe
(
fromMaybe
)
import Lambda.Term
-- | Deconstruct a lambda application.
app :: (Alternative m, Term t) => (t -> m a) -> (t -> m b) -> (t -> m (a, b))
app f g = unApp (\ x y -> (,) <$> f x <*> g y) (const empty)
-- | Deconstruct a lambda abstraction.
lam :: (Alternative m, Term t) => (String -> m a) -> (t -> m b) -> (t -> m (a, b))
lam f g = unLam (\ x y -> (,) <$> f x <*> g y) (const empty)
-- | Deconstruct a variable.
var :: (Alternative m, Term t) => t -> m String
var = unVar pure (const empty)
-- | Flipped '<$>' with the same precedence level but flipped fixity.
(|>) :: (Functor f) => f a -> (a -> b) -> f b
(|>) = flip (<$>)
infixr 4 |>
-- | Flipped 'fromMaybe' that has the same fixity as that of '<|>'.
(<!>) :: Maybe a -> a -> a
(<!>) = flip fromMaybe
infixl 3 <!>
| edom/ptt | src/Lambda/Deconstruct.hs | apache-2.0 | 1,138 | 0 | 11 | 322 | 430 | 242 | 188 | 30 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Openshift.V1.Handler where
import GHC.Generics
import Openshift.V1.ExecAction
import Openshift.V1.HTTPGetAction
import Openshift.V1.TCPSocketAction
import qualified Data.Aeson
-- | Handler defines a specific action that should be taken
data Handler = Handler
{ exec :: Maybe ExecAction -- ^ One and only one of the following should be specified. Exec specifies the action to take.
, httpGet :: Maybe HTTPGetAction -- ^ HTTPGet specifies the http request to perform.
, tcpSocket :: Maybe TCPSocketAction -- ^ TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported
} deriving (Show, Eq, Generic)
instance Data.Aeson.FromJSON Handler
instance Data.Aeson.ToJSON Handler
| minhdoboi/deprecated-openshift-haskell-api | openshift/lib/Openshift/V1/Handler.hs | apache-2.0 | 889 | 0 | 9 | 140 | 116 | 71 | 45 | 18 | 0 |
module Helpers.Binary (lastBits, bitsList, splitBits) where
-- Number of partitions of the binary expansion of n into consecutive blocks with no leading zeroes.
-- 23 = 0b11011 -> [0, 0b1, 0b11, 0b011, 0b1011] = [0,1,3,3,11]
lastBits :: Int -> [Int]
lastBits n = recurse 0 n where
recurse _ 0 = []
recurse k n' = (n `mod` 2^k) : recurse (k + 1) (div n' 2)
bitsList :: Integer -> [Bool]
bitsList 0 = [False]
bitsList n = recurse n [] where
recurse n' b
| n' == 0 = b
| even n' = recurse (n' `div` 2) (False : b)
| odd n' = recurse (n' `div` 2) (True : b)
splitBits :: Int -> [(Int, Int)]
splitBits n = recurse 0 n where
recurse _ 0 = []
recurse k n' = (n `div` 2^k, n `mod` 2^k) : recurse (k + 1) (div n' 2)
| peterokagey/haskellOEIS | src/Helpers/Binary.hs | apache-2.0 | 733 | 0 | 10 | 176 | 336 | 179 | 157 | 16 | 2 |
-- |
-- Module : Text.Megaparsec.ByteString
-- Copyright : © 2015 Megaparsec contributors
-- © 2007 Paolo Martini
-- License : BSD3
--
-- Maintainer : Mark Karpov <[email protected]>
-- Stability : experimental
-- Portability : portable
--
-- Convenience definitions for working with 'C.ByteString'.
module Text.Megaparsec.ByteString
( Parser
, parseFromFile )
where
import Text.Megaparsec.Error
import Text.Megaparsec.Prim
import qualified Data.ByteString.Char8 as C
-- | Different modules corresponding to various types of streams (@String@,
-- @Text@, @ByteString@) define it differently, so user can use “abstract”
-- @Parser@ type and easily change it by importing different “type
-- modules”. This one is for strict bytestrings.
type Parser = Parsec C.ByteString
-- | @parseFromFile p filePath@ runs a strict bytestring parser @p@ on the
-- input read from @filePath@ using 'ByteString.Char8.readFile'. Returns
-- either a 'ParseError' ('Left') or a value of type @a@ ('Right').
--
-- > main = do
-- > result <- parseFromFile numbers "digits.txt"
-- > case result of
-- > Left err -> print err
-- > Right xs -> print (sum xs)
parseFromFile :: Parser a -> String -> IO (Either ParseError a)
parseFromFile p fname = runParser p fname <$> C.readFile fname
| neongreen/megaparsec | Text/Megaparsec/ByteString.hs | bsd-2-clause | 1,330 | 0 | 9 | 253 | 122 | 79 | 43 | 9 | 1 |
{-# LANGUAGE TypeFamilies, FlexibleInstances, FlexibleContexts,
DeriveDataTypeable, TypeSynonymInstances #-}
module HEP.ModelScan.MSSMScan.Model.MSUGRA where
import HEP.ModelScan.MSSMScan.Model
import qualified Data.ByteString.Lazy.Char8 as B
import Data.ByteString.Lex.Lazy.Double
instance Model MSUGRA where
data ModelInput MSUGRA = IMSUGRA (Double,Double,Double,Double)
parseInput oneline = let chunks = B.split ' ' oneline
a1:a2:a3:a4:[] = take 6 $ filter (not. B.null) chunks
m0 = maybe 0 fst $ readDouble a1
m12 = maybe 0 fst $ readDouble a2
a0 = maybe 0 fst $ readDouble a3
tanb = maybe 0 fst $ readDouble a4
in IMSUGRA (m0,m12,a0,tanb)
tanbeta (IMSUGRA (_,_,_,tanb)) = tanb
type InputMSUGRA = ModelInput MSUGRA
instance Show InputMSUGRA where
show (IMSUGRA (m0,m12,a0,tanb)) = "m0=" ++ show m0 ++ ", "
++ "m12=" ++ show m12 ++ ", "
++ "a0=" ++ show a0 ++ ", "
++ "tanb=" ++ show tanb
| wavewave/MSSMScan | src/HEP/ModelScan/MSSMScan/Model/MSUGRA.hs | bsd-2-clause | 1,236 | 0 | 16 | 474 | 343 | 183 | 160 | 22 | 0 |
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ExtendedDefaultRules #-}
module Control.Monad.Shmonad.ExpressionSpec (main, spec, VStr(..), VInt(..)) where
import Test.Hspec
import Test.QuickCheck
import Control.Monad
import Control.Monad.Shmonad.Expression
import Control.Applicative ((<$>), (<*>))
import Data.Char (isDigit, chr)
import Data.Monoid ((<>))
import Data.Number.Nat
import qualified Data.Text.Lazy as L
default (L.Text)
randText :: Gen L.Text
randText = sized $ \n ->
do k <- choose (0, n)
L.pack <$> vectorOf k validChars
where validChars = chr <$> choose (32, 126)
instance Arbitrary L.Text where
arbitrary = randText
instance Arbitrary Name where
arbitrary = toName <$> randText `suchThat` isValidName
instance Arbitrary Nat where
arbitrary = do
NonNegative x <- arbitrary :: Gen (NonNegative Integer)
return $ toNat x
instance Variable a => Arbitrary (VarID a) where
arbitrary = VarID <$> arbitrary <*> arbitrary
newtype VStr = VStr (Expr Str)
instance Arbitrary VStr where
arbitrary = VStr <$> Var <$> arbitrary
newtype VInt = VInt (Expr Integer)
instance Arbitrary VInt where
arbitrary = VInt <$> Var <$> arbitrary
main :: IO ()
main = hspec spec
spec :: Spec
spec = do
variableSpec
expressionSpec
redirectSpec
variableSpec :: Spec
variableSpec = do
describe "A Name" $ do
it "must be non-empty" $
"" `shouldSatisfy` not . isValidName
it "must be non-empty (QC)" $ property $
\(Blind x) -> not . L.null $ fromName x
it "must not start with a digit" $ property $
\str -> not (L.null str) && isDigit (L.head str) ==>
not (isValidName str)
it "can only contain letters, digits and underscores" $ property $
\(Blind x) -> isValidName $ fromName x
let var :: (VarID Integer)
var = VarID (Just 0) "hello"
describe "A VarID" $ do
it "has a unique numerical ID and a name" $ do
varID var `shouldBe` Just 0
let n = toName "hello"
varName var `shouldBe` n
it "has an associated type" $ do
let var2 :: (VarID Str)
var2 = VarID (Just 1) "world"
varID var2 `shouldBe` Just 1
-- because of phantom type var, impossible to write:
-- var2 `shouldSatisfy` (/=) var
describe "The Variable typeclass" $ do
it "should turn a VarID into a unique name" $ do
let n = toName "hello0"
uniqueName var `shouldBe` n
it "should produce a unique name that is a valid shell name" $ property $
\(Blind (VStr (Var x))) -> isValidName . fromName $ uniqueName x
expressionSpec :: Spec
expressionSpec =
describe "An Expr" $ do
describe "Lit a" $
it "should have a single value" $ do
let l :: Expr Integer
l = Lit 1
shExpr l `shouldBe` "1"
describe "Var a" $
it "turns a VarID into an expression" $ do
let var :: Expr Str
var = Var (VarID (Just 2) "foo")
shExpr var `shouldBe` "${foo2}"
describe "Plus" $
it "adds two Expr Integers" $ do
let int1 = Lit 1
let int2 = Lit 2
let sumInts = Plus int1 int2
shExpr sumInts `shouldBe` "$((1+2))"
describe "Concat" $
it "concatenates two Expr Strs" $ do
let str1 = quote "Hello, "
let str2 = quote "world!"
let str = str1 <> str2
shExpr str `shouldBe` "\"Hello, \"\"world!\""
describe "Shown" $
it "turns an Expr a with Show a into Expr Str" $ do
let l :: Expr Integer
l = Lit 1
let s = Shown l
shExpr s `shouldBe` "1"
describe "StrEquals" $ do
it "checks whether two strings are equal" $ do
let l1 = quote ""
let l2 = quote "hi"
let eqs = l1 .==. l2
shExpr eqs `shouldBe` "[ \"\" = \"hi\" ]"
it "checks whether two strings are not equal" $ do
let l1 = quote ""
let l2 = quote "hi"
let ne = l1 ./=. l2
shExpr ne `shouldBe` "! [ \"\" = \"hi\" ]"
describe "NumCompare" $ do
let n1 = Lit (0 :: Integer)
let n2 = Lit 1
it "checks whether two numbers are equal" $ do
let eq = n1 .==. n2
shExpr eq `shouldBe` "[ 0 -eq 1 ]"
it "checks whether two numbers are not equal" $ do
let eq = n1 ./=. n2
shExpr eq `shouldBe` "! [ 0 -eq 1 ]"
it "checks whether one numbers is less than another" $ do
let lt = n1 .<. n2
shExpr lt `shouldBe` "[ 0 -lt 1 ]"
it "checks whether one number is less than or equal to another" $ do
let le = n1 .<=. n2
shExpr le `shouldBe` "[ 0 -le 1 ]"
it "checks whether one number is greater than another" $ do
let gt = n1 .>. n2
shExpr gt `shouldBe` "[ 0 -gt 1 ]"
it "checks whether one number is greater than or equal to another" $ do
let ge = n1 .>=. n2
shExpr ge `shouldBe` "[ 0 -ge 1 ]"
redirectSpec :: Spec
redirectSpec =
describe "A Redirect" $ do
it "can map a file descriptor to a file" $ do
let r = redirToStr (toFile (path "/tmp/blah"))
shExpr r `shouldBe` "> \"/tmp/blah\""
it "can map a file descriptor to a file for append" $ do
let r = redirToStr (appendToFile (path "/tmp/blah"))
shExpr r `shouldBe` ">> \"/tmp/blah\""
it "can map a file descriptor to a different file descriptor" $ do
let r = redirToStr stderrToStdout
shExpr r `shouldBe` "2>&1"
it "can send a file to stdin" $ do
let inputFile = fromFile (path "/test")
let r = redirToStr inputFile
shExpr r `shouldBe` "< \"/test\""
| corajr/shmonad | test/Control/Monad/Shmonad/ExpressionSpec.hs | bsd-2-clause | 5,547 | 0 | 18 | 1,602 | 1,721 | 829 | 892 | -1 | -1 |
module AERN2.PPoly.Eval where
import MixedTypesNumPrelude
import qualified AERN2.Poly.Cheb as Cheb hiding (evalDf)
import AERN2.Poly.Cheb (ChPoly)
import qualified AERN2.Poly.Cheb.Eval as ChE (evalDirect, evalDf, evalLDf)
import AERN2.PPoly.Type
import AERN2.MP.Ball
import AERN2.Poly.Ball
import AERN2.Interval
import Data.List
import AERN2.RealFun.Operations
import Debug.Trace
evalDirect :: PPoly -> MPBall -> MPBall
evalDirect (PPoly ps dom) x =
foldl1' hullMPBall $
map (\(_,f) -> ChE.evalDirect f xI) intersectingPieces
where
xI = (Cheb.fromDomToUnitInterval dom x)
xAsInterval = dyadicInterval xI
intersectingPieces =
filter (\p -> (fst p) `intersects` xAsInterval) ps
evalDirectWithAccuracy :: Accuracy -> PPoly -> MPBall -> MPBall
evalDirectWithAccuracy bts (PPoly ps dom) x =
foldl1' hullMPBall $
map (\(_,f) -> Cheb.evalDirectWithAccuracy bts f xI) intersectingPieces
where
xI = (Cheb.fromDomToUnitInterval dom x)
xAsInterval = dyadicInterval xI
intersectingPieces =
filter (\p -> (fst p) `intersects` xAsInterval) ps
evalDf :: PPoly -> [ChPoly MPBall] -> MPBall -> MPBall
evalDf (PPoly ps dom) fs' x =
foldl1' hullMPBall $
map (\((_, f), f') -> (ChE.evalDf f f' xI)) intersectingPieces
where
xI = (Cheb.fromDomToUnitInterval dom x)
xAsInterval = dyadicInterval xI
intersectingPieces =
filter (\p -> fst (fst p) `intersects` xAsInterval) $ zip ps fs'
evalLDf :: PPoly -> [ChPoly MPBall] -> MPBall -> MPBall
evalLDf (PPoly ps dom) fs' x =
foldl1' hullMPBall $
map (\((_, f), f') -> (ChE.evalLDf f f' xI)) intersectingPieces
where
xI = (Cheb.fromDomToUnitInterval dom x)
xAsInterval = dyadicInterval (Cheb.fromDomToUnitInterval dom xI)
intersectingPieces =
filter (\p -> fst (fst p) `intersects` xAsInterval) $ zip ps fs'
evalDI :: PPoly -> MPBall -> MPBall
evalDI f@(PPoly ps dom) x =
evalDf f dfs x
where
(Interval l r) = dom
c = 1/!(0.5*(r - l))
dfs = map ((c *) . Cheb.derivative . snd) ps
instance
CanApply PPoly MPBall where
type ApplyType PPoly MPBall = MPBall
apply p x =
case getAccuracy x of
Exact -> evalDirect p x
_ -> evalDI p x
instance
CanApply PPoly (CN MPBall) where
type ApplyType PPoly (CN MPBall) = CN MPBall
apply p x =
-- TODO: check x is in the domain
apply p <$> x
instance CanApplyApprox PPoly DyadicInterval where
type ApplyApproxType PPoly DyadicInterval = DyadicInterval
applyApprox p di =
dyadicInterval (fromEndpointsAsIntervals lB uB)
where
(Interval lB uB) = sampledRange di 5 p :: Interval MPBall MPBall
| michalkonecny/aern2 | aern2-fun-univariate/src/AERN2/PPoly/Eval.hs | bsd-3-clause | 2,584 | 0 | 14 | 504 | 950 | 509 | 441 | -1 | -1 |
{-# LANGUAGE
DeriveDataTypeable
, DeriveFunctor
, DeriveFoldable
, DeriveTraversable
#-}
module Language.TNT.Location
( Point (..)
, Location (..)
, Located (..)
) where
import Control.Comonad
import Data.Data
import Data.Foldable
import Data.Functor.Apply
import Data.Semigroup
import Data.Traversable
data Point = Point Int Int deriving (Show, Eq, Ord, Data, Typeable)
data Location = Location Point Point deriving (Show, Data, Typeable)
data Located a = Locate Location a deriving ( Show
, Functor
, Foldable
, Traversable
, Data
, Typeable
)
instance Semigroup Location where
Location a b <> Location c d = Location (min a c) (max b d)
instance Extend Located where
duplicate w@(Locate x _) = Locate x w
extend f w@(Locate x _) = Locate x (f w)
instance Comonad Located where
extract (Locate _ a) = a
instance Apply Located where
Locate x f <.> Locate y a = Locate (x <> y) (f a) | sonyandy/tnt | Language/TNT/Location.hs | bsd-3-clause | 1,206 | 0 | 9 | 469 | 346 | 183 | 163 | 32 | 0 |
-----------------------------------------------------------------------------
-- |
-- Module : Data.Group.Combinators
-- Copyright : (c) Edward Kmett 2009
-- License : BSD-style
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : portable
--
-- Utilities for working with Groups that conflict with names from the "Prelude".
--
-- Intended to be imported qualified.
--
-- > import Data.Group.Combinators as Group (replicate)
--
-----------------------------------------------------------------------------
module Data.Group.Combinators
( replicate
) where
import Prelude hiding (replicate)
import Data.Monoid (mappend, mempty)
import Data.Group
-- shamelessly stolen from Lennart Augustsson's post:
-- http://augustss.blogspot.com/2008/07/lost-and-found-if-i-write-108-in.html
-- adapted to groups, which can permit negative exponents
replicate :: (Group m, Integral n) => m -> n -> m
replicate x0 y0
| y0 < 0 = f (gnegate x0) (negate y0)
| y0 == 0 = mempty
| otherwise = f x0 y0
where
f x y
| even y = f (x `mappend` x) (y `quot` 2)
| y == 1 = x
| otherwise = g (x `mappend` x) ((y - 1) `quot` 2) x
g x y z
| even y = g (x `mappend` x) (y `quot` 2) z
| y == 1 = x `mappend` z
| otherwise = g (x `mappend` x) ((y - 1) `quot` 2) (x `mappend` z)
| ekmett/monoids | Data/Group/Combinators.hs | bsd-3-clause | 1,410 | 0 | 12 | 346 | 363 | 203 | 160 | 18 | 1 |
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Language.SynArrow where
import Prelude hiding ((.),id,init)
import Control.Category
import Control.Arrow hiding (second)
-- | The AST of arrow syntax
data SynArrow i a b c where
Arr :: a b c -> SynArrow i a b c
First :: SynArrow i a b c -> SynArrow i a (b,d) (c,d)
Compose :: SynArrow i a b c -> SynArrow i a c d -> SynArrow i a b d
Init :: i b -> SynArrow i a b b
Loop :: SynArrow i a (b,d) (c,d) -> SynArrow i a b c
LoopD :: i d -> a (b,d) (c,d) -> SynArrow i a b c
--second :: Optimizable a => SynArrow i a b c -> SynArrow i a (d,b) (d,c)
--second f = Arr swap >>> First f >>> Arr swap
instance Show (SynArrow i a b c) where
showsPrec d e = case e of
(Arr _) -> showParen (d > app_prec)
$ showString "arr _"
(First f) -> showParen (d > app_prec)
$ showString "first "
. showsPrec (app_prec+1) f
(Compose f g) -> showParen (d > compose_prec)
$ showsPrec (compose_prec+1) f
. showString " >>> "
. showsPrec (d+1) g
(Init _) -> showParen (d > app_prec)
$ showString "init _"
(LoopD _ _) -> showParen (d > app_prec)
$ showString "loopD _ _"
(Loop f) -> showParen (d > app_prec)
$ showString "loop "
. showsPrec (app_prec+1) f
where app_prec = 10
compose_prec = 1
instance Category a => Category (SynArrow i a) where
id = Arr id
f . g = Compose g f
instance Arrow a => Arrow (SynArrow i a) where
arr = Arr . arr
first = First
class Category a => SemiArrow a where
swap :: a (b,c) (c,b)
assoc1 :: a ((x,y),z) (x,(y,z))
assoc2 :: a (x,(y,z)) ((x,y),z)
(><) :: a b c -> a b' c' -> a (b,b') (c,c')
dup :: a b (b,b)
instance SemiArrow (->) where
swap (x,y) = (y,x)
assoc1 ((x,y),z) = (x,(y,z))
assoc2 (x,(y,z)) = ((x,y),z)
(><) = (***)
dup a = (a,a)
class Product m where
unit :: m ()
inj :: m a -> m b -> m (a,b)
fix :: m a
optimize :: (SemiArrow a, Product i) => SynArrow i a b c -> SynArrow i a b c
optimize a0 =
case a0 of
normal@(Arr _) -> normal
normal@(LoopD _ _) -> normal
(Init i) -> LoopD i swap
(First f) -> single (First (optimize f))
(Compose f g) -> single (Compose (optimize f) (optimize g))
(Loop f) -> single (Loop (optimize f))
where
single :: (SemiArrow a, Product i) => SynArrow i a b c -> SynArrow i a b c
single b0 =
case b0 of
-- composition
Compose (Arr f) (Arr g) -> Arr (f >>> g)
-- left tightening
Compose (Arr f) (LoopD i g) -> LoopD i ((f >< id) >>> g)
-- right tightening
Compose (LoopD i f) (Arr g) -> LoopD i (f >>> (g >< id))
-- sequencing
Compose (LoopD i f) (LoopD j g) ->
LoopD (inj i j) $ assoc' (juggle' (g >< id) . (f >< id))
-- extension
First (Arr f) -> Arr (f >< id)
-- superposing
First (LoopD i f) -> LoopD i (juggle' (f >< id))
-- loop-extension
Loop (Arr f) -> LoopD fix f
-- vanishing
Loop (LoopD i f) -> LoopD (inj fix i) (assoc' f)
a -> a
assoc' f = assoc2 >>> f >>> assoc1
juggle' f = juggle >>> f >>> juggle
juggle :: SemiArrow a => a ((b,c),d) ((b,d),c)
juggle = assoc2 <<< (id >< swap) <<< assoc1
| svenkeidel/hsynth | src/Language/SynArrow.hs | bsd-3-clause | 3,579 | 0 | 16 | 1,139 | 1,633 | 859 | 774 | 86 | 14 |
{-|
Copyright : (c) Dave Laing, 2017
License : BSD3
Maintainer : [email protected]
Stability : experimental
Portability : non-portable
-}
{-# LANGUAGE ConstraintKinds #-}
module Fragment.Tuple.Rules.Type (
TupleNormalizeConstraint
, tupleNormalizeRules
) where
import Control.Lens (review, preview)
import Rules.Type
import Ast.Type
import Fragment.Tuple.Ast.Type
type TupleNormalizeConstraint ki ty a = AsTyTuple ki ty
normalizeTuple :: TupleNormalizeConstraint ki ty a
=> (Type ki ty a -> Type ki ty a)
-> Type ki ty a
-> Maybe (Type ki ty a)
normalizeTuple normalizeFn ty = do
tys <- preview _TyTuple ty
return $ review _TyTuple (fmap normalizeFn tys)
tupleNormalizeRules :: TupleNormalizeConstraint ki ty a
=> NormalizeInput ki ty a
tupleNormalizeRules =
NormalizeInput [ NormalizeTypeRecurse normalizeTuple ]
| dalaing/type-systems | src/Fragment/Tuple/Rules/Type.hs | bsd-3-clause | 914 | 0 | 10 | 207 | 206 | 109 | 97 | 20 | 1 |
-----------------------------------------------------------------------------
-- |
-- Module : Data.SBV.Examples.Uninterpreted.Function
-- Copyright : (c) Levent Erkok
-- License : BSD3
-- Maintainer : [email protected]
-- Stability : experimental
--
-- Demonstrates function counter-examples
-----------------------------------------------------------------------------
module Data.SBV.Examples.Uninterpreted.Function where
import Data.SBV
-- | An uninterpreted function
f :: SWord8 -> SWord8 -> SWord16
f = uninterpret "f"
-- | Asserts that @f x z == f (y+2) z@ whenever @x == y+2@. Naturally correct:
--
-- >>> prove thmGood
-- Q.E.D.
thmGood :: SWord8 -> SWord8 -> SWord8 -> SBool
thmGood x y z = x .== y+2 ==> f x z .== f (y + 2) z
| josefs/sbv | Data/SBV/Examples/Uninterpreted/Function.hs | bsd-3-clause | 759 | 0 | 8 | 126 | 112 | 67 | 45 | 6 | 1 |
{-# LANGUAGE OverloadedStrings #-}
module Main where
import CMark (Node(..))
import Data.Maybe (fromMaybe)
import Data.Monoid ((<>))
import Data.Morgue.Agenda
import Data.Morgue.Agenda.Types
import Data.Text (Text, pack, stripSuffix)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import System.Environment (getArgs)
-- | generate indent
indent :: Int -> Text
indent k = T.replicate k " "
-- | dump a markdown AST
dump :: Int -> Node -> Text
dump k (Node _ nType ns) =
indent k <> pack (show nType) <> "\n" <> mconcat (map (dump (k + 1)) ns)
-- | dump our own, agenda specific AST
dumpOwn :: Int -> AgendaTree -> Text
dumpOwn k (AgendaTree t []) = indent k <> "elem: " <> repr t <> "\n"
dumpOwn k (AgendaTree t ns) =
indent k <> "elem: " <> repr t <> "\n" <> mconcat (map (dumpOwn (k + 1)) ns)
-- | render an `AgendaElement`
repr :: AgendaElement -> Text
repr (Elem d (Just todo) _ _)
| todo = "[ ] " <> (stripNewline . T.unlines) d
| otherwise = "[x] " <> (stripNewline . T.unlines) d
repr (Elem d Nothing _ _) = (stripNewline . T.unlines) d
-- | strip the trailing newline from a `Text`, if there is any
stripNewline :: Text -> Text
stripNewline = fromMaybe <$> id <*> stripSuffix "\n"
-- | get a file name from the command line
getFileName :: IO FilePath
getFileName = do
args <- getArgs
case args of
f : _ -> return f
_ -> error "no file specified"
-- | glue everything together (we use the guarantee that our tree dump ends with a newline)
main :: IO ()
main = getFileName >>= TIO.readFile >>=
mapM_ (TIO.putStr . dumpOwn 0) . getAgendaTree
| ibabushkin/morgue | app/Dump.hs | bsd-3-clause | 1,619 | 0 | 12 | 340 | 554 | 293 | 261 | 36 | 2 |
--------------------------------------------------------------------------------
-- |
-- Module : Graphics.Rendering.OpenGL.Raw.IBM.VertexArrayLists
-- Copyright : (c) Sven Panne 2015
-- License : BSD3
--
-- Maintainer : Sven Panne <[email protected]>
-- Stability : stable
-- Portability : portable
--
-- The <https://www.opengl.org/registry/specs/IBM/vertex_array_lists.txt IBM_vertex_array_lists> extension.
--
--------------------------------------------------------------------------------
module Graphics.Rendering.OpenGL.Raw.IBM.VertexArrayLists (
-- * Enums
gl_COLOR_ARRAY_LIST_IBM,
gl_COLOR_ARRAY_LIST_STRIDE_IBM,
gl_EDGE_FLAG_ARRAY_LIST_IBM,
gl_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM,
gl_FOG_COORDINATE_ARRAY_LIST_IBM,
gl_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM,
gl_INDEX_ARRAY_LIST_IBM,
gl_INDEX_ARRAY_LIST_STRIDE_IBM,
gl_NORMAL_ARRAY_LIST_IBM,
gl_NORMAL_ARRAY_LIST_STRIDE_IBM,
gl_SECONDARY_COLOR_ARRAY_LIST_IBM,
gl_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM,
gl_TEXTURE_COORD_ARRAY_LIST_IBM,
gl_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM,
gl_VERTEX_ARRAY_LIST_IBM,
gl_VERTEX_ARRAY_LIST_STRIDE_IBM,
-- * Functions
glColorPointerListIBM,
glEdgeFlagPointerListIBM,
glFogCoordPointerListIBM,
glIndexPointerListIBM,
glNormalPointerListIBM,
glSecondaryColorPointerListIBM,
glTexCoordPointerListIBM,
glVertexPointerListIBM
) where
import Graphics.Rendering.OpenGL.Raw.Tokens
import Graphics.Rendering.OpenGL.Raw.Functions
| phaazon/OpenGLRaw | src/Graphics/Rendering/OpenGL/Raw/IBM/VertexArrayLists.hs | bsd-3-clause | 1,481 | 0 | 4 | 154 | 115 | 84 | 31 | 27 | 0 |
{-# LANGUAGE TypeFamilies #-}
module LOGL.Internal.Shader
(
)
where
import Graphics.GLUtil
import LOGL.Internal.Resource
instance Resource ShaderProgram where
type LoadParam ShaderProgram = (String, FilePath, FilePath)
load (name, vfile, ffile) = do
shader <- simpleShaderProgram vfile ffile
return (name, shader)
delete prg = return ()
| atwupack/LearnOpenGL | src/LOGL/Internal/Shader.hs | bsd-3-clause | 368 | 0 | 9 | 74 | 102 | 57 | 45 | 11 | 0 |
-------------------------------------------------------------------------------
---- |
---- Module : Parser
---- Copyright : (c) Syoyo Fujita
---- License : BSD-style
----
---- Maintainer : [email protected]
---- Stability : experimental
---- Portability : GHC 6.10
----
---- Parser : A parser for LLL.
----
-------------------------------------------------------------------------------
{-# LANGUAGE DeriveDataTypeable #-}
module LLL.Parser where
import Text.ParserCombinators.Parsec
import qualified Text.ParserCombinators.Parsec.Token as P
import Text.ParserCombinators.Parsec.Expr
import Text.ParserCombinators.Parsec.Language
import Text.ParserCombinators.Parsec.Error
import Control.Monad.State
import Debug.Trace
import LLL.AST
-- | LLL parser state
data LLLState = LLLState { symbolTable :: SymbolTable
, n :: Int
}
-- | LLL parser having LLL parser state
type LLLParser a = GenParser Char LLLState a
-- | Initial state of shader env.
-- Builtin variables are added in global scope.
initLLLState :: LLLState
initLLLState = LLLState {
symbolTable = [("global", [])]
, n = 0
}
-- | Push scope into the symbol table
pushScope :: String -> [Symbol] -> LLLState -> LLLState
pushScope scope xs st =
st { symbolTable = newTable }
where
-- Add new scope to the first elem of the list.
newTable = [(scope, xs)] ++ (symbolTable st)
-- | Pop scope from the symbol table
popScope :: LLLState -> LLLState
popScope st =
st { symbolTable = newTable }
where
-- Pop first scope from the scope chain
newTable = tail (symbolTable st)
-- | Add the symbol to the first scope in the symbol list.
-- TODO: Check duplication of the symbol.
addSymbol :: Symbol -> LLLState -> LLLState
addSymbol sym st = trace ("// Add " ++ (show sym)) $
st { symbolTable = newTable }
where
newTable = case (symbolTable st) of
[(scope, xs)] -> [(scope, [sym] ++ xs)]
((scope, xs):xxs) -> [(scope, [sym] ++ xs)] ++ xxs
--
-- Topmost parsing rule
--
program :: LLLParser LLLUnit
program = do { ast <- many (spaces >> global)
; return ast
}
<?> "shader program"
global :: LLLParser Func
global = functionDefinition
<?> "top level definition"
functionDefinition ::LLLParser Func
functionDefinition = do { ty <- option (TyVoid) funType
; name <- identifier
; symbol "("
; symbol ")"
-- push scope
; updateState (pushScope name [])
; symbol "{"
; symbol "}"
-- pop scope
; updateState (popScope)
-- Add user function to global scope.
; -- updateState (addSymbol $ mkFunSym name ty (extractTysFromDecls decls))
; return (ShaderFunc ty name)
}
<?> "function definition"
funType = (reserved "void" >> return TyVoid)
--
-- Parse error reporting routines
--
offt :: Int -> String
offt n = replicate n ' '
showLine :: SourceName -> Int -> Int -> IO ()
showLine name n m =
do input <- readFile name
if (length (lines input)) < n
then
if length (lines input) == 0
then putStrLn ""
else
do { putStrLn $ (lines input) !! ((length (lines input)) - 1)
; putStrLn ""
; putStrLn $ ((offt (m-1)) ++ "^")
}
else
do { let l = (lines input) !! (n-1)
; putStrLn l
; putStrLn $ ((offt (m-1)) ++ "^")
}
--
-- Parser interface
--
parseLLLFromFile :: LLLParser a -> SourceName -> IO (Either ParseError a)
parseLLLFromFile p fname =
do { input <- readFile fname
; return (runParser p initLLLState fname input)
}
--
-- Same as in Error.hs of Parsec, just replaced to show error line.
--
showErrorMsg :: ParseError -> FilePath -> String
showErrorMsg err fname =
show (setSourceName (errorPos err) fname) ++ ":" ++
showErrorMessages "or" "unknown parse error"
"expecting" "unexpected" "end of input"
(errorMessages err)
mkMyError :: ParseError -> FilePath -> ParseError
mkMyError err fname = setErrorPos (setSourceName (errorPos err) fname) err
run :: LLLParser LLLUnit -> FilePath -> FilePath -> (LLLUnit -> IO ()) -> IO ()
run p prepname name proc =
do { result <- parseLLLFromFile p prepname
; case (result) of
Left err -> do { -- Parse preprocessed file, but print original file
-- when reporting error.
putStrLn "Parse err:"
; showLine name (sourceLine (errorPos err)) (sourceColumn (errorPos err))
; print (mkMyError err name)
}
Right x -> do { proc x
}
}
runLex :: LLLParser LLLUnit -> FilePath -> FilePath -> (LLLUnit -> IO ()) -> IO ()
runLex p prepname name proc =
run (do { whiteSpace
; x <- p
; eof
; return x
}
) prepname name proc
--
-- Useful parsing tools
--
lexer = P.makeTokenParser rslStyle
whiteSpace = P.whiteSpace lexer
lexeme = P.lexeme lexer
symbol = P.symbol lexer
natural = P.natural lexer
naturalOrFloat = P.naturalOrFloat lexer
stringLiteral = P.stringLiteral lexer
float = P.float lexer
parens = P.parens lexer
braces = P.braces lexer
semi = P.semi lexer
commaSep = P.commaSep lexer
identifier = P.identifier lexer
reserved = P.reserved lexer
reservedOp = P.reservedOp lexer
{-
expr :: LLLParser Expr
expr = buildExpressionParser table primary
<?> "expression"
primary = try (parens expr)
<|> triple
<|> try varRef
<|> procedureCall -- Do I really need "try"?
-- <|> procedureCall -- Do I really need "try"?
<|> number
<|> constString
<?> "primary"
table = [
-- typecast
[typecast]
-- unary
, [prefix "-" OpSub, prefix "!" OpNeg]
-- binop
, [binOp "." OpDot AssocLeft]
, [binOp "*" OpMul AssocLeft, binOp "/" OpDiv AssocLeft]
, [binOp "+" OpAdd AssocLeft, binOp "-" OpSub AssocLeft]
-- relop
, [binOp ">" OpGt AssocLeft, binOp ">=" OpGe AssocLeft]
, [binOp "<" OpLt AssocLeft, binOp "<=" OpLe AssocLeft]
, [binOp "==" OpEq AssocLeft, binOp "!=" OpNeq AssocLeft]
-- logop
, [binOp "&&" OpAnd AssocLeft, binOp "||" OpOr AssocLeft]
-- a ? b : c
, [conditional]
-- assign
, [ assignOp "=" OpAssign AssocRight
, assignOp "+=" OpAddAssign AssocRight
, assignOp "-=" OpSubAssign AssocRight
, assignOp "*=" OpMulAssign AssocRight
, assignOp "/=" OpDivAssign AssocRight
]
]
where
typecast
= Prefix ( do { ty <- rslType
; spacety <- option "" stringLiteral
; return (\e -> TypeCast Nothing ty spacety e)
} <?> "typecast" )
prefix name f
= Prefix ( do { reservedOp name
; return (\x -> UnaryOp Nothing f x)
} )
binOp name f assoc
= Infix ( do { reservedOp name
; return (\x y -> BinOp Nothing f x y)
} ) assoc
conditional
= Infix ( do { reservedOp "?"
; thenExpr <- expr
; reservedOp ":"
; return (\condExpr elseExpr -> Conditional Nothing condExpr thenExpr elseExpr)
} <?> "conditional" ) AssocRight
assignOp name f assoc
= Infix ( do { state <- getState
; reservedOp name
; return (\x y -> mkAssign f x y)
} <?> "assign" ) assoc
-- Make Assign node with flattening expression.
mkAssign :: Op -> Expr -> Expr -> Expr
mkAssign op x y = case op of
OpAssign -> Assign Nothing OpAssign x y
OpAddAssign -> Assign Nothing OpAssign x (BinOp Nothing OpAdd x y)
OpSubAssign -> Assign Nothing OpAssign x (BinOp Nothing OpSub x y)
OpMulAssign -> Assign Nothing OpAssign x (BinOp Nothing OpMul x y)
OpDivAssign -> Assign Nothing OpAssign x (BinOp Nothing OpDiv x y)
-}
rslStyle = javaStyle
{ reservedNames = [ "const"
, "break", "continue"
, "while", "if", "for", "solar", "illuminate", "illuminance"
, "surface", "volume", "displacement", "imager"
, "varying", "uniform", "facevarygin", "facevertex"
, "output"
, "extern"
, "return"
, "color", "vector", "normal", "matrix", "point", "void"
-- LLL 2.0
, "public", "class", "struct"
-- More is TODO
]
, reservedOpNames = ["+", "-", "*", "/"] -- More is TODO
, caseSensitive = True
, commentStart = "/*"
, commentEnd = "*/"
, commentLine = "//"
, nestedComments = True
}
| syoyo/LLL | LLL/Parser.hs | bsd-3-clause | 10,335 | 1 | 17 | 4,201 | 1,598 | 879 | 719 | 124 | 3 |
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveGeneric #-}
module Forml.Types.Namespace where
import Language.Javascript.JMacro
import Control.Applicative
import Text.Parsec hiding ((<|>), State, many, spaces, parse, label)
import Data.Monoid
import qualified Data.List as L
import Data.Serialize
import GHC.Generics
import Forml.Parser.Utils
import Forml.Javascript.Utils
import Prelude hiding (curry, (++))
newtype Namespace = Namespace [String] deriving (Eq, Ord, Generic)
instance Serialize Namespace
instance Monoid Namespace where
mempty = Namespace []
mappend (Namespace x) (Namespace y) = Namespace (x ++ y)
instance Show Namespace where
show (Namespace []) = "global"
show (Namespace x) = concat $ L.intersperse "." x
instance Syntax Namespace where
syntax = Namespace <$> (many1 (lower <|> char '_') `sepBy1` char '.')
instance ToJExpr Namespace where
toJExpr (Namespace []) = [jmacroE| (typeof global == "undefined" ? window : global) |]
toJExpr (Namespace (end -> x : xs)) = [jmacroE| `(Namespace xs)`["$" ++ `(x)`] |]
data Module = Module Namespace [Module]
| Var String
instance Show Module where
show (Module (Namespace (reverse -> (x:_))) _) = x
show (Var s) = s
| texodus/forml | src/hs/lib/Forml/Types/Namespace.hs | bsd-3-clause | 1,574 | 0 | 14 | 271 | 415 | 239 | 176 | 41 | 0 |
-- (c) 1999-2005 by Martin Erwig [see file COPYRIGHT]
-- | Static and Dynamic Inductive Graphs
module Data.Graph.Inductive.Graph (
-- * General Type Defintions
-- ** Node and Edge Types
Node,LNode,UNode,
Edge,LEdge,UEdge,
-- ** Types Supporting Inductive Graph View
Adj,Context,MContext,Decomp,GDecomp,UDecomp,
Path,LPath(..),UPath,
-- * Graph Type Classes
-- | We define two graph classes:
--
-- Graph: static, decomposable graphs.
-- Static means that a graph itself cannot be changed
--
-- DynGraph: dynamic, extensible graphs.
-- Dynamic graphs inherit all operations from static graphs
-- but also offer operations to extend and change graphs.
--
-- Each class contains in addition to its essential operations those
-- derived operations that might be overwritten by a more efficient
-- implementation in an instance definition.
--
-- Note that labNodes is essentially needed because the default definition
-- for matchAny is based on it: we need some node from the graph to define
-- matchAny in terms of match. Alternatively, we could have made matchAny
-- essential and have labNodes defined in terms of ufold and matchAny.
-- However, in general, labNodes seems to be (at least) as easy to define
-- as matchAny. We have chosen labNodes instead of the function nodes since
-- nodes can be easily derived from labNodes, but not vice versa.
Graph(..),
DynGraph(..),
-- * Operations
-- ** Graph Folds and Maps
ufold,gmap,nmap,emap,
-- ** Graph Projection
nodes,edges,newNodes,gelem,
-- ** Graph Construction and Destruction
insNode,insEdge,delNode,delEdge,delLEdge,
insNodes,insEdges,delNodes,delEdges,
buildGr,mkUGraph,
-- ** Graph Inspection
context,lab,neighbors,
suc,pre,lsuc,lpre,
out,inn,outdeg,indeg,deg,
equal,
-- ** Context Inspection
node',lab',labNode',neighbors',
suc',pre',lpre',lsuc',
out',inn',outdeg',indeg',deg',
) where
import Data.List (sortBy)
{- Signatures:
-- basic operations
empty :: Graph gr => gr a b
isEmpty :: Graph gr => gr a b -> Bool
match :: Graph gr => Node -> gr a b -> Decomp gr a b
mkGraph :: Graph gr => [LNode a] -> [LEdge b] -> gr a b
(&) :: DynGraph gr => Context a b -> gr a b -> gr a b
-- graph folds and maps
ufold :: Graph gr => ((Context a b) -> c -> c) -> c -> gr a b -> c
gmap :: Graph gr => (Context a b -> Context c d) -> gr a b -> gr c d
nmap :: Graph gr => (a -> c) -> gr a b -> gr c b
emap :: Graph gr => (b -> c) -> gr a b -> gr a c
-- graph projection
matchAny :: Graph gr => gr a b -> GDecomp g a b
nodes :: Graph gr => gr a b -> [Node]
edges :: Graph gr => gr a b -> [Edge]
labNodes :: Graph gr => gr a b -> [LNode a]
labEdges :: Graph gr => gr a b -> [LEdge b]
newNodes :: Graph gr => Int -> gr a b -> [Node]
noNodes :: Graph gr => gr a b -> Int
nodeRange :: Graph gr => gr a b -> (Node,Node)
gelem :: Graph gr => Node -> gr a b -> Bool
-- graph construction & destruction
insNode :: DynGraph gr => LNode a -> gr a b -> gr a b
insEdge :: DynGraph gr => LEdge b -> gr a b -> gr a b
delNode :: Graph gr => Node -> gr a b -> gr a b
delEdge :: DynGraph gr => Edge -> gr a b -> gr a b
delLEdge :: (DynGraph gr, Eq b) =>
LEdge b -> gr a b -> gr a b
insNodes :: DynGraph gr => [LNode a] -> gr a b -> gr a b
insEdges :: DynGraph gr => [LEdge b] -> gr a b -> gr a b
delNodes :: Graph gr => [Node] -> gr a b -> gr a b
delEdges :: DynGraph gr => [Edge] -> gr a b -> gr a b
buildGr :: DynGraph gr => [Context a b] -> gr a b
mkUGraph :: DynGraph gr => [Node] -> [Edge] -> gr () ()
-- graph inspection
context :: Graph gr => gr a b -> Node -> Context a b
lab :: Graph gr => gr a b -> Node -> Maybe a
neighbors :: Graph gr => gr a b -> Node -> [Node]
suc :: Graph gr => gr a b -> Node -> [Node]
pre :: Graph gr => gr a b -> Node -> [Node]
lsuc :: Graph gr => gr a b -> Node -> [(Node,b)]
lpre :: Graph gr => gr a b -> Node -> [(Node,b)]
out :: Graph gr => gr a b -> Node -> [LEdge b]
inn :: Graph gr => gr a b -> Node -> [LEdge b]
outdeg :: Graph gr => gr a b -> Node -> Int
indeg :: Graph gr => gr a b -> Node -> Int
deg :: Graph gr => gr a b -> Node -> Int
-- context inspection
node' :: Context a b -> Node
lab' :: Context a b -> a
labNode' :: Context a b -> LNode a
neighbors' :: Context a b -> [Node]
suc' :: Context a b -> [Node]
pre' :: Context a b -> [Node]
lpre' :: Context a b -> [(Node,b)]
lsuc' :: Context a b -> [(Node,b)]
out' :: Context a b -> [LEdge b]
inn' :: Context a b -> [LEdge b]
outdeg' :: Context a b -> Int
indeg' :: Context a b -> Int
deg' :: Context a b -> Int
-}
-- | Unlabeled node
type Node = Int
-- | Labeled node
type LNode a = (Node,a)
-- | Quasi-unlabeled node
type UNode = LNode ()
-- | Unlabeled edge
type Edge = (Node,Node)
-- | Labeled edge
type LEdge b = (Node,Node,b)
-- | Quasi-unlabeled edge
type UEdge = LEdge ()
-- | Unlabeled path
type Path = [Node]
-- | Labeled path
newtype LPath a = LP [LNode a]
instance Show a => Show (LPath a) where
show (LP xs) = show xs
-- | Quasi-unlabeled path
type UPath = [UNode]
-- | Labeled links to or from a 'Node'.
type Adj b = [(b,Node)]
-- | Links to the 'Node', the 'Node' itself, a label, links from the 'Node'.
type Context a b = (Adj b,Node,a,Adj b) -- Context a b "=" Context' a b "+" Node
type MContext a b = Maybe (Context a b)
-- | 'Graph' decomposition - the context removed from a 'Graph', and the rest
-- of the 'Graph'.
type Decomp g a b = (MContext a b,g a b)
-- | The same as 'Decomp', only more sure of itself.
type GDecomp g a b = (Context a b,g a b)
-- | Unlabeled context.
type UContext = ([Node],Node,[Node])
-- | Unlabeled decomposition.
type UDecomp g = (Maybe UContext,g)
-- | Minimum implementation: 'empty', 'isEmpty', 'match', 'mkGraph', 'labNodes'
class Graph gr where
-- essential operations
-- | An empty 'Graph'.
empty :: gr a b
-- | True if the given 'Graph' is empty.
isEmpty :: gr a b -> Bool
-- | Decompose a 'Graph' into the 'MContext' found for the given node and the
-- remaining 'Graph'.
match :: Node -> gr a b -> Decomp gr a b
-- | Create a 'Graph' from the list of 'LNode's and 'LEdge's.
mkGraph :: [LNode a] -> [LEdge b] -> gr a b
-- | A list of all 'LNode's in the 'Graph'.
labNodes :: gr a b -> [LNode a]
-- derived operations
-- | Decompose a graph into the 'Context' for an arbitrarily-chosen 'Node'
-- and the remaining 'Graph'.
matchAny :: gr a b -> GDecomp gr a b
-- | The number of 'Node's in a 'Graph'.
noNodes :: gr a b -> Int
-- | The minimum and maximum 'Node' in a 'Graph'.
nodeRange :: gr a b -> (Node,Node)
-- | A list of all 'LEdge's in the 'Graph'.
labEdges :: gr a b -> [LEdge b]
-- default implementation of derived operations
matchAny g = case labNodes g of
[] -> error "Match Exception, Empty Graph"
(v,_):_ -> (c,g') where (Just c,g') = match v g
noNodes = length . labNodes
nodeRange g = (minimum vs,maximum vs) where vs = map fst (labNodes g)
labEdges = ufold (\(_,v,_,s)->((map (\(l,w)->(v,w,l)) s)++)) []
class Graph gr => DynGraph gr where
-- | Merge the 'Context' into the 'DynGraph'.
(&) :: Context a b -> gr a b -> gr a b
-- | Fold a function over the graph.
ufold :: Graph gr => ((Context a b) -> c -> c) -> c -> gr a b -> c
ufold f u g | isEmpty g = u
| otherwise = f c (ufold f u g')
where (c,g') = matchAny g
-- | Map a function over the graph.
gmap :: DynGraph gr => (Context a b -> Context c d) -> gr a b -> gr c d
gmap f = ufold (\c->(f c&)) empty
-- | Map a function over the 'Node' labels in a graph.
nmap :: DynGraph gr => (a -> c) -> gr a b -> gr c b
nmap f = gmap (\(p,v,l,s)->(p,v,f l,s))
-- | Map a function over the 'Edge' labels in a graph.
emap :: DynGraph gr => (b -> c) -> gr a b -> gr a c
emap f = gmap (\(p,v,l,s)->(map1 f p,v,l,map1 f s))
where map1 g = map (\(l,v)->(g l,v))
-- | List all 'Node's in the 'Graph'.
nodes :: Graph gr => gr a b -> [Node]
nodes = map fst . labNodes
-- | List all 'Edge's in the 'Graph'.
edges :: Graph gr => gr a b -> [Edge]
edges = map (\(v,w,_)->(v,w)) . labEdges
-- | List N available 'Node's, i.e. 'Node's that are not used in the 'Graph'.
newNodes :: Graph gr => Int -> gr a b -> [Node]
newNodes i g = [n+1..n+i] where (_,n) = nodeRange g
-- | 'True' if the 'Node' is present in the 'Graph'.
gelem :: Graph gr => Node -> gr a b -> Bool
gelem v g = case match v g of {(Just _,_) -> True; _ -> False}
-- | Insert a 'LNode' into the 'Graph'.
insNode :: DynGraph gr => LNode a -> gr a b -> gr a b
insNode (v,l) = (([],v,l,[])&)
-- | Insert a 'LEdge' into the 'Graph'.
insEdge :: DynGraph gr => LEdge b -> gr a b -> gr a b
insEdge (v,w,l) g = (pr,v,la,(l,w):su) & g'
where (Just (pr,_,la,su),g') = match v g
-- | Remove a 'Node' from the 'Graph'.
delNode :: Graph gr => Node -> gr a b -> gr a b
delNode v = delNodes [v]
-- | Remove an 'Edge' from the 'Graph'.
delEdge :: DynGraph gr => Edge -> gr a b -> gr a b
delEdge (v,w) g = case match v g of
(Nothing,_) -> g
(Just (p,v',l,s),g') -> (p,v',l,filter ((/=w).snd) s) & g'
-- | Remove an 'LEdge' from the 'Graph'.
delLEdge :: (DynGraph gr, Eq b) => LEdge b -> gr a b -> gr a b
delLEdge (v,w,b) g = case match v g of
(Nothing,_) -> g
(Just (p,v',l,s),g') -> (p,v',l,filter (\(x,n) -> x /= b || n /= w) s) & g'
-- | Insert multiple 'LNode's into the 'Graph'.
insNodes :: DynGraph gr => [LNode a] -> gr a b -> gr a b
insNodes vs g = foldr insNode g vs
-- | Insert multiple 'LEdge's into the 'Graph'.
insEdges :: DynGraph gr => [LEdge b] -> gr a b -> gr a b
insEdges es g = foldr insEdge g es
-- | Remove multiple 'Node's from the 'Graph'.
delNodes :: Graph gr => [Node] -> gr a b -> gr a b
delNodes [] g = g
delNodes (v:vs) g = delNodes vs (snd (match v g))
-- | Remove multiple 'Edge's from the 'Graph'.
delEdges :: DynGraph gr => [Edge] -> gr a b -> gr a b
delEdges es g = foldr delEdge g es
-- | Build a 'Graph' from a list of 'Context's.
buildGr :: DynGraph gr => [Context a b] -> gr a b
buildGr = foldr (&) empty
-- mkGraph :: DynGraph gr => [LNode a] -> [LEdge b] -> gr a b
-- mkGraph vs es = (insEdges es . insNodes vs) empty
-- | Build a quasi-unlabeled 'Graph'.
mkUGraph :: Graph gr => [Node] -> [Edge] -> gr () ()
mkUGraph vs es = mkGraph (labUNodes vs) (labUEdges es)
labUEdges = map (\(v,w)->(v,w,()))
labUNodes = map (\v->(v,()))
-- | Find the context for the given 'Node'. Causes an error if the 'Node' is
-- not present in the 'Graph'.
context :: Graph gr => gr a b -> Node -> Context a b
context g v = case match v g of
(Nothing,_) -> error ("Match Exception, Node: "++show v)
(Just c,_) -> c
-- | Find the label for a 'Node'.
lab :: Graph gr => gr a b -> Node -> Maybe a
lab g v = fst (match v g) >>= return.lab'
-- | Find the neighbors for a 'Node'.
neighbors :: Graph gr => gr a b -> Node -> [Node]
neighbors = (\(p,_,_,s) -> map snd (p++s)) .: context
-- | Find all 'Node's that have a link from the given 'Node'.
suc :: Graph gr => gr a b -> Node -> [Node]
suc = map snd .: context4
-- | Find all 'Node's that link to to the given 'Node'.
pre :: Graph gr => gr a b -> Node -> [Node]
pre = map snd .: context1
-- | Find all 'Node's that are linked from the given 'Node' and the label of
-- each link.
lsuc :: Graph gr => gr a b -> Node -> [(Node,b)]
lsuc = map flip2 .: context4
-- | Find all 'Node's that link to the given 'Node' and the label of each link.
lpre :: Graph gr => gr a b -> Node -> [(Node,b)]
lpre = map flip2 .: context1
-- | Find all outward-bound 'LEdge's for the given 'Node'.
out :: Graph gr => gr a b -> Node -> [LEdge b]
out g v = map (\(l,w)->(v,w,l)) (context4 g v)
-- | Find all inward-bound 'LEdge's for the given 'Node'.
inn :: Graph gr => gr a b -> Node -> [LEdge b]
inn g v = map (\(l,w)->(w,v,l)) (context1 g v)
-- | The outward-bound degree of the 'Node'.
outdeg :: Graph gr => gr a b -> Node -> Int
outdeg = length .: context4
-- | The inward-bound degree of the 'Node'.
indeg :: Graph gr => gr a b -> Node -> Int
indeg = length .: context1
-- | The degree of the 'Node'.
deg :: Graph gr => gr a b -> Node -> Int
deg = (\(p,_,_,s) -> length p+length s) .: context
-- | The 'Node' in a 'Context'.
node' :: Context a b -> Node
node' (_,v,_,_) = v
-- | The label in a 'Context'.
lab' :: Context a b -> a
lab' (_,_,l,_) = l
-- | The 'LNode' from a 'Context'.
labNode' :: Context a b -> LNode a
labNode' (_,v,l,_) = (v,l)
-- | All 'Node's linked to or from in a 'Context'.
neighbors' :: Context a b -> [Node]
neighbors' (p,_,_,s) = map snd p++map snd s
-- | All 'Node's linked to in a 'Context'.
suc' :: Context a b -> [Node]
suc' (_,_,_,s) = map snd s
-- | All 'Node's linked from in a 'Context'.
pre' :: Context a b -> [Node]
pre' (p,_,_,_) = map snd p
-- | All 'Node's linked from in a 'Context', and the label of the links.
lpre' :: Context a b -> [(Node,b)]
lpre' (p,_,_,_) = map flip2 p
-- | All 'Node's linked from in a 'Context', and the label of the links.
lsuc' :: Context a b -> [(Node,b)]
lsuc' (_,_,_,s) = map flip2 s
-- | All outward-directed 'LEdge's in a 'Context'.
out' :: Context a b -> [LEdge b]
out' (_,v,_,s) = map (\(l,w)->(v,w,l)) s
-- | All inward-directed 'LEdge's in a 'Context'.
inn' :: Context a b -> [LEdge b]
inn' (p,v,_,_) = map (\(l,w)->(w,v,l)) p
-- | The outward degree of a 'Context'.
outdeg' :: Context a b -> Int
outdeg' (_,_,_,s) = length s
-- | The inward degree of a 'Context'.
indeg' :: Context a b -> Int
indeg' (p,_,_,_) = length p
-- | The degree of a 'Context'.
deg' :: Context a b -> Int
deg' (p,_,_,s) = length p+length s
-- graph equality
--
nodeComp :: Eq b => LNode b -> LNode b -> Ordering
nodeComp n@(v,_) n'@(w,_) | n == n' = EQ
| v<w = LT
| otherwise = GT
slabNodes :: (Eq a,Graph gr) => gr a b -> [LNode a]
slabNodes = sortBy nodeComp . labNodes
edgeComp :: Eq b => LEdge b -> LEdge b -> Ordering
edgeComp e@(v,w,_) e'@(x,y,_) | e == e' = EQ
| v<x || (v==x && w<y) = LT
| otherwise = GT
slabEdges :: (Eq b,Graph gr) => gr a b -> [LEdge b]
slabEdges = sortBy edgeComp . labEdges
-- instance (Eq a,Eq b,Graph gr) => Eq (gr a b) where
-- g == g' = slabNodes g == slabNodes g' && slabEdges g == slabEdges g'
equal :: (Eq a,Eq b,Graph gr) => gr a b -> gr a b -> Bool
equal g g' = slabNodes g == slabNodes g' && slabEdges g == slabEdges g'
----------------------------------------------------------------------
-- UTILITIES
----------------------------------------------------------------------
-- auxiliary functions used in the implementation of the
-- derived class members
--
(.:) :: (c -> d) -> (a -> b -> c) -> (a -> b -> d)
-- f .: g = \x y->f (g x y)
-- f .: g = (f .) . g
-- (.:) f = ((f .) .)
-- (.:) = (.) (.) (.)
(.:) = (.) . (.)
fst4 (x,_,_,_) = x
{- not used
snd4 (_,x,_,_) = x
thd4 (_,_,x,_) = x
-}
fth4 (_,_,_,x) = x
{- not used
fst3 (x,_,_) = x
snd3 (_,x,_) = x
thd3 (_,_,x) = x
-}
flip2 (x,y) = (y,x)
-- projecting on context elements
--
-- context1 g v = fst4 (contextP g v)
context1 :: Graph gr => gr a b -> Node -> Adj b
{- not used
context2 :: Graph gr => gr a b -> Node -> Node
context3 :: Graph gr => gr a b -> Node -> a
-}
context4 :: Graph gr => gr a b -> Node -> Adj b
context1 = fst4 .: context
{- not used
context2 = snd4 .: context
context3 = thd4 .: context
-}
context4 = fth4 .: context
| FranklinChen/hugs98-plus-Sep2006 | packages/fgl/Data/Graph/Inductive/Graph.hs | bsd-3-clause | 16,059 | 0 | 15 | 4,293 | 4,408 | 2,435 | 1,973 | 180 | 2 |
{-# LANGUAGE TupleSections, GADTs, StandaloneDeriving, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts #-}
module IndexedState
where
newtype IStateT m i o a = IStateT { runIState :: i -> m (o, a) }
class IMonad m where
ireturn :: a -> m i i a
(>>>=) :: m i j a -> (a -> m j k b) -> m i k b
(>>>) :: IMonad m => m i j a -> m j k b -> m i k b
mx >>> my = mx >>>= const my
class IMonadTrans t where
ilift :: Monad m => m a -> t m i i a
iget :: Monad m => IStateT m s s s
iget = IStateT $ \s -> return (s, s)
iput :: Monad m => o -> IStateT m i o ()
iput x = IStateT $ \_ -> return (x, ())
imodify :: Monad m => (i -> o) -> IStateT m i o ()
imodify f = IStateT $ \s -> return (f s, ())
instance Monad m => IMonad (IStateT m) where
ireturn x = IStateT (\s -> return (s, x))
IStateT f >>>= g = IStateT $ \s -> do
(s', x) <- f s
let IStateT h = g x
h s'
instance IMonadTrans IStateT where
ilift m = IStateT $ \s -> m >>= \x -> return (s, x)
type StateMachine = IStateT IO
newtype Size = Size Int deriving (Read, Show)
newtype Height = Height Int deriving (Read, Show)
newtype Weight = Weight Int deriving (Read, Show)
newtype Colour = Colour String deriving (Read, Show)
askKnownSize :: StateMachine as (Bool, as) Bool
askKnownSize = askYN' "Do you know your size?"
-- askSize takes an environment of type as and adds a Size element
askSize :: StateMachine as (Size, as) ()
askSize = askNumber "What is your size?" Size
receiveSize :: String -> StateMachine as (Size, as) ()
receiveSize = receiveNumber Size
-- askHeight takes an environment of type as and adds a Height element
askHeight :: StateMachine as (Height, as) ()
askHeight = askNumber "What is your height?" Height
-- etc
askWeight :: StateMachine as (Weight, as) ()
askWeight = askNumber "What is your weight?" Weight
askColour :: StateMachine as (Colour, as) ()
askColour =
ilift (putStrLn "What is your favourite colour?") >>>
ilift readLn >>>= \answer ->
imodify (Colour answer,)
calculateSize :: Height -> Weight -> Size
calculateSize (Height h) (Weight w) = Size (h - w) -- or whatever the calculation is
askNumber :: String -> (Int -> a) -> StateMachine as (a, as) ()
askNumber question mk =
ilift (putStrLn question) >>>
ilift readLn >>>= \answer ->
case reads answer of
[(x, _)] -> imodify (mk x,)
_ -> ilift (putStrLn "Please type a number") >>> askNumber question mk
justAskColour :: StateMachine as (Maybe Colour, as) ()
justAskColour =
ilift (putStrLn "What is your favourite colour?") >>>
imodify (Nothing, )
justAnswer :: String -> Suspended -> StateMachine as (Maybe Colour, (Size, (Bool, ()))) ()
justAnswer answer (Suspended AskSize e) =
iput e >>>
receiveSize answer >>>
iget >>>= \ s -> undefined -- resume' AskColour (Just s) --TODO: rewrite types of resume' and resume
receiveNumber :: (Int -> a) -> String -> StateMachine as (a, as) ()
receiveNumber mk answer =
case reads answer of
[(x, _)] -> imodify (mk x,)
_ -> error "invalid number"
askYN :: String -> StateMachine as as Bool
askYN question =
ilift (putStrLn question) >>>
ilift readLn >>>= \answer ->
case answer of
"y" -> ireturn True
"n" -> ireturn False
_ -> ilift (putStrLn "Please type y or n") >>> askYN question
askYN' :: String -> StateMachine as (Bool, as) Bool
askYN' question =
ilift (putStrLn question) >>>
ilift readLn >>>= \answer ->
case answer of
"y" -> imodify (True,) >>> ireturn True
"n" -> imodify (False,) >>> ireturn False
_ -> ilift (putStrLn "Please type y or n") >>> askYN' question
answerYN question answer =
case answer of
"y" -> imodify (True,) >>> ireturn True
"n" -> imodify (False,) >>> ireturn False
_ -> ilift (putStrLn "Please type y or n") >>> askYN' question
-- interaction :: StateMachine xs (Colour, (Size, xs)) ()
-- interaction :: interaction :: StateMachine () (Colour, (Size, ())) ()
interaction =
(suspend AskKnownSize >>> askKnownSize) >>>= \ answer ->
askOrCalculateSize answer >>>
askColour
where
askOrCalculateSize True = suspend AskSize >>> askSize
askOrCalculateSize False =
(suspend AskWeight >>> askWeight) >>>
(suspend AskHeight >>> askHeight) >>>
imodify (\ (h, (w, xs)) -> (calculateSize h w, xs)) >>> suspend AskColour
-- interaction' :: (Functor m, Show as) => i -> IStateT m i as t -> Stage as -> m Suspended
-- interaction' as machine stage = (\(r, _) -> Suspended stage r) <$> runIState machine as
--
-- interaction'' =
-- askYN "Do you know your size?" >>>= \ ans -> suspend AskWeight
-- interaction' () askWeight AskHeight
-- interaction' () askWeight AskHeight
data Stage as where
AskKnownSize :: Stage ()
AskSize :: Stage (Bool, ())
AskWeight :: Stage (Bool, ())
AskHeight :: Stage (Weight, (Bool, ()))
AskColour :: Stage (Size, (Bool, ()))
deriving instance Show (Stage as)
data Suspended where
Suspended :: (Show as) => Stage as -> as -> Suspended
instance Show Suspended where
show (Suspended stage as) = show stage ++ ", " ++ show as
instance Read Suspended where
readsPrec = const $ uncurry ($) . mapFst parse . fmap (drop 2) . break (==',')
where
parse :: String -> String -> [(Suspended, String)]
parse stage = case stage of
"AskKnownSize" -> parse' AskKnownSize
"AskSize" -> parse' AskSize
"AskWeight" -> parse' AskWeight
"AskHeight" -> parse' AskHeight
"AskColour" -> parse' AskColour
_ -> const []
parse' :: (Show as, Read as) => Stage as -> String -> [(Suspended, String)]
parse' stg st = [(Suspended stg (read st), mempty)]
mapFst :: (a -> c) -> (a, b) -> (c, b)
mapFst f ~(a, b) = (f a, b)
-- WORKS: runIState (resume (read "AskColour, (Size 33, (True, ()))" )) ()
-- WORKS: runIState (resume (read "AskKnownSize, ()" )) ()
-- runIState (resume (Suspended AskWeight (False, ()) )) ()
-- runIState (resume (Suspended AskHeight (Weight 40, ()))) ()
resume :: Suspended -> StateMachine as (Colour, (Size, (Bool, ()))) ()
resume (Suspended AskKnownSize e) =
iput e >>>
askKnownSize >>>= \ b ->
resume' (if b then AskSize else AskWeight) (b, e)
resume (Suspended AskSize e) =
iput e >>>
askSize >>>
iget >>>= resume' AskColour
resume (Suspended AskWeight e) =
iput e >>>
askWeight >>>
iget >>>= resume' AskHeight
resume (Suspended AskHeight e) =
iput e >>>
askHeight >>>
imodify (\(h, (w, xs)) -> (calculateSize h w, xs)) >>>
iget >>>= resume' AskColour
resume (Suspended AskColour e) =
iput e >>>
askColour
resume' :: Show as => Stage as -> as -> StateMachine as (Colour, (Size, (Bool, ()))) ()
resume' stage as = suspend stage >>> resume (Suspended stage as)
-- given persist :: Suspended -> IO ()
suspend :: (Show as) => Stage as -> StateMachine as as ()
suspend stage =
iget >>>= \env ->
ilift (persist (Suspended stage env))
persist :: Suspended -> IO ()
persist = print
-- main = runIState interaction () >>= print
-- main = runIState (resume (read "AskKnownSize, ()" )) () >>= print
main = resume'' "AskKnownSize, ()" sizeFlow ()
-- runIState (suspend AskHeight ) (Weight 4, ())
-- runIState (suspend AskWeight) ()
newtype Flow sp as o a = Flow { unFlow :: sp -> StateMachine as o a }
sizeFlow :: Flow Suspended as (Colour, (Size, (Bool, ()))) ()
sizeFlow = Flow resume
resume'' :: (Read sp, Show o, Show a) => String -> Flow sp i o a -> i -> IO ()
resume'' st flow i = runIState (unFlow flow (read st)) i >>= print
--- ----
data Flows sp as o a where
SizeFlow :: Flow Suspended as (Colour, (Size, (Bool, ()))) () -> Flows sp as o a
TryAtHomeFlow :: Flow Suspended as (Colour, (Size, (Int, ()))) () -> Flows sp as o a
getFlow "SizeFlow" = SizeFlow sizeFlow
getFlow "TryAtHomeFlow" = TryAtHomeFlow undefined
---
ask :: Suspended -> StateMachine as (Colour, (Size, (Bool, ()))) ()
ask (Suspended AskKnownSize e) =
iput e >>>
suspend AskKnownSize >>>
askKnownSize >>>= \ b ->
resume' (if b then AskSize else AskWeight) (b, e)
-- runIState (answer "5" (Suspended AskSize (True, ()))) () AskColour, (Size 5,(True,()))
answer :: String -> Suspended -> StateMachine as (Colour, (Size, (Bool, ()))) ()
answer answer (Suspended AskSize e) =
iput e >>>
receiveSize answer >>>
iget >>>= \ s -> resume' AskColour s
| homam/fsm-conversational-ui | src/IndexedState.hs | bsd-3-clause | 8,330 | 0 | 13 | 1,828 | 2,994 | 1,572 | 1,422 | 173 | 3 |
-- Copyright (c) 2017 Eric McCorkle. All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
-- 1. Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- 3. Neither the name of the author nor the names of any contributors
-- may be used to endorse or promote products derived from this software
-- without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS''
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-- USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
{-# OPTIONS_GHC -Wall -Werror #-}
{-# LANGUAGE DataKinds, TypeFamilies #-}
module RISCV.ISA.Registers.Regular(
Reg(..)
) where
import Prelude
import CLaSH.Class.BitPack
-- | Regular RISC-V registers (ie. those provided by the I-instruction set)
data Reg =
ZERO
| RA
| SP
| GP
| TP
| T0
| T1
| T2
| FP
| S1
| A0
| A1
| A2
| A3
| A4
| A5
| A6
| A7
| S2
| S3
| S4
| S5
| S6
| S7
| S8
| S9
| S10
| S11
| T3
| T4
| T5
| T6
deriving (Eq, Ord, Show)
instance Enum Reg where
fromEnum ZERO = 0x00
fromEnum RA = 0x01
fromEnum SP = 0x02
fromEnum GP = 0x03
fromEnum TP = 0x04
fromEnum T0 = 0x05
fromEnum T1 = 0x06
fromEnum T2 = 0x07
fromEnum FP = 0x08
fromEnum S1 = 0x09
fromEnum A0 = 0x0a
fromEnum A1 = 0x0b
fromEnum A2 = 0x0c
fromEnum A3 = 0x0d
fromEnum A4 = 0x0e
fromEnum A5 = 0x0f
fromEnum A6 = 0x10
fromEnum A7 = 0x11
fromEnum S2 = 0x12
fromEnum S3 = 0x13
fromEnum S4 = 0x14
fromEnum S5 = 0x15
fromEnum S6 = 0x16
fromEnum S7 = 0x17
fromEnum S8 = 0x18
fromEnum S9 = 0x19
fromEnum S10 = 0x1a
fromEnum S11 = 0x1b
fromEnum T3 = 0x1c
fromEnum T4 = 0x1d
fromEnum T5 = 0x1e
fromEnum T6 = 0x1f
toEnum 0x00 = ZERO
toEnum 0x01 = RA
toEnum 0x02 = SP
toEnum 0x03 = GP
toEnum 0x04 = TP
toEnum 0x05 = T0
toEnum 0x06 = T1
toEnum 0x07 = T2
toEnum 0x08 = FP
toEnum 0x09 = S1
toEnum 0x0a = A0
toEnum 0x0b = A1
toEnum 0x0c = A2
toEnum 0x0d = A3
toEnum 0x0e = A4
toEnum 0x0f = A5
toEnum 0x10 = A6
toEnum 0x11 = A7
toEnum 0x12 = S2
toEnum 0x13 = S3
toEnum 0x14 = S4
toEnum 0x15 = S5
toEnum 0x16 = S6
toEnum 0x17 = S7
toEnum 0x18 = S8
toEnum 0x19 = S9
toEnum 0x1a = S10
toEnum 0x1b = S11
toEnum 0x1c = T3
toEnum 0x1d = T4
toEnum 0x1e = T5
toEnum 0x1f = T6
toEnum _ = error "Invalid register ID"
instance BitPack Reg where
type BitSize Reg = 5
pack = toEnum . fromEnum
unpack = toEnum . fromEnum
| emc2/clash-riscv | src/RISCV/ISA/Registers/Regular.hs | bsd-3-clause | 3,540 | 0 | 6 | 878 | 736 | 405 | 331 | 110 | 0 |
{-# LANGUAGE FlexibleContexts, ConstraintKinds #-}
-----------------------------------------------------------------------------
-- |
-- Module : Call.Util.Deck
-- Copyright : (c) Fumiaki Kinoshita 2014
-- License : BSD3
--
-- Maintainer : Fumiaki Kinoshita <[email protected]>
-- Stability : experimental
-- Portability : non-portable
--
-- Polyphonic sampler
--
-----------------------------------------------------------------------------
module Audiovisual.Sampler where
import qualified Data.Vector.Storable as V
import qualified Data.Vector.Storable.Mutable as MV
import Control.Monad.ST
import Control.Monad.State.Strict
import Data.Audio
import Foreign.Storable
data Sampler a = Sampler [(Sample a, Time)]
empty :: Sampler a
empty = Sampler []
playback :: (Num a, Storable a, MonadState (Sampler a) m) => Time -> Int -> m (V.Vector a)
playback dt n = do
Sampler vs <- get
let (vs'', r) = runST $ do
v <- MV.new n
vs' <- forM vs $ \(s0@(Sample d (Source s)), t0) -> do
if d > t0 then return []
else do
forM_ [0..n-1] $ \i -> do
z <- MV.unsafeRead v i
MV.unsafeWrite v i $ z + s (t0 + f * fromIntegral i)
return [(s0, t0 + dt)]
v' <- V.unsafeFreeze v
return (vs', v')
put $ Sampler $ concat vs''
return r
where
f = dt / fromIntegral n
play :: MonadState (Sampler a) m => Sample a -> m ()
play s = modify $ \(Sampler xs) -> Sampler $ (s, 0) : xs
| fumieval/audiovisual | src/Audiovisual/Sampler.hs | bsd-3-clause | 1,505 | 0 | 29 | 369 | 488 | 258 | 230 | 30 | 2 |
{-# LANGUAGE CPP, OverloadedStrings #-}
-- | DNS Resolver and generic (lower-level) lookup functions.
module Network.DNS.Resolver (
-- * Documentation
-- ** Configuration for resolver
FileOrNumericHost(..), ResolvConf(..), defaultResolvConf
-- ** Intermediate data type for resolver
, ResolvSeed, makeResolvSeed
-- ** Type and function for resolver
, Resolver(..), withResolver, withResolvers
-- ** Looking up functions
, lookup
, lookupAuth
-- ** Raw looking up function
, lookupRaw
, lookupRawAD
, fromDNSMessage
, fromDNSFormat
) where
import Control.Exception (bracket)
import Data.Char (isSpace)
import Data.List (isPrefixOf)
import Data.Maybe (fromMaybe)
import Network.BSD (getProtocolNumber)
import Network.DNS.Decode
import Network.DNS.Encode
import Network.DNS.Internal
import qualified Data.ByteString.Char8 as BS
import Network.Socket (HostName, Socket, SocketType(Stream, Datagram))
import Network.Socket (AddrInfoFlag(..), AddrInfo(..), SockAddr(..))
import Network.Socket (Family(AF_INET, AF_INET6), PortNumber(..))
import Network.Socket (close, socket, connect, getPeerName, getAddrInfo)
import Network.Socket (defaultHints, defaultProtocol)
import Prelude hiding (lookup)
import System.Random (getStdRandom, random)
import System.Timeout (timeout)
import Data.Word (Word16)
#if __GLASGOW_HASKELL__ < 709
import Control.Applicative ((<$>), (<*>), pure)
#endif
#if mingw32_HOST_OS == 1
import Network.Socket (send)
import qualified Data.ByteString.Char8 as BS
import Control.Monad (when)
#else
import Network.Socket.ByteString (sendAll)
#endif
----------------------------------------------------------------
-- | Union type for 'FilePath' and 'HostName'. Specify 'FilePath' to
-- \"resolv.conf\" or numeric IP address in 'String' form.
--
-- /Warning/: Only numeric IP addresses are valid @RCHostName@s.
--
-- Example (using Google's public DNS cache):
--
-- >>> let cache = RCHostName "8.8.8.8"
--
data FileOrNumericHost = RCFilePath FilePath -- ^ A path for \"resolv.conf\"
| RCHostName HostName -- ^ A numeric IP address
| RCHostPort HostName PortNumber -- ^ A numeric IP address and port number
-- | Type for resolver configuration. The easiest way to construct a
-- @ResolvConf@ object is to modify the 'defaultResolvConf'.
data ResolvConf = ResolvConf {
resolvInfo :: FileOrNumericHost
-- | Timeout in micro seconds.
, resolvTimeout :: Int
-- | The number of retries including the first try.
, resolvRetry :: Int
-- | This field was obsoleted.
, resolvBufsize :: Integer
}
-- | Return a default 'ResolvConf':
--
-- * 'resolvInfo' is 'RCFilePath' \"\/etc\/resolv.conf\".
--
-- * 'resolvTimeout' is 3,000,000 micro seconds.
--
-- * 'resolvRetry' is 3.
--
-- * 'resolvBufsize' is 512. (obsoleted)
--
-- Example (use Google's public DNS cache instead of resolv.conf):
--
-- >>> let cache = RCHostName "8.8.8.8"
-- >>> let rc = defaultResolvConf { resolvInfo = cache }
--
defaultResolvConf :: ResolvConf
defaultResolvConf = ResolvConf {
resolvInfo = RCFilePath "/etc/resolv.conf"
, resolvTimeout = 3 * 1000 * 1000
, resolvRetry = 3
, resolvBufsize = 512
}
----------------------------------------------------------------
-- | Abstract data type of DNS Resolver seed.
-- When implementing a DNS cache, this should be re-used.
data ResolvSeed = ResolvSeed {
addrInfo :: AddrInfo
, rsTimeout :: Int
, rsRetry :: Int
, rsBufsize :: Integer
}
-- | Abstract data type of DNS Resolver
-- When implementing a DNS cache, this MUST NOT be re-used.
data Resolver = Resolver {
genId :: IO Word16
, dnsSock :: Socket
, dnsTimeout :: Int
, dnsRetry :: Int
, dnsBufsize :: Integer
}
----------------------------------------------------------------
-- | Make a 'ResolvSeed' from a 'ResolvConf'.
--
-- Examples:
--
-- >>> rs <- makeResolvSeed defaultResolvConf
--
makeResolvSeed :: ResolvConf -> IO ResolvSeed
makeResolvSeed conf = ResolvSeed <$> addr
<*> pure (resolvTimeout conf)
<*> pure (resolvRetry conf)
<*> pure (resolvBufsize conf)
where
addr = case resolvInfo conf of
RCHostName numhost -> makeAddrInfo numhost Nothing
RCHostPort numhost mport -> makeAddrInfo numhost $ Just mport
RCFilePath file -> toAddr <$> readFile file >>= \i -> makeAddrInfo i Nothing
toAddr cs = let l:_ = filter ("nameserver" `isPrefixOf`) $ lines cs
in extract l
extract = reverse . dropWhile isSpace . reverse . dropWhile isSpace . drop 11
makeAddrInfo :: HostName -> Maybe PortNumber -> IO AddrInfo
makeAddrInfo addr mport = do
proto <- getProtocolNumber "udp"
let hints = defaultHints {
addrFlags = [AI_ADDRCONFIG, AI_NUMERICHOST, AI_PASSIVE]
, addrSocketType = Datagram
, addrProtocol = proto
}
a:_ <- getAddrInfo (Just hints) (Just addr) (Just "domain")
let connectPort = case addrAddress a of
SockAddrInet pn ha -> SockAddrInet (fromMaybe pn mport) ha
SockAddrInet6 pn fi ha sid -> SockAddrInet6 (fromMaybe pn mport) fi ha sid
unixAddr -> unixAddr
return $ a { addrAddress = connectPort }
----------------------------------------------------------------
-- | Giving a thread-safe 'Resolver' to the function of the second
-- argument. A socket for UDP is opened inside and is surely closed.
-- Multiple 'withResolver's can be used concurrently.
-- Multiple lookups must be done sequentially with a given
-- 'Resolver'. If multiple 'Resolver's are necessary for
-- concurrent purpose, use 'withResolvers'.
withResolver :: ResolvSeed -> (Resolver -> IO a) -> IO a
withResolver seed func = bracket (openSocket seed) close $ \sock -> do
connectSocket sock seed
func $ makeResolver seed sock
-- | Giving thread-safe 'Resolver's to the function of the second
-- argument. Sockets for UDP are opened inside and are surely closed.
-- For each 'Resolver', multiple lookups must be done sequentially.
-- 'Resolver's can be used concurrently.
withResolvers :: [ResolvSeed] -> ([Resolver] -> IO a) -> IO a
withResolvers seeds func = bracket openSockets closeSockets $ \socks -> do
mapM_ (uncurry connectSocket) $ zip socks seeds
let resolvs = zipWith makeResolver seeds socks
func resolvs
where
openSockets = mapM openSocket seeds
closeSockets = mapM close
openSocket :: ResolvSeed -> IO Socket
openSocket seed = socket (addrFamily ai) (addrSocketType ai) (addrProtocol ai)
where
ai = addrInfo seed
connectSocket :: Socket -> ResolvSeed -> IO ()
connectSocket sock seed = connect sock (addrAddress ai)
where
ai = addrInfo seed
makeResolver :: ResolvSeed -> Socket -> Resolver
makeResolver seed sock = Resolver {
genId = getRandom
, dnsSock = sock
, dnsTimeout = rsTimeout seed
, dnsRetry = rsRetry seed
, dnsBufsize = rsBufsize seed
}
getRandom :: IO Word16
getRandom = getStdRandom random
----------------------------------------------------------------
-- | Looking up resource records of a domain. The first parameter is one of
-- the field accessors of the 'DNSMessage' type -- this allows you to
-- choose which section (answer, authority, or additional) you would like
-- to inspect for the result.
lookupSection :: (DNSMessage -> [ResourceRecord])
-> Resolver
-> Domain
-> TYPE
-> IO (Either DNSError [RData])
lookupSection section rlv dom typ = do
eans <- lookupRaw rlv dom typ
case eans of
Left err -> return $ Left err
Right ans -> return $ fromDNSMessage ans toRData
where
{- CNAME hack
dom' = if "." `isSuffixOf` dom then dom else dom ++ "."
correct r = rrname r == dom' && rrtype r == typ
-}
correct (ResourceRecord _ rrtype _ _) = rrtype == typ
correct (OptRecord _ _ _ _) = False
toRData x = map getRdata . filter correct $ section x
-- | Extract necessary information from 'DNSMessage'
fromDNSMessage :: DNSMessage -> (DNSMessage -> a) -> Either DNSError a
fromDNSMessage ans conv = case errcode ans of
NoErr -> Right $ conv ans
FormatErr -> Left FormatError
ServFail -> Left ServerFailure
NameErr -> Left NameError
NotImpl -> Left NotImplemented
Refused -> Left OperationRefused
BadOpt -> Left BadOptRecord
where
errcode = rcode . flags . header
-- | For backward compatibility.
fromDNSFormat :: DNSMessage -> (DNSMessage -> a) -> Either DNSError a
fromDNSFormat = fromDNSMessage
-- | Look up resource records for a domain, collecting the results
-- from the ANSWER section of the response.
--
-- We repeat an example from "Network.DNS.Lookup":
--
-- >>> let hostname = Data.ByteString.Char8.pack "www.example.com"
-- >>> rs <- makeResolvSeed defaultResolvConf
-- >>> withResolver rs $ \resolver -> lookup resolver hostname A
-- Right [RD_A 93.184.216.34]
--
lookup :: Resolver -> Domain -> TYPE -> IO (Either DNSError [RData])
lookup = lookupSection answer
-- | Look up resource records for a domain, collecting the results
-- from the AUTHORITY section of the response.
lookupAuth :: Resolver -> Domain -> TYPE -> IO (Either DNSError [RData])
lookupAuth = lookupSection authority
-- | Look up a name and return the entire DNS Response. If the
-- initial UDP query elicits a truncated answer, the query is
-- retried over TCP. The TCP retry may extend the total time
-- taken by one more timeout beyond timeout * tries.
--
-- Sample output is included below, however it is /not/ tested
-- the sequence number is unpredictable (it has to be!).
--
-- The example code:
--
-- @
-- let hostname = Data.ByteString.Char8.pack \"www.example.com\"
-- rs <- makeResolvSeed defaultResolvConf
-- withResolver rs $ \resolver -> lookupRaw resolver hostname A
-- @
--
-- And the (formatted) expected output:
--
-- @
-- Right (DNSMessage
-- { header = DNSHeader
-- { identifier = 1,
-- flags = DNSFlags
-- { qOrR = QR_Response,
-- opcode = OP_STD,
-- authAnswer = False,
-- trunCation = False,
-- recDesired = True,
-- recAvailable = True,
-- rcode = NoErr,
-- authenData = False
-- },
-- },
-- question = [Question { qname = \"www.example.com.\",
-- qtype = A}],
-- answer = [ResourceRecord {rrname = \"www.example.com.\",
-- rrtype = A,
-- rrttl = 800,
-- rdlen = 4,
-- rdata = 93.184.216.119}],
-- authority = [],
-- additional = []})
-- @
--
lookupRaw :: Resolver -> Domain -> TYPE -> IO (Either DNSError DNSMessage)
lookupRaw = lookupRawInternal receive False
-- | Same as lookupRaw, but the query sets the AD bit, which solicits the
-- the authentication status in the server reply. In most applications
-- (other than diagnostic tools) that want authenticated data It is
-- unwise to trust the AD bit in the responses of non-local servers, this
-- interface should in most cases only be used with a loopback resolver.
--
lookupRawAD :: Resolver -> Domain -> TYPE -> IO (Either DNSError DNSMessage)
lookupRawAD = lookupRawInternal receive True
-- Lookup loop, we try UDP until we get a response. If the response
-- is truncated, we try TCP once, with no further UDP retries.
-- EDNS0 support would significantly reduce the need for TCP retries.
--
-- For now, we optimize for low latency high-availability caches
-- (e.g. running on a loopback interface), where TCP is cheap
-- enough. We could attempt to complete the TCP lookup within the
-- original time budget of the truncated UDP query, by wrapping both
-- within a a single 'timeout' thereby staying within the original
-- time budget, but it seems saner to give TCP a full opportunity to
-- return results. TCP latency after a truncated UDP reply will be
-- atypical.
--
-- Future improvements might also include support for TCP on the
-- initial query, and of course support for multiple nameservers.
lookupRawInternal ::
(Socket -> IO DNSMessage)
-> Bool
-> Resolver
-> Domain
-> TYPE
-> IO (Either DNSError DNSMessage)
lookupRawInternal _ _ _ dom _
| isIllegal dom = return $ Left IllegalDomain
lookupRawInternal rcv ad rlv dom typ = do
seqno <- genId rlv
let query = (if ad then composeQueryAD else composeQuery) seqno [q]
checkSeqno = check seqno
loop query checkSeqno 0 False
where
loop query checkSeqno cnt mismatch
| cnt == retry = do
let ret | mismatch = SequenceNumberMismatch
| otherwise = TimeoutExpired
return $ Left ret
| otherwise = do
sendAll sock query
response <- timeout tm (rcv sock)
case response of
Nothing -> loop query checkSeqno (cnt + 1) False
Just res -> do
let valid = checkSeqno res
case valid of
False -> loop query checkSeqno (cnt + 1) False
True | not $ trunCation $ flags $ header res
-> return $ Right res
_ -> tcpRetry query sock tm
sock = dnsSock rlv
tm = dnsTimeout rlv
retry = dnsRetry rlv
q = makeQuestion dom typ
check seqno res = identifier (header res) == seqno
-- Create a TCP socket `just like` our UDP socket and retry the same
-- query over TCP. Since TCP is a reliable transport, and we just
-- got a (truncated) reply from the server over UDP (so it has the
-- answer, but it is just too large for UDP), we expect to succeed
-- quickly on the first try. There will be no further retries.
tcpRetry ::
Query
-> Socket
-> Int
-> IO (Either DNSError DNSMessage)
tcpRetry query sock tm = do
peer <- getPeerName sock
bracket (tcpOpen peer)
(maybe (return ()) close)
(tcpLookup query peer tm)
-- Create a TCP socket with the given socket address (taken from a
-- corresponding UDP socket). This might throw an I/O Exception
-- if we run out of file descriptors. Should this use tryIOError,
-- and return "Nothing" also in that case? If so, perhaps similar
-- code is needed in openSocket, but that has to wait until we
-- refactor `withResolver` to not do "early" socket allocation, and
-- instead allocate a fresh UDP socket for each `lookupRawInternal`
-- invocation. It would be bad to fail an entire `withResolver`
-- action, if the socket shortage is transient, and the user intends
-- to make many DNS queries with the same resolver handle.
tcpOpen :: SockAddr -> IO (Maybe Socket)
tcpOpen peer = do
case (peer) of
SockAddrInet _ _ ->
socket AF_INET Stream defaultProtocol >>= return . Just
SockAddrInet6 _ _ _ _ ->
socket AF_INET6 Stream defaultProtocol >>= return . Just
_ -> return Nothing -- Only IPv4 and IPv6 are possible
-- Perform a DNS query over TCP, if we were successful in creating
-- the TCP socket. The socket creation can only fail if we run out
-- of file descriptors, we're not making connections here. Failure
-- is reported as "server" failure, though it is really our stub
-- resolver that's failing. This is likely good enough.
tcpLookup ::
Query
-> SockAddr
-> Int
-> Maybe Socket
-> IO (Either DNSError DNSMessage)
tcpLookup _ _ _ Nothing = return $ Left ServerFailure
tcpLookup query peer tm (Just vc) = do
response <- timeout tm $ do
connect vc $ peer
sendAll vc $ encodeVC query
receiveVC vc
case response of
Nothing -> return $ Left TimeoutExpired
Just res -> return $ Right res
#if mingw32_HOST_OS == 1
-- Windows does not support sendAll in Network.ByteString.
-- This implements sendAll with Haskell Strings.
sendAll :: Socket -> BS.ByteString -> IO ()
sendAll sock bs = do
sent <- send sock (BS.unpack bs)
when (sent < fromIntegral (BS.length bs)) $ sendAll sock (BS.drop (fromIntegral sent) bs)
#endif
isIllegal :: Domain -> Bool
isIllegal "" = True
isIllegal dom
| '.' `BS.notElem` dom = True
| ':' `BS.elem` dom = True
| '/' `BS.elem` dom = True
| BS.length dom > 253 = True
| any (\x -> BS.length x > 63)
(BS.split '.' dom) = True
isIllegal _ = False
| greydot/dns | Network/DNS/Resolver.hs | bsd-3-clause | 17,032 | 0 | 23 | 4,476 | 3,004 | 1,622 | 1,382 | 219 | 7 |
{-# LANGUAGE PatternSynonyms #-}
module System.Win32.SystemServices.Services
( HandlerFunction
, ServiceMainFunction
, SCM_ACCESS_RIGHTS (..)
, SVC_ACCESS_RIGHTS (..)
, SERVICE_ACCEPT (..)
, SERVICE_CONTROL (..)
, SERVICE_ERROR (..)
, SERVICE_STATE (..)
, pattern SERVICE_CONTINUE_PENDING
, pattern SERVICE_PAUSE_PENDING
, pattern SERVICE_PAUSED
, pattern SERVICE_RUNNING
, pattern SERVICE_START_PENDING
, pattern SERVICE_STOP_PENDING
, pattern SERVICE_STOPPED
, SERVICE_STATUS (..)
, SERVICE_TYPE (..)
, SERVICE_START_TYPE(..)
, pattern SERVICE_FILE_SYSTEM_DRIVER
, pattern SERVICE_KERNEL_DRIVER
, pattern SERVICE_WIN32_OWN_PROCESS
, pattern SERVICE_WIN32_SHARE_PROCESS
, pattern SERVICE_INTERACTIVE_PROCESS
, pattern SERVICE_AUTO_START
, pattern SERVICE_BOOT_START
, pattern SERVICE_DEMAND_START
, pattern SERVICE_DISABLED
, pattern SERVICE_SYSTEM_START
, FromDWORD (..)
, EnumServiceState (..)
, EnumServiceStatus (..)
, SERVICE_CONFIG (..)
, nO_ERROR
, eRROR_SERVICE_SPECIFIC_ERROR
, changeServiceConfig
, changeServiceConfigDependencies
, changeServiceConfigStartType
, queryServiceConfig
, closeServiceHandle
, controlService
, openSCManagerDef
, openService
, openService'
, queryServiceStatus
, setServiceStatus
, startServiceWithoutArgs
, startServiceCtrlDispatcher
, withHandle
, enumDependentServices
) where
import Control.Exception
import Control.Monad (unless, forM_)
import Control.Monad.Fix
import Data.IORef
import Foreign.C.Types (CWchar)
import Foreign.C.String (CWString, peekCWString, withCWString, withCWStringLen)
import Import
import System.Win32.SystemServices.Services.Raw
import System.Win32.SystemServices.Services.SCM_ACCESS_RIGHTS as AR
import System.Win32.SystemServices.Services.SVC_ACCESS_RIGHTS as SV
import System.Win32.SystemServices.Services.SERVICE_ACCEPT
import System.Win32.SystemServices.Services.SERVICE_CONTROL
import System.Win32.SystemServices.Services.SERVICE_ERROR
import qualified System.Win32.SystemServices.Services.SERVICE_CONTROL as SC
import System.Win32.SystemServices.Services.SERVICE_STATE
import System.Win32.SystemServices.Services.SERVICE_STATUS
import System.Win32.SystemServices.Services.SERVICE_TABLE_ENTRY
import System.Win32.SystemServices.Services.SERVICE_TYPE
import qualified System.Win32.SystemServices.Services.SERVICE_OPTIONAL as SO
import System.Win32.SystemServices.Services.QUERY_SERVICE_CONFIG
import System.Win32.SystemServices.Services.SERVICE_START_TYPE
import System.Win32.SystemServices.Services.Types
-- | A handler function is registered with the service dispatcher thread
-- from a 'ServiceMainFunction'. The first argument is a 'HANDLE' returned
-- from calling 'registerServiceCtrlHandler'. The second argument represents
-- the command this service has been directed to perform.
type HandlerFunction = HANDLE -> SERVICE_CONTROL -> IO Bool
-- | The service dispatcher thread will call each function of this type that
-- you provide. The first argument will be the name of the service. Any
-- additional command-line parameters will appear in the second argument.
--
-- Each of these functions should call 'registerServiceCtrlHandler' to
-- register a function to handle incoming commands. It should then set
-- the service's status to 'START_PENDING', and specify that no controls
-- will be accepted. At this point the function may perform any other
-- initialization steps before setting the service's status to
-- 'RUNNING'. All of this should take no more than 100ms.
type ServiceMainFunction = String -> [String] -> HANDLE -> IO ()
withCWString' :: Maybe String -> (CWString -> IO a) -> IO a
withCWString' (Just s) f = withCWString s f
withCWString' Nothing f = f nullPtr
withCWStringList' :: Maybe [String] -> (CWString -> IO a) -> IO a
withCWStringList' (Just ss) f = withCWStringList ss f
withCWStringList' Nothing f = f nullPtr
wNUL :: CWchar
wNUL = 0
withCWStringList :: [String] -> (CWString -> IO a) -> IO a
withCWStringList ss fun =
let
wsize = sizeOf (undefined :: CWchar)
size' = if (length ss) == 0
then 0
else foldl (+) 0 $ map (\s -> length s + 1) ss
size = (size' + 1) * wsize
in
allocaBytes size $ \ptr ->
do
pRef <- newIORef ptr
forM_ ss $ \s ->
withCWStringLen s $ \(p', l') -> do
let l = l' * wsize
p <- readIORef pRef
copyBytes p p' l
let nulPos = p `plusPtr` l
poke nulPos wNUL
writeIORef pRef $ nulPos `plusPtr` wsize
p <- readIORef pRef
poke p wNUL
fun ptr
peekCWStringList :: LPCWSTR -> IO [String]
peekCWStringList pStr = do
str <- peekCWString pStr
let
wsize = sizeOf (undefined :: CWchar)
len = length str * wsize
if len == 0
then return []
else do
strs <- peekCWStringList $ pStr `plusPtr` (len + wsize)
return $ str:strs
changeServiceConfig :: HANDLE -> DWORD -> DWORD -> DWORD -> Maybe String -> Maybe String -> LPDWORD -> Maybe [String] -> Maybe String -> Maybe String -> Maybe String -> IO ()
changeServiceConfig h svcType startType errCtl path' loadOrderGrp' tag srvDeps' startName' pass' displayname' =
withCWString' path' $ \path ->
withCWString' loadOrderGrp' $ \loadOrderGrp ->
withCWStringList' srvDeps' $ \srvDeps ->
withCWString' startName' $ \startName ->
withCWString' pass' $ \pass ->
withCWString' displayname' $ \displayname ->
failIfFalse_ (unwords ["changeServiceConfig"]) $
c_ChangeServiceConfig h svcType startType errCtl path loadOrderGrp tag srvDeps startName pass displayname
changeServiceConfigDependencies :: HANDLE -> [String] -> IO ()
changeServiceConfigDependencies h dependsOnSvcs =
let snc = SO.toDWORD SO.SERVICE_NO_CHANGE
in changeServiceConfig h snc snc snc Nothing Nothing nullPtr (Just dependsOnSvcs) Nothing Nothing Nothing
changeServiceConfigStartType :: HANDLE -> DWORD -> IO ()
changeServiceConfigStartType h startType =
let snc = SO.toDWORD SO.SERVICE_NO_CHANGE in
changeServiceConfig h snc startType snc Nothing Nothing nullPtr Nothing Nothing Nothing Nothing
data SERVICE_CONFIG = SERVICE_CONFIG
{ scServiceType :: Int
, scStartType :: Int
, scErrorControl :: Int
, scBinaryPathName :: String
, scLoadOrderGroup :: String
, scTagId :: Int
, scDependencies :: [String]
, scServiceStartName :: String
, scDisplayName :: String
} deriving (Show)
fromRawServiceConfig :: QUERY_SERVICE_CONFIG -> IO SERVICE_CONFIG
fromRawServiceConfig config = do
bpn <- peekCWString $ rawBinaryPathName config
ogr <- peekCWString $ rawLoadOrderGroup config
dep <- peekCWStringList $ rawDependencies config
ssn <- peekCWString $ rawServiceStartName config
sdn <- peekCWString $ rawDisplayName config
return SERVICE_CONFIG
{ scServiceType = fromIntegral $ rawServiceType config
, scStartType = fromIntegral $ rawStartType config
, scErrorControl = fromIntegral $ rawErrorControl config
, scBinaryPathName = bpn
, scLoadOrderGroup = ogr
, scTagId = fromIntegral $ rawTagId config
, scDependencies = dep
, scServiceStartName = ssn
, scDisplayName = sdn
}
failIfTrue_ :: String -> IO Bool -> IO ()
failIfTrue_ s b = do
b' <- b
failIfFalse_ s $ return $ not b'
queryServiceConfig :: HANDLE -> IO SERVICE_CONFIG
queryServiceConfig h =
alloca $ \pBufSize -> do
failIfTrue_ (unwords ["queryServiceConfig", "get buffer size"]) $
c_QueryServiceConfig h nullPtr 0 pBufSize
bufSize <- peek pBufSize
allocaBytes (fromIntegral bufSize) $ \pConfig -> do
failIfFalse_ (unwords ["queryServiceConfig", "get actual config", "buf size is", show bufSize]) $
c_QueryServiceConfig h pConfig bufSize pBufSize
config <- peek pConfig
fromRawServiceConfig config
closeServiceHandle :: HANDLE -> IO ()
closeServiceHandle =
failIfFalse_ (unwords ["CloseServiceHandle"]) . c_CloseServiceHandle
controlService :: HANDLE -> SERVICE_CONTROL -> IO SERVICE_STATUS
controlService h c = alloca $ \pStatus -> do
failIfFalse_ (unwords ["ControlService"])
$ c_ControlService h (SC.toDWORD c) pStatus
peek pStatus
openSCManagerDef :: SCM_ACCESS_RIGHTS -> IO HANDLE
openSCManagerDef ar =
failIfNull (unwords ["OpenSCManager"])
$ c_OpenSCManager nullPtr nullPtr (AR.toDWORD ar)
_openService :: HANDLE -> String -> DWORD -> IO HANDLE
_openService h n ar =
withTString n $ \lpcwstr -> failIfNull (unwords ["OpenService", n])
$ c_OpenService h lpcwstr ar
-- |Opens an existing service.
openService :: HANDLE
-- ^ MSDN documentation: A handle to the service control manager
-- database. The OpenSCManager function returns this handle.
-> String
-- ^ MSDN documentation: The name of the service to be opened. This is
-- the name specified by the lpServiceName parameter of the CreateService
-- function when the service object was created, not the service display
-- name that is shown by user interface applications to identify the service.
-> SVC_ACCESS_RIGHTS
-- ^ The list of access rights for a service.
-> IO HANDLE
-- ^ This function will raise an exception if the Win32 call returned an
-- error condition.openService h n ar =
openService h n ar = _openService h n (SV.toDWORD ar)
-- |Opens an existing service with list of access rights.
openService' :: HANDLE
-- ^ MSDN documentation: A handle to the service control manager
-- database. The OpenSCManager function returns this handle.
-> String
-- ^ MSDN documentation: The name of the service to be opened. This is
-- the name specified by the lpServiceName parameter of the CreateService
-- function when the service object was created, not the service display
-- name that is shown by user interface applications to identify the service.
-> [SVC_ACCESS_RIGHTS]
-- ^ The list of access rights for a service.
-> IO HANDLE
-- ^ This function will raise an exception if the Win32 call returned an
-- error condition.
openService' h n ars =
_openService h n (SV.flag ars)
-- |Retrieves the current status of the specified service.
queryServiceStatus :: HANDLE
-- ^ MSDN documentation: A handle to the service. This handle is returned
-- by the OpenService or the CreateService function, and it must have the
-- SERVICE_QUERY_STATUS access right. For more information, see Service
-- Security and Access Rights.
-> IO SERVICE_STATUS
-- ^ This function will raise an exception if the Win32 call returned an
-- error condition.
queryServiceStatus h = alloca $ \pStatus -> do
failIfFalse_ (unwords ["QueryServiceStatus"])
$ c_QueryServiceStatus h pStatus
peek pStatus
-- | Register an handler function to be called whenever the operating system
-- receives service control messages.
registerServiceCtrlHandlerEx :: String
-- ^ The name of the service. According to MSDN documentation this
-- argument is unused in WIN32_OWN_PROCESS type services, which is the
-- only type supported by this binding. Even so, it is recommended
-- that the name of the service be used.
--
-- MSDN description: The name of the service run by the calling thread.
-- This is the service name that the service control program specified in
-- the CreateService function when creating the service.
-> HandlerFunction
-- ^ A Handler function to be called in response to service control
-- messages. Behind the scenes this is translated into a "HandlerEx" type
-- handler.
-> IO (HANDLE, LPHANDLER_FUNCTION_EX)
-- ^ The returned handle may be used in calls to SetServiceStatus. For
-- convenience Handler functions also receive a handle for the service.
registerServiceCtrlHandlerEx str handler =
withTString str $ \lptstr ->
-- use 'ret' instead of (h', _) to avoid divergence.
mfix $ \ret -> do
fpHandler <- handlerToFunPtr $ toHandlerEx (fst ret) handler
h <- failIfNull (unwords ["RegisterServiceCtrlHandlerEx", str])
$ c_RegisterServiceCtrlHandlerEx lptstr fpHandler nullPtr
return (h, fpHandler)
-- |Updates the service control manager's status information for the calling
-- service.
setServiceStatus :: HANDLE
-- ^ MSDN documentation: A handle to the status information structure for
-- the current service. This handle is returned by the
-- RegisterServiceCtrlHandlerEx function.
-> SERVICE_STATUS
-- ^ MSDN documentation: A pointer to the SERVICE_STATUS structure the
-- contains the latest status information for the calling service.
-> IO ()
-- ^ This function will raise an exception if the Win32 call returned an
-- error condition.
setServiceStatus h status =
with status $ \pStatus -> do
failIfFalse_ (unwords ["SetServiceStatus", show h, show status])
$ c_SetServiceStatus h pStatus
-- |Starts a service.
startServiceWithoutArgs :: HANDLE -> IO ()
-- ^ MSDN documentation: A handle to the service. This handle is returned
-- by the OpenService or CreateService function, and it must have the
-- SERVICE_START access right.
startServiceWithoutArgs h =
failIfFalse_ (unwords ["StartService"])
$ c_StartService h 0 nullPtr
-- |Register a callback function to initialize the service, which will be
-- called by the operating system immediately. startServiceCtrlDispatcher
-- will block until the provided callback function returns.
--
-- MSDN documentation: Connects the main thread of a service process to the
-- service control manager, which causes the thread to be the service control
-- dispatcher thread for the calling process.
startServiceCtrlDispatcher :: String
-- ^ The name of the service. According to MSDN documentation this
-- argument is unused in WIN32_OWN_PROCESS type services, which is the
-- only type supported by this binding. Even so, it is recommended
-- that the name of the service be used.
--
-- MSDN description: The name of the service run by the calling thread.
-- This is the service name that the service control program specified in
-- the CreateService function when creating the service.
-> DWORD
-- ^
-- [@waitHint@] The estimated time required for a pending start, stop,
-- pause, or continue operation, in milliseconds.
-> HandlerFunction
-> ServiceMainFunction
-- ^ This is a callback function that will be called by the operating
-- system whenever the service is started. It should perform service
-- initialization including the registration of a handler function.
-- MSDN documentation gives conflicting advice as to whether this function
-- should return before the service has entered the stopped state.
-- In the official example the service main function blocks until the
-- service is ready to stop.
-> IO ()
-- ^ An exception will be raised if the underlying Win32 call returns an
-- error condition.
startServiceCtrlDispatcher name wh handler main =
withTString name $ \lptstr ->
bracket (toSMF main handler wh >>= smfToFunPtr) freeHaskellFunPtr $ \fpMain ->
withArray [SERVICE_TABLE_ENTRY lptstr fpMain, nullSTE] $ \pSTE ->
failIfFalse_ (unwords ["StartServiceCtrlDispatcher", name]) $ do
c_StartServiceCtrlDispatcher pSTE
toSMF :: ServiceMainFunction -> HandlerFunction -> DWORD -> IO SERVICE_MAIN_FUNCTION
toSMF f handler wh = return $ \len pLPTSTR -> do
lptstrx <- peekArray (fromIntegral len) pLPTSTR
args <- mapM peekTString lptstrx
-- MSDN guarantees args will have at least 1 member.
let name = head args
(h, fpHandler) <- registerServiceCtrlHandlerEx name handler
setServiceStatus h $ SERVICE_STATUS SERVICE_WIN32_OWN_PROCESS SERVICE_START_PENDING [] nO_ERROR 0 0 wh
f name (tail args) h
freeHaskellFunPtr fpHandler
-- This was originally written with older style handle functions in mind.
-- I'm now using HandlerEx style functions, and need to add support for
-- the extra parameters here.
toHandlerEx :: HANDLE -> HandlerFunction -> HANDLER_FUNCTION_EX
toHandlerEx h f = \dwControl _ _ _ ->
case SC.fromDWORD dwControl of
Right control -> do
handled <- f h control
case control of
INTERROGATE -> return nO_ERROR
-- If we ever support extended control codes this will have to
-- change. see "Dev Center - Desktop > Docs > Desktop app
-- development documentation > System Services > Services >
-- Service Reference > Service Functions > HandlerEx".
_ -> return $ if handled then nO_ERROR
else eRROR_CALL_NOT_IMPLEMENTED
Left _ -> return eRROR_CALL_NOT_IMPLEMENTED
withHandle :: IO HANDLE -> (HANDLE -> IO a) -> IO a
withHandle before = bracket before closeServiceHandle
data EnumServiceStatus = EnumServiceStatus
{ enumServiceName :: String
, enumDisplayName :: String
, enumServiceStatus :: SERVICE_STATUS
}
enumDependentServices :: HANDLE -> EnumServiceState -> IO [EnumServiceStatus]
enumDependentServices hService ess =
alloca $ \pcbBytesNeeded ->
alloca $ \lpServicesReturned -> do
res <- c_EnumDependentServices hService (enumServiceStateToDWORD ess)
nullPtr 0 pcbBytesNeeded lpServicesReturned
if res
then return [] -- The only case when call without a buffer succeeds is when no buffer is needed.
else do
lastErr <- getLastError
unless (lastErr == eRROR_MORE_DATA) $
failWith "EnumDependentServices" lastErr
bytesNeeded <- peek pcbBytesNeeded
allocaBytes (fromIntegral bytesNeeded) $ \lpServices -> do
failIfFalse_ "EnumDependentServices" $ c_EnumDependentServices hService (enumServiceStateToDWORD ess)
lpServices bytesNeeded pcbBytesNeeded lpServicesReturned
actualServices <- peek lpServicesReturned
rawStatuses <- peekArray (fromIntegral actualServices) lpServices
mapM rawEssToEss rawStatuses
where
rawEssToEss rawEss = do
svcName <- peekCWString $ rawESSServiceName rawEss
dispName <- peekCWString $ rawESSDisplayName rawEss
return EnumServiceStatus
{ enumServiceName = svcName
, enumDisplayName = dispName
, enumServiceStatus = rawESSServiceStatus rawEss
}
| nick0x01/Win32-services | src/System/Win32/SystemServices/Services.hs | bsd-3-clause | 18,709 | 0 | 21 | 4,043 | 3,307 | 1,769 | 1,538 | 293 | 4 |
import Criterion.Main
import IOCP.Windows
main = defaultMain [bench "getLastError" getLastError]
| joeyadams/hs-windows-iocp | lab/bench-getLastError.hs | bsd-3-clause | 98 | 0 | 7 | 11 | 27 | 14 | 13 | 3 | 1 |
{-# LANGUAGE OverloadedStrings #-}
module ReadXLSX.AllSheetsToJSON
where
import Codec.Xlsx
import Data.Aeson (encode, Value)
import Data.ByteString.Lazy (ByteString)
import qualified Data.Map as DM
import Data.Text (Text)
import ReadXLSX.SheetToDataframe
allSheetsToDataframe :: Xlsx -> (Cell -> Value) -> Bool -> ByteString
allSheetsToDataframe xlsx cellToValue header = encode $
DM.map (\sheet -> sheetToMapList sheet cellToValue header)
nonEmptySheets
where nonEmptySheets = DM.filter isNotEmpty (DM.map _wsCells $ DM.fromList (_xlSheets xlsx))
isNotEmpty cellmap = DM.keys cellmap /= []
allSheetsToTwoDataframes :: Xlsx -> Text -> (Cell -> Value) -> Text -> (Cell -> Value) -> Bool -> Bool -> ByteString
allSheetsToTwoDataframes xlsx key1 cellToValue1 key2 cellToValue2 header toNull =
encode $
DM.map (\sheet -> sheetToTwoMapLists sheet key1 cellToValue1 key2 cellToValue2 header toNull)
nonEmptySheets
where nonEmptySheets = DM.filter isNotEmpty (DM.map _wsCells $ DM.fromList (_xlSheets xlsx))
isNotEmpty cellmap = DM.keys cellmap /= []
-- encode $ if toNull then out else twoDataframes
-- where twoDataframes = sheetToTwoMapLists cells key1 cellToValue1 key2 cellToValue2 header
-- out = if isNullDataframe df2 then DM.fromList [(key1, df1), (key2, [DHSI.empty])] else twoDataframes
-- df1 = twoDataframes DM.! key1
-- df2 = twoDataframes DM.! key2
| stla/jsonxlsx | src/ReadXLSX/AllSheetsToJSON.hs | bsd-3-clause | 1,648 | 0 | 12 | 469 | 339 | 181 | 158 | 21 | 1 |
module Termination.Generaliser where
import Core.Renaming (Out)
import Core.Syntax (Var)
import Evaluator.Syntax
import Utilities (FinMap, FinSet, Tag, Tagged, injectTag, tag, tagInt)
import qualified Data.IntMap as IM
import qualified Data.IntSet as IS
data Generaliser = Generaliser
{ generaliseStackFrame :: Tagged StackFrame -> Bool
, generaliseHeapBinding :: Out Var -> HeapBinding -> Bool
}
generaliseNothing :: Generaliser
generaliseNothing = Generaliser (\_ -> False) (\_ _ -> False)
generaliserFromGrowing :: FinMap Bool -> Generaliser
generaliserFromGrowing = generaliserFromFinSet . IM.keysSet . IM.filter id
generaliserFromFinSet :: FinSet -> Generaliser
generaliserFromFinSet generalise_what = Generaliser
{ generaliseStackFrame =
\kf -> should_generalise (stackFrameTag' kf)
, generaliseHeapBinding =
\_ hb -> maybe False (should_generalise . pureHeapBindingTag') $ heapBindingTag hb
}
where
should_generalise tg = IS.member (tagInt tg) generalise_what
pureHeapBindingTag' :: Tag -> Tag
pureHeapBindingTag' = injectTag 5
stackFrameTag' :: Tagged StackFrame -> Tag
stackFrameTag' = injectTag 3 . tag
qaTag' :: Anned QA -> Tag
qaTag' = injectTag 2 . annedTag
| osa1/chsc | Termination/Generaliser.hs | bsd-3-clause | 1,227 | 0 | 11 | 207 | 336 | 186 | 150 | 27 | 1 |
{-# LANGUAGE RecordWildCards #-}
module Target
( targetRules
)
where
import Control.Applicative ((<$>))
import Control.Monad (forM_, when)
import Development.Shake
import Development.Shake.FilePath
import Config
import Dirs
import LocalCommand
import HaddockMaster
import OS
import Paths
import PlatformDB
import Types
import Utils
targetRules :: BuildConfig -> Rules ()
targetRules bc = do
buildRules
installRules bc
targetDir ~> do
hpRel <- askHpRelease
bc' <- askBuildConfig
let OS{..} = osFromConfig bc'
let packages = platformPackages hpRel
need $ vdir ghcVirtualTarget
: dir (haddockDocDir bc')
: map (dir . (targetDir </+>) . osPackageTargetDir) packages
osTargetAction
buildRules :: Rules ()
buildRules = do
packageBuildDir PackageWildCard %/> \buildDir -> do
hpRel <- askHpRelease
bc <- askBuildConfig
buildAction buildDir hpRel bc
buildAction :: FilePath -> Release -> BuildConfig -> Action ()
buildAction buildDir hpRel bc = do
need [ dir sourceDir, vdir ghcVirtualTarget ]
needsAlex <- usesTool ["//*.x", "//*.lx"]
needsHappy <- usesTool ["//*.y", "//*.ly"]
-- These are not *all* the dependencies; just those of the HP
-- packages, not those from GHC. depsLibs is just the libraries,
-- while deps adds any HP packages which provide needed tools.
depsLibs <- map read <$> readFileLines (packageDepsFile pkg)
deps <-
return $ depsLibs ++ needsAlex ?: [alexVer]
++ needsHappy ?: [happyVer]
putNormal $ show pkg ++ " needs " ++ unwords (map show deps)
need $ map (dir . packageBuildDir) deps
putNormal $ ">>> Building " ++ show pkg
command_ [] "cp" ["-pR", sourceDir, buildDir]
ghcPkgVerbosity <- shakeToGhcPkgVerbosity
removeDirectoryRecursive depsDB
localCommand' [] "ghc-pkg" ["init", depsDB]
forM_ deps $ \d -> do
let inplace = packageInplaceConf d
hasInplace <- doesFileExist inplace
when hasInplace $
localCommand' [] "ghc-pkg"
[ "register"
, "--package-db=" ++ depsDB
, "--verbose=" ++ show ghcPkgVerbosity
, inplace
]
cabalVerbosity <- show . fromEnum <$> shakeToCabalVerbosity
let cabal c as = localCommand' [Cwd buildDir] "cabal" $
c : ("--verbose=" ++ cabalVerbosity) : as
when (not isAlexOrHappy) $
cabal "clean" [] -- This is a hack to handle when packages, other
-- than alex or happy themselves, have outdated
-- bootstrap files in their sdist tarballs.
cabal "configure" $ confOpts needsAlex needsHappy
cabal "build" []
cabal "register"
["--gen-pkg-config=" ++ packageTargetConf pkg ® buildDir]
osPackagePostRegister pkg
cabal "register"
["--inplace"
, "--gen-pkg-config=" ++ packageInplaceConf pkg ® buildDir]
cReadArgs <- map (haddockReadArg . osGhcPkgPathMunge pkgHtmlDir)
<$> haddockAllCorePkgLocs hpRel bc
pReadArgs <- map (haddockReadArg . osPlatformPkgPathMunge pkgHtmlDir)
<$> haddockPlatformPkgLocs depsLibs
cabal "haddock" $
[ "--hyperlink-source" -- TODO(mzero): make optional
, "--with-haddock=" ++ haddockExe ® buildDir
]
++ map (\s -> "--haddock-option=" ++ s) (cReadArgs ++ pReadArgs)
where
OS{..} = osFromConfig bc
pkg = extractPackage buildDir
sourceDir = packageSourceDir pkg
depsDB = packageDepsDB pkg
isAlexOrHappy = pkgName pkg `elem` ["alex", "happy"]
usesTool pats =
if not isAlexOrHappy
then (not . null) <$> getDirectoryFiles sourceDir pats
else return False -- don't depend on yourself!
happyExe = packageBuildDir happyVer </> "dist/build/happy/happy"
happyTemplateDir = packageBuildDir happyVer
alexExe = packageBuildDir alexVer </> "dist/build/alex/alex"
haddockExe = ghcLocalDir </> "bin/haddock"
haveCabalInstall = False
cabalInstallDir = undefined
doProfiling = True
doShared = osDoShared
confOpts needsAlex needsHappy =
osPackageConfigureExtraArgs pkg
++ map ("--package-db="++) [ "clear", "global", "../package.conf.d" ]
++ needsAlex ?: [ "--with-alex=" ++ alexExe ® buildDir ]
++ needsHappy ?: [ "--with-happy=" ++ happyExe ® buildDir
, "--happy-options=--template=" ++ happyTemplateDir ® buildDir
]
++ haveCabalInstall ?: [ "--with-cabal-install=" ++ cabalInstallDir ]
++ doProfiling ?: [ "--enable-library-profiling" ]
++ doShared ?: [ "--enable-shared" ]
b ?: l = if b then l else []
alexVer = findPackage "alex"
happyVer = findPackage "happy"
findPackage s = case filter ((==s) . pkgName) . allPackages $ hpRel of
(p:_) -> p
[] -> error $ "Can't find needed package " ++ s ++ " in HP."
pkgHtmlDir = osPkgHtmlDir pkg
installRules :: BuildConfig -> Rules ()
installRules bc = do
targetDir </+> osPackageTargetDir PackageWildCard %/> \targetPkgDir -> do
let pkg = read $ takeFileName targetPkgDir :: Package
let buildDir = packageBuildDir pkg
need [ dir buildDir ]
-- The reason to "copy" rather than "install" is to avoid actually
-- executing anything from within the targetDir, thus keeping it
-- pristine, just as it will be for the actual end-user when first
-- installed.
localCommand' [Cwd buildDir]
"cabal" ["copy", "--destdir=" ++ targetDir ® buildDir]
osPackageInstallAction pkg
where
OS{..} = osFromConfig bc
| bgamari/haskell-platform | hptool/src/Target.hs | bsd-3-clause | 6,025 | 0 | 19 | 1,831 | 1,403 | 698 | 705 | 124 | 4 |
-----------------------------------------------------------------------------
-- |
-- Module : Language.Pylon.Util.Generics
-- Copyright : Lukas Heidemann 2014
-- License : BSD
--
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : semi-portable
--------------------------------------------------------------------------------
module Language.Pylon.Util.Generics where
--------------------------------------------------------------------------------
import Data.Data
import Data.Typeable
import Data.Generics.Uniplate.Data
import Data.Generics.Str
--------------------------------------------------------------------------------
-- Traversals
--------------------------------------------------------------------------------
transformCtx :: (Monad m, Data on) => (on -> [m on -> m on]) -> (on -> m on) -> on -> m on
transformCtx gs f x = cur' >>= f . gen . strUn where
(cur, gen) = uniplate x
(strL, strUn) = strStructure cur
gs' = gs x ++ repeat id
cur' = sequence -- sequence and convert back to str
$ zipWith ($) gs' -- apply contexts
$ fmap (transformCtx gs f) -- transform children
$ strL -- str to list
| zrho/pylon | src/Language/Pylon/Util/Generics.hs | bsd-3-clause | 1,242 | 0 | 11 | 232 | 220 | 126 | 94 | 14 | 1 |
{-# LANGUAGE PartialTypeSignatures #-}
{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
module MultiClockFifo where
import CLaSH.Prelude
import CLaSH.Prelude.Explicit
import Data.Maybe (isJust)
fifoMem wclk rclk addrSize wfull raddr wdataM =
asyncRam' wclk rclk
(pow2SNat addrSize)
raddr
(mux (not <$> wfull)
wdataM
(pure Nothing))
ptrCompareT addrSize flagGen (bin,ptr,flag) (s_ptr,inc) =
((bin',ptr',flag')
,(flag,addr,ptr))
where
-- GRAYSTYLE2 pointer
bin' = bin + boolToBV (inc && not flag)
ptr' = (bin' `shiftR` 1) `xor` bin'
addr = slice (addrSize `subSNat` d1) d0 bin
flag' = flagGen ptr' s_ptr
-- FIFO empty: when next pntr == synchronized wptr or on reset
isEmpty = (==)
rptrEmptyInit = (0,0,True)
-- FIFO full: when next pntr == synchonized {~wptr[addrSize:addrSize-1],wptr[addrSize-1:0]}
isFull addrSize ptr s_ptr =
ptr == complement (slice addrSize (addrSize `subSNat` d1) s_ptr) ++#
slice (addrSize `subSNat` d2) d0 s_ptr
wptrFullInit = (0,0,False)
-- Dual flip-flip synchroniser
ptrSync clk1 clk2 = register' clk2 0
. register' clk2 0
. unsafeSynchronizer clk1 clk2
-- Async FIFO synchroniser
fifo
:: _
=> SNat (addrSize + 2)
-> SClock wclk
-> SClock rclk
-> Signal' rclk Bool
-> Signal' wclk (Maybe a)
-> (Signal' rclk a, Signal' rclk Bool, Signal' wclk Bool)
fifo addrSize wclk rclk rinc wdataM = (rdata,rempty,wfull)
where
s_rptr = ptrSync rclk wclk rptr
s_wptr = ptrSync wclk rclk wptr
rdata = fifoMem wclk rclk addrSize wfull raddr
(liftA2 (,) <$> (Just <$> waddr) <*> wdataM)
(rempty,raddr,rptr) = mealyB' rclk (ptrCompareT addrSize isEmpty) rptrEmptyInit
(s_wptr,rinc)
(wfull,waddr,wptr) = mealyB' wclk (ptrCompareT addrSize (isFull addrSize))
wptrFullInit (s_rptr,isJust <$> wdataM)
| trxeste/wrk | haskell/cl3sh/MultiClockFifo.hs | bsd-3-clause | 2,032 | 0 | 13 | 567 | 609 | 333 | 276 | -1 | -1 |
--------------------------------------------------------------------------
-- |
-- Module : Language.Assembly.X86
-- Copyright : (c) Martin Grabmueller and Dirk Kleeblatt
-- License : BSD3
--
-- Maintainer : [email protected],[email protected]
-- Stability : provisional
-- Portability : portable
--
-- Disassembler for x86 machine code.
--
-- This is a disassembler for object code for the x86 architecture.
-- It provides functions for disassembling byte arrays, byte lists and
-- memory blocks containing raw binary code.
--
-- Features:
--
-- - Disassembles memory blocks, lists or arrays of bytes into lists of
-- instructions.
--
-- - Abstract instructions provide as much information as possible about
-- opcodes, addressing modes or operand sizes, allowing for detailed
-- output.
--
-- - Provides functions for displaying instructions in Intel or AT&T
-- style (like the GNU tools)
--
-- Differences to GNU tools, like gdb or objdump:
--
-- - Displacements are shown in decimal, with sign if negative.
--
-- Missing:
--
-- - LOCK and repeat prefixes are recognized, but not contained in the
-- opcodes of instructions.
--
-- - Support for 16-bit addressing modes. Could be added when needed.
--
-- - Complete disassembly of all 64-bit instructions. I have tried to
-- disassemble them properly but have been limited to the information
-- in the docs, because I have no 64-bit machine to test on. This will
-- probably change when I get GNU as to produce 64-bit object files.
--
-- - Not all MMX and SSE/SSE2/SSE3 instructions are decoded yet. This is
-- just a matter of missing time.
--
-- - segment override prefixes are decoded, but not appended to memory
-- references
--
-- On the implementation:
--
-- This disassembler uses the Parsec parser combinators, working on byte
-- lists. This proved to be very convenient, as the combinators keep
-- track of the current position, etc.
--------------------------------------------------------------------------
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE FlexibleContexts #-}
module Language.Assembly.X86 (
-- * Types
Opcode,
Operand(..),
InstrOperandSize(..),
Instruction(..),
ShowStyle(..),
Config(..),
-- * Functions
disassembleBlock,
disassembleList,
disassembleArray,
disassembleFile,
disassembleBlockWithConfig,
disassembleListWithConfig,
disassembleArrayWithConfig,
disassembleFileWithConfig,
showIntel,
showAtt,
defaultConfig
) where
import Data.Array.IArray
import Data.Char
import Foreign
import Language.Assembly.X86.Instruction
import Language.Assembly.X86.Parse
import Language.Assembly.X86.Print
import Text.Parsec hiding (many, (<|>))
-- | Disassemble a block of memory. Starting at the location
-- pointed to by the given pointer, the given number of bytes are
-- disassembled.
disassembleBlock :: Ptr Word8 -> Int -> IO (Either ParseError [Instruction])
disassembleBlock ptr len =
disassembleBlockWithConfig defaultConfig{confStartAddr = fromIntegral (minusPtr ptr nullPtr)}
ptr len
disassembleBlockWithConfig :: Config -> Ptr Word8 -> Int -> IO (Either ParseError [Instruction])
disassembleBlockWithConfig config ptr len =
do l <- toList ptr len 0 []
parseInstructions (configToState config) (reverse l)
where toList :: (Ptr Word8) -> Int -> Int -> [Word8] -> IO [Word8]
toList ptr len idx acc
| idx < len = do p <- peekByteOff ptr idx
toList ptr len (idx + 1) (p : acc)
--return (p : r)
| idx >= len = return acc
-- | Disassemble the contents of the given array.
disassembleArray :: (Monad m, IArray a Word8, Ix i) =>
a i Word8 -> m (Either ParseError [Instruction])
disassembleArray arr = disassembleArrayWithConfig defaultConfig arr
disassembleArrayWithConfig :: (Monad m, IArray a Word8, Ix i) => Config ->
a i Word8 -> m (Either ParseError [Instruction])
disassembleArrayWithConfig config arr = parseInstructions (configToState config) l
where l = elems arr
-- | Disassemble the contents of the given list.
disassembleList :: (Monad m) =>
[Word8] -> m (Either ParseError [Instruction])
disassembleList ls = disassembleListWithConfig defaultConfig ls
disassembleListWithConfig :: (Monad m) => Config ->
[Word8] -> m (Either ParseError [Instruction])
disassembleListWithConfig config ls =
parseInstructions (configToState config) ls
disassembleFile :: FilePath -> IO (Either ParseError [Instruction])
disassembleFile filename = disassembleFileWithConfig defaultConfig filename
disassembleFileWithConfig
:: Config -> FilePath -> IO (Either ParseError [Instruction])
disassembleFileWithConfig config filename = do
l <- readFile filename
parseInstructions (configToState config) (map (fromIntegral . ord) l)
instrToString :: [Instruction] -> ShowStyle -> [[Char]]
instrToString insts style =
map showInstr insts
where
showInstr = case style of
IntelStyle -> showIntel
AttStyle -> showAtt
-- | Test function for disassembling the contents of a binary file and
-- displaying it in the provided style ("IntelStyle" or "AttStyle").
testFile :: FilePath -> ShowStyle -> IO ()
testFile fname style = do
l <- readFile fname
i <- parseInstructions defaultState (map (fromIntegral . ord) l)
case i of
Left err -> putStrLn (show err)
Right i' -> mapM_ (putStrLn . showInstr) i'
where
showInstr = case style of
IntelStyle -> showIntel
AttStyle -> showAtt
| cnc-patch/disass | src/Language/Assembly/X86.hs | bsd-3-clause | 5,729 | 0 | 12 | 1,226 | 1,030 | 570 | 460 | 78 | 3 |
module Control.ComonadTrans where
import Prelude()
import Control.Comonad
class ComonadTrans f where
lower ::
Comonad g =>
f g a
-> g a
| tonymorris/lens-proposal | src/Control/ComonadTrans.hs | bsd-3-clause | 152 | 0 | 9 | 38 | 50 | 26 | 24 | 8 | 0 |
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.PackageDescription.Check
-- Copyright : Lennart Kolmodin 2008
-- License : BSD3
--
-- Maintainer : [email protected]
-- Portability : portable
--
-- This has code for checking for various problems in packages. There is one
-- set of checks that just looks at a 'PackageDescription' in isolation and
-- another set of checks that also looks at files in the package. Some of the
-- checks are basic sanity checks, others are portability standards that we'd
-- like to encourage. There is a 'PackageCheck' type that distinguishes the
-- different kinds of check so we can see which ones are appropriate to report
-- in different situations. This code gets uses when configuring a package when
-- we consider only basic problems. The higher standard is uses when when
-- preparing a source tarball and by Hackage when uploading new packages. The
-- reason for this is that we want to hold packages that are expected to be
-- distributed to a higher standard than packages that are only ever expected
-- to be used on the author's own environment.
module Distribution.PackageDescription.Check (
-- * Package Checking
PackageCheck(..),
checkPackage,
checkConfiguredPackage,
-- ** Checking package contents
checkPackageFiles,
checkPackageContent,
CheckPackageContentOps(..),
checkPackageFileNames,
) where
import Distribution.PackageDescription
import Distribution.PackageDescription.Configuration
import Distribution.Compiler
import Distribution.System
import Distribution.License
import Distribution.Simple.CCompiler
import Distribution.Simple.Utils hiding (findPackageDesc, notice)
import Distribution.Version
import Distribution.Package
import Distribution.Text
import Language.Haskell.Extension
import Data.Maybe
( isNothing, isJust, catMaybes, mapMaybe, maybeToList, fromMaybe )
import Data.List (sort, group, isPrefixOf, nub, find)
import Control.Monad
( filterM, liftM )
import qualified System.Directory as System
( doesFileExist, doesDirectoryExist )
import qualified Data.Map as Map
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>), (<+>))
import qualified System.Directory (getDirectoryContents)
import System.IO (openBinaryFile, IOMode(ReadMode), hGetContents)
import System.FilePath
( (</>), takeExtension, isRelative, isAbsolute
, splitDirectories, splitPath, splitExtension )
import System.FilePath.Windows as FilePath.Windows
( isValid )
-- | Results of some kind of failed package check.
--
-- There are a range of severities, from merely dubious to totally insane.
-- All of them come with a human readable explanation. In future we may augment
-- them with more machine readable explanations, for example to help an IDE
-- suggest automatic corrections.
--
data PackageCheck =
-- | This package description is no good. There's no way it's going to
-- build sensibly. This should give an error at configure time.
PackageBuildImpossible { explanation :: String }
-- | A problem that is likely to affect building the package, or an
-- issue that we'd like every package author to be aware of, even if
-- the package is never distributed.
| PackageBuildWarning { explanation :: String }
-- | An issue that might not be a problem for the package author but
-- might be annoying or detrimental when the package is distributed to
-- users. We should encourage distributed packages to be free from these
-- issues, but occasionally there are justifiable reasons so we cannot
-- ban them entirely.
| PackageDistSuspicious { explanation :: String }
-- | Like PackageDistSuspicious but will only display warnings
-- rather than causing abnormal exit when you run 'cabal check'.
| PackageDistSuspiciousWarn { explanation :: String }
-- | An issue that is OK in the author's environment but is almost
-- certain to be a portability problem for other environments. We can
-- quite legitimately refuse to publicly distribute packages with these
-- problems.
| PackageDistInexcusable { explanation :: String }
deriving (Eq)
instance Show PackageCheck where
show notice = explanation notice
check :: Bool -> PackageCheck -> Maybe PackageCheck
check False _ = Nothing
check True pc = Just pc
checkSpecVersion :: PackageDescription -> [Int] -> Bool -> PackageCheck
-> Maybe PackageCheck
checkSpecVersion pkg specver cond pc
| specVersion pkg >= Version specver [] = Nothing
| otherwise = check cond pc
-- ------------------------------------------------------------
-- * Standard checks
-- ------------------------------------------------------------
-- | Check for common mistakes and problems in package descriptions.
--
-- This is the standard collection of checks covering all aspects except
-- for checks that require looking at files within the package. For those
-- see 'checkPackageFiles'.
--
-- It requires the 'GenericPackageDescription' and optionally a particular
-- configuration of that package. If you pass 'Nothing' then we just check
-- a version of the generic description using 'flattenPackageDescription'.
--
checkPackage :: GenericPackageDescription
-> Maybe PackageDescription
-> [PackageCheck]
checkPackage gpkg mpkg =
checkConfiguredPackage pkg
++ checkConditionals gpkg
++ checkPackageVersions gpkg
++ checkDevelopmentOnlyFlags gpkg
where
pkg = fromMaybe (flattenPackageDescription gpkg) mpkg
--TODO: make this variant go away
-- we should always know the GenericPackageDescription
checkConfiguredPackage :: PackageDescription -> [PackageCheck]
checkConfiguredPackage pkg =
checkSanity pkg
++ checkFields pkg
++ checkLicense pkg
++ checkSourceRepos pkg
++ checkGhcOptions pkg
++ checkCCOptions pkg
++ checkCPPOptions pkg
++ checkPaths pkg
++ checkCabalVersion pkg
-- ------------------------------------------------------------
-- * Basic sanity checks
-- ------------------------------------------------------------
-- | Check that this package description is sane.
--
checkSanity :: PackageDescription -> [PackageCheck]
checkSanity pkg =
catMaybes [
check (null . (\(PackageName n) -> n) . packageName $ pkg) $
PackageBuildImpossible "No 'name' field."
, check (null . versionBranch . packageVersion $ pkg) $
PackageBuildImpossible "No 'version' field."
, check (all ($ pkg) [ null . executables
, null . testSuites
, null . benchmarks
, isNothing . library ]) $
PackageBuildImpossible
"No executables, libraries, tests, or benchmarks found. Nothing to do."
, check (not (null duplicateNames)) $
PackageBuildImpossible $ "Duplicate sections: " ++ commaSep duplicateNames
++ ". The name of every executable, test suite, and benchmark section in"
++ " the package must be unique."
]
--TODO: check for name clashes case insensitively: windows file systems cannot
--cope.
++ maybe [] (checkLibrary pkg) (library pkg)
++ concatMap (checkExecutable pkg) (executables pkg)
++ concatMap (checkTestSuite pkg) (testSuites pkg)
++ concatMap (checkBenchmark pkg) (benchmarks pkg)
++ catMaybes [
check (specVersion pkg > cabalVersion) $
PackageBuildImpossible $
"This package description follows version "
++ display (specVersion pkg) ++ " of the Cabal specification. This "
++ "tool only supports up to version " ++ display cabalVersion ++ "."
]
where
exeNames = map exeName $ executables pkg
testNames = map testName $ testSuites pkg
bmNames = map benchmarkName $ benchmarks pkg
duplicateNames = dups $ exeNames ++ testNames ++ bmNames
checkLibrary :: PackageDescription -> Library -> [PackageCheck]
checkLibrary pkg lib =
catMaybes [
check (not (null moduleDuplicates)) $
PackageBuildImpossible $
"Duplicate modules in library: "
++ commaSep (map display moduleDuplicates)
-- check use of required-signatures/exposed-signatures sections
, checkVersion [1,21] (not (null (requiredSignatures lib))) $
PackageDistInexcusable $
"To use the 'required-signatures' field the package needs to specify "
++ "at least 'cabal-version: >= 1.21'."
, checkVersion [1,21] (not (null (exposedSignatures lib))) $
PackageDistInexcusable $
"To use the 'exposed-signatures' field the package needs to specify "
++ "at least 'cabal-version: >= 1.21'."
]
where
checkVersion :: [Int] -> Bool -> PackageCheck -> Maybe PackageCheck
checkVersion ver cond pc
| specVersion pkg >= Version ver [] = Nothing
| otherwise = check cond pc
moduleDuplicates = dups (libModules lib ++
map moduleReexportName (reexportedModules lib))
checkExecutable :: PackageDescription -> Executable -> [PackageCheck]
checkExecutable pkg exe =
catMaybes [
check (null (modulePath exe)) $
PackageBuildImpossible $
"No 'main-is' field found for executable " ++ exeName exe
, check (not (null (modulePath exe))
&& (not $ fileExtensionSupportedLanguage $ modulePath exe)) $
PackageBuildImpossible $
"The 'main-is' field must specify a '.hs' or '.lhs' file "
++ "(even if it is generated by a preprocessor), "
++ "or it may specify a C/C++/obj-C source file."
, checkSpecVersion pkg [1,17]
(fileExtensionSupportedLanguage (modulePath exe)
&& takeExtension (modulePath exe) `notElem` [".hs", ".lhs"]) $
PackageDistInexcusable $
"The package uses a C/C++/obj-C source file for the 'main-is' field. "
++ "To use this feature you must specify 'cabal-version: >= 1.18'."
, check (not (null moduleDuplicates)) $
PackageBuildImpossible $
"Duplicate modules in executable '" ++ exeName exe ++ "': "
++ commaSep (map display moduleDuplicates)
]
where
moduleDuplicates = dups (exeModules exe)
checkTestSuite :: PackageDescription -> TestSuite -> [PackageCheck]
checkTestSuite pkg test =
catMaybes [
case testInterface test of
TestSuiteUnsupported tt@(TestTypeUnknown _ _) -> Just $
PackageBuildWarning $
quote (display tt) ++ " is not a known type of test suite. "
++ "The known test suite types are: "
++ commaSep (map display knownTestTypes)
TestSuiteUnsupported tt -> Just $
PackageBuildWarning $
quote (display tt) ++ " is not a supported test suite version. "
++ "The known test suite types are: "
++ commaSep (map display knownTestTypes)
_ -> Nothing
, check (not $ null moduleDuplicates) $
PackageBuildImpossible $
"Duplicate modules in test suite '" ++ testName test ++ "': "
++ commaSep (map display moduleDuplicates)
, check mainIsWrongExt $
PackageBuildImpossible $
"The 'main-is' field must specify a '.hs' or '.lhs' file "
++ "(even if it is generated by a preprocessor), "
++ "or it may specify a C/C++/obj-C source file."
, checkSpecVersion pkg [1,17] (mainIsNotHsExt && not mainIsWrongExt) $
PackageDistInexcusable $
"The package uses a C/C++/obj-C source file for the 'main-is' field. "
++ "To use this feature you must specify 'cabal-version: >= 1.18'."
]
where
moduleDuplicates = dups $ testModules test
mainIsWrongExt = case testInterface test of
TestSuiteExeV10 _ f -> not $ fileExtensionSupportedLanguage f
_ -> False
mainIsNotHsExt = case testInterface test of
TestSuiteExeV10 _ f -> takeExtension f `notElem` [".hs", ".lhs"]
_ -> False
checkBenchmark :: PackageDescription -> Benchmark -> [PackageCheck]
checkBenchmark _pkg bm =
catMaybes [
case benchmarkInterface bm of
BenchmarkUnsupported tt@(BenchmarkTypeUnknown _ _) -> Just $
PackageBuildWarning $
quote (display tt) ++ " is not a known type of benchmark. "
++ "The known benchmark types are: "
++ commaSep (map display knownBenchmarkTypes)
BenchmarkUnsupported tt -> Just $
PackageBuildWarning $
quote (display tt) ++ " is not a supported benchmark version. "
++ "The known benchmark types are: "
++ commaSep (map display knownBenchmarkTypes)
_ -> Nothing
, check (not $ null moduleDuplicates) $
PackageBuildImpossible $
"Duplicate modules in benchmark '" ++ benchmarkName bm ++ "': "
++ commaSep (map display moduleDuplicates)
, check mainIsWrongExt $
PackageBuildImpossible $
"The 'main-is' field must specify a '.hs' or '.lhs' file "
++ "(even if it is generated by a preprocessor)."
]
where
moduleDuplicates = dups $ benchmarkModules bm
mainIsWrongExt = case benchmarkInterface bm of
BenchmarkExeV10 _ f -> takeExtension f `notElem` [".hs", ".lhs"]
_ -> False
-- ------------------------------------------------------------
-- * Additional pure checks
-- ------------------------------------------------------------
checkFields :: PackageDescription -> [PackageCheck]
checkFields pkg =
catMaybes [
check (not . FilePath.Windows.isValid . display . packageName $ pkg) $
PackageDistInexcusable $
"Unfortunately, the package name '" ++ display (packageName pkg)
++ "' is one of the reserved system file names on Windows. Many tools "
++ "need to convert package names to file names so using this name "
++ "would cause problems."
, check (isNothing (buildType pkg)) $
PackageBuildWarning $
"No 'build-type' specified. If you do not need a custom Setup.hs or "
++ "./configure script then use 'build-type: Simple'."
, case buildType pkg of
Just (UnknownBuildType unknown) -> Just $
PackageBuildWarning $
quote unknown ++ " is not a known 'build-type'. "
++ "The known build types are: "
++ commaSep (map display knownBuildTypes)
_ -> Nothing
, check (isJust (setupBuildInfo pkg) && buildType pkg /= Just Custom) $
PackageBuildWarning $
"Ignoring the 'custom-setup' section because the 'build-type' is "
++ "not 'Custom'. Use 'build-type: Custom' if you need to use a "
++ "custom Setup.hs script."
, check (not (null unknownCompilers)) $
PackageBuildWarning $
"Unknown compiler " ++ commaSep (map quote unknownCompilers)
++ " in 'tested-with' field."
, check (not (null unknownLanguages)) $
PackageBuildWarning $
"Unknown languages: " ++ commaSep unknownLanguages
, check (not (null unknownExtensions)) $
PackageBuildWarning $
"Unknown extensions: " ++ commaSep unknownExtensions
, check (not (null languagesUsedAsExtensions)) $
PackageBuildWarning $
"Languages listed as extensions: "
++ commaSep languagesUsedAsExtensions
++ ". Languages must be specified in either the 'default-language' "
++ " or the 'other-languages' field."
, check (not (null ourDeprecatedExtensions)) $
PackageDistSuspicious $
"Deprecated extensions: "
++ commaSep (map (quote . display . fst) ourDeprecatedExtensions)
++ ". " ++ unwords
[ "Instead of '" ++ display ext
++ "' use '" ++ display replacement ++ "'."
| (ext, Just replacement) <- ourDeprecatedExtensions ]
, check (null (category pkg)) $
PackageDistSuspicious "No 'category' field."
, check (null (maintainer pkg)) $
PackageDistSuspicious "No 'maintainer' field."
, check (null (synopsis pkg) && null (description pkg)) $
PackageDistInexcusable "No 'synopsis' or 'description' field."
, check (null (description pkg) && not (null (synopsis pkg))) $
PackageDistSuspicious "No 'description' field."
, check (null (synopsis pkg) && not (null (description pkg))) $
PackageDistSuspicious "No 'synopsis' field."
--TODO: recommend the bug reports URL, author and homepage fields
--TODO: recommend not using the stability field
--TODO: recommend specifying a source repo
, check (length (synopsis pkg) >= 80) $
PackageDistSuspicious
"The 'synopsis' field is rather long (max 80 chars is recommended)."
-- check use of impossible constraints "tested-with: GHC== 6.10 && ==6.12"
, check (not (null testedWithImpossibleRanges)) $
PackageDistInexcusable $
"Invalid 'tested-with' version range: "
++ commaSep (map display testedWithImpossibleRanges)
++ ". To indicate that you have tested a package with multiple "
++ "different versions of the same compiler use multiple entries, "
++ "for example 'tested-with: GHC==6.10.4, GHC==6.12.3' and not "
++ "'tested-with: GHC==6.10.4 && ==6.12.3'."
]
where
unknownCompilers = [ name | (OtherCompiler name, _) <- testedWith pkg ]
unknownLanguages = [ name | bi <- allBuildInfo pkg
, UnknownLanguage name <- allLanguages bi ]
unknownExtensions = [ name | bi <- allBuildInfo pkg
, UnknownExtension name <- allExtensions bi
, name `notElem` map display knownLanguages ]
ourDeprecatedExtensions = nub $ catMaybes
[ find ((==ext) . fst) deprecatedExtensions
| bi <- allBuildInfo pkg
, ext <- allExtensions bi ]
languagesUsedAsExtensions =
[ name | bi <- allBuildInfo pkg
, UnknownExtension name <- allExtensions bi
, name `elem` map display knownLanguages ]
testedWithImpossibleRanges =
[ Dependency (PackageName (display compiler)) vr
| (compiler, vr) <- testedWith pkg
, isNoVersion vr ]
checkLicense :: PackageDescription -> [PackageCheck]
checkLicense pkg =
catMaybes [
check (license pkg == UnspecifiedLicense) $
PackageDistInexcusable
"The 'license' field is missing."
, check (license pkg == AllRightsReserved) $
PackageDistSuspicious
"The 'license' is AllRightsReserved. Is that really what you want?"
, case license pkg of
UnknownLicense l -> Just $
PackageBuildWarning $
quote ("license: " ++ l) ++ " is not a recognised license. The "
++ "known licenses are: "
++ commaSep (map display knownLicenses)
_ -> Nothing
, check (license pkg == BSD4) $
PackageDistSuspicious $
"Using 'license: BSD4' is almost always a misunderstanding. 'BSD4' "
++ "refers to the old 4-clause BSD license with the advertising "
++ "clause. 'BSD3' refers the new 3-clause BSD license."
, case unknownLicenseVersion (license pkg) of
Just knownVersions -> Just $
PackageDistSuspicious $
"'license: " ++ display (license pkg) ++ "' is not a known "
++ "version of that license. The known versions are "
++ commaSep (map display knownVersions)
++ ". If this is not a mistake and you think it should be a known "
++ "version then please file a ticket."
_ -> Nothing
, check (license pkg `notElem` [ AllRightsReserved
, UnspecifiedLicense, PublicDomain]
-- AllRightsReserved and PublicDomain are not strictly
-- licenses so don't need license files.
&& null (licenseFiles pkg)) $
PackageDistSuspicious "A 'license-file' is not specified."
]
where
unknownLicenseVersion (GPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | GPL (Just v') <- knownLicenses ]
unknownLicenseVersion (LGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | LGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (AGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | AGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (Apache (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | Apache (Just v') <- knownLicenses ]
unknownLicenseVersion _ = Nothing
checkSourceRepos :: PackageDescription -> [PackageCheck]
checkSourceRepos pkg =
catMaybes $ concat [[
case repoKind repo of
RepoKindUnknown kind -> Just $ PackageDistInexcusable $
quote kind ++ " is not a recognised kind of source-repository. "
++ "The repo kind is usually 'head' or 'this'"
_ -> Nothing
, check (isNothing (repoType repo)) $
PackageDistInexcusable
"The source-repository 'type' is a required field."
, check (isNothing (repoLocation repo)) $
PackageDistInexcusable
"The source-repository 'location' is a required field."
, check (repoType repo == Just CVS && isNothing (repoModule repo)) $
PackageDistInexcusable
"For a CVS source-repository, the 'module' is a required field."
, check (repoKind repo == RepoThis && isNothing (repoTag repo)) $
PackageDistInexcusable $
"For the 'this' kind of source-repository, the 'tag' is a required "
++ "field. It should specify the tag corresponding to this version "
++ "or release of the package."
, check (maybe False System.FilePath.isAbsolute (repoSubdir repo)) $
PackageDistInexcusable
"The 'subdir' field of a source-repository must be a relative path."
]
| repo <- sourceRepos pkg ]
--TODO: check location looks like a URL for some repo types.
checkGhcOptions :: PackageDescription -> [PackageCheck]
checkGhcOptions pkg =
catMaybes [
checkFlags ["-fasm"] $
PackageDistInexcusable $
"'ghc-options: -fasm' is unnecessary and will not work on CPU "
++ "architectures other than x86, x86-64, ppc or sparc."
, checkFlags ["-fvia-C"] $
PackageDistSuspicious $
"'ghc-options: -fvia-C' is usually unnecessary. If your package "
++ "needs -via-C for correctness rather than performance then it "
++ "is using the FFI incorrectly and will probably not work with GHC "
++ "6.10 or later."
, checkFlags ["-fhpc"] $
PackageDistInexcusable $
"'ghc-options: -fhpc' is not not necessary. Use the configure flag "
++ " --enable-coverage instead."
, checkFlags ["-prof"] $
PackageBuildWarning $
"'ghc-options: -prof' is not necessary and will lead to problems "
++ "when used on a library. Use the configure flag "
++ "--enable-library-profiling and/or --enable-executable-profiling."
, checkFlags ["-o"] $
PackageBuildWarning $
"'ghc-options: -o' is not needed. "
++ "The output files are named automatically."
, checkFlags ["-hide-package"] $
PackageBuildWarning $
"'ghc-options: -hide-package' is never needed. "
++ "Cabal hides all packages."
, checkFlags ["--make"] $
PackageBuildWarning $
"'ghc-options: --make' is never needed. Cabal uses this automatically."
, checkFlags ["-main-is"] $
PackageDistSuspicious $
"'ghc-options: -main-is' is not portable."
, checkFlags ["-O0", "-Onot"] $
PackageDistSuspicious $
"'ghc-options: -O0' is not needed. "
++ "Use the --disable-optimization configure flag."
, checkFlags [ "-O", "-O1"] $
PackageDistInexcusable $
"'ghc-options: -O' is not needed. "
++ "Cabal automatically adds the '-O' flag. "
++ "Setting it yourself interferes with the --disable-optimization flag."
, checkFlags ["-O2"] $
PackageDistSuspiciousWarn $
"'ghc-options: -O2' is rarely needed. "
++ "Check that it is giving a real benefit "
++ "and not just imposing longer compile times on your users."
, checkFlags ["-split-objs"] $
PackageBuildWarning $
"'ghc-options: -split-objs' is not needed. "
++ "Use the --enable-split-objs configure flag."
, checkFlags ["-optl-Wl,-s", "-optl-s"] $
PackageDistInexcusable $
"'ghc-options: -optl-Wl,-s' is not needed and is not portable to all"
++ " operating systems. Cabal 1.4 and later automatically strip"
++ " executables. Cabal also has a flag --disable-executable-stripping"
++ " which is necessary when building packages for some Linux"
++ " distributions and using '-optl-Wl,-s' prevents that from working."
, checkFlags ["-fglasgow-exts"] $
PackageDistSuspicious $
"Instead of 'ghc-options: -fglasgow-exts' it is preferable to use "
++ "the 'extensions' field."
, check ("-threaded" `elem` lib_ghc_options) $
PackageBuildWarning $
"'ghc-options: -threaded' has no effect for libraries. It should "
++ "only be used for executables."
, check ("-rtsopts" `elem` lib_ghc_options) $
PackageBuildWarning $
"'ghc-options: -rtsopts' has no effect for libraries. It should "
++ "only be used for executables."
, check (any (\opt -> "-with-rtsopts" `isPrefixOf` opt) lib_ghc_options) $
PackageBuildWarning $
"'ghc-options: -with-rtsopts' has no effect for libraries. It "
++ "should only be used for executables."
, checkAlternatives "ghc-options" "extensions"
[ (flag, display extension) | flag <- all_ghc_options
, Just extension <- [ghcExtension flag] ]
, checkAlternatives "ghc-options" "extensions"
[ (flag, extension) | flag@('-':'X':extension) <- all_ghc_options ]
, checkAlternatives "ghc-options" "cpp-options" $
[ (flag, flag) | flag@('-':'D':_) <- all_ghc_options ]
++ [ (flag, flag) | flag@('-':'U':_) <- all_ghc_options ]
, checkAlternatives "ghc-options" "include-dirs"
[ (flag, dir) | flag@('-':'I':dir) <- all_ghc_options ]
, checkAlternatives "ghc-options" "extra-libraries"
[ (flag, lib) | flag@('-':'l':lib) <- all_ghc_options ]
, checkAlternatives "ghc-options" "extra-lib-dirs"
[ (flag, dir) | flag@('-':'L':dir) <- all_ghc_options ]
, checkAlternatives "ghc-options" "frameworks"
[ (flag, fmwk) | (flag@"-framework", fmwk) <-
zip all_ghc_options (safeTail all_ghc_options) ]
, checkAlternatives "ghc-options" "extra-framework-dirs"
[ (flag, dir) | (flag@"-framework-path", dir) <-
zip all_ghc_options (safeTail all_ghc_options) ]
]
where
all_ghc_options = concatMap get_ghc_options (allBuildInfo pkg)
lib_ghc_options = maybe [] (get_ghc_options . libBuildInfo) (library pkg)
get_ghc_options bi = hcOptions GHC bi ++ hcProfOptions GHC bi
++ hcSharedOptions GHC bi
checkFlags :: [String] -> PackageCheck -> Maybe PackageCheck
checkFlags flags = check (any (`elem` flags) all_ghc_options)
ghcExtension ('-':'f':name) = case name of
"allow-overlapping-instances" -> enable OverlappingInstances
"no-allow-overlapping-instances" -> disable OverlappingInstances
"th" -> enable TemplateHaskell
"no-th" -> disable TemplateHaskell
"ffi" -> enable ForeignFunctionInterface
"no-ffi" -> disable ForeignFunctionInterface
"fi" -> enable ForeignFunctionInterface
"no-fi" -> disable ForeignFunctionInterface
"monomorphism-restriction" -> enable MonomorphismRestriction
"no-monomorphism-restriction" -> disable MonomorphismRestriction
"mono-pat-binds" -> enable MonoPatBinds
"no-mono-pat-binds" -> disable MonoPatBinds
"allow-undecidable-instances" -> enable UndecidableInstances
"no-allow-undecidable-instances" -> disable UndecidableInstances
"allow-incoherent-instances" -> enable IncoherentInstances
"no-allow-incoherent-instances" -> disable IncoherentInstances
"arrows" -> enable Arrows
"no-arrows" -> disable Arrows
"generics" -> enable Generics
"no-generics" -> disable Generics
"implicit-prelude" -> enable ImplicitPrelude
"no-implicit-prelude" -> disable ImplicitPrelude
"implicit-params" -> enable ImplicitParams
"no-implicit-params" -> disable ImplicitParams
"bang-patterns" -> enable BangPatterns
"no-bang-patterns" -> disable BangPatterns
"scoped-type-variables" -> enable ScopedTypeVariables
"no-scoped-type-variables" -> disable ScopedTypeVariables
"extended-default-rules" -> enable ExtendedDefaultRules
"no-extended-default-rules" -> disable ExtendedDefaultRules
_ -> Nothing
ghcExtension "-cpp" = enable CPP
ghcExtension _ = Nothing
enable e = Just (EnableExtension e)
disable e = Just (DisableExtension e)
checkCCOptions :: PackageDescription -> [PackageCheck]
checkCCOptions pkg =
catMaybes [
checkAlternatives "cc-options" "include-dirs"
[ (flag, dir) | flag@('-':'I':dir) <- all_ccOptions ]
, checkAlternatives "cc-options" "extra-libraries"
[ (flag, lib) | flag@('-':'l':lib) <- all_ccOptions ]
, checkAlternatives "cc-options" "extra-lib-dirs"
[ (flag, dir) | flag@('-':'L':dir) <- all_ccOptions ]
, checkAlternatives "ld-options" "extra-libraries"
[ (flag, lib) | flag@('-':'l':lib) <- all_ldOptions ]
, checkAlternatives "ld-options" "extra-lib-dirs"
[ (flag, dir) | flag@('-':'L':dir) <- all_ldOptions ]
, checkCCFlags [ "-O", "-Os", "-O0", "-O1", "-O2", "-O3" ] $
PackageDistSuspicious $
"'cc-options: -O[n]' is generally not needed. When building with "
++ " optimisations Cabal automatically adds '-O2' for C code. "
++ "Setting it yourself interferes with the --disable-optimization "
++ "flag."
]
where all_ccOptions = [ opts | bi <- allBuildInfo pkg
, opts <- ccOptions bi ]
all_ldOptions = [ opts | bi <- allBuildInfo pkg
, opts <- ldOptions bi ]
checkCCFlags :: [String] -> PackageCheck -> Maybe PackageCheck
checkCCFlags flags = check (any (`elem` flags) all_ccOptions)
checkCPPOptions :: PackageDescription -> [PackageCheck]
checkCPPOptions pkg =
catMaybes [
checkAlternatives "cpp-options" "include-dirs"
[ (flag, dir) | flag@('-':'I':dir) <- all_cppOptions]
]
where all_cppOptions = [ opts | bi <- allBuildInfo pkg
, opts <- cppOptions bi ]
checkAlternatives :: String -> String -> [(String, String)] -> Maybe PackageCheck
checkAlternatives badField goodField flags =
check (not (null badFlags)) $
PackageBuildWarning $
"Instead of " ++ quote (badField ++ ": " ++ unwords badFlags)
++ " use " ++ quote (goodField ++ ": " ++ unwords goodFlags)
where (badFlags, goodFlags) = unzip flags
checkPaths :: PackageDescription -> [PackageCheck]
checkPaths pkg =
[ PackageBuildWarning $
quote (kind ++ ": " ++ path)
++ " is a relative path outside of the source tree. "
++ "This will not work when generating a tarball with 'sdist'."
| (path, kind) <- relPaths ++ absPaths
, isOutsideTree path ]
++
[ PackageDistInexcusable $
quote (kind ++ ": " ++ path) ++ " is an absolute path."
| (path, kind) <- relPaths
, isAbsolute path ]
++
[ PackageDistInexcusable $
quote (kind ++ ": " ++ path) ++ " points inside the 'dist' "
++ "directory. This is not reliable because the location of this "
++ "directory is configurable by the user (or package manager). In "
++ "addition the layout of the 'dist' directory is subject to change "
++ "in future versions of Cabal."
| (path, kind) <- relPaths ++ absPaths
, isInsideDist path ]
++
[ PackageDistInexcusable $
"The 'ghc-options' contains the path '" ++ path ++ "' which points "
++ "inside the 'dist' directory. This is not reliable because the "
++ "location of this directory is configurable by the user (or package "
++ "manager). In addition the layout of the 'dist' directory is subject "
++ "to change in future versions of Cabal."
| bi <- allBuildInfo pkg
, (GHC, flags) <- options bi
, path <- flags
, isInsideDist path ]
where
isOutsideTree path = case splitDirectories path of
"..":_ -> True
".":"..":_ -> True
_ -> False
isInsideDist path = case map lowercase (splitDirectories path) of
"dist" :_ -> True
".":"dist":_ -> True
_ -> False
-- paths that must be relative
relPaths =
[ (path, "extra-src-files") | path <- extraSrcFiles pkg ]
++ [ (path, "extra-tmp-files") | path <- extraTmpFiles pkg ]
++ [ (path, "extra-doc-files") | path <- extraDocFiles pkg ]
++ [ (path, "data-files") | path <- dataFiles pkg ]
++ [ (path, "data-dir") | path <- [dataDir pkg]]
++ [ (path, "license-file") | path <- licenseFiles pkg ]
++ concat
[ [ (path, "c-sources") | path <- cSources bi ]
++ [ (path, "js-sources") | path <- jsSources bi ]
++ [ (path, "install-includes") | path <- installIncludes bi ]
++ [ (path, "hs-source-dirs") | path <- hsSourceDirs bi ]
| bi <- allBuildInfo pkg ]
-- paths that are allowed to be absolute
absPaths = concat
[ [ (path, "includes") | path <- includes bi ]
++ [ (path, "include-dirs") | path <- includeDirs bi ]
++ [ (path, "extra-lib-dirs") | path <- extraLibDirs bi ]
| bi <- allBuildInfo pkg ]
--TODO: check sets of paths that would be interpreted differently between Unix
-- and windows, ie case-sensitive or insensitive. Things that might clash, or
-- conversely be distinguished.
--TODO: use the tar path checks on all the above paths
-- | Check that the package declares the version in the @\"cabal-version\"@
-- field correctly.
--
checkCabalVersion :: PackageDescription -> [PackageCheck]
checkCabalVersion pkg =
catMaybes [
-- check syntax of cabal-version field
check (specVersion pkg >= Version [1,10] []
&& not simpleSpecVersionRangeSyntax) $
PackageBuildWarning $
"Packages relying on Cabal 1.10 or later must only specify a "
++ "version range of the form 'cabal-version: >= x.y'. Use "
++ "'cabal-version: >= " ++ display (specVersion pkg) ++ "'."
-- check syntax of cabal-version field
, check (specVersion pkg < Version [1,9] []
&& not simpleSpecVersionRangeSyntax) $
PackageDistSuspicious $
"It is recommended that the 'cabal-version' field only specify a "
++ "version range of the form '>= x.y'. Use "
++ "'cabal-version: >= " ++ display (specVersion pkg) ++ "'. "
++ "Tools based on Cabal 1.10 and later will ignore upper bounds."
-- check syntax of cabal-version field
, checkVersion [1,12] simpleSpecVersionSyntax $
PackageBuildWarning $
"With Cabal 1.10 or earlier, the 'cabal-version' field must use "
++ "range syntax rather than a simple version number. Use "
++ "'cabal-version: >= " ++ display (specVersion pkg) ++ "'."
-- check use of test suite sections
, checkVersion [1,8] (not (null $ testSuites pkg)) $
PackageDistInexcusable $
"The 'test-suite' section is new in Cabal 1.10. "
++ "Unfortunately it messes up the parser in older Cabal versions "
++ "so you must specify at least 'cabal-version: >= 1.8', but note "
++ "that only Cabal 1.10 and later can actually run such test suites."
-- check use of default-language field
-- note that we do not need to do an equivalent check for the
-- other-language field since that one does not change behaviour
, checkVersion [1,10] (any isJust (buildInfoField defaultLanguage)) $
PackageBuildWarning $
"To use the 'default-language' field the package needs to specify "
++ "at least 'cabal-version: >= 1.10'."
, check (specVersion pkg >= Version [1,10] []
&& (any isNothing (buildInfoField defaultLanguage))) $
PackageBuildWarning $
"Packages using 'cabal-version: >= 1.10' must specify the "
++ "'default-language' field for each component (e.g. Haskell98 or "
++ "Haskell2010). If a component uses different languages in "
++ "different modules then list the other ones in the "
++ "'other-languages' field."
-- check use of reexported-modules sections
, checkVersion [1,21]
(maybe False (not.null.reexportedModules) (library pkg)) $
PackageDistInexcusable $
"To use the 'reexported-module' field the package needs to specify "
++ "at least 'cabal-version: >= 1.21'."
-- check use of thinning and renaming
, checkVersion [1,21] (not (null depsUsingThinningRenamingSyntax)) $
PackageDistInexcusable $
"The package uses "
++ "thinning and renaming in the 'build-depends' field: "
++ commaSep (map display depsUsingThinningRenamingSyntax)
++ ". To use this new syntax, the package needs to specify at least"
++ "'cabal-version: >= 1.21'."
-- check use of 'extra-framework-dirs' field
, checkVersion [1,23] (any (not . null) (buildInfoField extraFrameworkDirs)) $
-- Just a warning, because this won't break on old Cabal versions.
PackageDistSuspiciousWarn $
"To use the 'extra-framework-dirs' field the package needs to specify"
++ " at least 'cabal-version: >= 1.23'."
-- check use of default-extensions field
-- don't need to do the equivalent check for other-extensions
, checkVersion [1,10] (any (not . null) (buildInfoField defaultExtensions)) $
PackageBuildWarning $
"To use the 'default-extensions' field the package needs to specify "
++ "at least 'cabal-version: >= 1.10'."
-- check use of extensions field
, check (specVersion pkg >= Version [1,10] []
&& (any (not . null) (buildInfoField oldExtensions))) $
PackageBuildWarning $
"For packages using 'cabal-version: >= 1.10' the 'extensions' "
++ "field is deprecated. The new 'default-extensions' field lists "
++ "extensions that are used in all modules in the component, while "
++ "the 'other-extensions' field lists extensions that are used in "
++ "some modules, e.g. via the {-# LANGUAGE #-} pragma."
-- check use of "foo (>= 1.0 && < 1.4) || >=1.8 " version-range syntax
, checkVersion [1,8] (not (null versionRangeExpressions)) $
PackageDistInexcusable $
"The package uses full version-range expressions "
++ "in a 'build-depends' field: "
++ commaSep (map displayRawDependency versionRangeExpressions)
++ ". To use this new syntax the package needs to specify at least "
++ "'cabal-version: >= 1.8'. Alternatively, if broader compatibility "
++ "is important, then convert to conjunctive normal form, and use "
++ "multiple 'build-depends:' lines, one conjunct per line."
-- check use of "build-depends: foo == 1.*" syntax
, checkVersion [1,6] (not (null depsUsingWildcardSyntax)) $
PackageDistInexcusable $
"The package uses wildcard syntax in the 'build-depends' field: "
++ commaSep (map display depsUsingWildcardSyntax)
++ ". To use this new syntax the package need to specify at least "
++ "'cabal-version: >= 1.6'. Alternatively, if broader compatibility "
++ "is important then use: " ++ commaSep
[ display (Dependency name (eliminateWildcardSyntax versionRange))
| Dependency name versionRange <- depsUsingWildcardSyntax ]
-- check use of "tested-with: GHC (>= 1.0 && < 1.4) || >=1.8 " syntax
, checkVersion [1,8] (not (null testedWithVersionRangeExpressions)) $
PackageDistInexcusable $
"The package uses full version-range expressions "
++ "in a 'tested-with' field: "
++ commaSep (map displayRawDependency testedWithVersionRangeExpressions)
++ ". To use this new syntax the package needs to specify at least "
++ "'cabal-version: >= 1.8'."
-- check use of "tested-with: GHC == 6.12.*" syntax
, checkVersion [1,6] (not (null testedWithUsingWildcardSyntax)) $
PackageDistInexcusable $
"The package uses wildcard syntax in the 'tested-with' field: "
++ commaSep (map display testedWithUsingWildcardSyntax)
++ ". To use this new syntax the package need to specify at least "
++ "'cabal-version: >= 1.6'. Alternatively, if broader compatibility "
++ "is important then use: " ++ commaSep
[ display (Dependency name (eliminateWildcardSyntax versionRange))
| Dependency name versionRange <- testedWithUsingWildcardSyntax ]
-- check use of "data-files: data/*.txt" syntax
, checkVersion [1,6] (not (null dataFilesUsingGlobSyntax)) $
PackageDistInexcusable $
"Using wildcards like "
++ commaSep (map quote $ take 3 dataFilesUsingGlobSyntax)
++ " in the 'data-files' field requires 'cabal-version: >= 1.6'. "
++ "Alternatively if you require compatibility with earlier Cabal "
++ "versions then list all the files explicitly."
-- check use of "extra-source-files: mk/*.in" syntax
, checkVersion [1,6] (not (null extraSrcFilesUsingGlobSyntax)) $
PackageDistInexcusable $
"Using wildcards like "
++ commaSep (map quote $ take 3 extraSrcFilesUsingGlobSyntax)
++ " in the 'extra-source-files' field requires "
++ "'cabal-version: >= 1.6'. Alternatively if you require "
++ "compatibility with earlier Cabal versions then list all the files "
++ "explicitly."
-- check use of "source-repository" section
, checkVersion [1,6] (not (null (sourceRepos pkg))) $
PackageDistInexcusable $
"The 'source-repository' section is new in Cabal 1.6. "
++ "Unfortunately it messes up the parser in earlier Cabal versions "
++ "so you need to specify 'cabal-version: >= 1.6'."
-- check for new licenses
, checkVersion [1,4] (license pkg `notElem` compatLicenses) $
PackageDistInexcusable $
"Unfortunately the license " ++ quote (display (license pkg))
++ " messes up the parser in earlier Cabal versions so you need to "
++ "specify 'cabal-version: >= 1.4'. Alternatively if you require "
++ "compatibility with earlier Cabal versions then use 'OtherLicense'."
-- check for new language extensions
, checkVersion [1,2,3] (not (null mentionedExtensionsThatNeedCabal12)) $
PackageDistInexcusable $
"Unfortunately the language extensions "
++ commaSep (map (quote . display) mentionedExtensionsThatNeedCabal12)
++ " break the parser in earlier Cabal versions so you need to "
++ "specify 'cabal-version: >= 1.2.3'. Alternatively if you require "
++ "compatibility with earlier Cabal versions then you may be able to "
++ "use an equivalent compiler-specific flag."
, checkVersion [1,4] (not (null mentionedExtensionsThatNeedCabal14)) $
PackageDistInexcusable $
"Unfortunately the language extensions "
++ commaSep (map (quote . display) mentionedExtensionsThatNeedCabal14)
++ " break the parser in earlier Cabal versions so you need to "
++ "specify 'cabal-version: >= 1.4'. Alternatively if you require "
++ "compatibility with earlier Cabal versions then you may be able to "
++ "use an equivalent compiler-specific flag."
, check (specVersion pkg >= Version [1,23] []
&& isNothing (setupBuildInfo pkg)
&& buildType pkg == Just Custom) $
PackageBuildWarning $
"Packages using 'cabal-version: >= 1.23' with 'build-type: Custom' "
++ "must use a 'custom-setup' section with a 'setup-depends' field "
++ "that specifies the dependencies of the Setup.hs script itself. "
++ "The 'setup-depends' field uses the same syntax as 'build-depends', "
++ "so a simple example would be 'setup-depends: base, Cabal'."
, check (specVersion pkg < Version [1,23] []
&& isNothing (setupBuildInfo pkg)
&& buildType pkg == Just Custom) $
PackageDistSuspiciousWarn $
"From version 1.23 cabal supports specifiying explicit dependencies "
++ "for Custom setup scripts. Consider using cabal-version >= 1.23 and "
++ "adding a 'custom-setup' section with a 'setup-depends' field "
++ "that specifies the dependencies of the Setup.hs script itself. "
++ "The 'setup-depends' field uses the same syntax as 'build-depends', "
++ "so a simple example would be 'setup-depends: base, Cabal'."
]
where
-- Perform a check on packages that use a version of the spec less than
-- the version given. This is for cases where a new Cabal version adds
-- a new feature and we want to check that it is not used prior to that
-- version.
checkVersion :: [Int] -> Bool -> PackageCheck -> Maybe PackageCheck
checkVersion ver cond pc
| specVersion pkg >= Version ver [] = Nothing
| otherwise = check cond pc
buildInfoField field = map field (allBuildInfo pkg)
dataFilesUsingGlobSyntax = filter usesGlobSyntax (dataFiles pkg)
extraSrcFilesUsingGlobSyntax = filter usesGlobSyntax (extraSrcFiles pkg)
usesGlobSyntax str = case parseFileGlob str of
Just (FileGlob _ _) -> True
_ -> False
versionRangeExpressions =
[ dep | dep@(Dependency _ vr) <- buildDepends pkg
, usesNewVersionRangeSyntax vr ]
testedWithVersionRangeExpressions =
[ Dependency (PackageName (display compiler)) vr
| (compiler, vr) <- testedWith pkg
, usesNewVersionRangeSyntax vr ]
simpleSpecVersionRangeSyntax =
either (const True)
(foldVersionRange'
True
(\_ -> False)
(\_ -> False) (\_ -> False)
(\_ -> True) -- >=
(\_ -> False)
(\_ _ -> False)
(\_ _ -> False) (\_ _ -> False)
id)
(specVersionRaw pkg)
-- is the cabal-version field a simple version number, rather than a range
simpleSpecVersionSyntax =
either (const True) (const False) (specVersionRaw pkg)
usesNewVersionRangeSyntax :: VersionRange -> Bool
usesNewVersionRangeSyntax =
(> 2) -- uses the new syntax if depth is more than 2
. foldVersionRange'
(1 :: Int)
(const 1)
(const 1) (const 1)
(const 1) (const 1)
(const (const 1))
(+) (+)
(const 3) -- uses new ()'s syntax
depsUsingWildcardSyntax = [ dep | dep@(Dependency _ vr) <- buildDepends pkg
, usesWildcardSyntax vr ]
-- TODO: If the user writes build-depends: foo with (), this is
-- indistinguishable from build-depends: foo, so there won't be an
-- error even though there should be
depsUsingThinningRenamingSyntax =
[ name
| bi <- allBuildInfo pkg
, (name, _) <- Map.toList (targetBuildRenaming bi) ]
testedWithUsingWildcardSyntax =
[ Dependency (PackageName (display compiler)) vr
| (compiler, vr) <- testedWith pkg
, usesWildcardSyntax vr ]
usesWildcardSyntax :: VersionRange -> Bool
usesWildcardSyntax =
foldVersionRange'
False (const False)
(const False) (const False)
(const False) (const False)
(\_ _ -> True) -- the wildcard case
(||) (||) id
eliminateWildcardSyntax =
foldVersionRange'
anyVersion thisVersion
laterVersion earlierVersion
orLaterVersion orEarlierVersion
(\v v' -> intersectVersionRanges (orLaterVersion v) (earlierVersion v'))
intersectVersionRanges unionVersionRanges id
compatLicenses = [ GPL Nothing, LGPL Nothing, AGPL Nothing, BSD3, BSD4
, PublicDomain, AllRightsReserved
, UnspecifiedLicense, OtherLicense ]
mentionedExtensions = [ ext | bi <- allBuildInfo pkg
, ext <- allExtensions bi ]
mentionedExtensionsThatNeedCabal12 =
nub (filter (`elem` compatExtensionsExtra) mentionedExtensions)
-- As of Cabal-1.4 we can add new extensions without worrying about
-- breaking old versions of cabal.
mentionedExtensionsThatNeedCabal14 =
nub (filter (`notElem` compatExtensions) mentionedExtensions)
-- The known extensions in Cabal-1.2.3
compatExtensions =
map EnableExtension
[ OverlappingInstances, UndecidableInstances, IncoherentInstances
, RecursiveDo, ParallelListComp, MultiParamTypeClasses
, FunctionalDependencies, Rank2Types
, RankNTypes, PolymorphicComponents, ExistentialQuantification
, ScopedTypeVariables, ImplicitParams, FlexibleContexts
, FlexibleInstances, EmptyDataDecls, CPP, BangPatterns
, TypeSynonymInstances, TemplateHaskell, ForeignFunctionInterface
, Arrows, Generics, NamedFieldPuns, PatternGuards
, GeneralizedNewtypeDeriving, ExtensibleRecords, RestrictedTypeSynonyms
, HereDocuments] ++
map DisableExtension
[MonomorphismRestriction, ImplicitPrelude] ++
compatExtensionsExtra
-- The extra known extensions in Cabal-1.2.3 vs Cabal-1.1.6
-- (Cabal-1.1.6 came with ghc-6.6. Cabal-1.2 came with ghc-6.8)
compatExtensionsExtra =
map EnableExtension
[ KindSignatures, MagicHash, TypeFamilies, StandaloneDeriving
, UnicodeSyntax, PatternSignatures, UnliftedFFITypes, LiberalTypeSynonyms
, TypeOperators, RecordWildCards, RecordPuns, DisambiguateRecordFields
, OverloadedStrings, GADTs, RelaxedPolyRec
, ExtendedDefaultRules, UnboxedTuples, DeriveDataTypeable
, ConstrainedClassMethods
] ++
map DisableExtension
[MonoPatBinds]
-- | A variation on the normal 'Text' instance, shows any ()'s in the original
-- textual syntax. We need to show these otherwise it's confusing to users when
-- we complain of their presence but do not pretty print them!
--
displayRawVersionRange :: VersionRange -> String
displayRawVersionRange =
Disp.render
. fst
. foldVersionRange' -- precedence:
-- All the same as the usual pretty printer, except for the parens
( Disp.text "-any" , 0 :: Int)
(\v -> (Disp.text "==" <> disp v , 0))
(\v -> (Disp.char '>' <> disp v , 0))
(\v -> (Disp.char '<' <> disp v , 0))
(\v -> (Disp.text ">=" <> disp v , 0))
(\v -> (Disp.text "<=" <> disp v , 0))
(\v _ -> (Disp.text "==" <> dispWild v , 0))
(\(r1, p1) (r2, p2) ->
(punct 2 p1 r1 <+> Disp.text "||" <+> punct 2 p2 r2 , 2))
(\(r1, p1) (r2, p2) ->
(punct 1 p1 r1 <+> Disp.text "&&" <+> punct 1 p2 r2 , 1))
(\(r, _ ) -> (Disp.parens r, 0)) -- parens
where
dispWild (Version b _) =
Disp.hcat (Disp.punctuate (Disp.char '.') (map Disp.int b))
<> Disp.text ".*"
punct p p' | p < p' = Disp.parens
| otherwise = id
displayRawDependency :: Dependency -> String
displayRawDependency (Dependency pkg vr) =
display pkg ++ " " ++ displayRawVersionRange vr
-- ------------------------------------------------------------
-- * Checks on the GenericPackageDescription
-- ------------------------------------------------------------
-- | Check the build-depends fields for any weirdness or bad practise.
--
checkPackageVersions :: GenericPackageDescription -> [PackageCheck]
checkPackageVersions pkg =
catMaybes [
-- Check that the version of base is bounded above.
-- For example this bans "build-depends: base >= 3".
-- It should probably be "build-depends: base >= 3 && < 4"
-- which is the same as "build-depends: base == 3.*"
check (not (boundedAbove baseDependency)) $
PackageDistInexcusable $
"The dependency 'build-depends: base' does not specify an upper "
++ "bound on the version number. Each major release of the 'base' "
++ "package changes the API in various ways and most packages will "
++ "need some changes to compile with it. The recommended practise "
++ "is to specify an upper bound on the version of the 'base' "
++ "package. This ensures your package will continue to build when a "
++ "new major version of the 'base' package is released. If you are "
++ "not sure what upper bound to use then use the next major "
++ "version. For example if you have tested your package with 'base' "
++ "version 4.5 and 4.6 then use 'build-depends: base >= 4.5 && < 4.7'."
]
where
-- TODO: What we really want to do is test if there exists any
-- configuration in which the base version is unbounded above.
-- However that's a bit tricky because there are many possible
-- configurations. As a cheap easy and safe approximation we will
-- pick a single "typical" configuration and check if that has an
-- open upper bound. To get a typical configuration we finalise
-- using no package index and the current platform.
finalised = finalizePackageDescription
[] (const True) buildPlatform
(unknownCompilerInfo
(CompilerId buildCompilerFlavor (Version [] [])) NoAbiTag)
[] pkg
baseDependency = case finalised of
Right (pkg', _) | not (null baseDeps) ->
foldr intersectVersionRanges anyVersion baseDeps
where
baseDeps =
[ vr | Dependency (PackageName "base") vr <- buildDepends pkg' ]
-- Just in case finalizePackageDescription fails for any reason,
-- or if the package doesn't depend on the base package at all,
-- then we will just skip the check, since boundedAbove noVersion = True
_ -> noVersion
boundedAbove :: VersionRange -> Bool
boundedAbove vr = case asVersionIntervals vr of
[] -> True -- this is the inconsistent version range.
intervals -> case last intervals of
(_, UpperBound _ _) -> True
(_, NoUpperBound ) -> False
checkConditionals :: GenericPackageDescription -> [PackageCheck]
checkConditionals pkg =
catMaybes [
check (not $ null unknownOSs) $
PackageDistInexcusable $
"Unknown operating system name "
++ commaSep (map quote unknownOSs)
, check (not $ null unknownArches) $
PackageDistInexcusable $
"Unknown architecture name "
++ commaSep (map quote unknownArches)
, check (not $ null unknownImpls) $
PackageDistInexcusable $
"Unknown compiler name "
++ commaSep (map quote unknownImpls)
]
where
unknownOSs = [ os | OS (OtherOS os) <- conditions ]
unknownArches = [ arch | Arch (OtherArch arch) <- conditions ]
unknownImpls = [ impl | Impl (OtherCompiler impl) _ <- conditions ]
conditions = maybe [] fvs (condLibrary pkg)
++ concatMap (fvs . snd) (condExecutables pkg)
fvs (CondNode _ _ ifs) = concatMap compfv ifs -- free variables
compfv (c, ct, mct) = condfv c ++ fvs ct ++ maybe [] fvs mct
condfv c = case c of
Var v -> [v]
Lit _ -> []
CNot c1 -> condfv c1
COr c1 c2 -> condfv c1 ++ condfv c2
CAnd c1 c2 -> condfv c1 ++ condfv c2
checkDevelopmentOnlyFlagsBuildInfo :: BuildInfo -> [PackageCheck]
checkDevelopmentOnlyFlagsBuildInfo bi =
catMaybes [
check has_WerrorWall $
PackageDistInexcusable $
"'ghc-options: -Wall -Werror' makes the package very easy to "
++ "break with future GHC versions because new GHC versions often "
++ "add new warnings. Use just 'ghc-options: -Wall' instead."
++ extraExplanation
, check (not has_WerrorWall && has_Werror) $
PackageDistInexcusable $
"'ghc-options: -Werror' makes the package easy to "
++ "break with future GHC versions because new GHC versions often "
++ "add new warnings. "
++ extraExplanation
, checkFlags ["-fdefer-type-errors"] $
PackageDistInexcusable $
"'ghc-options: -fdefer-type-errors' is fine during development but "
++ "is not appropriate for a distributed package. "
++ extraExplanation
-- -dynamic is not a debug flag
, check (any (\opt -> "-d" `isPrefixOf` opt && opt /= "-dynamic")
ghc_options) $
PackageDistInexcusable $
"'ghc-options: -d*' debug flags are not appropriate "
++ "for a distributed package. "
++ extraExplanation
, checkFlags ["-fprof-auto", "-fprof-auto-top", "-fprof-auto-calls",
"-fprof-cafs", "-fno-prof-count-entries",
"-auto-all", "-auto", "-caf-all"] $
PackageDistSuspicious $
"'ghc-options: -fprof*' profiling flags are typically not "
++ "appropriate for a distributed library package. These flags are "
++ "useful to profile this package, but when profiling other packages "
++ "that use this one these flags clutter the profile output with "
++ "excessive detail. If you think other packages really want to see "
++ "cost centres from this package then use '-fprof-auto-exported' "
++ "which puts cost centres only on exported functions. "
++ extraExplanation
]
where
extraExplanation =
" Alternatively, if you want to use this, make it conditional based "
++ "on a Cabal configuration flag (with 'manual: True' and 'default: "
++ "False') and enable that flag during development."
has_WerrorWall = has_Werror && ( has_Wall || has_W )
has_Werror = "-Werror" `elem` ghc_options
has_Wall = "-Wall" `elem` ghc_options
has_W = "-W" `elem` ghc_options
ghc_options = hcOptions GHC bi ++ hcProfOptions GHC bi
++ hcSharedOptions GHC bi
checkFlags :: [String] -> PackageCheck -> Maybe PackageCheck
checkFlags flags = check (any (`elem` flags) ghc_options)
checkDevelopmentOnlyFlags :: GenericPackageDescription -> [PackageCheck]
checkDevelopmentOnlyFlags pkg =
concatMap checkDevelopmentOnlyFlagsBuildInfo
[ bi
| (conditions, bi) <- allConditionalBuildInfo
, not (any guardedByManualFlag conditions) ]
where
guardedByManualFlag = definitelyFalse
-- We've basically got three-values logic here: True, False or unknown
-- hence this pattern to propagate the unknown cases properly.
definitelyFalse (Var (Flag n)) = maybe False not (Map.lookup n manualFlags)
definitelyFalse (Var _) = False
definitelyFalse (Lit b) = not b
definitelyFalse (CNot c) = definitelyTrue c
definitelyFalse (COr c1 c2) = definitelyFalse c1 && definitelyFalse c2
definitelyFalse (CAnd c1 c2) = definitelyFalse c1 || definitelyFalse c2
definitelyTrue (Var (Flag n)) = fromMaybe False (Map.lookup n manualFlags)
definitelyTrue (Var _) = False
definitelyTrue (Lit b) = b
definitelyTrue (CNot c) = definitelyFalse c
definitelyTrue (COr c1 c2) = definitelyTrue c1 || definitelyTrue c2
definitelyTrue (CAnd c1 c2) = definitelyTrue c1 && definitelyTrue c2
manualFlags = Map.fromList
[ (flagName flag, flagDefault flag)
| flag <- genPackageFlags pkg
, flagManual flag ]
allConditionalBuildInfo :: [([Condition ConfVar], BuildInfo)]
allConditionalBuildInfo =
concatMap (collectCondTreePaths libBuildInfo)
(maybeToList (condLibrary pkg))
++ concatMap (collectCondTreePaths buildInfo . snd)
(condExecutables pkg)
++ concatMap (collectCondTreePaths testBuildInfo . snd)
(condTestSuites pkg)
++ concatMap (collectCondTreePaths benchmarkBuildInfo . snd)
(condBenchmarks pkg)
-- get all the leaf BuildInfo, paired up with the path (in the tree sense)
-- of if-conditions that guard it
collectCondTreePaths :: (a -> b)
-> CondTree v c a
-> [([Condition v], b)]
collectCondTreePaths mapData = go []
where
go conditions condNode =
-- the data at this level in the tree:
(reverse conditions, mapData (condTreeData condNode))
: concat
[ go (condition:conditions) ifThen
| (condition, ifThen, _) <- condTreeComponents condNode ]
++ concat
[ go (condition:conditions) elseThen
| (condition, _, Just elseThen) <- condTreeComponents condNode ]
-- ------------------------------------------------------------
-- * Checks involving files in the package
-- ------------------------------------------------------------
-- | Sanity check things that requires IO. It looks at the files in the
-- package and expects to find the package unpacked in at the given file path.
--
checkPackageFiles :: PackageDescription -> FilePath -> IO [PackageCheck]
checkPackageFiles pkg root = checkPackageContent checkFilesIO pkg
where
checkFilesIO = CheckPackageContentOps {
doesFileExist = System.doesFileExist . relative,
doesDirectoryExist = System.doesDirectoryExist . relative,
getDirectoryContents = System.Directory.getDirectoryContents . relative,
getFileContents = \f -> openBinaryFile (relative f) ReadMode >>= hGetContents
}
relative path = root </> path
-- | A record of operations needed to check the contents of packages.
-- Used by 'checkPackageContent'.
--
data CheckPackageContentOps m = CheckPackageContentOps {
doesFileExist :: FilePath -> m Bool,
doesDirectoryExist :: FilePath -> m Bool,
getDirectoryContents :: FilePath -> m [FilePath],
getFileContents :: FilePath -> m String
}
-- | Sanity check things that requires looking at files in the package.
-- This is a generalised version of 'checkPackageFiles' that can work in any
-- monad for which you can provide 'CheckPackageContentOps' operations.
--
-- The point of this extra generality is to allow doing checks in some virtual
-- file system, for example a tarball in memory.
--
checkPackageContent :: Monad m => CheckPackageContentOps m
-> PackageDescription
-> m [PackageCheck]
checkPackageContent ops pkg = do
cabalBomError <- checkCabalFileBOM ops
licenseErrors <- checkLicensesExist ops pkg
setupError <- checkSetupExists ops pkg
configureError <- checkConfigureExists ops pkg
localPathErrors <- checkLocalPathsExist ops pkg
vcsLocation <- checkMissingVcsInfo ops pkg
return $ licenseErrors
++ catMaybes [cabalBomError, setupError, configureError]
++ localPathErrors
++ vcsLocation
checkCabalFileBOM :: Monad m => CheckPackageContentOps m
-> m (Maybe PackageCheck)
checkCabalFileBOM ops = do
epdfile <- findPackageDesc ops
case epdfile of
Left pc -> return $ Just pc
Right pdfile -> (flip check pc . startsWithBOM . fromUTF8) `liftM` (getFileContents ops pdfile)
where pc = PackageDistInexcusable $
pdfile ++ " starts with an Unicode byte order mark (BOM). This may cause problems with older cabal versions."
-- |Find a package description file in the given directory. Looks for
-- @.cabal@ files. Like 'Distribution.Simple.Utils.findPackageDesc',
-- but generalized over monads.
findPackageDesc :: Monad m => CheckPackageContentOps m
-> m (Either PackageCheck FilePath) -- ^<pkgname>.cabal
findPackageDesc ops
= do let dir = "."
files <- getDirectoryContents ops dir
-- to make sure we do not mistake a ~/.cabal/ dir for a <pkgname>.cabal
-- file we filter to exclude dirs and null base file names:
cabalFiles <- filterM (doesFileExist ops)
[ dir </> file
| file <- files
, let (name, ext) = splitExtension file
, not (null name) && ext == ".cabal" ]
case cabalFiles of
[] -> return (Left $ PackageBuildImpossible noDesc)
[cabalFile] -> return (Right cabalFile)
multiple -> return (Left $ PackageBuildImpossible $ multiDesc multiple)
where
noDesc :: String
noDesc = "No cabal file found.\n"
++ "Please create a package description file <pkgname>.cabal"
multiDesc :: [String] -> String
multiDesc l = "Multiple cabal files found.\n"
++ "Please use only one of: "
++ intercalate ", " l
checkLicensesExist :: Monad m => CheckPackageContentOps m
-> PackageDescription
-> m [PackageCheck]
checkLicensesExist ops pkg = do
exists <- mapM (doesFileExist ops) (licenseFiles pkg)
return
[ PackageBuildWarning $
"The '" ++ fieldname ++ "' field refers to the file "
++ quote file ++ " which does not exist."
| (file, False) <- zip (licenseFiles pkg) exists ]
where
fieldname | length (licenseFiles pkg) == 1 = "license-file"
| otherwise = "license-files"
checkSetupExists :: Monad m => CheckPackageContentOps m
-> PackageDescription
-> m (Maybe PackageCheck)
checkSetupExists ops pkg = do
let simpleBuild = buildType pkg == Just Simple
hsexists <- doesFileExist ops "Setup.hs"
lhsexists <- doesFileExist ops "Setup.lhs"
return $ check (not simpleBuild && not hsexists && not lhsexists) $
PackageDistInexcusable $
"The package is missing a Setup.hs or Setup.lhs script."
checkConfigureExists :: Monad m => CheckPackageContentOps m
-> PackageDescription
-> m (Maybe PackageCheck)
checkConfigureExists ops PackageDescription { buildType = Just Configure } = do
exists <- doesFileExist ops "configure"
return $ check (not exists) $
PackageBuildWarning $
"The 'build-type' is 'Configure' but there is no 'configure' script. "
++ "You probably need to run 'autoreconf -i' to generate it."
checkConfigureExists _ _ = return Nothing
checkLocalPathsExist :: Monad m => CheckPackageContentOps m
-> PackageDescription
-> m [PackageCheck]
checkLocalPathsExist ops pkg = do
let dirs = [ (dir, kind)
| bi <- allBuildInfo pkg
, (dir, kind) <-
[ (dir, "extra-lib-dirs") | dir <- extraLibDirs bi ]
++ [ (dir, "extra-framework-dirs")
| dir <- extraFrameworkDirs bi ]
++ [ (dir, "include-dirs") | dir <- includeDirs bi ]
++ [ (dir, "hs-source-dirs") | dir <- hsSourceDirs bi ]
, isRelative dir ]
missing <- filterM (liftM not . doesDirectoryExist ops . fst) dirs
return [ PackageBuildWarning {
explanation = quote (kind ++ ": " ++ dir)
++ " directory does not exist."
}
| (dir, kind) <- missing ]
checkMissingVcsInfo :: Monad m => CheckPackageContentOps m
-> PackageDescription
-> m [PackageCheck]
checkMissingVcsInfo ops pkg | null (sourceRepos pkg) = do
vcsInUse <- liftM or $ mapM (doesDirectoryExist ops) repoDirnames
if vcsInUse
then return [ PackageDistSuspicious message ]
else return []
where
repoDirnames = [ dirname | repo <- knownRepoTypes
, dirname <- repoTypeDirname repo ]
message = "When distributing packages it is encouraged to specify source "
++ "control information in the .cabal file using one or more "
++ "'source-repository' sections. See the Cabal user guide for "
++ "details."
checkMissingVcsInfo _ _ = return []
repoTypeDirname :: RepoType -> [FilePath]
repoTypeDirname Darcs = ["_darcs"]
repoTypeDirname Git = [".git"]
repoTypeDirname SVN = [".svn"]
repoTypeDirname CVS = ["CVS"]
repoTypeDirname Mercurial = [".hg"]
repoTypeDirname GnuArch = [".arch-params"]
repoTypeDirname Bazaar = [".bzr"]
repoTypeDirname Monotone = ["_MTN"]
repoTypeDirname _ = []
-- ------------------------------------------------------------
-- * Checks involving files in the package
-- ------------------------------------------------------------
-- | Check the names of all files in a package for portability problems. This
-- should be done for example when creating or validating a package tarball.
--
checkPackageFileNames :: [FilePath] -> [PackageCheck]
checkPackageFileNames files =
(take 1 . mapMaybe checkWindowsPath $ files)
++ (take 1 . mapMaybe checkTarPath $ files)
-- If we get any of these checks triggering then we're likely to get
-- many, and that's probably not helpful, so return at most one.
checkWindowsPath :: FilePath -> Maybe PackageCheck
checkWindowsPath path =
check (not $ FilePath.Windows.isValid path') $
PackageDistInexcusable $
"Unfortunately, the file " ++ quote path ++ " is not a valid file "
++ "name on Windows which would cause portability problems for this "
++ "package. Windows file names cannot contain any of the characters "
++ "\":*?<>|\" and there are a few reserved names including \"aux\", "
++ "\"nul\", \"con\", \"prn\", \"com1-9\", \"lpt1-9\" and \"clock$\"."
where
path' = ".\\" ++ path
-- force a relative name to catch invalid file names like "f:oo" which
-- otherwise parse as file "oo" in the current directory on the 'f' drive.
-- | Check a file name is valid for the portable POSIX tar format.
--
-- The POSIX tar format has a restriction on the length of file names. It is
-- unfortunately not a simple restriction like a maximum length. The exact
-- restriction is that either the whole path be 100 characters or less, or it
-- be possible to split the path on a directory separator such that the first
-- part is 155 characters or less and the second part 100 characters or less.
--
checkTarPath :: FilePath -> Maybe PackageCheck
checkTarPath path
| length path > 255 = Just longPath
| otherwise = case pack nameMax (reverse (splitPath path)) of
Left err -> Just err
Right [] -> Nothing
Right (first:rest) -> case pack prefixMax remainder of
Left err -> Just err
Right [] -> Nothing
Right (_:_) -> Just noSplit
where
-- drop the '/' between the name and prefix:
remainder = init first : rest
where
nameMax, prefixMax :: Int
nameMax = 100
prefixMax = 155
pack _ [] = Left emptyName
pack maxLen (c:cs)
| n > maxLen = Left longName
| otherwise = Right (pack' maxLen n cs)
where n = length c
pack' maxLen n (c:cs)
| n' <= maxLen = pack' maxLen n' cs
where n' = n + length c
pack' _ _ cs = cs
longPath = PackageDistInexcusable $
"The following file name is too long to store in a portable POSIX "
++ "format tar archive. The maximum length is 255 ASCII characters.\n"
++ "The file in question is:\n " ++ path
longName = PackageDistInexcusable $
"The following file name is too long to store in a portable POSIX "
++ "format tar archive. The maximum length for the name part (including "
++ "extension) is 100 ASCII characters. The maximum length for any "
++ "individual directory component is 155.\n"
++ "The file in question is:\n " ++ path
noSplit = PackageDistInexcusable $
"The following file name is too long to store in a portable POSIX "
++ "format tar archive. While the total length is less than 255 ASCII "
++ "characters, there are unfortunately further restrictions. It has to "
++ "be possible to split the file path on a directory separator into "
++ "two parts such that the first part fits in 155 characters or less "
++ "and the second part fits in 100 characters or less. Basically you "
++ "have to make the file name or directory names shorter, or you could "
++ "split a long directory name into nested subdirectories with shorter "
++ "names.\nThe file in question is:\n " ++ path
emptyName = PackageDistInexcusable $
"Encountered a file with an empty name, something is very wrong! "
++ "Files with an empty name cannot be stored in a tar archive or in "
++ "standard file systems."
-- ------------------------------------------------------------
-- * Utils
-- ------------------------------------------------------------
quote :: String -> String
quote s = "'" ++ s ++ "'"
commaSep :: [String] -> String
commaSep = intercalate ", "
dups :: Ord a => [a] -> [a]
dups xs = [ x | (x:_:_) <- group (sort xs) ]
fileExtensionSupportedLanguage :: FilePath -> Bool
fileExtensionSupportedLanguage path =
isHaskell || isC
where
extension = takeExtension path
isHaskell = extension `elem` [".hs", ".lhs"]
isC = isJust (filenameCDialect extension)
| garetxe/cabal | Cabal/Distribution/PackageDescription/Check.hs | bsd-3-clause | 74,822 | 0 | 22 | 19,949 | 14,050 | 7,284 | 6,766 | 1,257 | 33 |
module PL.Find_Model (
make_fixed
) where
-- $Id$
import PL.Type
import PL.Tree
import PL.Param
import PL.Signatur
import PL.Struktur
import PL.Interpretation
import PL.Semantik
import Challenger.Partial
import Autolib.ToDoc
import Autolib.Reporter
import Autolib.Set
import Autolib.Size
import Inter.Types
import Data.Typeable
data Find_Model = Find_Model deriving ( Show, Read, Typeable )
instance OrderScore Find_Model where
scoringOrder _ = Increasing
instance Partial Find_Model Param ( Interpretation Int ) where
report Find_Model p = do
inform $ vcat
[ text "Finden Sie für die Formel"
, nest 4 $ toDoc $ formel p
, text "ein Modell (eine Interpretation) der Größe"
, nest 4 $ toDoc $ model_size p
]
peng $ formel p
initial Find_Model p =
PL.Interpretation.empty ( signatur $ formel p )
( mkSet [ 1 .. model_size p ] )
partial Find_Model p i = do
assert ( model_size p == cardinality ( universum $ struktur i ) )
$ text "Modellgröße ist korrekt?"
check ( signatur $ formel p ) i
total Find_Model p i = do
v <- evaluate_top i ( formel p )
inform $ text "Wert der Formel unter der Interpretation ist" <+> toDoc v
when ( not v ) $ reject $ text "Interpretation ist kein Modell"
make_fixed :: Make
make_fixed = direct Find_Model PL.Param.example
| florianpilz/autotool | src/PL/Find_Model.hs | gpl-2.0 | 1,387 | 11 | 17 | 340 | 404 | 205 | 199 | -1 | -1 |
{-|
Module : Isotope.Parsers
Description : Parsers for chemical and condensed formulae.
Copyright : Michael Thomas
License : GPL-3
Maintainer : Michael Thomas <[email protected]>
Stability : Experimental
This module provides parsers for element symbols and elemental composition as
well molecular, condensed and empirical formulae. In addition, quasiquoters are
provided.
-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE FlexibleInstances #-}
module Isotope.Parsers (
-- * Parsers
elementSymbol
, subFormula
, elementalComposition
, molecularFormula
, condensedFormula
, empiricalFormula
, ele
, mol
, con
, emp
) where
import Isotope.Base
import Language.Haskell.TH.Quote
import Language.Haskell.TH.Syntax
import Language.Haskell.TH.Lift
import Text.Megaparsec
import Text.Megaparsec.String
import qualified Text.Megaparsec.Lexer as L
import Data.List
import Data.Map (Map)
import Data.Monoid ((<>))
-- | Parses an element symbol string.
elementSymbol :: Parser ElementSymbol
elementSymbol = read <$> choice (try . string <$> elementSymbolStrList)
where
elementList = show <$> elementSymbolList
reverseLengthSort x y = length y `compare` length x
elementSymbolStrList = sortBy reverseLengthSort elementList
-- | Parses an sub-formula (i.e., \"C2\").
subFormula :: Parser (ElementSymbol, Int)
subFormula =
(\sym num -> (sym, fromIntegral num)) <$> elementSymbol <*> option 1 L.integer
-- | Parses an elemental composition (i.e. \"C6H6\").
elementalComposition :: Parser ElementalComposition
elementalComposition = mkElementalComposition <$> many subFormula
-- | Parses a molecular formula (i.e. \"C6H6\").
molecularFormula :: Parser MolecularFormula
molecularFormula = mkMolecularFormula <$> many subFormula
-- | Parses a condensed formula, i.e., \"N(CH3)3\".
condensedFormula :: Parser CondensedFormula
condensedFormula =
CondensedFormula <$> many (leftCondensedFormula <|> rightCondensedFormula)
where
subMolecularFormula :: Parser MolecularFormula
subMolecularFormula = mkMolecularFormula . pure <$> subFormula
leftCondensedFormula :: Parser (Either MolecularFormula (CondensedFormula, Int))
leftCondensedFormula = Left <$> subMolecularFormula
rightCondensedFormula :: Parser (Either MolecularFormula (CondensedFormula, Int))
rightCondensedFormula = do
_ <- char '('
formula <- condensedFormula
_ <- char ')'
num <- option 1 L.integer
return $ Right (formula, fromIntegral num)
-- | Parses a empirical formula (i.e. \"CH\").
empiricalFormula :: Parser EmpiricalFormula
empiricalFormula = mkEmpiricalFormula <$> many subFormula
-- Helper function for `ElementalComposition` quasiquoter
quoteElementalComposition :: String -> Q Exp
quoteElementalComposition s =
case parse (condensedFormula <* eof) "" s of
Left err -> fail $
"Could not parse elemental formula!\n" <> parseErrorPretty err
Right v -> lift $ toElementalComposition v
-- Helper function for `MolecularFormula` quasiquoter
quoteMolecularFormula :: String -> Q Exp
quoteMolecularFormula s =
case parse (condensedFormula <* eof) "" s of
Left err -> fail $
"Could not parse molecular formula!\n" <> parseErrorPretty err
Right v -> lift $ toMolecularFormula v
-- Helper function for `CondensedFormula` quasiquoter
quoteCondensedFormula :: String -> Q Exp
quoteCondensedFormula s =
case parse (condensedFormula <* eof) "" s of
Left err -> fail $
"Could not parse condensed formula!\n" <> parseErrorPretty err
Right v -> lift v
-- Helper function for `EmpiricalFormula` quasiquoter
quoteEmpiricalFormula s =
case parse (condensedFormula <* eof) "" s of
Left err -> fail $
"Could not parse empirical formula!\n" <> parseErrorPretty err
Right v -> lift $ toEmpiricalFormula v
-- | Quasiquoter for `ElementalComposition`
ele :: QuasiQuoter
ele = QuasiQuoter {
quoteExp = quoteElementalComposition
, quotePat = notHandled "patterns" "elemental composition"
, quoteType = notHandled "types" "elemental composition"
, quoteDec = notHandled "declarations" "elemental composition"
}
-- | Quasiquoter for `MolecularFormula`
mol :: QuasiQuoter
mol = QuasiQuoter {
quoteExp = quoteMolecularFormula
, quotePat = notHandled "patterns" "molecular formula"
, quoteType = notHandled "types" "molecular formula"
, quoteDec = notHandled "declarations" "molecular formula"
}
-- | Quasiquoter for `CondensedFormula`
con :: QuasiQuoter
con = QuasiQuoter {
quoteExp = quoteCondensedFormula
, quotePat = notHandled "patterns" "condensed formula"
, quoteType = notHandled "types" "condensed formula"
, quoteDec = notHandled "declarations" "condensed formula"
}
-- | Quasiquoter for `EmpiricalFormula`
emp :: QuasiQuoter
emp = QuasiQuoter {
quoteExp = quoteEmpiricalFormula
, quotePat = notHandled "patterns" "empirical formula"
, quoteType = notHandled "types" "empirical formula"
, quoteDec = notHandled "declarations" "empirical formula"
}
-- Helper function used in QuasiQuoters
notHandled :: String -> String -> a
notHandled feature quoterName =
error $ feature <> " are not handled by the" <> quoterName <> "quasiquoter."
$(deriveLift ''ElementSymbol)
$(deriveLift ''ElementalComposition)
$(deriveLift ''MolecularFormula)
$(deriveLift ''CondensedFormula)
$(deriveLift ''EmpiricalFormula)
$(deriveLift ''Map)
| Michaelt293/isotope | src/Isotope/Parsers.hs | gpl-3.0 | 5,472 | 0 | 12 | 958 | 1,081 | 573 | 508 | 108 | 2 |
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Behave.Units (
module Export
, DMoisture
, DFraction
, DRatio
, DAzimuth
, FuelLoad
, SaToVolRatio
, HeatOfCombustion
, HeatPerUnitArea
, ReactionVelocity
, Ratio
, Length
, Dimensionless
, Fraction
, Moisture
, TotalMineralContent
, EffectiveMineralContent
, Speed
, ByramsIntensity
, RateOfSpread
, Azimuth
, ReactionIntensity
, Time
, lbSqFt
, lbCuFt
, btu
, btuLb
, btuFtSec
, btuSqFtMin
, btuSqFt
, perFoot
, footMin
, one
, perCent
, perOne
, _0
, _1
, (*~)
, (/~)
) where
import Numeric.Units.Dimensional
import Numeric.Units.Dimensional.UnitNames (atom)
import Numeric.Units.Dimensional.Prelude
import Numeric.Units.Dimensional.NonSI as Export hiding (btu)
import Numeric.Units.Dimensional.SIUnits as Export
import Numeric.Units.Dimensional.Quantities as Export
import Numeric.NumType.DK.Integers (TypeInt(..))
import Prelude () -- for instances
{-
1. Lóngitud
2. Masa
3. Tiempo
4. Corriente eléctrica
5. Temperatura termodinámica
6. Cantidad de substancia
7. Intensidad lumínica
-}
type DFuelLoad = 'Dim 'Neg2 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero
type DSaToVolRatio = 'Dim 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero
type DHeatOfCombustion = 'Dim 'Pos2 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero
type DHeatPerUnitArea = 'Dim 'Zero 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero
type DReactionVelocity = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero
type DByramsIntensity = 'Dim 'Pos1 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero
type DRatio = DOne
type DFraction = DOne
type DMoisture = DFraction
type DAzimuth = DPlaneAngle
type FuelLoad = Quantity DFuelLoad Double
type SaToVolRatio = Quantity DSaToVolRatio Double
type HeatOfCombustion = Quantity DHeatOfCombustion Double
type HeatPerUnitArea = Quantity DHeatPerUnitArea Double
type ReactionVelocity = Quantity DReactionVelocity Double
type ByramsIntensity = Quantity DByramsIntensity Double
type Ratio = Quantity DRatio Double
type Fraction = Quantity DFraction Double
type Moisture = Quantity DMoisture Double
type TotalMineralContent = Fraction
type EffectiveMineralContent = Fraction
type Speed = Quantity DVelocity Double
type RateOfSpread = Speed
type Azimuth = Quantity DAzimuth Double
type ReactionIntensity = HeatFluxDensity Double
perCent :: Fractional a => Unit 'NonMetric DOne a
perCent = mkUnitQ n 0.01 one
where n = atom "[%]" "%" "Per cent"
perOne :: Fractional a => Unit 'NonMetric DOne a
perOne = mkUnitQ n 1.0 one
where n = atom "[one]" "one" "Ratio"
btu :: Fractional a => Unit 'NonMetric DEnergy a
btu = mkUnitQ n 0.293071 (watt * hour)
where n = atom "[btu]" "btu" "British Thermal Unit"
lbSqFt :: Unit 'NonMetric DFuelLoad Double
lbSqFt = poundMass/(foot ^ pos2)
lbCuFt :: Unit 'NonMetric DDensity Double
lbCuFt = poundMass/(foot ^ pos3)
btuLb:: Unit 'NonMetric DHeatOfCombustion Double
btuLb = btu / poundMass
btuFtSec :: Unit 'NonMetric DByramsIntensity Double
btuFtSec = btu / foot / second
btuSqFtMin :: Unit 'NonMetric DHeatFluxDensity Double
btuSqFtMin = btuSqFt / minute
btuSqFt :: Unit 'NonMetric DHeatPerUnitArea Double
btuSqFt = btu / foot ^ pos2
perFoot :: Unit 'NonMetric DSaToVolRatio Double
perFoot = foot ^ neg1
footMin :: Unit 'NonMetric DVelocity Double
footMin = foot / minute
| albertov/behave-hs | src/Behave/Units.hs | bsd-3-clause | 3,872 | 0 | 7 | 959 | 967 | 548 | 419 | 105 | 1 |
{-# LANGUAGE Haskell98 #-}
{-# LINE 1 "Data/Text/Internal/Read.hs" #-}
-- |
-- Module : Data.Text.Internal.Read
-- Copyright : (c) 2014 Bryan O'Sullivan
--
-- License : BSD-style
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : GHC
--
-- Common internal functions for reading textual data.
module Data.Text.Internal.Read
(
IReader
, IParser(..)
, T(..)
, digitToInt
, hexDigitToInt
, perhaps
) where
import Control.Applicative as App (Applicative(..))
import Control.Arrow (first)
import Control.Monad (ap)
import Data.Char (ord)
type IReader t a = t -> Either String (a,t)
newtype IParser t a = P {
runP :: IReader t a
}
instance Functor (IParser t) where
fmap f m = P $ fmap (first f) . runP m
instance Applicative (IParser t) where
pure a = P $ \t -> Right (a,t)
{-# INLINE pure #-}
(<*>) = ap
instance Monad (IParser t) where
return = App.pure
m >>= k = P $ \t -> case runP m t of
Left err -> Left err
Right (a,t') -> runP (k a) t'
{-# INLINE (>>=) #-}
fail msg = P $ \_ -> Left msg
data T = T !Integer !Int
perhaps :: a -> IParser t a -> IParser t a
perhaps def m = P $ \t -> case runP m t of
Left _ -> Right (def,t)
r@(Right _) -> r
hexDigitToInt :: Char -> Int
hexDigitToInt c
| c >= '0' && c <= '9' = ord c - ord '0'
| c >= 'a' && c <= 'f' = ord c - (ord 'a' - 10)
| otherwise = ord c - (ord 'A' - 10)
digitToInt :: Char -> Int
digitToInt c = ord c - ord '0'
| phischu/fragnix | tests/packages/scotty/Data.Text.Internal.Read.hs | bsd-3-clause | 1,641 | 0 | 13 | 527 | 571 | 307 | 264 | 46 | 2 |
module Hint.Sandbox ( sandboxed ) where
import Hint.Base
import Hint.Context
import Hint.Configuration
import Hint.Util
import {-# SOURCE #-} Hint.Typecheck ( typeChecks_unsandboxed )
import Control.Monad.Catch
sandboxed :: MonadInterpreter m => (Expr -> m a) -> (Expr -> m a)
sandboxed = if ghcVersion >= 610 then id else old_sandboxed
old_sandboxed :: MonadInterpreter m => (Expr -> m a) -> (Expr -> m a)
old_sandboxed do_stuff = \expr -> do no_sandbox <- fromConf all_mods_in_scope
if no_sandbox
then do_stuff expr
else usingAModule do_stuff expr
usingAModule :: MonadInterpreter m => (Expr -> m a) -> (Expr -> m a)
usingAModule do_stuff_on = \expr ->
--
-- To avoid defaulting, we will evaluate this expression without the
-- monomorphism-restriction. This means that expressions that normally
-- would not typecheck, suddenly will. Thus, we first check if the
-- expression typechecks as is. If it doesn't, there is no need in
-- going on (if it does, it may not typecheck once we restrict the
-- context; that is the whole idea of this!)
--
do type_checks <- typeChecks_unsandboxed expr
case type_checks of
False -> do_stuff_on expr -- fail as you wish...
True ->
do (loaded, imports) <- allModulesInContext
zombies <- fromState zombie_phantoms
quals <- fromState qual_imports
--
let e = safeBndFor expr
let mod_text no_prel mod_name = textify [
["{-# LANGUAGE NoMonomorphismRestriction #-}"],
["{-# LANGUAGE NoImplicitPrelude #-}" | no_prel],
["module " ++ mod_name],
["where"],
["import " ++ m | m <- loaded ++ imports,
not $ m `elem` (map pm_name zombies)],
["import qualified " ++ m ++ " as " ++ q | (m,q) <- quals],
[e ++ " = " ++ expr] ]
--
let go no_prel = do pm <- addPhantomModule (mod_text no_prel)
setTopLevelModules [pm_name pm]
r <- do_stuff_on e
`catchIE` (\err ->
case err of
WontCompile _ ->
do removePhantomModule pm
throwM err
_ -> throwM err)
removePhantomModule pm
return r
-- If the Prelude was not explicitly imported but implicitly
-- imported in some interpreted module, then the user may
-- get very unintuitive errors when turning sandboxing on. Thus
-- we will import the Prelude if the operation fails...
-- I guess this may lead to even more obscure errors, but
-- hopefully in much less frequent situations...
r <- onAnEmptyContext $ go True
`catchIE` (\err -> case err of
WontCompile _ -> go False
_ -> throwM err)
--
return r
--
where textify = unlines . concat
| konn/hint-forked | src/Hint/Sandbox.hs | bsd-3-clause | 3,665 | 0 | 27 | 1,664 | 643 | 333 | 310 | 50 | 4 |
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE helpset
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN"
"http://java.sun.com/products/javahelp/helpset_1_0.dtd">
<helpset xml:lang=de version="1.0">
<!-- title -->
<title>JBackpack-Hilfe</title>
<!-- maps -->
<maps>
<homeID>Index</homeID>
<mapref location="de/jhelpmap.jhm" />
</maps>
<!-- views -->
<view>
<name>TOC</name>
<label>Inhaltsverzeichnis</label>
<type>javax.help.TOCView</type>
<data>de/jhelptoc.xml</data>
</view>
<view>
<name>Index</name>
<label>Index</label>
<type>javax.help.IndexView</type>
<data>de/jhelpidx.xml</data>
</view>
<view>
<name>Search</name>
<label>Search</label>
<type>javax.help.SearchView</type>
<data engine="com.sun.java.help.search.DefaultSearchEngine">
JavaHelpSearch_de
</data>
</view>
</helpset>
| amon-ra/jbackpack | src/ch/fhnw/jbackpack/help/windows/HelpSet_de.hs | gpl-3.0 | 961 | 75 | 60 | 203 | 375 | 193 | 182 | -1 | -1 |
{-# LANGUAGE CPP #-}
{-# LANGUAGE PatternGuards #-}
#ifdef TRUSTWORTHY
{-# LANGUAGE Trustworthy #-}
#endif
-----------------------------------------------------------------------------
-- |
-- Module : Control.Lens.Internal.FieldTH
-- Copyright : (C) 2014-2015 Edward Kmett, (C) 2014 Eric Mertens
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <[email protected]>
-- Stability : experimental
-- Portability : non-portable
--
-----------------------------------------------------------------------------
module Control.Lens.Internal.FieldTH
( LensRules(..)
, DefName(..)
, makeFieldOptics
, makeFieldOpticsForDec
) where
import Control.Lens.At
import Control.Lens.Fold
import Control.Lens.Internal.TH
import Control.Lens.Plated
import Control.Lens.Prism
import Control.Lens.Setter
import Control.Lens.Getter
import Control.Lens.Traversal
import Control.Lens.Tuple
import Control.Applicative
import Control.Monad
import Language.Haskell.TH.Lens
import Language.Haskell.TH
import Data.Foldable (toList)
import Data.Maybe (isJust,maybeToList)
import Data.List (nub, findIndices)
import Data.Either (partitionEithers)
import Data.Set.Lens
import Data.Map ( Map )
import Data.Set ( Set )
import qualified Data.Set as Set
import qualified Data.Map as Map
import qualified Data.Traversable as T
import Prelude
------------------------------------------------------------------------
-- Field generation entry point
------------------------------------------------------------------------
-- | Compute the field optics for the type identified by the given type name.
-- Lenses will be computed when possible, Traversals otherwise.
makeFieldOptics :: LensRules -> Name -> DecsQ
makeFieldOptics rules tyName =
do info <- reify tyName
case info of
TyConI dec -> makeFieldOpticsForDec rules dec
_ -> fail "makeFieldOptics: Expected type constructor name"
makeFieldOpticsForDec :: LensRules -> Dec -> DecsQ
makeFieldOpticsForDec rules dec = case dec of
DataD _ tyName vars cons _ ->
makeFieldOpticsForDec' rules tyName (mkS tyName vars) cons
NewtypeD _ tyName vars con _ ->
makeFieldOpticsForDec' rules tyName (mkS tyName vars) [con]
DataInstD _ tyName args cons _ ->
makeFieldOpticsForDec' rules tyName (tyName `conAppsT` args) cons
NewtypeInstD _ tyName args con _ ->
makeFieldOpticsForDec' rules tyName (tyName `conAppsT` args) [con]
_ -> fail "makeFieldOptics: Expected data or newtype type-constructor"
where
mkS tyName vars = tyName `conAppsT` map VarT (toListOf typeVars vars)
-- | Compute the field optics for a deconstructed Dec
-- When possible build an Iso otherwise build one optic per field.
makeFieldOpticsForDec' :: LensRules -> Name -> Type -> [Con] -> DecsQ
makeFieldOpticsForDec' rules tyName s cons =
do fieldCons <- traverse normalizeConstructor cons
let allFields = toListOf (folded . _2 . folded . _1 . folded) fieldCons
let defCons = over normFieldLabels (expandName allFields) fieldCons
allDefs = setOf (normFieldLabels . folded) defCons
perDef <- T.sequenceA (fromSet (buildScaffold rules s defCons) allDefs)
let defs = Map.toList perDef
case _classyLenses rules tyName of
Just (className, methodName) ->
makeClassyDriver rules className methodName s defs
Nothing -> do decss <- traverse (makeFieldOptic rules) defs
return (concat decss)
where
-- Traverse the field labels of a normalized constructor
normFieldLabels :: Traversal [(Name,[(a,Type)])] [(Name,[(b,Type)])] a b
normFieldLabels = traverse . _2 . traverse . _1
-- Map a (possibly missing) field's name to zero-to-many optic definitions
expandName :: [Name] -> Maybe Name -> [DefName]
expandName allFields = concatMap (_fieldToDef rules tyName allFields) . maybeToList
-- | Normalized the Con type into a uniform positional representation,
-- eliminating the variance between records, infix constructors, and normal
-- constructors.
normalizeConstructor ::
Con ->
Q (Name, [(Maybe Name, Type)]) -- ^ constructor name, field name, field type
normalizeConstructor (RecC n xs) =
return (n, [ (Just fieldName, ty) | (fieldName,_,ty) <- xs])
normalizeConstructor (NormalC n xs) =
return (n, [ (Nothing, ty) | (_,ty) <- xs])
normalizeConstructor (InfixC (_,ty1) n (_,ty2)) =
return (n, [ (Nothing, ty1), (Nothing, ty2) ])
normalizeConstructor (ForallC _ _ con) =
do con' <- normalizeConstructor con
return (set (_2 . mapped . _1) Nothing con')
data OpticType = GetterType | LensType | IsoType
-- | Compute the positional location of the fields involved in
-- each constructor for a given optic definition as well as the
-- type of clauses to generate and the type to annotate the declaration
-- with.
buildScaffold ::
LensRules ->
Type {- ^ outer type -} ->
[(Name, [([DefName], Type)])] {- ^ normalized constructors -} ->
DefName {- ^ target definition -} ->
Q (OpticType, OpticStab, [(Name, Int, [Int])])
{- ^ optic type, definition type, field count, target fields -}
buildScaffold rules s cons defName =
do (s',t,a,b) <- buildStab s (concatMap snd consForDef)
let defType
| Just (_,cx,a') <- preview _ForallT a =
let optic | lensCase = getterTypeName
| otherwise = foldTypeName
in OpticSa cx optic s' a'
-- Getter and Fold are always simple
| not (_allowUpdates rules) =
let optic | lensCase = getterTypeName
| otherwise = foldTypeName
in OpticSa [] optic s' a
-- Generate simple Lens and Traversal where possible
| _simpleLenses rules || s' == t && a == b =
let optic | isoCase && _allowIsos rules = iso'TypeName
| lensCase = lens'TypeName
| otherwise = traversal'TypeName
in OpticSa [] optic s' a
-- Generate type-changing Lens and Traversal otherwise
| otherwise =
let optic | isoCase && _allowIsos rules = isoTypeName
| lensCase = lensTypeName
| otherwise = traversalTypeName
in OpticStab optic s' t a b
opticType | has _ForallT a = GetterType
| not (_allowUpdates rules) = GetterType
| isoCase = IsoType
| otherwise = LensType
return (opticType, defType, scaffolds)
where
consForDef :: [(Name, [Either Type Type])]
consForDef = over (mapped . _2 . mapped) categorize cons
scaffolds :: [(Name, Int, [Int])]
scaffolds = [ (n, length ts, rightIndices ts) | (n,ts) <- consForDef ]
rightIndices :: [Either Type Type] -> [Int]
rightIndices = findIndices (has _Right)
-- Right: types for this definition
-- Left : other types
categorize :: ([DefName], Type) -> Either Type Type
categorize (defNames, t)
| defName `elem` defNames = Right t
| otherwise = Left t
lensCase :: Bool
lensCase = all (\x -> lengthOf (_2 . folded . _Right) x == 1) consForDef
isoCase :: Bool
isoCase = case scaffolds of
[(_,1,[0])] -> True
_ -> False
data OpticStab = OpticStab Name Type Type Type Type
| OpticSa Cxt Name Type Type
stabToType :: OpticStab -> Type
stabToType (OpticStab c s t a b) = quantifyType [] (c `conAppsT` [s,t,a,b])
stabToType (OpticSa cx c s a ) = quantifyType cx (c `conAppsT` [s,a])
stabToContext :: OpticStab -> Cxt
stabToContext OpticStab{} = []
stabToContext (OpticSa cx _ _ _) = cx
stabToOptic :: OpticStab -> Name
stabToOptic (OpticStab c _ _ _ _) = c
stabToOptic (OpticSa _ c _ _) = c
stabToS :: OpticStab -> Type
stabToS (OpticStab _ s _ _ _) = s
stabToS (OpticSa _ _ s _) = s
stabToA :: OpticStab -> Type
stabToA (OpticStab _ _ _ a _) = a
stabToA (OpticSa _ _ _ a) = a
-- | Compute the s t a b types given the outer type 's' and the
-- categorized field types. Left for fixed and Right for visited.
-- These types are "raw" and will be packaged into an 'OpticStab'
-- shortly after creation.
buildStab :: Type -> [Either Type Type] -> Q (Type,Type,Type,Type)
buildStab s categorizedFields =
do (subA,a) <- unifyTypes targetFields
let s' = applyTypeSubst subA s
-- compute possible type changes
sub <- T.sequenceA (fromSet (newName . nameBase) unfixedTypeVars)
let (t,b) = over both (substTypeVars sub) (s',a)
return (s',t,a,b)
where
(fixedFields, targetFields) = partitionEithers categorizedFields
fixedTypeVars = setOf typeVars fixedFields
unfixedTypeVars = setOf typeVars s Set.\\ fixedTypeVars
-- | Build the signature and definition for a single field optic.
-- In the case of a singleton constructor irrefutable matches are
-- used to enable the resulting lenses to be used on a bottom value.
makeFieldOptic ::
LensRules ->
(DefName, (OpticType, OpticStab, [(Name, Int, [Int])])) ->
DecsQ
makeFieldOptic rules (defName, (opticType, defType, cons)) =
do cls <- mkCls
T.sequenceA (cls ++ sig ++ def)
where
mkCls = case defName of
MethodName c n | _generateClasses rules ->
do classExists <- isJust <$> lookupTypeName (show c)
return (if classExists then [] else [makeFieldClass defType c n])
_ -> return []
sig = case defName of
_ | not (_generateSigs rules) -> []
TopName n -> [sigD n (return (stabToType defType))]
MethodName{} -> []
fun n = funD n clauses : inlinePragma n
def = case defName of
TopName n -> fun n
MethodName c n -> [makeFieldInstance defType c (fun n)]
clauses = makeFieldClauses rules opticType cons
------------------------------------------------------------------------
-- Classy class generator
------------------------------------------------------------------------
makeClassyDriver ::
LensRules ->
Name ->
Name ->
Type {- ^ Outer 's' type -} ->
[(DefName, (OpticType, OpticStab, [(Name, Int, [Int])]))] ->
DecsQ
makeClassyDriver rules className methodName s defs = T.sequenceA (cls ++ inst)
where
cls | _generateClasses rules = [makeClassyClass className methodName s defs]
| otherwise = []
inst = [makeClassyInstance rules className methodName s defs]
makeClassyClass ::
Name ->
Name ->
Type {- ^ Outer 's' type -} ->
[(DefName, (OpticType, OpticStab, [(Name, Int, [Int])]))] ->
DecQ
makeClassyClass className methodName s defs = do
let ss = map (stabToS . view (_2 . _2)) defs
(sub,s') <- unifyTypes (s : ss)
c <- newName "c"
let vars = toListOf typeVars s'
fd | null vars = []
| otherwise = [FunDep [c] vars]
classD (cxt[]) className (map PlainTV (c:vars)) fd
$ sigD methodName (return (lens'TypeName `conAppsT` [VarT c, s']))
: concat
[ [sigD defName (return ty)
,valD (varP defName) (normalB body) []
] ++
inlinePragma defName
| (TopName defName, (_, stab, _)) <- defs
, let body = appsE [varE composeValName, varE methodName, varE defName]
, let ty = quantifyType' (Set.fromList (c:vars))
(stabToContext stab)
$ stabToOptic stab `conAppsT`
[VarT c, applyTypeSubst sub (stabToA stab)]
]
makeClassyInstance ::
LensRules ->
Name ->
Name ->
Type {- ^ Outer 's' type -} ->
[(DefName, (OpticType, OpticStab, [(Name, Int, [Int])]))] ->
DecQ
makeClassyInstance rules className methodName s defs = do
methodss <- traverse (makeFieldOptic rules') defs
instanceD (cxt[]) (return instanceHead)
$ valD (varP methodName) (normalB (varE idValName)) []
: map return (concat methodss)
where
instanceHead = className `conAppsT` (s : map VarT vars)
vars = toListOf typeVars s
rules' = rules { _generateSigs = False
, _generateClasses = False
}
------------------------------------------------------------------------
-- Field class generation
------------------------------------------------------------------------
makeFieldClass :: OpticStab -> Name -> Name -> DecQ
makeFieldClass defType className methodName =
classD (cxt []) className [PlainTV s, PlainTV a] [FunDep [s] [a]]
[sigD methodName (return methodType)]
where
methodType = quantifyType' (Set.fromList [s,a])
(stabToContext defType)
$ stabToOptic defType `conAppsT` [VarT s,VarT a]
s = mkName "s"
a = mkName "a"
makeFieldInstance :: OpticStab -> Name -> [DecQ] -> DecQ
makeFieldInstance defType className =
instanceD (cxt [])
(return (className `conAppsT` [stabToS defType, stabToA defType]))
------------------------------------------------------------------------
-- Optic clause generators
------------------------------------------------------------------------
makeFieldClauses :: LensRules -> OpticType -> [(Name, Int, [Int])] -> [ClauseQ]
makeFieldClauses rules opticType cons =
case opticType of
IsoType -> [ makeIsoClause conName | (conName, _, _) <- cons ]
GetterType -> [ makeGetterClause conName fieldCount fields
| (conName, fieldCount, fields) <- cons ]
LensType -> [ makeFieldOpticClause conName fieldCount fields irref
| (conName, fieldCount, fields) <- cons ]
where
irref = _lazyPatterns rules
&& length cons == 1
-- | Construct an optic clause that returns an unmodified value
-- given a constructor name and the number of fields on that
-- constructor.
makePureClause :: Name -> Int -> ClauseQ
makePureClause conName fieldCount =
do xs <- replicateM fieldCount (newName "x")
-- clause: _ (Con x1..xn) = pure (Con x1..xn)
clause [wildP, conP conName (map varP xs)]
(normalB (appE (varE pureValName) (appsE (conE conName : map varE xs))))
[]
-- | Construct an optic clause suitable for a Getter or Fold
-- by visited the fields identified by their 0 indexed positions
makeGetterClause :: Name -> Int -> [Int] -> ClauseQ
makeGetterClause conName fieldCount [] = makePureClause conName fieldCount
makeGetterClause conName fieldCount fields =
do f <- newName "f"
xs <- replicateM (length fields) (newName "x")
let pats (i:is) (y:ys)
| i `elem` fields = varP y : pats is ys
| otherwise = wildP : pats is (y:ys)
pats is _ = map (const wildP) is
fxs = [ appE (varE f) (varE x) | x <- xs ]
body = foldl (\a b -> appsE [varE apValName, a, b])
(appE (varE coerceValName) (head fxs))
(tail fxs)
-- clause f (Con x1..xn) = coerce (f x1) <*> ... <*> f xn
clause [varP f, conP conName (pats [0..fieldCount - 1] xs)]
(normalB body)
[]
-- | Build a clause that updates the field at the given indexes
-- When irref is 'True' the value with me matched with an irrefutable
-- pattern. This is suitable for Lens and Traversal construction
makeFieldOpticClause :: Name -> Int -> [Int] -> Bool -> ClauseQ
makeFieldOpticClause conName fieldCount [] _ =
makePureClause conName fieldCount
makeFieldOpticClause conName fieldCount (field:fields) irref =
do f <- newName "f"
xs <- replicateM fieldCount (newName "x")
ys <- replicateM (1 + length fields) (newName "y")
let xs' = foldr (\(i,x) -> set (ix i) x) xs (zip (field:fields) ys)
mkFx i = appE (varE f) (varE (xs !! i))
body0 = appsE [ varE fmapValName
, lamE (map varP ys) (appsE (conE conName : map varE xs'))
, mkFx field
]
body = foldl (\a b -> appsE [varE apValName, a, mkFx b]) body0 fields
let wrap = if irref then tildeP else id
clause [varP f, wrap (conP conName (map varP xs))]
(normalB body)
[]
-- | Build a clause that constructs an Iso
makeIsoClause :: Name -> ClauseQ
makeIsoClause conName = clause [] (normalB (appsE [varE isoValName, destruct, construct])) []
where
destruct = do x <- newName "x"
lam1E (conP conName [varP x]) (varE x)
construct = conE conName
------------------------------------------------------------------------
-- Unification logic
------------------------------------------------------------------------
-- The field-oriented optic generation supports incorporating fields
-- with distinct but unifiable types into a single definition.
-- | Unify the given list of types, if possible, and return the
-- substitution used to unify the types for unifying the outer
-- type when building a definition's type signature.
unifyTypes :: [Type] -> Q (Map Name Type, Type)
unifyTypes (x:xs) = foldM (uncurry unify1) (Map.empty, x) xs
unifyTypes [] = fail "unifyTypes: Bug: Unexpected empty list"
-- | Attempt to unify two given types using a running substitution
unify1 :: Map Name Type -> Type -> Type -> Q (Map Name Type, Type)
unify1 sub (VarT x) y
| Just r <- Map.lookup x sub = unify1 sub r y
unify1 sub x (VarT y)
| Just r <- Map.lookup y sub = unify1 sub x r
unify1 sub x y
| x == y = return (sub, x)
unify1 sub (AppT f1 x1) (AppT f2 x2) =
do (sub1, f) <- unify1 sub f1 f2
(sub2, x) <- unify1 sub1 x1 x2
return (sub2, AppT (applyTypeSubst sub2 f) x)
unify1 sub x (VarT y)
| elemOf typeVars y (applyTypeSubst sub x) =
fail "Failed to unify types: occurs check"
| otherwise = return (Map.insert y x sub, x)
unify1 sub (VarT x) y = unify1 sub y (VarT x)
-- TODO: Unify contexts
unify1 sub (ForallT v1 [] t1) (ForallT v2 [] t2) =
-- This approach works out because by the time this code runs
-- all of the type variables have been renamed. No risk of shadowing.
do (sub1,t) <- unify1 sub t1 t2
v <- fmap nub (traverse (limitedSubst sub1) (v1++v2))
return (sub1, ForallT v [] t)
unify1 _ x y = fail ("Failed to unify types: " ++ show (x,y))
-- | Perform a limited substitution on type variables. This is used
-- when unifying rank-2 fields when trying to achieve a Getter or Fold.
limitedSubst :: Map Name Type -> TyVarBndr -> Q TyVarBndr
limitedSubst sub (PlainTV n)
| Just r <- Map.lookup n sub =
case r of
VarT m -> limitedSubst sub (PlainTV m)
_ -> fail "Unable to unify exotic higher-rank type"
limitedSubst sub (KindedTV n k)
| Just r <- Map.lookup n sub =
case r of
VarT m -> limitedSubst sub (KindedTV m k)
_ -> fail "Unable to unify exotic higher-rank type"
limitedSubst _ tv = return tv
-- | Apply a substitution to a type. This is used after unifying
-- the types of the fields in unifyTypes.
applyTypeSubst :: Map Name Type -> Type -> Type
applyTypeSubst sub = rewrite aux
where
aux (VarT n) = Map.lookup n sub
aux _ = Nothing
------------------------------------------------------------------------
-- Field generation parameters
------------------------------------------------------------------------
data LensRules = LensRules
{ _simpleLenses :: Bool
, _generateSigs :: Bool
, _generateClasses :: Bool
, _allowIsos :: Bool
, _allowUpdates :: Bool -- ^ Allow Lens/Traversal (otherwise Getter/Fold)
, _lazyPatterns :: Bool
, _fieldToDef :: Name -> [Name] -> Name -> [DefName]
-- ^ Type Name -> Field Names -> Target Field Name -> Definition Names
, _classyLenses :: Name -> Maybe (Name,Name)
-- type name to class name and top method
}
-- | Name to give to generated field optics.
data DefName
= TopName Name -- ^ Simple top-level definiton name
| MethodName Name Name -- ^ makeFields-style class name and method name
deriving (Show, Eq, Ord)
------------------------------------------------------------------------
-- Miscellaneous utility functions
------------------------------------------------------------------------
-- | Template Haskell wants type variables declared in a forall, so
-- we find all free type variables in a given type and declare them.
quantifyType :: Cxt -> Type -> Type
quantifyType c t = ForallT vs c t
where
vs = map PlainTV (toList (setOf typeVars t))
-- | This function works like 'quantifyType' except that it takes
-- a list of variables to exclude from quantification.
quantifyType' :: Set Name -> Cxt -> Type -> Type
quantifyType' exclude c t = ForallT vs c t
where
vs = map PlainTV (toList (setOf typeVars t Set.\\ exclude))
------------------------------------------------------------------------
-- Support for generating inline pragmas
------------------------------------------------------------------------
inlinePragma :: Name -> [DecQ]
#ifdef INLINING
#if MIN_VERSION_template_haskell(2,8,0)
# ifdef OLD_INLINE_PRAGMAS
-- 7.6rc1?
inlinePragma methodName = [pragInlD methodName (inlineSpecNoPhase Inline False)]
# else
-- 7.7.20120830
inlinePragma methodName = [pragInlD methodName Inline FunLike AllPhases]
# endif
#else
-- GHC <7.6, TH <2.8.0
inlinePragma methodName = [pragInlD methodName (inlineSpecNoPhase True False)]
#endif
#else
inlinePragma _ = []
#endif
| timjb/lens | src/Control/Lens/Internal/FieldTH.hs | bsd-3-clause | 21,608 | 0 | 20 | 5,368 | 6,018 | 3,151 | 2,867 | 356 | 6 |
module Test () where
{-@ foo :: {vv:[{v:[a]|((len v) = 1)}]|((len vv)= 1)} -> [[a]] @-}
foo [[x]] = [[x]]
| abakst/liquidhaskell | tests/pos/grty2.hs | bsd-3-clause | 110 | 0 | 7 | 24 | 28 | 18 | 10 | 2 | 1 |
module Vec0 () where
import Language.Haskell.Liquid.Prelude
import Data.Vector hiding(map, concat, zipWith, filter, foldl, foldr, (++))
xs = [1,2,3,4] :: [Int]
vs = fromList xs
--prop0 = liquidAssertB (x >= 0)
-- where x = Prelude.head xs
--
--prop1 = liquidAssertB (n > 0)
-- where n = Prelude.length xs
--
--prop2 = liquidAssertB (Data.Vector.length vs > 0)
--prop3 = liquidAssertB (Data.Vector.length vs > 3)
prop6 = crash (0 == 1)
x0 = vs ! 0
| mightymoose/liquidhaskell | tests/neg/vector0a.hs | bsd-3-clause | 472 | 0 | 7 | 100 | 108 | 71 | 37 | 7 | 1 |
module T5776 where
-- The point about this test is that we should get a rule like this:
-- "foo" [ALWAYS]
-- forall (@ a)
-- ($dEq :: Eq a)
-- ($dEq1 :: Eq a)
-- (x :: a)
-- (y :: a)
-- (z :: a).
-- T5776.f (g @ a $dEq1 x y)
-- (g @ a $dEq y z)
-- = GHC.Types.True
--
-- Note the *two* forall'd dEq parameters. This is important.
-- See Note [Simplifying RULE lhs constraints] in TcSimplify
{-# RULES "foo" forall x y z.
f (g x y) (g y z) = True
#-}
g :: Eq a => a -> a -> Bool
{-# NOINLINE g #-}
g = (==)
f :: Bool -> Bool -> Bool
{-# NOINLINE f #-}
f a b = False
blah :: Int -> Int -> Bool
blah x y = f (g x y) (g x y)
| ezyang/ghc | testsuite/tests/simplCore/should_compile/T5776.hs | bsd-3-clause | 713 | 0 | 7 | 245 | 115 | 69 | 46 | 11 | 1 |
module Main where
import Control.Monad (forever, when)
import Data.List (intercalate)
import Data.Traversable (traverse)
import Morse (stringToMorse, morseToChar)
import System.Environment (getArgs)
import System.Exit (exitFailure,
exitSuccess)
import System.IO (hGetLine, hIsEOF, stdin)
convertToMorse :: IO ()
convertToMorse = forever $ do
weAreDone <- hIsEOF stdin
when weAreDone exitSuccess
line <- hGetLine stdin
convertLine line
where
convertLine line = do
let morse = stringToMorse line
case morse of
(Just str) -> putStrLn (intercalate " " str)
Nothing -> do
putStrLn $ "ERROR: " ++ line
exitFailure
convertFromMorse :: IO ()
convertFromMorse = forever $ do
weAreDone <- hIsEOF stdin
when weAreDone exitSuccess
line <- hGetLine stdin
convertLine line where
convertLine line = do
let decoded :: Maybe String
decoded = traverse morseToChar (words line)
case decoded of
(Just s) -> putStrLn s
Nothing -> do
putStrLn $ "ERROR: " ++ line
exitFailure
main :: IO ()
main = do
mode <- getArgs
case mode of
[arg] ->
case arg of
"from" -> convertFromMorse
"to" -> convertToMorse
_ -> argError
_ -> argError
where
argError = do
putStrLn "Please specify the\
\ first argument\
\ as being 'from' or\
\ 'to' morse,\
\ such as: morse to"
exitFailure
| candu/haskellbook | ch14/morse/src/Main.hs | mit | 1,530 | 0 | 15 | 480 | 427 | 210 | 217 | 49 | 4 |
module Handler.Repo where
import Import
import Data.Maybe (fromJust)
import qualified GitHub as GH
getRepoR :: Text -> Text -> Handler Html
getRepoR ownerLogin name = do
-- TODO: Factor all this out.
userId <- requireAuthId
user <- runDB $ get userId
let token = userToken $ fromJust user
client <- GH.newClient token
repo <- GH.fetchRepo client ownerLogin name
milestones <- GH.fetchMilestones client repo GH.AllStates
defaultLayout $ do
setTitle "Milestones"
$(widgetFile "repository")
| jspahrsummers/ScrumBut | Handler/Repo.hs | mit | 541 | 0 | 12 | 124 | 158 | 76 | 82 | 15 | 1 |
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UnicodeSyntax #-}
module Main where
import Test.Hspec
import Test.QuickCheck
import Data.Word (Word8)
import Codec.Picture ( PixelRGBA8(..)
, Image(..)
, pixelAt)
import Pixs.Operations.Pixel ((⊕))
import qualified Pixs.Transformation as T
import qualified Data.Vector.Storable as VS
import qualified Pixs.Operations.Image as A
import Control.Monad (replicateM)
instance Arbitrary (Image PixelRGBA8) where
arbitrary = do
Positive size ← arbitrary ∷ Gen (Positive Int)
pixs ← listOfSize size
Positive w ← arbitrary ∷ Gen (Positive Int)
let w' = w `rem` size-1
return Image { imageWidth = w'
, imageHeight = w' `div` size-1
, imageData = VS.fromList pixs
}
listOfSize ∷ Int → Gen [Word8]
listOfSize x = fmap concat $ replicateM x genPixel
genPixel ∷ Gen [Word8]
genPixel = do
a ← arbitrary ∷ Gen Word8
b ← arbitrary ∷ Gen Word8
c ← arbitrary ∷ Gen Word8
d ← arbitrary ∷ Gen Word8
return [a,b,c,d]
instance Arbitrary PixelRGBA8 where
arbitrary = do
r ← arbitrary ∷ Gen Word8
g ← arbitrary ∷ Gen Word8
b ← arbitrary ∷ Gen Word8
a ← arbitrary ∷ Gen Word8
return $ PixelRGBA8 r g b a
deriving instance Eq (Image PixelRGBA8)
deriving instance Show (Image PixelRGBA8)
prop_reflexivity ∷ Image PixelRGBA8 → Bool
prop_reflexivity img = img == img
prop_double_reflect_ID ∷ Image PixelRGBA8 → Bool
prop_double_reflect_ID img = if imageWidth img >= 0 && imageHeight img >= 0
then T.reflectVertical (T.reflectVertical img) == img
else True
double_apply_ID ∷ (Image PixelRGBA8 -> Image PixelRGBA8)
→ Image PixelRGBA8
→ Bool
double_apply_ID f img = if imageWidth img >= 0 && imageHeight img >= 0
then (f $ f img) == img
else True
prop_pixel_comm ∷ (PixelRGBA8 → PixelRGBA8 → PixelRGBA8)
→ PixelRGBA8
→ PixelRGBA8
→ Bool
prop_pixel_comm op p₁ p₂ = p₁ `op` p₂ == p₂ `op` p₁
prop_pixel_assoc ∷ (PixelRGBA8 → PixelRGBA8 → PixelRGBA8)
→ PixelRGBA8
→ PixelRGBA8
→ PixelRGBA8
→ Bool
prop_pixel_assoc op p₁ p₂ p₃ = (p₁ `op` p₂) `op` p₃ == p₁ `op` (p₂ `op` p₃)
prop_pixel_dist ∷ (PixelRGBA8 → PixelRGBA8 → PixelRGBA8)
→ (PixelRGBA8 → PixelRGBA8 → PixelRGBA8)
→ PixelRGBA8
→ PixelRGBA8
→ PixelRGBA8
→ Bool
prop_pixel_dist op₁ op₂ p₁ p₂ p₃ =
p₁ `op₁` (p₂ `op₂` p₃) == (p₁ `op₁` p₂) `op₂` (p₁ `op₁` p₃)
&& (p₂ `op₂` p₃) `op₁` p₁ == (p₂ `op₁` p₁) `op₂` (p₃ `op₁` p₁)
prop_change_red_ID ∷ Int → Image PixelRGBA8 → Bool
prop_change_red_ID x img = if (imageWidth img) >= 0 && (imageHeight img) >= 0
then T.changeRed x (T.changeRed (-x) img) == img
else True
prop_red_correct ∷ Int → Positive Int → Positive Int → Image PixelRGBA8 → Bool
prop_red_correct a (Positive x) (Positive y) img
= if (imageWidth img) >= 0 && (imageHeight img) >= 0
then let (PixelRGBA8 r _ _ _) = pixelAt img x y
newImg = T.changeRed a img
(PixelRGBA8 r' _ _ _) = pixelAt newImg x y
in r' == (r ⊕ x)
else True
sides ∷ [Image a] → [Int]
sides = (>>= \x → [imageWidth x, imageHeight x])
prop_image_comm ∷ (Image PixelRGBA8 → Image PixelRGBA8 → Image PixelRGBA8)
→ Image PixelRGBA8
→ Image PixelRGBA8
→ Bool
prop_image_comm op img₁ img₂ =
(any (< 0) $ sides [img₁, img₂])
|| (img₁ `op` img₂) == (img₂ `op` img₁)
prop_image_assoc ∷ (Image PixelRGBA8 → Image PixelRGBA8 → Image PixelRGBA8)
→ Image PixelRGBA8
→ Image PixelRGBA8
→ Image PixelRGBA8
→ Bool
prop_image_assoc op img₁ img₂ img₃ =
(any (< 0) $ sides [img₁, img₂, img₃])
|| (img₁ `op` (img₂ `op` img₃)) == ((img₁ `op` img₂) `op` img₃)
main ∷ IO ()
main = hspec $ do
describe "Image equality" $ do
it "is reflexive" $ property
prop_reflexivity
describe "reflectVertical" $ do
it "gives identity when applied twice" $ property $
double_apply_ID T.reflectVertical
describe "reflectHorizontal" $ do
it "gives identity when applied twice" $ property $
double_apply_ID T.reflectHorizontal
describe "reflect" $ do
it "gives identity when applied twice" $ property $
double_apply_ID T.reflect
describe "Pixel addition" $ do
it "is commutative" $ property $
prop_pixel_comm (+)
it "is associative" $ property $
prop_pixel_assoc (+)
it "correctly adds two arbitrary pixels" $
let p₁ = PixelRGBA8 21 21 21 21
p₂ = PixelRGBA8 30 30 30 30
in p₁ + p₂ `shouldBe` PixelRGBA8 51 51 51 30
it "handles overflow" $
let p₁ = PixelRGBA8 250 250 250 250
p₂ = PixelRGBA8 20 20 20 20
in p₁ + p₂ `shouldBe` PixelRGBA8 255 255 255 250
describe "Pixel subtraction" $
it "handles underflow" $
let p₁ = PixelRGBA8 5 5 5 5
p₂ = PixelRGBA8 20 20 20 20
in p₁ - p₂ `shouldBe` PixelRGBA8 0 0 0 20
describe "Pixel negation" $
it "handles normal case" $
let p = PixelRGBA8 250 250 250 250
in negate p `shouldBe` PixelRGBA8 5 5 5 255
describe "Pixel multiplication" $ do
it "is commutative" $ property $
prop_pixel_comm (*)
it "is associative" $ property $
prop_pixel_assoc (*)
it "is distributive over addition" $ property $
prop_pixel_dist (*) (+)
describe "Image addition" $ do
it "is commutative" $ property $
prop_image_comm A.add
it "is associative" $ property $
prop_image_assoc A.add
describe "Image multiplication" $ do
it "is commutative" $ property $
prop_image_comm A.multiply
it "is associative" $ property $
prop_image_assoc A.multiply
describe "Red adjustment" $ do
it "is correct" $ property $
prop_red_correct
it "Gives ID when applied twice with x and -x" $ property $
prop_change_red_ID
describe "Negation" $ do
let prop_double_neg_ID ∷ Image PixelRGBA8 → Bool
prop_double_neg_ID img = if imageWidth img >= 0 && imageHeight img >= 0
then let img' = T.negateImage . T.negateImage $ img
in img' == img
else True
it "gives ID when applied twice." $ property $
prop_double_neg_ID
| ayberkt/pixs | tests/Spec.hs | mit | 7,253 | 149 | 21 | 2,297 | 2,332 | 1,183 | 1,149 | 170 | 2 |
{-# LANGUAGE OverloadedStrings #-}
module JoScript.Util.JsonTest (tests) where
import Prelude (flip, String, ($), Int)
import Test.HUnit
import JoScript.Util.Json
import Data.Aeson hiding (withObject)
tests = [ TestLabel "JoScript.Util.JsonTest.withObject" withObjectUniques
, TestLabel "JoScript.Util.JsonTest.withObject" withObjectDups
]
withObjectUniques = TestCase $ do
let (a, b) = (1 :: Int, 2 :: Int)
let expected = object ["a" .= a, "b" .= b]
let resulted = withObject ["a" .= a] (object ["b" .= b])
assertEqual "withObject with no duplicated" expected resulted
withObjectDups = TestCase $ do
let (a, b) = (1 :: Int, 2 :: Int)
let expected = object ["a" .= b]
let resulted = withObject ["a" .= b] (object ["a" .= a])
assertEqual "withObject's left should replace values on the right" expected resulted
| AKST/jo | source/test/JoScript/Util/JsonTest.hs | mit | 848 | 0 | 15 | 158 | 282 | 153 | 129 | 18 | 1 |
{-|
Module: Treb.Routes
Description: Trebuchet types.
Copyright: Travis Whitaker 2015
License: MIT
Maintainer: [email protected]
Stability: Provisional
Portability: POSIX
-}
{-# LANGUAGE DataKinds, PolyKinds, RankNTypes, TypeFamilies, TypeOperators,
ScopedTypeVariables, OverloadedStrings, FlexibleContexts,
QuasiQuotes #-}
module Treb.Routes
( TrebApi
, trebApiProxy
, trebServer ) where
import Servant
import Treb.Routes.DataBlockUpload
--import Treb.Routes.DataBlockCreate
--import Treb.Routes.FileUpload
--import Treb.Routes.DataBlockFilter
--import Treb.Routes.DataBlockGet ( DataBlockGetH )
--import Treb.Routes.DataBlockGetMetadata ( DataBlockGetMetadataH )
--import Treb.Routes.DataBlockGetFilter ( DataBlockGetFilterH )
--import Treb.Routes.DataBlockPutMetadata ( DataBlockPutMetadataH )
--import Treb.Routes.JobCreate ( JobCreateH )
--import Treb.Routes.JobFilter ( JobFilterH )
--import Treb.Routes.UserFilter ( UserFilterH )
--import Treb.Routes.UserGet ( UserGetH )
--import Treb.Routes.JobTemplateFilter ( JobTemplateFilterH )
import Treb.Routes.Types
---- Trebuchet API ----
type TrebApi =
---- DataBlock ----
-- NOTE: The following requests captures the "datablock_id" in the URL. This is
-- used instead of DataBlockName because serializing that cleanly is tricky.
-- That ought to be done at a later point. This will require a query to
-- PostgreSQL to determine the DataBlockName so that it may be looked up in the
-- server DataBlockName to DataBlock mapping.
DataBlockUploadH
-- DataBlockCreateH
-- :<|> FileUploadH
-- :<|> DataBlockFilterH
-- :<|> DataBlockGetH
-- :<|> DataBlockGetMetadataH
-- :<|> DataBlockGetFilterH
-- :<|> DataBlockPutMetadataH
--
-- ---- Job ----
-- :<|> JobCreateH
-- :<|> JobFilterH
--
-- ---- User ----
-- :<|> UserFilterH
-- :<|> UserGetH
--
-- ---- Job Template ----
-- :<|> JobTemplateFilterH
trebServer :: TrebServer TrebApi
--trebServer = dataBlockCreateH :<|> fileUploadH
trebServer = dataBlockUploadH -- dataBlockCreateH :<|> fileUploadH :<|> dataBlockFilterH
trebApiProxy :: Proxy TrebApi
trebApiProxy = Proxy
| MadSciGuys/trebuchet | src/Treb/Routes.hs | mit | 2,268 | 0 | 5 | 446 | 105 | 80 | 25 | 16 | 1 |
module Network.S3URLSpec
( main
, spec
) where
import Prelude
import Control.Lens
import Data.Aeson
import Data.Monoid ((<>))
import Network.S3URL
import Network.AWS
( Endpoint
, Region(..)
, _svcEndpoint
, endpointHost
, endpointPort
, endpointSecure
)
import Network.AWS.S3 (BucketName(..))
import Test.Hspec
import qualified Data.ByteString.Lazy.Char8 as C8
main :: IO ()
main = hspec spec
spec :: Spec
spec = describe "S3URL" $ do
it "parses from JSON" $
withDecoded "http://localhost:4569/my-bucket" $ \url -> do
let ep = serviceEndpoint url
view endpointSecure ep `shouldBe` False
view endpointHost ep `shouldBe` "localhost"
view endpointPort ep `shouldBe` 4569
s3Bucket url `shouldBe` BucketName "my-bucket"
it "parses from JSON without authority" $
withDecoded "http:///my-bucket" $ \url -> do
let ep = serviceEndpoint url
view endpointSecure ep `shouldBe` False
view endpointHost ep `shouldBe` "s3.amazonaws.com"
view endpointPort ep `shouldBe` 80
s3Bucket url `shouldBe` BucketName "my-bucket"
it "parses from JSON without port" $
withDecoded "https://localhost/my-bucket" $ \url -> do
let ep = serviceEndpoint url
view endpointSecure ep `shouldBe` True
view endpointHost ep `shouldBe` "localhost"
view endpointPort ep `shouldBe` 443
it "has nice parse errors" $ do
let Left err1 = eitherDecode "\"ftp://invalid\"" :: Either String S3URL
let Left err2 = eitherDecode "\"https://localhost\"" :: Either String S3URL
err1 `shouldEndWith` "Invalid S3 URL: cannot infer port"
err2 `shouldEndWith` "Invalid S3 URL: bucket not provided"
serviceEndpoint :: S3URL -> Endpoint
serviceEndpoint url = _svcEndpoint (s3Service url) NorthVirginia
withDecoded :: String -> (S3URL -> Expectation) -> Expectation
withDecoded str ex = either failure ex decoded
where
decoded = eitherDecode $ C8.pack $ "\"" <> str <> "\""
failure err = expectationFailure $ unlines
[ "Expected " <> str <> " to parse as JSON"
, "Error: " <> err
]
| pbrisbin/tee-io | test/Network/S3URLSpec.hs | mit | 2,253 | 0 | 15 | 607 | 595 | 305 | 290 | 55 | 1 |
import Graphics.Gloss
import System.IO.Unsafe
import System.Environment
import Data.Char
-- | Main entry point to the application.
-- | module Main where
-- | The main entry point.
main = animate (InWindow "Sierpinski Triangles" (500, 650) (20, 20))
black (picture_sierpinski getDegree)
getDegree :: Int
getDegree = (digitToInt (head (head (unsafePerformIO (getArgs)))))
side :: Float
side = 100.0
-- Sierpinski Triangles
picture_sierpinski :: Int -> Float -> Picture
picture_sierpinski degree time
= sierpinski degree time (aquamarine)
-- Base of triangles
base_tri :: Color -> Picture
base_tri color
= Color color
$ Polygon [
((-(side/2)),0),
((side/2),0),
(0,(-(((sqrt 3.0)/2)*side)))]
sierpinski :: Int -> Float -> Color -> Picture
sierpinski 0 time color = base_tri color
sierpinski n time color
= let inner
= Scale 0.5 0.5
$ sierpinski (n-1) time (mix color)
in Pictures
[base_tri color
, Translate (-(side/2)) (-((((sqrt 3.0)/2)*side)/2)) $ inner
, Translate ((side/2)) (-((((sqrt 3.0)/2)*side)/2)) $ inner
, Translate (0) (((((sqrt 3.0)/2)*side)/2)) $ inner]
--
mix :: Color -> Color
mix c = mixColors 1 2 red c
| kylegodbey/haskellProject | src/sierpinski.hs | mit | 1,256 | 10 | 20 | 303 | 530 | 289 | 241 | 33 | 1 |
module Util.TextPos (
TextPos(..), append
)
where
import qualified Data.ByteString.UTF8 as BS
import Data.Monoid
type Line = Int
type Column = Int
data TextPos =
TextPos !Line !Column
deriving (Eq,Show)
instance Monoid TextPos where
mempty = TextPos 0 0
mappend (TextPos l1 c1) (TextPos l2 c2) =
TextPos
(l1 + l2)
(if l2 == 0 then c1+c2 else c2)
append :: TextPos -> BS.ByteString -> TextPos
append = BS.foldr f
where
f :: Char -> TextPos -> TextPos
f '\n' (TextPos l c) =
TextPos (l + 1) 0
f _ (TextPos l c) =
TextPos l (c + 1)
| DrNico/rhodium | tools/rhc-strap/Util/TextPos.hs | mit | 648 | 0 | 9 | 219 | 243 | 132 | 111 | 26 | 2 |
module Data.AER where
| fhaust/aer | src/Data/AER.hs | mit | 29 | 0 | 3 | 10 | 6 | 4 | 2 | 1 | 0 |
module Decibel (Decibel,
mkDecibel,
toDecibel,
fromDecibel) where
data Decibel a = Decibel a
instance Show a => Show (Decibel a) where
show (Decibel a) = show a
mkDecibel :: a -> Decibel a
mkDecibel x = Decibel x
-- from linear to decibels
toDecibel :: (Floating a, Fractional a) => a -> a -> Decibel a
toDecibel p pRef = Decibel (10 * logBase 10 (p / pRef))
fromDecibel :: (Floating a, Fractional a) => Decibel a -> a
fromDecibel (Decibel x) = 10**(x / 10)
| Vetii/SCFDMA | src/Decibel.hs | mit | 517 | 0 | 10 | 145 | 205 | 107 | 98 | 13 | 1 |
let timeAction action = getCurrentTime >>= (\t1 -> action >>= (\g -> getCurrentTime >>= (\t2 -> let timeInUnits = (realToFrac $ diffUTCTime t2 t1 :: Float) in return timeInUnits)))
let runData f = randomIO >>= (\randomChar -> if (last (show f)) == randomChar then return () else return ())
-- TODO: deepseq
let timeData d = timeAction (runData d)
seed <- newStdGen
let randomlist n = newStdGen >>= (return . take n . unfoldr (Just . random))
let n = 30 :: Int
ds1 <- mapM (\_ -> randomlist n >>= return . Set.fromList ) [1..n]
ds2 <- mapM (\_ -> randomlist n >>= return . Set.fromList ) [1..n]
let c1 = Set.fromList ds1
let c2 = Set.fromList ds2
timeData (conjunctionOr c1 c2)
| jprider63/LMonad | benchmark/bench.hs | mit | 683 | 5 | 20 | 129 | 311 | 163 | 148 | -1 | -1 |
-- Generated by protobuf-simple. DO NOT EDIT!
module Types.Fixed64List where
import Control.Applicative ((<$>))
import Prelude ()
import qualified Data.ProtoBufInt as PB
newtype Fixed64List = Fixed64List
{ value :: PB.Seq PB.Word64
} deriving (PB.Show, PB.Eq, PB.Ord)
instance PB.Default Fixed64List where
defaultVal = Fixed64List
{ value = PB.defaultVal
}
instance PB.Mergeable Fixed64List where
merge a b = Fixed64List
{ value = PB.merge (value a) (value b)
}
instance PB.Required Fixed64List where
reqTags _ = PB.fromList []
instance PB.WireMessage Fixed64List where
fieldToValue (PB.WireTag 1 PB.Bit64) self = (\v -> self{value = PB.append (value self) v}) <$> PB.getFixed64
fieldToValue tag self = PB.getUnknown tag self
messageToFields self = do
PB.putFixed64List (PB.WireTag 1 PB.Bit64) (value self)
| sru-systems/protobuf-simple | test/Types/Fixed64List.hs | mit | 852 | 0 | 13 | 156 | 291 | 156 | 135 | 20 | 0 |
-- This is a helper module, defining some commonly used code.
-- Other lessons can import this module.
module Helper
( module Lesson01
) where
import Lesson01 (Suit (..), Rank (..), Card (..), deck)
| snoyberg/haskell-impatient-poker-players | src/Helper.hs | mit | 208 | 0 | 6 | 43 | 41 | 29 | 12 | 3 | 0 |
dopt_set dfs f = dfs{ dumpFlags = IntSet.insert (fromEnum f) (dumpFlags dfs) }
| chreekat/vim-haskell-syntax | test/golden/toplevel/with-rec-update-after-eq.hs | mit | 79 | 0 | 9 | 13 | 38 | 19 | 19 | 1 | 1 |
{-# OPTIONS_HADDOCK ignore-exports #-}
{-| In module EXParser we export two main functions(evaluate and parseArithmetic) through which we come to the parsed expression, that is from input data-string to the output-some data structure like parse tree.
-}
module EXParser(
evaluate,
parseArithmetic
) where
import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Expr
import Data.Char
import EXData
import Control.Monad
import Data.Either.Unwrap
-- | table indicates possible operators.
table :: OperatorTable Char () Expression
-- OperatorTable takes 3 arguments: Char, (), Expression
table = [ [op "*" Mult AssocLeft, op "/" Division AssocLeft], [op "+" Add AssocLeft, op "-" Sub AssocLeft]]
-- parser supports operations as *, /, +, -.
where
op s f = Infix(string s >> return f)
-- ">>" means bind in monads
-- | factor is parser for expression in combination of brackets.
factor :: Parser Expression
factor = do {
_ <- char '(';
x <- expr ;
_ <- char ')';
return x
} <|> number
<|> cell
-- "<|>" is a parser combinator; the idea of using that sign is to combine the small parsers in to big ones
-- | number is parser for numbers.
number :: Parser Expression
number = do {
ds <- many1 digit;
return (Constant . read $ ds)
}
-- | cell is for parsing notation for referencing other cells.
cell :: Parser Expression
cell = do {
c <- lower;
y <- many1 digit;
-- digit and many1 are functions in library Parsec
return (Cell (ord c - ord 'a' + 1) (read y))
-- read convertes to y from a string
}
-- | Function removeSpace is removing spaces.
removeSpace :: String -> String
removeSpace [] = []
removeSpace (x:xs)
| isSpace x = removeSpace xs
| otherwise = x: removeSpace xs
-- | expr is parser for arithmetic expressions.
expr :: Parser Expression
-- it is a parser that returns an expression
expr = buildExpressionParser table factor
-- buildExpressionParser is a function in library parsec
-- | parseArithmetic is function for parsing, that is taking the actual string and returning type Either
parseArithmetic :: String -- ^ as string we can take anything, meaning we can type in anything
-> Either ExError Expression -- ^ arithmetic expression don't return ExError
parseArithmetic s
| s == "" = Left NoValue
| isLeft value = Left ParseError
| otherwise = Right (fromRight value)
where
value = parse expr "" $ removeSpace s
-- parse is a function, that actually parses our entered strings, that are arithmetic expressions in cell
-- so with predefined parser types we help ourselves to define the most important function, that is parser
-- | This function evaluates expressions and then returns error or constant.
evaluate :: Expression -> Either ExError Expression
-- we change type for easy calculation
evaluate expression
| isRight value = fmap Constant value
|otherwise = Left $ fromLeft value
where
value = evaluateHelper expression
-- | evaluateHelper is function that helps us evaluate expression.
evaluateHelper :: Expression -> Either ExError Integer
evaluateHelper (Cell _ _) = Left EvaluationError
evaluateHelper (Constant a) = Right a
evaluateHelper (Add a b) = liftM2 (+) (evaluateHelper a) (evaluateHelper b)
evaluateHelper (Sub a b) = liftM2 (-) (evaluateHelper a) (evaluateHelper b)
evaluateHelper (Mult a b) = liftM2 (*) (evaluateHelper a) (evaluateHelper b)
evaluateHelper (Division a b) = liftM2 div (evaluateHelper a) (evaluateHelper b)
-- we use function liftM2(Control.Monad library) to promote a function evaluateHelper to a monad, scanning the monadic arguments from left to right
| lepoticka/ExcellingCabbage | EXParser.hs | gpl-2.0 | 3,814 | 0 | 13 | 869 | 762 | 391 | 371 | 56 | 1 |
module Main where
import Amath.Types
import Amath.Proof
import Amath.Expr.AbsExp
import Amath.Expr.ExprFuncs
import Data.Maybe
import Sequence5
import System (getArgs, getProgName)
import Control.Monad.State
import Data.List
import qualified Data.Map as Map
import Data.Char
--import Amath.Expr.ExprFuncs
import System.Directory as Dir
outFile = "result.txt"
printErrMsg :: String -> IO ()
printErrMsg prgname =
error $ "Version: 0.1" ++ "\nThis program generates the proof of a numeric sequence." ++ "\n\n" ++
"Usage:\n\n> " ++ prgname ++ " \"expression\" Min-len Max-len dm-file pm-file WM-size ...\n"
main :: IO ()
main = do
args <- getArgs
progName <- getProgName
--start <- getCurrentTime
if length args >= 6
then do let [sq, starts, fins, dmfile, pmfile, wms] = take 6 args
let options = drop 6 args
let isSMWMdigit = all isDigit wms
if not isSMWMdigit || read wms < 0
then printErrMsg progName
else return ()
dmStr <- readFile dmfile -- read ltm file
let dm = parseDM (dmStr) -- parse the ltm file
--writeFile "dmfile.txt" $ show dm
let dmmap = Map.fromList dm
pmStr <- readFile pmfile
let (Pmem pm') = parsePM pmStr
if null pm'
then putStrLn "Could not parse pm-file."
else return ()
let pm = dropZeroWeighted (Pmem pm')
--writeFile "pmfile.txt" (show pm)
let wm = read wms
let fin = read fins
let start = read starts
if (not . null $ sq) && (head sq == '[')
then do
let seq = (read sq :: [Int] )
--putStrLn $ show seq
solveSeq dmmap pm wm start fin options (1,seq)
return ()
else do
seqs <- getSeqs sq
results <- mapM (solveSeq dmmap pm wm start fin options) $ zip [1..] (map fst seqs)
matchResults results seqs
else do putStrLn "\nThe number of arguments is wrong!"
putStrLn ""
printErrMsg progName
matchResults :: [(Maybe Int)] -> [([Int],Int)] -> IO ()
matchResults results seqs = do
let tmp = (map (\(_,x) -> (Just x)) seqs)
if (results == tmp)
then putStrLn "\nAll answers correct."
else do
let count' = filter (\(b1,b2) -> isJust b1) $ zip results tmp
let count = length $ filter (/=True) $ map (\(b1,b2) -> (fromJust b1) == (fromJust b2)) count'
let countn = length $ filter (isNothing) results
putStrLn $ "\n" ++ show count ++ " wrong predictions"
putStrLn $ show countn ++ " failed attempts\n"
mapM_ (\(pred, (seq,ans)) -> putStrLn (show seq ++ ": answer=" ++ show ans ++ ", prediction=" ++ show pred)) $ zip results seqs
getRules :: [PRule] -> [PRule]
getRules xs = filter check' xs
where
check' x@(Rule name value []) = True
--check' x@(Rule name value (y@(EEqual (EFunc _ _) _):ys)) = False
check' _ = True
func = EAdd (EFunc (Ident "f") (EInt 3)) (EFunc (Ident "f") (EInt 4) )
-- read list of integer sequences from a file
-- return blank list if file does not exist or does not contain sequences
getSeqs :: FilePath -> IO [([Int],Int)]
getSeqs filename = do
fileExists <- Dir.doesFileExist filename
if fileExists then do
--putStrLn $ "Reading file: " ++ filename
file <- readFile filename
result' <- mapM parseSeq (lines file)
let result = (filter (not . null) result')
let seqs = map (\x -> (init x, last x)) result
return seqs
else do
putStrLn $ "File " ++ filename ++ " does not exist."
return []
parseSeq :: String -> IO [Int]
parseSeq s = do
let s' = dropWhile (/='[') s
let s'' = takeWhile (/=']') s'
if null s || null s''
then return []
else do
let sq = read (s'' ++ "]")
--putStrLn $ "Read line: " ++ (show sq)
return sq
solveSeq :: Map.Map Exp Exp -> [PRule] -> Int -> Int -> Int -> [String] -> (Int,[Int]) -> IO (Maybe Int)
solveSeq dmmap pm wm start fin options (no,seq) = do
let seqlen = length seq
let closure = getClosure seq
let line = "Problem " ++ show no ++ ": " ++ show seq
putStrLn $ take (length line) $ repeat '='
putStrLn $ line
putStrLn $ take (length line) $ repeat '='
let pctx = (PCtx (5, wm, dmmap, getRules pm, [], func, [], seq))
let sctx = SCtx (closure, seq, [(i-1) | i <- [1..seqlen]], pctx,options)
result <- evalStateT (solveInterative start fin) sctx
return result
| arnizamani/SeqSolver | seqsolver5.hs | gpl-2.0 | 5,101 | 0 | 20 | 1,875 | 1,625 | 813 | 812 | 103 | 5 |
{-# LANGUAGE TemplateHaskell #-}
module Rushhour.Data where
-- $Id$
import Autolib.TES.Identifier
import Autolib.Reader
import Autolib.ToDoc
import Autolib.Size
import Autolib.Hash
import Autolib.FiniteMap
import Data.Typeable
import Data.Array
import Control.Monad ( guard )
data Rushhour = Rushhour deriving ( Typeable )
data Rushhour_Inverse = Rushhour_Inverse deriving ( Typeable )
$(derives [makeReader, makeToDoc] [''Rushhour])
$(derives [makeReader, makeToDoc] [''Rushhour_Inverse])
type Position = ( Int, Int )
data Orientation = Vertical | Horizontal
deriving ( Eq, Ord, Typeable, Enum, Bounded, Ix )
$(derives [makeReader, makeToDoc] [''Orientation])
offset :: Orientation -> Position
offset Vertical = ( 0, 1 )
offset Horizontal = ( 1, 0 )
data Car = Car { orientation :: Orientation
, extension :: Int
, position :: Position
}
deriving ( Eq, Ord, Typeable )
$(derives [makeReader, makeToDoc] [''Car])
type Zug = ( Identifier, Int )
instance Size Zug where size _ = 1
data Instance =
Instance { width :: Int -- ^ range is [ - width .. width ]
, height :: Int -- ^ range ist [ - height .. height ]
, cars :: FiniteMap Identifier Car
, target :: Identifier -- ^ free this car (in positive direction)
}
deriving ( Eq, Ord, Typeable )
$(derives [makeReader, makeToDoc] [''Instance])
-- | Problem 9 of Railroad Rushhour (Binary Arts)
example :: Instance
example = Instance
{ width = 3, height = 3, target = read "X"
, cars = listToFM
[ ( read "A", Car { orientation = Vertical, extension = 2, position = ( -3, 2 ) } )
, ( read "B", Car { orientation = Horizontal, extension = 2, position = ( 2, 3 ) } )
, ( read "C", Car { orientation = Vertical, extension = 2, position = ( -3, 0 ) } )
, ( read "D", Car { orientation = Vertical, extension = 2, position = ( -3, -2 ) } )
, ( read "E", Car { orientation = Vertical, extension = 2, position = ( 0, -2 ) } )
, ( read "F", Car { orientation = Horizontal, extension = 2, position = ( -3, -3 ) } )
, ( read "G", Car { orientation = Horizontal, extension = 2, position = ( -1, -3 ) } )
, ( read "H", Car { orientation = Horizontal, extension = 2, position = ( 1, -3 ) } )
, ( read "O", Car { orientation = Horizontal, extension = 3, position = ( -2, 3 ) } )
, ( read "P", Car { orientation = Vertical, extension = 3, position = ( 0, 0 ) } )
, ( read "Q", Car { orientation = Vertical, extension = 3, position = ( 3, 0 ) } )
, ( read "R", Car { orientation = Vertical, extension = 3, position = ( 3, -3 ) } )
, ( read "X", Car { orientation = Horizontal, extension = 2, position = ( -2, 0 ) } )
]
}
occupied :: Instance -> Array Position [ Identifier ]
occupied i =
let w = width i ; h = height i
bnd = (( negate w, negate h),(w,h))
in accumArray ( \ old new -> new : old ) [] bnd $ do
( name, car ) <- fmToList $ cars i
let (x,y) = position car
(dx, dy) = offset $ orientation car
d <- [ 0 .. extension car - 1 ]
return ( (x+d*dx, y+d*dy), name )
-- | list of maximal extension of a fresh car beginning here
-- return only extensions >= first param
-- omit cases that block the target car (same direction, nearer to exit)
spaces :: Int
-> Instance
-> [ ( Position , Orientation , Int ) ]
spaces atleast i = do
let Just t = lookupFM ( cars i ) ( target i )
let occ = occupied i
( ul, or ) = bounds occ
bnd = ((ul, minBound), (or, maxBound ))
ok q = inRange ( bounds occ ) q && null ( occ ! q )
( p @ (x,y) , o ) <- range bnd
let ( dx, dy ) = offset o
guard $ not
( orientation t == o && dominates ( position t ) p )
let e = length $ takeWhile ok $ do
d <- [ 0 .. ]
let q = ( x + d*dx, y + d*dy )
return q
guard $ e > atleast
return ( p, o, e - 1 )
dominates (a,b) (c,d) =
(a == c && b < d) || (a < c && b == d)
collisions :: Instance -> [ Doc ]
collisions i = do
(p, names) <- assocs $ occupied i
guard $ length names > 1
return $ hsep [ text "Kollision"
, text "zwischen", toDoc names
, text "auf Position" , toDoc p
]
consistent :: Instance -> Bool
consistent = null . collisions
instance Nice Instance where nice = present
present :: Instance -> Doc
present i =
let w = width i + 1 ; h = height i + 1
bnd = ((negate $ 2 * w, negate h), (2 * w, h))
a = accumArray ( \ old new -> new ) ' ' bnd []
left_right = do
x <- [ negate $ 2 * w, 2 * w ]
y <- [ negate h .. h ]
return ( (x,y), '*' )
top_bottom = do
x <- [ negate $ 2 * w .. 2 * w ]
y <- [ negate h , h ]
return ( (x,y), '*' )
core = do
((x,y), c ) <- assocs $ occupied i
return ( (2 * x, y)
, case c of
[] -> '.'
[n] -> head $ show n
_ -> '?'
)
hole = do
( name, car ) <- fmToList $ cars i
guard $ name == target i
let (x,y) = position car
(dx, dy ) = offset $ orientation car
return ((2 * (x + dx * (w-x)), y + dy * (h-y)), ' ')
b = a // left_right // top_bottom // core // hole
in vcat $ do
let ((l,u),(r,o)) = bounds b
y <- reverse [ u .. o ]
return $ text $ do
x <- [ l .. r ]
return $ b ! (x,y)
-- local variables:
-- mode: haskell
-- end:
| florianpilz/autotool | src/Rushhour/Data.hs | gpl-2.0 | 5,455 | 29 | 23 | 1,672 | 2,291 | 1,274 | 1,017 | 127 | 3 |
{-# LANGUAGE CPP #-}
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
module Access.System.FilePath
( module Access.System.FilePath.Windows
) where
import Access.System.FilePath.Windows
#else
module Access.System.FilePath
( module Access.System.FilePath.Posix
) where
import Access.System.FilePath.Posix
#endif
| bheklilr/filepath-io-access | Access/System/FilePath.hs | gpl-2.0 | 335 | 0 | 5 | 48 | 28 | 21 | 7 | 4 | 0 |
--
-- Copyright (c) 2014 Citrix Systems, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
{-# LANGUAGE FlexibleContexts #-}
module XenMgr.PowerManagement (
initPm
, isLidClosed
, isAcAdapter
, getBatteryLevel
, getVmsToDehibernate
, PMAction (..)
, PMSettings (..)
, executePmAction
, pmGetSettings
, pmSaveSettings
, pmSaveBatteryLidCloseAction
, pmSaveAcLidCloseAction
, pmActionToStr
, pmActionOfStr
, pmShutdownVms
, hostWhenIdle
, hostWhenIdleDoWithState
, pmGetScreenRestoreVm
, pmSetScreenRestoreVm
, pmClearScreenRestoreVm
) where
import Control.Monad
import Control.Monad.Error hiding (liftIO)
import Control.Applicative
import Control.Concurrent
import Control.Exception
import System.Process (readProcessWithExitCode)
import Data.String
import Data.Maybe
import Data.IORef
import Data.List (nub)
import qualified Data.Text.Lazy as TL
import Tools.Log
import Tools.XenStore
import Tools.File
import Tools.Misc
import Tools.Process
import Tools.IfM
import Tools.Future
import XenMgr.Errors
import XenMgr.Config
import XenMgr.Db
import XenMgr.Vm
import XenMgr.User
import XenMgr.Host
import XenMgr.XM
import Vm.Queries
import Vm.State
import XenMgr.Rpc
import qualified XenMgr.Connect.Xl as Xl
import XenMgr.Connect.InputDaemon
data PMAction = ActionSleep
| ActionHibernate
| ActionShutdown
| ActionForcedShutdown
| ActionReboot
| ActionNothing
| ActionInvalid
deriving (Eq, Show)
data PMSettings = PMSettings { pmLidCloseACAction :: PMAction
, pmLidCloseBatteryAction :: PMAction }
deriving (Eq, Show)
data BatteryLevel = BatNormal | BatWarning | BatLow | BatCritical
deriving (Eq, Show)
instance Marshall PMAction where
dbRead path = dbReadStr path >>= (\act -> let pmact = (pmActionOfStr act) in
case pmact of
ActionInvalid -> do
liftIO $ warn ("Incorrect pm action specification: " ++ act)
return ActionNothing
_ -> return pmact )
dbWrite path a = dbWriteStr path (pmActionToStr a)
instance Marshall PMSettings where
dbRead path = do
acLidAction <- dbReadWithDefault ActionNothing (path ++ "/" ++ "ac-lid-close-action")
batteryLidAction <- dbReadWithDefault ActionNothing (path ++ "/" ++ "battery-lid-close-action")
return $ PMSettings { pmLidCloseACAction = acLidAction
, pmLidCloseBatteryAction = batteryLidAction }
dbWrite path v = do dbWrite (path ++ "/" ++ "ac-lid-close-action") $ pmLidCloseACAction v
dbWrite (path ++ "/" ++ "battery-lid-close-action") $ pmLidCloseBatteryAction v
pmActionOfStr "sleep" = ActionSleep
pmActionOfStr "hibernate" = ActionHibernate
pmActionOfStr "shutdown" = ActionShutdown
pmActionOfStr "forced-shutdown" = ActionForcedShutdown
pmActionOfStr "reboot" = ActionReboot
pmActionOfStr "nothing" = ActionNothing
pmActionOfStr "" = ActionNothing
pmActionOfStr bad = ActionInvalid
pmActionToStr ActionSleep = "sleep"
pmActionToStr ActionHibernate = "hibernate"
pmActionToStr ActionShutdown = "shutdown"
pmActionToStr ActionForcedShutdown = "forced-shutdown"
pmActionToStr ActionReboot = "reboot"
pmActionToStr ActionNothing = "nothing"
pmActionToStr ActionInvalid = "nothing"
pmGetSettings :: Rpc PMSettings
pmGetSettings = dbReadWithDefault PMSettings { pmLidCloseACAction = ActionNothing
, pmLidCloseBatteryAction = ActionNothing }
"/power-management"
pmSaveSettings :: PMSettings -> Rpc ()
pmSaveSettings s = dbWrite "/power-management" s
pmSaveBatteryLidCloseAction :: PMAction -> Rpc ()
pmSaveBatteryLidCloseAction = dbWrite "/power-management/battery-lid-close-action"
pmSaveAcLidCloseAction :: PMAction -> Rpc ()
pmSaveAcLidCloseAction = dbWrite "/power-management/ac-lid-close-action"
hostStateOfPmAction :: PMAction -> HostState
hostStateOfPmAction ActionSleep = HostGoingToSleep
hostStateOfPmAction ActionHibernate = HostGoingToHibernate
hostStateOfPmAction ActionReboot = HostRebooting
hostStateOfPmAction ActionShutdown = HostShuttingDown
hostStateOfPmAction ActionForcedShutdown = HostShuttingDown
hostStateOfPmAction ActionNothing = HostIdle
hostStateOfPmAction ActionInvalid = HostIdle
-- Do an operation if the host is idle
hostWhenIdle :: (MonadRpc e m) => m () -> m ()
hostWhenIdle action = getHostState >>= maybeExec
where maybeExec HostIdle = action
maybeExec _ = return ()
-- Do an operation which is allowed only if the host is idle (resetting it to idle afterwards)
hostWhenIdleDoWithState :: (MonadRpc e m) => HostState -> m () -> m ()
hostWhenIdleDoWithState newState action =
hostWhenIdle $
(do setHostState newState
action
setHostState HostIdle
) `catchError` (\e -> setHostState HostIdle >> throwError e)
isLidClosed :: IO Bool
isLidClosed = xsRead "/pm/lid_state" >>= pure . f where f (Just "0") = True
f _ = False
isAcAdapter :: IO Bool
isAcAdapter = xsRead "/pm/ac_adapter" >>= pure . f where f (Just "1") = True
f _ = False
getBatteryLevel :: IO BatteryLevel
getBatteryLevel =
xsRead "/pm/currentbatterylevel" >>= pure . f
where
f (Just "0") = BatNormal
f (Just "1") = BatWarning
f (Just "2") = BatLow
f (Just "3") = BatCritical
f _ = BatNormal
isAsleep :: Uuid -> Rpc Bool
isAsleep uuid = (== 3) <$> getVmAcpiState uuid
getCurrentPmAction :: Rpc (Maybe PMAction)
getCurrentPmAction =
liftIO $ xsRead "/xenmgr/pm-current-action" >>= return . f
where
f (Just "sleep") = Just ActionSleep
f (Just "hibernate") = Just ActionHibernate
f (Just "shutdown") = Just ActionShutdown
f (Just "forced-shutdown") = Just ActionForcedShutdown
f (Just "reboot") = Just ActionReboot
f _ = Nothing
setCurrentPmAction :: PMAction -> Rpc ()
setCurrentPmAction action =
liftIO $ xsWrite "/xenmgr/pm-current-action" (str action)
where
str ActionReboot = "reboot"
str ActionSleep = "sleep"
str ActionHibernate = "hibernate"
str ActionShutdown = "shutdown"
str ActionForcedShutdown = "forced-shutdown"
str ActionNothing = error "bad pm action"
str ActionInvalid = error "bad pm action"
clearCurrentPmAction :: Rpc ()
clearCurrentPmAction =
liftIO $ xsRm "/xenmgr/pm-current-action"
pmGetScreenRestoreVm :: Rpc (Maybe Uuid)
pmGetScreenRestoreVm = dbMaybeRead "/xenmgr/pm-visible-vm"
pmClearScreenRestoreVm :: Rpc ()
pmClearScreenRestoreVm = dbRm "/xenmgr/pm-visible-vm"
pmSetScreenRestoreVm :: Uuid -> Rpc ()
pmSetScreenRestoreVm vm = dbWrite "/xenmgr/pm-visible-vm" vm
pmShutdownVms :: Bool -> Rpc ()
pmShutdownVms force = do
vms <- getVmShutdownOrder
parallelVmExecInStages vms maybeShutdown
return ()
where
maybeShutdown uuid | force = whenM (isRunning uuid) $ forceShutdownVm uuid
| otherwise = do
acpi <- getVmAcpiState uuid
when (acpi == 3) $
do resumed <- liftIO $ resumeFromSleep uuid
when (not resumed) $ failResumeFromSleep
running <- isRunning uuid
when running $
(shutdownVm uuid >> waitForVmInternalState uuid Shutdown Shutdown 3)
`catchError` shutdownError
--FIXME! : should really translate xenvm errors into something better than strings
shutdownError err
| show err == "103:VM didn't shutdown as expected." = return ()
| otherwise = throwError err
-- common code for shutdown/reboot
shutdownCommon :: String -> Bool -> XM ()
shutdownCommon offCommand force = do
liftRpc $ pmShutdownVms force
liftIO $ do
info "PM: halting host now"
spawnShell offCommand
-- wait for actuall poweroff
threadDelay $ 360 * (10^6)
-- returns True if vm was put to sleep here, False if that was not necessary (because
-- it already was in S3 for example)
putS3 :: Uuid -> XM Bool
putS3 uuid = putS3' uuid =<< liftRpc (getVmS3Mode uuid)
putS3' uuid S3Ignore = return True
putS3' uuid S3Pv = liftRpc $ do
acpi <- getVmAcpiState uuid
case acpi of
3 -> return False
_ -> info ("PM: putting " ++ show uuid ++ " to sleep") >> sleepVm uuid >> return True
putS3' uuid S3Restart = liftRpc $ do
acpi <- getVmAcpiState uuid
case acpi of
3 -> return False
_ -> info ("PM: shutting " ++ show uuid ++ " down") >> shutdownVm uuid >> return True
putS3' uuid m = error ("s3 mode " ++ show m ++ " unimplemented")
resumeS3 :: Uuid -> XM ()
resumeS3 uuid = resumeS3' uuid =<< liftRpc (getVmS3Mode uuid)
resumeS3' uuid S3Ignore = return ()
resumeS3' uuid S3Pv = do
void . liftIO $ Xl.resumeFromSleep uuid
info $ "PM: Successfully resumed " ++ show uuid ++ " from S3"
resumeS3' uuid S3Restart = do
liftRpc $ rebootVm uuid
info $ "PM: Restarted " ++ show uuid ++ " after S3"
resumeS3' uuid S3Snapshot =
return () -- unimplemented
putS4 :: Uuid -> XM ()
putS4 uuid = putS4' uuid =<< liftRpc (getVmS4Mode uuid)
putS4' uuid S4Ignore = return ()
putS4' uuid S4Pv = liftRpc $ do
addons <- getVmPvAddons uuid
-- FIXME: this definately needs cleaning up with respect to which actions require preemptive pv-addons db check,
-- which require preemptive pv-addons check via hypercall (or xs lookup),
-- which are fine to fail post-factum
when (not addons) $ do
warn $ "PM: VM " ++ show uuid ++ " has no PV addons!"
failActionRequiresPvAddons
info $ "PM: attempt to hibernate " ++ show uuid
hibernateVm uuid
-- ^ above sets the 'hibernated' db flag for us
putS4' uuid S4Restart = liftRpc $ do
info ("PM: shutting " ++ show uuid ++ " down")
shutdownVm uuid
-- manually toggle S4 flag to induce proper restart action on next host boot
saveConfigProperty uuid vmHibernated True
putS4' uuid m = error ("s4 mode " ++ show m ++ " unimplemented")
-- We allow only one PM action to be run at the time
executePmAction :: PMAction -> XM ()
executePmAction action = executePmActionInternal action True -- supervised by default
executePmActionInternal :: PMAction -> Bool -> XM ()
executePmActionInternal action supervised =
when (action /= ActionNothing) $ do
info $ "PM: received pm action request: " ++ show action
current <- liftRpc getCurrentPmAction
case current of
Just c -> info $ "PM: but pm action " ++ show c ++ " is currently running, so cannot do"
Nothing -> (do liftRpc $ setCurrentPmAction action
execute_ action supervised
liftRpc $ clearCurrentPmAction)
`catchError` \err -> do
liftRpc $ clearCurrentPmAction
throwError err
execute_ ActionReboot supervised = do
info "PM: received host reboot request"
shutdownCommon "reboot" False
execute_ ActionShutdown supervised = do
info "PM: received host shutdown request"
shutdownCommon "poweroff" False
execute_ ActionForcedShutdown supervised = do
info "PM: received host force shutdown request"
setHostState HostShuttingDown
shutdownCommon "poweroff" True
execute_ ActionSleep supervised = do
info "PM: received host sleep request"
queue <- filter (\(uuid,slept) -> slept == True) <$> putVmsToSleep
liftRpc (whenM inputAuthOnBoot $ info "PM: locking screen" >> inputLock)
info "PM: expiring user sessions"
liftRpc expireSessions
-- FIXME: we probably should have separate 'host-resuming-from-sleep-state' here
liftRpc $ setHostState HostIdle
-- Resume all vms
resumeQueue (map fst queue)
liftRpc $ pmClearScreenRestoreVm
where
-- stage S3 so vms go to sleep in parallel.
putVmsToSleep = xmContext >>= \xm -> liftRpc $ do
guests <- getGuestVms
-- FIXME: remove this by making all vms (not just user vms) go thru this pipeline
let needsS3Restart uuid = (`elem` [ S3Restart ]) <$> getVmS3Mode uuid
more <- getVmsBy needsS3Restart
parallelVmExecInStages [ guests, more ] (sleep xm)
sleep xm uuid = go =<< isRunning uuid where
go True = runXM xm $ putS3 uuid
go _ = return False
resumeQueue = mapM resumeS3
expireSessions =
do users <- enumActiveUsers
mapM expire users
where
expire u = info ("PM: terminating user session " ++ show u) >> expireUserSession u
execute_ ActionHibernate supervised = do
info "PM: received host hibernate request"
-- execute hibernate request in parallel for all VMS (but pvm always last)
-- if it bugs, raise nice error message
parallelHib `catchError` \err -> failHibernateFailed
-- now hibernated vms are already shut down, run common shutdown code to get rid of service vms
liftRpc $ dbWrite "/platform/hibernated" "true"
shutdownCommon "poweroff" False
where
maybeSwitch [] = return ()
maybeSwitch (uuid:_) = switchVm uuid >> return ()
parallelHib = xmContext >>= \xm -> liftRpc $
do guests <- getGuestVms
parallelVmExecInStages [guests] (attempt xm)
attempt xm uuid = go =<< isRunning uuid where
go True = (runXM xm $ putS4 uuid) `catchError` on_vm_hib_error uuid
go _ = return ()
-- what to do on VM hibernate error:
-- If we are supervised by the user, propagate exception during hibernate.
-- otherwise, swallow it, shutdown VM and continue with hibernate sequence
on_vm_hib_error uuid err | supervised == True = do warn $ "PM: problem when trying to hibernate " ++ show uuid ++ ", aborting sequence"
throwError err
| otherwise = do warn $ "PM: problem when trying to hibernate, shutting it down instead: " ++ show uuid ++ ": " ++ show err
shutdownVm uuid
execute_ ActionNothing supervised = return ()
execute_ ActionInvalid supervised = return ()
isTXTLaunch :: IO Bool
isTXTLaunch =
do (_, out, _) <- readProcessWithExitCode "txt-stat" [] ""
let out' = TL.pack out
case (TL.find flag'a out', TL.find flag'b out') of
((_, ma), (_, mb)) | not (null ma) && not (null mb)
-> return True
_ -> return False
where
flag'a = TL.pack $ "TXT measured launch: TRUE"
flag'b = TL.pack $ "secrets flag set: TRUE"
assertNotTXTLaunch :: Rpc ()
assertNotTXTLaunch = from =<< liftIO isTXTLaunch where
from False = return ()
from _ = failCannotSleepInTXTMeasuredLaunch
-- Resume all vms from hibernation
getVmsToDehibernate :: Rpc [Uuid]
getVmsToDehibernate = do
-- only do this if autostart enabled
autostart <- appAutoStart
if not autostart
then return []
else getGuestVms >>=
filterM getVmHibernated >>=
filterM (\uuid -> not <$> isRunning uuid)
type EventHandler = XM ()
type Event = (String,String)
handleLidStateChanged closed = do
debug $ "PM: detected lid state change event, closed=" ++ (show closed)
when closed $ do
a <- action
hostWhenIdleDoWithState (hostStateOfPmAction a) $ do
executePmActionInternal a False
where
action = do
settings <- liftRpc pmGetSettings
ac <- liftIO isAcAdapter
return $ case ac of
True -> pmLidCloseACAction settings
False -> pmLidCloseBatteryAction settings
handlePowerButtonPressed = do
debug "PM: detected power button press event"
hostWhenIdleDoWithState HostShuttingDown $ executePmActionInternal ActionShutdown True
handleSleepButtonPressed = do
debug "PM: detected sleep button press event"
hostWhenIdleDoWithState HostGoingToSleep $ executePmActionInternal ActionSleep True
handleBatteryLevelChanged = do
level <- liftIO $ getBatteryLevel
debug $ "PM: detected battery level change event = " ++ (show level)
when (level == BatCritical) $
executePmActionInternal ActionHibernate False
whenEvent :: Event -> EventHandler -> XM ()
whenEvent (intf,signal) h =
let rule = matchSignal intf signal
in
xmContext >>= \c -> liftRpc $ rpcOnSignal rule (process c)
where
process c _ signal = runXM c (void $ future h)
lidStateChanged = ("com.citrix.xenclient.input", "lid_state_changed")
powerButtonPressed = ("com.citrix.xenclient.xcpmd", "power_button_pressed")
sleepButtonPressed = ("com.citrix.xenclient.xcpmd", "sleep_button_pressed")
batteryLevelNotification = ("com.citrix.xenclient.xcpmd", "battery_level_notification")
initPm :: XM ()
initPm = do
whenEvent lidStateChanged $ do
closed <- liftIO isLidClosed
handleLidStateChanged closed
whenEvent powerButtonPressed (handlePowerButtonPressed)
whenEvent sleepButtonPressed (handleSleepButtonPressed)
whenEvent batteryLevelNotification (handleBatteryLevelChanged)
info "installed PM event handlers"
| OpenXT/manager | xenmgr/XenMgr/PowerManagement.hs | gpl-2.0 | 18,563 | 0 | 19 | 5,001 | 4,154 | 2,051 | 2,103 | 365 | 7 |
module Examples.ShoeLift.KeenHeel where
import CornerPoints.Create(slopeAdjustedForVerticalAngle, Slope(..), Angle(..), flatXSlope, flatYSlope )
import CornerPoints.HorizontalFaces(createBottomFaces, createTopFacesWithVariableSlope, createTopFaces,)
import CornerPoints.Points(Point(..))
import CornerPoints.CornerPoints(CornerPoints(..), (+++), (|+++|))
import Stl.StlCornerPoints((|+++^|), Faces(..))
import Stl.StlBase (StlShape(..), newStlShape, stlShapeToText)
import Stl.StlFileWriter(writeStlToFile)
import CornerPoints.FaceExtraction ( extractTopFace, extractBottomFrontLine, extractFrontTopLine, extractBackTopLine, extractBottomFace, extractBackBottomLine, extractFrontFace )
import CornerPoints.FaceConversions(lowerFaceFromUpperFace, backBottomLineFromBottomFrontLine, backTopLineFromFrontTopLine, frontTopLineFromBackTopLine, upperFaceFromLowerFace,
bottomFrontLineFromBackBottomLine, lowerFaceFromUpperFace)
import CornerPoints.Transpose ( transposeZ, transposeX, transposeY)
import CornerPoints.Debug((+++^?), CubeName(..), CubeDebug(..), CubeDebugs(..))
import CornerPoints.Radius(Radius(..))
-------------------------------------------------------------------------- tread attachment and adaptor ----------------------------------------
{-
Attaches to the tread.
Keep the shape of the tread for 1 horizontal cm then convert to the shape of the sole attachment.
-}
writeTreadToStlFile :: IO()
writeTreadToStlFile = writeFile "src/Data/temp.stl" $ stlShapeToText treadStlFile
treadStlFile = newStlShape "KeenHeelTread" $ treadTriangles
treadTriangles =
(
[FacesBackFrontTop | x <- [1,2..36]]
|+++^|
treadTopCubes
)
++
(
[FacesBackBottomFront | x <- [1,2..36]]
|+++^|
treadBtmCubes
)
treadTopCubes =
--front line
(
map (extractFrontTopLine) (createTopFaces treadTopOrigin soleRadius angles flatXSlope flatYSlope)
|+++|
--back line
map (backTopLineFromFrontTopLine . extractFrontTopLine) (createTopFaces treadTopOrigin keyWayRadius angles flatXSlope flatYSlope))
|+++|
--the top faces of the btm cubes
(
map (lowerFaceFromUpperFace . extractTopFace) treadBtmCubes
)
treadBtmCubes =
map ((transposeZ (+ 10)) . upperFaceFromLowerFace ) treadBtmFaces
|+++|
treadBtmFaces
treadBtmFaces =
--front line
map (extractBottomFrontLine)
(createBottomFaces treadBtmOrigin treadRadius angles flatXSlope flatYSlope)
|+++|
--back line
map (backBottomLineFromBottomFrontLine . extractBottomFrontLine)
(createBottomFaces treadBtmOrigin keyWayRadius angles flatXSlope flatYSlope)
treadDebug =
[CubeName "treadCubes" | x <- [1..]]
+++^?
treadTopCubes
treadTopOrigin = (Point{x_axis=0, y_axis=0, z_axis=30})
treadBtmOrigin = (Point{x_axis=0, y_axis=0, z_axis=0})
------------------------------------------------------------------------- sole attachment -------------------------------------------------------
{-
This attaches directly to the sole of the keen shoe.
Will go up around the sides of the shoe about 2 cm.
Don't use any slope. Will use an adjuster later, to add the slope.
Top and bottom will both be same shape. Will adapt down to the tread size later.
-}
writeAdaptorToStlFile :: IO()
writeAdaptorToStlFile = writeFile "src/Data/temp.stl" $ stlShapeToText adaptorStlFile
adaptorStlFile = newStlShape "KeenHeelAdaptor" $ adaptorTriangles
adaptorTriangles =
[FacesBackBottomFrontTop | x <- [1,2..36]]
|+++^|
adaptorCubes
adaptorDebug =
[CubeName "adaptorCubes" | x <- [1..]]
+++^?
adaptorCubes
adaptorCubes = adaptorTopFaces |+++| adaptorBtmFaces
----------- top faces
adaptorTopFaces =
--front line
map (extractFrontTopLine) (createTopFaces adaptorTopOrigin soleRadius angles flatXSlope adaptorSlope)
|+++|
--back line
map (backTopLineFromFrontTopLine . extractFrontTopLine) (createTopFaces adaptorTopOrigin keyWayRadius angles flatXSlope adaptorSlope)
adaptorBtmFaces =
--front line
map (extractBottomFrontLine)
(createBottomFaces adaptorBtmOrigin soleRadius angles flatXSlope flatYSlope)
|+++|
--back line
map (backBottomLineFromBottomFrontLine . extractBottomFrontLine)
(createBottomFaces adaptorBtmOrigin keyWayRadius angles flatXSlope flatYSlope)
adaptorTopOrigin = (Point{x_axis=0, y_axis=0, z_axis=30})
adaptorBtmOrigin = (Point{x_axis=0, y_axis=0, z_axis=0})
--25 degrees is the original value on oversized print
adaptorSlope = NegYSlope (25)
--------------------------------------------------------------------------- create the keyway ---------------------------------------------------------
{-
Only extend it 1 cm into each piece, to minimize weight.
The top needs to be sloped the same as the sole, as this causes the key to slope the same as the keyway in the sole. Use adaptorSlope.
I have not done the slope for the 1st print
Will need to use the same height for the sloped section, as the sole had, so the slope is the same. Will stop the print when I have the
desired 1 cm of top section.
-}
writeKeyToStlFile :: IO()
writeKeyToStlFile = writeFile "src/Data/temp.stl" $ stlShapeToText keyStlFile
keyStlFile = newStlShape "KeenToeKey" $ keyTriangles
keyTriangles = [FacesBottomFrontTop | x <- [1,2..36]]
|+++^|
keyCubes
keyDebug =
[CubeName "keyCubes" | x <- [1..]]
+++^?
keyCubes
keyCubes =
createTopFaces topKeyOrigin keyRadius angles flatXSlope flatYSlope
|+++|
createBottomFaces btmKeyOrigin keyRadius angles flatXSlope flatYSlope
topKeyOrigin = (Point{x_axis=0, y_axis=(0), z_axis=20})
btmKeyOrigin = (Point{x_axis=0, y_axis=0, z_axis=0})
------------------------------------------------------------------------- radius ---------------------------------------------------------------------
angles = map (Angle) [0,10..380]
--radius of the keyway, base on the shape of the keen sole.
keyWayRadius = map (\(Radius x) -> (Radius (x * 0.5))) soleRadius
--radius of the key, slightly undersized from the keyWayRadius
keyRadius = map (\(Radius x) -> (Radius (x * 0.49))) soleRadius
--radius of the tread of the original keen shoe.
--Increase it by 4 so that it will go up around the sides of the shoe for better attachment.
soleRadius = -- map (\(Radius x) -> Radius (x + 4))
[Radius 38,--0
Radius 38,--1
Radius 38,--2
Radius 37,--3
Radius 36,--4
Radius 36,--5
Radius 36,--6
Radius 37,--7
Radius 37,--8
Radius 37,--9
Radius 39,--10
Radius 40,--11
Radius 42,--12
Radius 46,--13
Radius 53,--14
Radius 47,--15
Radius 44,--16
Radius 42,--17
Radius 41, --18 180 degrees
Radius 42, --17
Radius 44, --16
Radius 47,--15
Radius 52,--14
Radius 46,--13
Radius 43,--12
Radius 40,--11
Radius 39,--10
Radius 39,--9
Radius 38,--8
Radius 38,--7
Radius 38,--6
Radius 39,--5
Radius 39,--4
Radius 38,--3
Radius 38,--2
Radius 38,--1
Radius 38--0
]
--radius of the heel tread as measured
--oversize it by 4 mm to it goes around the outside of the heel.
treadRadius = map (\(Radius x) -> Radius (x + 4))
[Radius 38,--0
Radius 37,--1
Radius 37,--2
Radius 36,--3
Radius 34,--4
Radius 33,--5
Radius 32,--6
Radius 30,--7
Radius 30,--8
Radius 29,--9
Radius 30,--10
Radius 32,--11
Radius 35,--12
Radius 41,--13
Radius 48,--14
Radius 63,--15
Radius 67,--16
Radius 64,--17
Radius 66, --18 180 degrees
Radius 62, --17
Radius 64, --16
Radius 63,--15
Radius 47,--14
Radius 42,--13
Radius 37,--12
Radius 34,--11
Radius 33,--10
Radius 32,--9
Radius 32,--8
Radius 33,--7
Radius 34,--6
Radius 35,--5
Radius 36,--4
Radius 37,--3
Radius 37,--2
Radius 38,--1
Radius 38 --0
]
| heathweiss/Tricad | src/Examples/ShoeLift/KeenHeel.hs | gpl-2.0 | 7,935 | 0 | 11 | 1,513 | 1,746 | 1,010 | 736 | 171 | 1 |
-- https://patternsinfp.wordpress.com/2011/01/31/lenses-are-the-coalgebras-for-the-costate-comonad/
{-# LANGUAGE RankNTypes #-}
module Comonad where
import Prelude hiding ((.), id)
import Control.Category
class Functor w => Comonad w where
extract :: w a -> a
duplicate :: w a -> w (w a)
f <==> g = \x -> f x == g x
type ComonadLaw = forall a w . (Eq (w a), Eq (w (w (w a))), Comonad w)
=> w a -> Bool
law1 :: ComonadLaw
law1 = (extract . duplicate) <==> id
law2 :: ComonadLaw
law2 = (fmap extract . duplicate) <==> id
law3 :: ComonadLaw
law3 = (fmap duplicate . duplicate) <==> (duplicate . duplicate)
data CoState v a = CoState v (v -> a)
instance Functor (CoState v) where
fmap g (CoState v f) = CoState v (g . f)
instance Comonad (CoState v) where
extract (CoState v f) = f v
duplicate (CoState v f) = CoState v (\u -> CoState u f)
type CoAlgebra c a = a -> c a
type CoAlgebraComonadLaw = forall w a . (Eq a, Eq (w (w a)), Comonad w)
=> (a -> w a) -> a -> Bool
law4 :: CoAlgebraComonadLaw
law4 f = (extract . f) <==> id
law5 :: CoAlgebraComonadLaw
law5 f = (duplicate . f) <==> (fmap f . f)
-- Lenses are coalgebras of a costate comonad
{-
QUOTE:
Pierce lenses are pairs of functions between source and target data
type S and T a get function is S -> T and a source function
is a S x T -> S
The story is that the GET is some projection of the data in the source
and so in order to be able to update the source given a modify view, one
needs the original copy of the source to be able to recunstruct the missing
information.
-}
type Get s t = s -> t
type Put s t = s -> (t -> s)
type Lens' s t = (Get s t, Put s t)
type Lens'' s t = s -> (t, t -> s)
type Lens s t = s -> CoState s (t -> s)
data LensW s t = L (Lens s t)
instance Category LensW where
id = L (\s -> CoState s (const id))
(L g) . (L f) = L _
| andorp/presentations | HAL2016/Comonad.hs | gpl-3.0 | 1,905 | 0 | 13 | 480 | 690 | 375 | 315 | 38 | 1 |
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE ViewPatterns #-}
-- FIXME: Better solution for abstrTerm
{-# LANGUAGE FlexibleContexts #-}
-- |
-- Copyright : (c) 2010-2012 Benedikt Schmidt
-- License : GPL v3 (see LICENSE)
--
-- Maintainer : Benedikt Schmidt <[email protected]>
-- Portability : GHC only
--
-- Variants of protocol rules.
module Theory.Tools.RuleVariants where
import Term.Narrowing.Variants
import Term.Rewriting.Norm
import Theory.Model
import Theory.Tools.EquationStore
import Extension.Prelude
import Logic.Connectives
-- import Control.Applicative
import Control.Monad.Bind
import Control.Monad.Reader
import qualified Control.Monad.Trans.PreciseFresh as Precise
import qualified Data.Map as M
import qualified Data.Set as S
-- import Data.Traversable (traverse)
-- import Utils.Misc (stringSHA256)
-- import System.IO.Unsafe
-- import System.IO
-- import System.Directory
-- import qualified Data.Binary as B
-- import qualified Data.ByteString.Lazy as BS
import Debug.Trace.Ignore
tmpdir :: FilePath
tmpdir = "/tmp/tamarin/"
-- Variants of protocol rules
----------------------------------------------------------------------
-- | Compute the variants of a protocol rule.
-- 1. Abstract away terms in facts with variables.
-- 2. Compute variants of RHSs of equations.
-- 3. Apply variant substitutions to equations
-- to obtain DNF of equations.
-- 4. Simplify rule.
variantsProtoRule :: MaudeHandle -> ProtoRuleE -> ProtoRuleAC
variantsProtoRule hnd ru@(Rule ri prems0 concs0 acts0) =
-- rename rule to decrease variable indices
(`Precise.evalFresh` Precise.nothingUsed) . renamePrecise $ convertRule `evalFreshAvoiding` ru
where
convertRule = do
(abstrPsCsAs, bindings) <- abstrRule
let eqsAbstr = map swap (M.toList bindings)
abstractedTerms = map snd eqsAbstr
abstractionSubst = substFromList eqsAbstr
variantSubsts = computeVariantsCached (fAppList abstractedTerms) hnd
substs = [ restrictVFresh (frees abstrPsCsAs) $
removeRenamings $ ((`runReader` hnd) . normSubstVFresh') $
composeVFresh vsubst abstractionSubst
| vsubst <- variantSubsts ]
case substs of
[] -> error $ "variantsProtoRule: rule has no variants `"++show ru++"'"
_ -> do
-- x <- return (emptySubst, Just substs) --
x <- simpDisjunction hnd (const (const False)) (Disj substs)
case trace (show ("SIMP",abstractedTerms,
"abstr", abstrPsCsAs,
"substs", substs,
"simpSubsts:", x)) x of
-- the variants can be simplified to a single case
(commonSubst, Nothing) ->
return $ makeRule abstrPsCsAs commonSubst trueDisj
(commonSubst, Just freshSubsts) ->
return $ makeRule abstrPsCsAs commonSubst freshSubsts
abstrRule = (`runBindT` noBindings) $ do
-- first import all vars into binding to obtain nicer names
mapM_ abstrTerm [ varTerm v | v <- frees (prems0, concs0, acts0) ]
(,,) <$> mapM abstrFact prems0
<*> mapM abstrFact concs0
<*> mapM abstrFact acts0
irreducible = irreducibleFunSyms (mhMaudeSig hnd)
abstrFact = traverse abstrTerm
abstrTerm (viewTerm -> FApp o args) | o `S.member` irreducible =
fApp o <$> mapM abstrTerm args
abstrTerm t = do
at :: LNTerm <- varTerm <$> importBinding (`LVar` sortOfLNTerm t) t (getHint t)
return at
where getHint (viewTerm -> Lit (Var v)) = lvarName v
getHint _ = "z"
makeRule (ps, cs, as) subst freshSubsts0 =
Rule (ProtoRuleACInfo ri (Disj freshSubsts) []) prems concs acts
where prems = apply subst ps
concs = apply subst cs
acts = apply subst as
freshSubsts = map (restrictVFresh (frees (prems, concs, acts))) freshSubsts0
trueDisj = [ emptySubstVFresh ]
computeVariantsCached :: LNTerm -> MaudeHandle -> [LNSubstVFresh]
computeVariantsCached inp hnd = computeVariants inp `runReader` hnd
{-
unsafePerformIO $ do
createDirectoryIfMissing True tmpdir
let hashInput = tmpdir ++ stringSHA256 (show inp)
fEx <- doesFileExist hashInput
if fEx
then B.decodeFile hashInput
else do let result = computeVariants inp `runReader` hnd
(tmpFile,tmpHnd) <- openBinaryTempFile tmpdir "variants.tmp"
BS.hPut tmpHnd $ B.encode result
renameFile tmpFile hashInput
return result
-}
| samscott89/tamarin-prover | lib/theory/src/Theory/Tools/RuleVariants.hs | gpl-3.0 | 5,197 | 0 | 19 | 1,604 | 876 | 486 | 390 | 70 | 5 |
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE OverlappingInstances #-}
module Game.OrbRPG.Combinations where
import Game.OrbRPG.Types
import System.Random
-- Main combination function
(@>>) :: Orb -> Orb -> Orb
-- Null Combinations
_ @>> Null = Null
Null @>> Black = White
Null @>> White = Black
Null @>> _ = Null
-- White + White
White @>> White = P Red
-- White + Black
White @>> Black = P Red
-- White + Primary
White @>> P Red = L Lambda
White @>> P Green = L Mu
White @>> P Blue = L Lambda
-- White + Letter
White @>> L Lambda = G Nyx
White @>> L Mu = E Cesium
White @>> L Omega = P Blue
-- White + Element
White @>> E Deuterium = L Lambda
White @>> E Erbium = P Red
White @>> E Cesium = L Mu
-- White + God
White @>> G Nyx = E Deuterium
White @>> G Hypnos = P Red
White @>> G Thanatos = P Green
-- White + Demon
White @>> D Mammon = L Omega
White @>> D Asmodeus = E Deuterium
White @>> D Belial = L Omega
-- White + Tech
White @>> T Piston = G Nyx
White @>> T Transistor = L Omega
White @>> T Gear = E Deuterium
-- Black + White
Black @>> White = E Deuterium
-- Black + Black
Black @>> Black = L Lambda
-- Black + Primary
Black @>> P Red = L Mu
Black @>> P Green = P Red
Black @>> P Blue = E Erbium
-- Black + Letter
Black @>> L Lambda = G Nyx
Black @>> L Mu = G Nyx
Black @>> L Omega = White
-- Black + Element
Black @>> E Deuterium = P Red
Black @>> E Erbium = P Red
Black @>> E Cesium = White
-- Black + God
Black @>> G Nyx = E Erbium
Black @>> G Hypnos = E Erbium
Black @>> G Thanatos = L Lambda
-- Black + Demon
Black @>> D Mammon = P Red
Black @>> D Asmodeus = P Blue
Black @>> D Belial = P Red
-- Black + Tech
Black @>> T Piston = D Asmodeus
Black @>> T Transistor = E Cesium
Black @>> T Gear = L Mu
-- Primary + White
P Red @>> White = L Omega
P Green @>> White = E Deuterium
P Blue @>> White = E Deuterium
-- Primary + Black
P Red @>> Black = L Mu
P Green @>> Black = E Deuterium
P Blue @>> Black = E Cesium
-- Primary + Primary
P Red @>> P Red = E Deuterium
P Red @>> P Green = L Lambda
P Red @>> P Blue = E Deuterium
P Green @>> P Red = L Lambda
P Green @>> P Green = E Erbium
P Green @>> P Blue = P Red
P Blue @>> P Red = P Red
P Blue @>> P Green = White
P Blue @>> P Blue = P Blue
-- Primary + Letter
P Red @>> L Lambda = G Nyx
P Red @>> L Mu = E Deuterium
P Red @>> L Omega = P Blue
P Green @>> L Lambda = E Deuterium
P Green @>> L Mu = L Lambda
P Green @>> L Omega = L Lambda
P Blue @>> L Lambda = E Deuterium
P Blue @>> L Mu = E Deuterium
P Blue @>> L Omega = P Green
-- Primary + Element
P Red @>> E Deuterium = L Lambda
P Red @>> E Erbium = P Red
P Red @>> E Cesium = L Lambda
P Green @>> E Deuterium = L Lambda
P Green @>> E Erbium = P Green
P Green @>> E Cesium = L Omega
P Blue @>> E Deuterium = P Red
P Blue @>> E Erbium = E Erbium
P Blue @>> E Cesium = D Mammon
-- Primary + God
P Red @>> G Nyx = White
P Red @>> G Hypnos = P Green
P Red @>> G Thanatos = G Thanatos
P Green @>> G Nyx = L Omega
P Green @>> G Hypnos = D Mammon
P Green @>> G Thanatos = D Asmodeus
P Blue @>> G Nyx = E Deuterium
P Blue @>> G Hypnos = E Deuterium
P Blue @>> G Thanatos = L Mu
-- Primary + Demon
P Red @>> D Mammon = T Piston
P Red @>> D Asmodeus = P Blue
P Red @>> D Belial = L Lambda
P Green @>> D Mammon = E Deuterium
P Green @>> D Asmodeus = G Nyx
P Green @>> D Belial = P Red
P Blue @>> D Mammon = L Mu
P Blue @>> D Asmodeus = G Hypnos
P Blue @>> D Belial = E Deuterium
-- Primary + Tech
P Red @>> T Piston = D Asmodeus
P Red @>> T Transistor = E Deuterium
P Red @>> T Gear = G Hypnos
P Green @>> T Piston = L Lambda
P Green @>> T Transistor = P Green
P Green @>> T Gear = D Belial
P Blue @>> T Piston = G Thanatos
P Blue @>> T Transistor = P Red
P Blue @>> T Gear = T Transistor
-- Letter + White
L Lambda @>> White = L Mu
L Mu @>> White = P Blue
L Omega @>> White = G Nyx
-- Letter + Black
L Lambda @>> Black = P Red
L Mu @>> Black = White
L Omega @>> Black = P Red
-- Letter + Primary
L Lambda @>> P Red = E Deuterium
L Lambda @>> P Green = G Nyx
L Lambda @>> P Blue = L Lambda
L Mu @>> P Red = P Red
L Mu @>> P Green = G Nyx
L Mu @>> P Blue = P Red
L Omega @>> P Red = P Green
L Omega @>> P Green = L Lambda
L Omega @>> P Blue = E Erbium
-- Letter + Letter
L Lambda @>> L Lambda = L Lambda
L Lambda @>> L Mu = E Cesium
L Lambda @>> L Omega = L Omega
L Mu @>> L Lambda = G Hypnos
L Mu @>> L Mu = L Lambda
L Mu @>> L Omega = L Mu
L Omega @>> L Lambda = G Nyx
L Omega @>> L Mu = P Green
L Omega @>> L Omega = P Red
-- Letter + Element
L Lambda @>> E Deuterium = P Red
L Lambda @>> E Erbium = E Deuterium
L Lambda @>> E Cesium = L Lambda
L Mu @>> E Deuterium = G Hypnos
L Mu @>> E Erbium = L Omega
L Mu @>> E Cesium = G Nyx
L Omega @>> E Deuterium = P Green
L Omega @>> E Erbium = Black
L Omega @>> E Cesium = D Mammon
-- Letter + God
L Lambda @>> G Nyx = L Lambda
L Lambda @>> G Hypnos = D Asmodeus
L Lambda @>> G Thanatos = E Deuterium
L Mu @>> G Nyx = E Erbium
L Mu @>> G Hypnos = E Deuterium
L Mu @>> G Thanatos = E Deuterium
L Omega @>> G Nyx = D Belial
L Omega @>> G Hypnos = White
L Omega @>> G Thanatos = D Mammon
-- Letter + Demon
L Lambda @>> D Mammon = D Asmodeus
L Lambda @>> D Asmodeus = L Lambda
L Lambda @>> D Belial = L Lambda
L Mu @>> D Mammon = P Green
L Mu @>> D Asmodeus = P Red
L Mu @>> D Belial = D Mammon
L Omega @>> D Mammon = T Piston
L Omega @>> D Asmodeus = L Mu
L Omega @>> D Belial = T Transistor
-- Letter + Tech
L Lambda @>> T Piston = P Red
L Lambda @>> T Transistor = L Lambda
L Lambda @>> T Gear = E Deuterium
L Mu @>> T Piston = P Blue
L Mu @>> T Transistor = P Red
L Mu @>> T Gear = D Asmodeus
L Omega @>> T Piston = White
L Omega @>> T Transistor = L Lambda
L Omega @>> T Gear = White
-- Element + White
E Deuterium @>> White = L Mu
E Erbium @>> White = Black
E Cesium @>> White = E Erbium
-- Element + Black
E Deuterium @>> Black = L Lambda
E Erbium @>> Black = L Mu
E Cesium @>> Black = D Mammon
-- Element + Primary
E Deuterium @>> P Red = G Nyx
E Deuterium @>> P Green = L Mu
E Deuterium @>> P Blue = G Nyx
E Erbium @>> P Red = L Mu
E Erbium @>> P Green = White
E Erbium @>> P Blue = E Deuterium
E Cesium @>> P Red = Black
E Cesium @>> P Green = L Lambda
E Cesium @>> P Blue = P Red
-- Element + Letter
E Deuterium @>> L Lambda = P Blue
E Deuterium @>> L Mu = L Lambda
E Deuterium @>> L Omega = E Erbium
E Erbium @>> L Lambda = E Cesium
E Erbium @>> L Mu = L Lambda
E Erbium @>> L Omega = L Mu
E Cesium @>> L Lambda = P Green
E Cesium @>> L Mu = L Mu
E Cesium @>> L Omega = L Lambda
-- Element + Element
E Deuterium @>> E Deuterium = E Erbium
E Deuterium @>> E Erbium = Black
E Deuterium @>> E Cesium = G Nyx
E Erbium @>> E Deuterium = L Mu
E Erbium @>> E Erbium = L Mu
E Erbium @>> E Cesium = P Red
E Cesium @>> E Deuterium = L Lambda
E Cesium @>> E Erbium = P Red
E Cesium @>> E Cesium = P Red
-- Element + God
E Deuterium @>> G Nyx = E Cesium
E Deuterium @>> G Hypnos = P Green
E Deuterium @>> G Thanatos = P Green
E Erbium @>> G Nyx = L Mu
E Erbium @>> G Hypnos = G Thanatos
E Erbium @>> G Thanatos = P Red
E Cesium @>> G Nyx = D Asmodeus
E Cesium @>> G Hypnos = G Nyx
E Cesium @>> G Thanatos = P Green
-- Element + Demon
E Deuterium @>> D Mammon = L Lambda
E Deuterium @>> D Asmodeus = E Deuterium
E Deuterium @>> D Belial = D Asmodeus
E Erbium @>> D Mammon = Black
E Erbium @>> D Asmodeus = E Erbium
E Erbium @>> D Belial = D Mammon
E Cesium @>> D Mammon = E Erbium
E Cesium @>> D Asmodeus = G Thanatos
E Cesium @>> D Belial = E Deuterium
-- Element + Tech
E Deuterium @>> T Piston = Black
E Deuterium @>> T Transistor = P Red
E Deuterium @>> T Gear = G Nyx
E Erbium @>> T Piston = P Red
E Erbium @>> T Transistor = P Red
E Erbium @>> T Gear = E Deuterium
E Cesium @>> T Piston = P Red
E Cesium @>> T Transistor = Black
E Cesium @>> T Gear = E Deuterium
-- God + White
G Nyx @>> White = G Nyx
G Hypnos @>> White = P Red
G Thanatos @>> White = L Lambda
-- God + Black
G Nyx @>> Black = G Nyx
G Hypnos @>> Black = E Deuterium
G Thanatos @>> Black = P Red
-- God + Primary
G Nyx @>> P Red = D Mammon
G Nyx @>> P Green = Black
G Nyx @>> P Blue = L Lambda
G Hypnos @>> P Red = E Cesium
G Hypnos @>> P Green = G Nyx
G Hypnos @>> P Blue = D Asmodeus
G Thanatos @>> P Red = L Lambda
G Thanatos @>> P Green = L Lambda
G Thanatos @>> P Blue = P Red
-- God + Letter
G Nyx @>> L Lambda = T Transistor
G Nyx @>> L Mu = D Mammon
G Nyx @>> L Omega = White
G Hypnos @>> L Lambda = White
G Hypnos @>> L Mu = G Nyx
G Hypnos @>> L Omega = G Nyx
G Thanatos @>> L Lambda = D Belial
G Thanatos @>> L Mu = D Asmodeus
G Thanatos @>> L Omega = T Piston
-- God + Element
G Nyx @>> E Deuterium = E Deuterium
G Nyx @>> E Erbium = D Mammon
G Nyx @>> E Cesium = P Red
G Hypnos @>> E Deuterium = E Deuterium
G Hypnos @>> E Erbium = P Blue
G Hypnos @>> E Cesium = P Red
G Thanatos @>> E Deuterium = E Deuterium
G Thanatos @>> E Erbium = L Mu
G Thanatos @>> E Cesium = P Red
-- God + God
G Nyx @>> G Nyx = P Green
G Nyx @>> G Hypnos = E Deuterium
G Nyx @>> G Thanatos = L Lambda
G Hypnos @>> G Nyx = L Omega
G Hypnos @>> G Hypnos = E Deuterium
G Hypnos @>> G Thanatos = L Lambda
G Thanatos @>> G Nyx = L Lambda
G Thanatos @>> G Hypnos = D Mammon
G Thanatos @>> G Thanatos = L Mu
-- God + Demon
G Nyx @>> D Mammon = L Omega
G Nyx @>> D Asmodeus = P Red
G Nyx @>> D Belial = Black
G Hypnos @>> D Mammon = P Red
G Hypnos @>> D Asmodeus = T Transistor
G Hypnos @>> D Belial = G Nyx
G Thanatos @>> D Mammon = L Mu
G Thanatos @>> D Asmodeus = E Erbium
G Thanatos @>> D Belial = T Gear
-- God + Tech
G Nyx @>> T Piston = L Lambda
G Nyx @>> T Transistor = P Green
G Nyx @>> T Gear = T Transistor
G Hypnos @>> T Piston = P Red
G Hypnos @>> T Transistor = P Blue
G Hypnos @>> T Gear = P Blue
G Thanatos @>> T Piston = D Asmodeus
G Thanatos @>> T Transistor = G Nyx
G Thanatos @>> T Gear = E Erbium
-- Demon + White
D Mammon @>> White = G Hypnos
D Asmodeus @>> White = L Omega
D Belial @>> White = P Red
-- Demon + Black
D Mammon @>> Black = T Piston
D Asmodeus @>> Black = E Erbium
D Belial @>> Black = G Hypnos
-- Demon + Primary
D Mammon @>> P Red = L Omega
D Mammon @>> P Green = P Red
D Mammon @>> P Blue = P Blue
D Asmodeus @>> P Red = E Cesium
D Asmodeus @>> P Green = L Mu
D Asmodeus @>> P Blue = E Erbium
D Belial @>> P Red = G Nyx
D Belial @>> P Green = P Red
D Belial @>> P Blue = Black
-- Demon + Letter
D Mammon @>> L Lambda = P Red
D Mammon @>> L Mu = G Hypnos
D Mammon @>> L Omega = L Omega
D Asmodeus @>> L Lambda = E Erbium
D Asmodeus @>> L Mu = G Nyx
D Asmodeus @>> L Omega = G Nyx
D Belial @>> L Lambda = L Mu
D Belial @>> L Mu = D Asmodeus
D Belial @>> L Omega = P Red
-- Demon + Element
D Mammon @>> E Deuterium = L Mu
D Mammon @>> E Erbium = E Erbium
D Mammon @>> E Cesium = E Cesium
D Asmodeus @>> E Deuterium = P Green
D Asmodeus @>> E Erbium = P Red
D Asmodeus @>> E Cesium = G Nyx
D Belial @>> E Deuterium = G Nyx
D Belial @>> E Erbium = G Hypnos
D Belial @>> E Cesium = P Green
-- Demon + God
D Mammon @>> G Nyx = Black
D Mammon @>> G Hypnos = D Asmodeus
D Mammon @>> G Thanatos = P Green
D Asmodeus @>> G Nyx = D Belial
D Asmodeus @>> G Hypnos = D Asmodeus
D Asmodeus @>> G Thanatos = Black
D Belial @>> G Nyx = G Nyx
D Belial @>> G Hypnos = White
D Belial @>> G Thanatos = Black
-- Demon + Demon
D Mammon @>> D Mammon = G Thanatos
D Mammon @>> D Asmodeus = P Green
D Mammon @>> D Belial = L Mu
D Asmodeus @>> D Mammon = T Transistor
D Asmodeus @>> D Asmodeus = E Erbium
D Asmodeus @>> D Belial = P Red
D Belial @>> D Mammon = P Green
D Belial @>> D Asmodeus = G Thanatos
D Belial @>> D Belial = P Red
-- Demon + Tech
D Mammon @>> T Piston = L Lambda
D Mammon @>> T Transistor = E Cesium
D Mammon @>> T Gear = L Omega
D Asmodeus @>> T Piston = L Lambda
D Asmodeus @>> T Transistor = E Erbium
D Asmodeus @>> T Gear = D Mammon
D Belial @>> T Piston = L Mu
D Belial @>> T Transistor = L Lambda
D Belial @>> T Gear = L Omega
-- Tech + White
T Piston @>> White = L Mu
T Transistor @>> White = G Hypnos
T Gear @>> White = P Red
-- Tech + Black
T Piston @>> Black = L Mu
T Transistor @>> Black = G Nyx
T Gear @>> Black = E Cesium
-- Tech + Primary
T Piston @>> P Red = L Mu
T Piston @>> P Green = P Green
T Piston @>> P Blue = G Nyx
T Transistor @>> P Red = L Lambda
T Transistor @>> P Green = D Asmodeus
T Transistor @>> P Blue = L Mu
T Gear @>> P Red = L Omega
T Gear @>> P Green = T Piston
T Gear @>> P Blue = P Red
-- Tech + Letter
T Piston @>> L Lambda = G Nyx
T Piston @>> L Mu = E Erbium
T Piston @>> L Omega = L Lambda
T Transistor @>> L Lambda = L Mu
T Transistor @>> L Mu = G Nyx
T Transistor @>> L Omega = P Blue
T Gear @>> L Lambda = L Lambda
T Gear @>> L Mu = G Nyx
T Gear @>> L Omega = D Mammon
-- Tech + Element
T Piston @>> E Deuterium = L Omega
T Piston @>> E Erbium = L Omega
T Piston @>> E Cesium = L Mu
T Transistor @>> E Deuterium = E Cesium
T Transistor @>> E Erbium = G Nyx
T Transistor @>> E Cesium = D Asmodeus
T Gear @>> E Deuterium = L Lambda
T Gear @>> E Erbium = E Erbium
T Gear @>> E Cesium = P Blue
-- Tech + God
T Piston @>> G Nyx = G Hypnos
T Piston @>> G Hypnos = L Lambda
T Piston @>> G Thanatos = L Mu
T Transistor @>> G Nyx = G Hypnos
T Transistor @>> G Hypnos = L Lambda
T Transistor @>> G Thanatos = P Red
T Gear @>> G Nyx = T Piston
T Gear @>> G Hypnos = D Mammon
T Gear @>> G Thanatos = T Piston
-- Tech + Demon
T Piston @>> D Mammon = L Lambda
T Piston @>> D Asmodeus = G Nyx
T Piston @>> D Belial = E Deuterium
T Transistor @>> D Mammon = D Asmodeus
T Transistor @>> D Asmodeus = P Red
T Transistor @>> D Belial = L Mu
T Gear @>> D Mammon = T Transistor
T Gear @>> D Asmodeus = D Asmodeus
T Gear @>> D Belial = T Gear
-- Tech + Tech
T Piston @>> T Piston = E Cesium
T Piston @>> T Transistor = G Nyx
T Piston @>> T Gear = E Deuterium
T Transistor @>> T Piston = E Deuterium
T Transistor @>> T Transistor = E Deuterium
T Transistor @>> T Gear = White
T Gear @>> T Piston = G Nyx
T Gear @>> T Transistor = L Lambda
T Gear @>> T Gear = G Nyx
-- Finally done!
-- Expands a single element into its neighbors in their respective probabilities
-- This implicitly holds the intra Orb-type rarity
xpand :: (Enum a, Bounded a) => a -> [a]
xpand _ = [a',a',a',b,b,c]
where
a' = minBound
b = succ a'
c = succ b
xpand' :: (Orbable a, Enum a, Bounded a) => Int -> a -> [Orb]
xpand' n = map o . concat . replicate n . xpand
-- These are the individual Orb type probabilities
pp :: [Orb]
pp = xpand' 12 (minBound :: Primary)
ll :: [Orb]
ll = xpand' 10 (minBound :: Letter)
ee :: [Orb]
ee = xpand' 8 (minBound :: Element)
gg :: [Orb]
gg = xpand' 6 (minBound :: God)
dd :: [Orb]
dd = xpand' 4 (minBound :: Demon)
tt :: [Orb]
tt = xpand' 2 (minBound :: Tech)
orbProbList :: [Orb]
orbProbList = concat [[White],[Black],pp,ll,ee,gg,dd,tt]
randElem :: (RandomGen g) => [a] -> g -> (a,g)
randElem as g = (as !! i,g')
where
len = length as
(i,g') = randomR (0, len - 1) g
instance Random Primary where
randomR (a,z) g = (toEnum (retval `mod` 3 ),g')
where (retval,g') = randomR (fromEnum a ,fromEnum z ) g
random = randElem $ xpand Red
instance Random Letter where
randomR (a,z) g = (toEnum (retval `mod` 3 ),g')
where (retval,g') = randomR (fromEnum a ,fromEnum z ) g
random = randElem $ xpand Lambda
instance Random Element where
randomR (a,z) g = (toEnum (retval `mod` 3 ),g')
where (retval,g') = randomR (fromEnum a ,fromEnum z ) g
random = randElem $ xpand Deuterium
instance Random God where
randomR (a,z) g = (toEnum (retval `mod` 3 ),g')
where (retval,g') = randomR (fromEnum a ,fromEnum z ) g
random = randElem $ xpand Nyx
instance Random Demon where
randomR (a,z) g = (toEnum (retval `mod` 3 ),g')
where (retval,g') = randomR (fromEnum a ,fromEnum z ) g
random = randElem $ xpand Mammon
instance Random Tech where
randomR (a,z) g = (toEnum (retval `mod` 3 ),g')
where (retval,g') = randomR (fromEnum a ,fromEnum z ) g
random = randElem $ xpand Piston
instance Random Orb where
randomR (a,z) g = (toEnum (retval `mod` 21 ),g')
where (retval,g') = randomR (fromEnum a ,fromEnum z ) g
random = randElem orbProbList
class Orbable a where
o :: a -> Orb
instance Orbable Primary where
o = P
instance Orbable Letter where
o = L
instance Orbable Element where
o = E
instance Orbable God where
o = G
instance Orbable Demon where
o = D
instance Orbable Tech where
o = T
instance Orbable Orb where
o = id
data OrbTree a = OrbNode {orb :: Orb
,attr :: a
,cLeft :: OrbTree a
,cRight :: OrbTree a
}
| OrbLeaf {orb :: Orb
,attr :: a}
combinate :: (Orb -> a -> a -> a) -> OrbTree a -> OrbTree a -> OrbTree a
combinate f xx yy =
OrbNode{orb = combined
,attr = f combined (attr xx) (attr yy)
,cLeft = xx
,cRight = yy}
where
combined :: Orb
combined = orb xx @>> orb yy
-- | For a given orb type, gives the calculation of its damage types and points
-- towards that type
baseEnergy :: Orb -> [Damage]
baseEnergy = doitup
where
go :: (Enum a) => a -> EnergyType -> EnergyType -> [Damage]
go a e1 e2 = [Dmg (fromEnum a) e1, Dmg (fromEnum a) e2]
doitup Null = []
doitup White = []
doitup Black = []
doitup (P p) = go p Abstract Physical
doitup (L l) = go l Abstract Symbol
doitup (E e) = go e Physical Symbol
doitup (G g) = go g Spiritual Progress
doitup (D d) = go d Spiritual Regress
doitup (T t) = go t Progress Regress
| deontologician/orbRPG | Game/OrbRPG/Combinations.hs | gpl-3.0 | 17,672 | 0 | 11 | 4,600 | 9,372 | 4,045 | 5,327 | 507 | 9 |
{--
.. Notation is important as per this link:
exporting data constructors: http://en.wikibooks.org/wiki/Haskell/Modules.
--}
module Login(Login (..),
Email,
Name,
getLoginEmail,
empty)
where
import Control.Monad.State
import Control.Monad.Reader
import qualified Control.Applicative as C
import qualified Data.Acid as A
import Data.Acid.Remote
import Data.SafeCopy
import Data.Typeable
import qualified Data.Map as M
import qualified Data.Aeson as J
import qualified Data.Text.Lazy.Encoding as E
import qualified Data.Text.Lazy as L
import Data.Time.Clock
import GHC.Generics
import Control.Exception
type Email = String
type Name = String
data Login = Login{email :: Email, verified :: Bool}
deriving (Show, Generic, Typeable, Eq, Ord)
instance J.ToJSON Login
instance J.FromJSON Login
empty = Login {email = "", verified = False}
create = Login
verify :: Login -> Login
verify aLogin = aLogin {verified = True}
getLoginEmail = email
$(deriveSafeCopy 0 'base ''Login)
| dservgun/erp | src/common/Login.hs | gpl-3.0 | 1,038 | 0 | 8 | 196 | 266 | 166 | 100 | -1 | -1 |
{-|
Module : Devel.Config
Description : To have wai-devel depend on it's environment a lot less.
Copyright : (c)
License : GPL-3
Maintainer : [email protected]
Stability : experimental
Portability : POSIX
Currently we'll query for this information from the stack binary.
Ideal case it to use the stack library to figure out depends and stuff.
Depending on the stack library causes a breakage in the dependecy tree.
As of now I can't find a single function (or set of functions) that fetches this information from stack.
Closest thing is in the stack Main module.
Will be rewritten to depend on the stack library.
-}
module Devel.Config (setConfig) where
import System.Process (readProcessWithExitCode)
import System.Environment (unsetEnv, setEnv)
import System.Exit (ExitCode(..))
setConfig :: IO ()
setConfig = do
(path, pkgDb) <- getConfig
_ <- unsetEnv "PATH"
_ <- unsetEnv "GHC_PACKAGE_PATH"
_ <- setEnv "PATH" path
setEnv "GHC_PACKAGE_PATH" pkgDb
type PATH = String
type PACKAGEDB = String
type Config = (PATH, PACKAGEDB)
getConfig :: IO Config
getConfig = do
(exitCode, stdout, stderr) <- readProcessWithExitCode "stack" ["path"] ""
case exitCode of
ExitSuccess -> parseConfig stdout
ExitFailure _ -> fail stderr
where
parseConfig :: String -> IO Config
parseConfig stdout = do
let outputList = lines stdout
tupleList = map (span (/=':') ) outputList
path = concatMap getPath tupleList
pkgDb = concatMap getPkgDb tupleList ++ ":"
return (path, pkgDb)
getPath :: (String, String) -> String
getPath (key,value)
| key == "bin-path" = dropWhile (==':') $ filter (/=' ') value
| otherwise = ""
getPkgDb :: (String, String) -> String
getPkgDb (key,value)
| key == "snapshot-pkg-db" = dropWhile (==':') $ filter (/=' ') value
| otherwise = ""
| bitemyapp/wai-devel | src/Devel/Config.hs | gpl-3.0 | 1,892 | 0 | 15 | 419 | 434 | 228 | 206 | 35 | 2 |
module Data.XDR.Parser
( LanguageOptions (..)
, parseString
, parseFile
, ParseError
) where
import Control.Applicative hiding (many, (<|>))
import Control.Arrow
import Control.Monad
import Control.Monad.Identity
import Control.Monad.Trans
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.Foldable hiding (concat)
import Data.List
import Data.Map (Map)
import qualified Data.Map as M
import Data.Maybe
import Data.Set (Set)
import qualified Data.Set as S
import System.Path
import Text.Parsec hiding (ParseError)
import Text.Parsec.ByteString hiding (Parser)
import Text.Parsec.Token (makeTokenParser, GenLanguageDef (..))
import qualified Text.Parsec.Token as T
import Text.Parsec.Expr
import Data.XDR.AST
import Data.XDR.PathUtils
-- | Lexer
l :: (Monad m) => T.GenTokenParser ByteString Context m
l = makeTokenParser
LanguageDef { commentStart = "/*"
, commentEnd = "*/"
, commentLine = "//"
, nestedComments = True
, identStart = letter
, identLetter = alphaNum <|> char '_'
, opStart = oneOf "+-/*=."
, opLetter = oneOf "+-/*=."
, reservedNames = tokens
, reservedOpNames = ["+", "-", "/", "*", "=", "."]
, caseSensitive = True
}
where
tokens = [ "bool", "case", "const", "default", "double", "quadruple", "enum"
, "float", "hyper", "opaque", "string", "struct", "switch", "typedef"
, "union", "unsigned", "void", "int", "import", "module"
]
angles, braces, parens, squares :: (Monad m) => Parser m a -> Parser m a
angles = T.angles l
braces = T.braces l
parens = T.parens l
squares = T.squares l
colon, comma, semi :: (Monad m) => Parser m String
colon = T.colon l
comma = T.comma l
semi = T.semi l
commaSep, commaSep1 :: (Monad m) => Parser m a -> Parser m [a]
commaSep = T.commaSep l
commaSep1 = T.commaSep1 l
identifier :: (Monad m) => Parser m String
identifier = T.identifier l
integer :: (Monad m) => Parser m Integer
integer = T.integer l
reserved, reservedOp :: (Monad m) => String -> Parser m ()
reserved = T.reserved l
reservedOp = T.reservedOp l
stringLiteral :: (Monad m) => Parser m String
stringLiteral = T.stringLiteral l
whiteSpace :: (Monad m) => Parser m ()
whiteSpace = T.whiteSpace l
-- | Extensions to the basic XDR language can be turned on with these options.
data LanguageOptions =
-- | Allows the caller to predefine some constant values. e.g. True == 1
Defines { constantDefinitions :: [(String, Integer)] }
-- | Turns on the imports extension. Imported files are searched
-- for in the directories given.
| Imports { importDirs :: [AbsDir] }
deriving (Show, Eq)
-- | Trivial error type
newtype ParseError = ParseError String
instance Show ParseError where
show (ParseError str) = str
-- | Parse a string. The Imports language extension is not available
-- via this parser since it doesn't run in the IO Monad (fix this).
parseString :: [LanguageOptions] -> ByteString -> String -> Either [ParseError] Specification
parseString options txt source =
case runParser specification (initContext defines) source txt of
Left err -> Left [ParseError . show $ err]
Right spec -> Right spec
where
defines = concat [cs | (Defines cs) <- options]
-- | Parse a file. The Imports language extension is available.
parseFile :: [LanguageOptions] -> AbsFile -> IO (Either [ParseError] Specification)
parseFile options path =
parseImportSpecification defines includes path
where
defines = concat [cs | (Defines cs) <- options]
includes = concat [cs | (Imports cs) <- options]
{- do
input <- B.readFile path'
return $ parseString options input path'
where
path' = getPathString' path
-}
data ImportSpec = ImportSpec [RelFile] [Definition]
-- FIXME: using ExceptionT IO would simplify this
parseImportSpecification :: [(String, Integer)] -> [AbsDir] -> AbsFile -> IO (Either [ParseError] Specification)
parseImportSpecification defines includes path = do
txt <- B.readFile path'
result <- runParserT (importSpec includes) (initContext defines) path' txt
case result of
Left errs -> return $ Left [ParseError . show $ errs]
Right ispec -> return $ Right ispec
where
path' = getPathString' path
data Context = Context { constTable :: Map String ConstExpr
, nextEnum :: Integer
}
initContext :: [(String, Integer)] -> Context
initContext defines = Context (M.fromList . map (second ConstLit) $ defines) 0
-- type Parser = GenParser Char Context
type Parser = ParsecT ByteString Context
constPrim :: (Monad m) => Parser m ConstExpr
constPrim = (ConstLit <$> integer)
<|> (ConstLit <$> boolean)
<|> (findReference =<< identifier)
-- 3.4 Boolean
-- Interpret TRUE and FALSE as const-literals.
boolean :: (Monad m) => Parser m Integer
boolean = (1 <$ string "TRUE") <|> (0 <$ string "FALSE")
findReference :: (Monad m) => String -> Parser m ConstExpr
findReference n = do
c <- getState
case M.lookup n (constTable c) of
Nothing -> unexpected $ "unknown constant '" ++ n ++ "'"
Just e -> return . ConstRef . ConstantDef n $ e
-- Operator Precedence:
-- Unary: + - ~
-- Multiplicative: * / %
-- Additive: + -
-- Shift: << >>
-- Bitwise AND: &
-- Bitwise XOR: ^
-- Bitwise OR: |
constExpr :: (Monad m) => Parser m ConstExpr
constExpr = buildExpressionParser table term
where
table = [ [ prefix "+" id
, prefix "-" (ConstUnExpr NEG)
, prefix "~" (ConstUnExpr NOT)
]
, [ binary "*" (ConstBinExpr MUL) AssocLeft
, binary "/" (ConstBinExpr DIV) AssocLeft
, binary "%" (ConstBinExpr MOD) AssocLeft
]
, [ binary "+" (ConstBinExpr ADD) AssocLeft
, binary "-" (ConstBinExpr SUB) AssocLeft
]
, [ binary "<<" (ConstBinExpr SHL) AssocLeft
, binary ">>" (ConstBinExpr SHR) AssocLeft
]
, [ binary "&" (ConstBinExpr AND) AssocLeft
]
, [ binary "^" (ConstBinExpr XOR) AssocLeft
]
, [ binary "|" (ConstBinExpr OR) AssocLeft
]
]
prefix name fun = Prefix (mkOp name fun)
binary name fun = Infix (mkOp name fun)
mkOp name fun = reservedOp name *> pure fun
term = constPrim <|> parens constExpr
simpleType :: (Monad m) => String -> Type -> Parser m Type
simpleType keyword t = const t <$> try (reserved keyword)
typeSpec :: (Monad m) => Parser m Type
typeSpec = choice [ try (reserved "unsigned" *> (simpleType "int" TUInt <|> simpleType "hyper" TUHyper))
, simpleType "int" TInt
, simpleType "hyper" THyper
, simpleType "float" TFloat
, simpleType "double" TDouble
, simpleType "quadruple" TQuadruple
, simpleType "bool" TBool
, try enumTypeSpec
, try structTypeSpec
, try unionTypeSpec
, TTypedef <$> identifier
] <?> "type"
enumTypeSpec :: (Monad m) => Parser m Type
enumTypeSpec = TEnum <$> (reserved "enum" *> enumDetail)
enumDetail :: (Monad m) => Parser m EnumDetail
enumDetail = setNextEnum 0 *> braces body
where
body = EnumDetail <$> commaSep pair
pair = do
n <- identifier
mc <- optionMaybe (reservedOp "=" *> constExpr)
mkElem n mc
setNextEnum n = do
ctxt <- getState
setState $ ctxt { nextEnum = n }
incNextEnum = do
ctxt <- getState
let v = nextEnum ctxt
setState $ ctxt { nextEnum = succ v }
return v
mkElem n Nothing = incNextEnum >>= insertConst n . ConstLit
mkElem n (Just e) =
let v = evalConstExpr e in (setNextEnum (v + 1)) *> insertConst n e
insertConst name e = do
ctxt <- getState
let table = constTable ctxt
-- maybe the constant has already been defined ? We only
-- complain if they're trying to give it a different value.
case M.lookup name table of
Nothing -> insert name e table ctxt
Just v' -> unexpected . concat $ [ "multiple definitions for "
, name
]
pure $ ConstantDef name e
where
insert name v table ctxt = setState $ ctxt { constTable = M.insert name v table }
structTypeSpec :: (Monad m) => Parser m Type
structTypeSpec = TStruct <$> (reserved "struct" *> structDetail)
structDetail :: (Monad m) => Parser m StructDetail
structDetail = braces body
where body = StructDetail <$> many1 (declaration <* semi)
unionTypeSpec :: (Monad m) => Parser m Type
unionTypeSpec = TUnion <$> (reserved "union" *> unionDetail)
infixl 4 <*-*>
(<*-*>) :: (Applicative f) => f (a -> b -> c) -> f (a, b) -> f c
(<*-*>) fn fab = uncurry <$> fn <*> fab
unionDetail :: (Monad m) => Parser m UnionDetail
unionDetail = UnionDetail <$> switch <*-*> braces ((,) <$> caseStatements <*> deflt)
where
switch = reserved "switch" *> parens declaration
caseStatements = many1 caseStatement
caseStatement = (,) <$> (reserved "case" *> constExpr <* colon) <*> declaration <* semi
deflt = optionMaybe (reserved "default" *> colon *> declaration <* semi)
declaration :: (Monad m) => Parser m Decl
declaration =
choice [ pure DeclVoid <* reserved "void"
, try (mkString <$> (reserved "string" *> identifier) <*> angles (optionMaybe constExpr))
, (reserved "opaque" *> identifier) >>= mkOpaque
, typeSpec >>= mkBasicOrPointer
] <?> "declaration"
where
mkBasicOrPointer :: (Monad m) => Type -> Parser m Decl
mkBasicOrPointer t = choice [ mkPointer t <$> (reservedOp "*" *> identifier)
, identifier >>= mkBasic t
]
mkBasic :: (Monad m) => Type -> String -> Parser m Decl
mkBasic t n = choice [ mkArray t n <$> squares constExpr
, mkVarArray t n <$> angles (optionMaybe constExpr)
, pure (mkSimple t n)
]
mkOpaque :: (Monad m) => String -> Parser m Decl
mkOpaque n = choice [ mkFixedOpaque n <$> squares constExpr
, mkVarOpaque n <$> angles (optionMaybe constExpr)
]
mkSimple t n = Decl n $ DeclSimple t
mkArray t n = Decl n . DeclArray t
mkVarArray t n = Decl n . DeclVarArray t
mkFixedOpaque n = Decl n . DeclOpaque
mkVarOpaque n = Decl n . DeclVarOpaque
mkString n = Decl n . DeclString
mkPointer t n = Decl n $ DeclPointer t
constantDef :: (Monad m) => Parser m ConstantDef
constantDef = ((,) <$> (reserved "const" *> identifier <* reservedOp "=") <*> constExpr) >>= uncurry insertConst
typeDef :: (Monad m) => Parser m Typedef
typeDef = choice [ mkSimple <$> (reserved "typedef" *> declaration)
, mkEnum <$> (reserved "enum" *> identifier) <*> enumDetail
, mkStruct <$> (reserved "struct" *> identifier) <*> structDetail
, mkUnion <$> (reserved "union" *> identifier) <*> unionDetail
] <?> "typedef"
where
mkSimple (Decl n di) = Typedef n $ DefSimple di
mkSimple _ = error "internal error" -- FIXME: get rid of this
mkEnum n = Typedef n . DefEnum
mkStruct n = Typedef n . DefStruct
mkUnion n = Typedef n . DefUnion
definition :: (Monad m) => Parser m Definition
definition = ((DefConstant <$> constantDef) <|> (DefTypedef <$> typeDef)) <* semi
withInput :: ByteString -> Parser IO a -> Parser IO a
withInput new p = do
old <- getInput
oldCtxt <- getState
setInput new
r <- p
setInput old
putState oldCtxt
return r
module' :: (Monad m) => Parser m Module
module' = Module <$> sepBy1 segment (reservedOp ".")
where
segment = (:) <$> letter <*> many (alphaNum <|> char '_')
moduleStatement :: (Monad m) => Parser m Module
moduleStatement = reserved "module" *> module' <* semi
moduleToRelFile :: Module -> RelFile
moduleToRelFile (Module elements) =
((Data.List.foldl (</>) (asRelDir "") . map asRelDir $ prefix) </>
(asRelFile file)) <.> "xdr"
where
prefix = reverse . tail . reverse $ elements
file = head . reverse $ elements
importStatement :: [AbsDir] -> Parser IO ((Module, Specification), Context)
importStatement includes = do
mod <- reserved "import" *> module' <* semi
let path = moduleToRelFile mod
mpath <- liftIO $ pathLookup includes path
case mpath of
Nothing -> unexpected $ "couldn't find import '" ++ getPathString' path ++ "'"
Just path' -> do
let pathTxt = getPathString' path'
txt <- liftIO $ B.readFile pathTxt
withInput txt ((\s c -> ((mod, s), c)) <$> importSpec includes <*> getState)
-- An xdr file that contains imports
importSpec :: [AbsDir] -> Parser IO Specification
importSpec includes = do
ctxt <- getState
mod <- whiteSpace *> moduleStatement
specs <- whiteSpace *> many (importStatement includes)
-- we need to combine all the contexts generated by the imports.
ctxt' <- foldrM combineImports ctxt . map snd $ specs
-- parse the rest of the file in this new uber context
putState ctxt'
Specification _ _ defs <- specification
return $ Specification mod (M.fromList . map fst $ specs) defs
combineImports :: Context -> Context -> Parser IO Context
combineImports (Context m1 _) (Context m2 _) = return $ Context (M.union m1 m2) 0
-- FIXME: any defines passed in from the command line will appear as duplicates, so the following code needs updating
-- if not . null $ duplicates
-- then fail $ "duplicate constant definitions: " ++ show duplicates
-- else return $ Context (M.union m1 m2) 0
-- where
-- duplicates = M.toList $ M.intersection m1 m2
specification :: (Monad m) => Parser m Specification
specification = Specification (Module ["global"]) M.empty <$> (whiteSpace *> many definition <* eof)
---------------------------------------------------------------- | jthornber/xdrgen | Data/XDR/Parser.hs | gpl-3.0 | 14,479 | 0 | 19 | 4,033 | 4,297 | 2,239 | 2,058 | 272 | 2 |
module Dep.Algorithms.Seq (
overLabel,labelHead,reduceFSM,overFSM,concatFSM,headFSM,concatReduceFSM,
graySequence
) where
import Data.BitVector
import Data.Function (flip)
import Data.Hashable (Hashable(..))
import qualified Data.HashMap.Strict as HM
import Data.List(intersperse,find)
import Data.Word(Word64)
import Debug.Trace(trace)
import Dep.Algorithms
import Dep.Structures
import Dep.Utils(fixpoint,singleGroupBy,grayInc,hashItemLists)
graySequence :: Int -> [BitVector]
graySequence n = rs
where r0 = 0 :: Word64
gi = grayInc n
bv = bitVec n
rs = bv r0 : cgs (gi r0)
cgs ri | ri /= 0 = bv ri : cgs (gi ri)
| otherwise = []
overLabel :: (a -> b) -> FSMState a -> FSMState b
overLabel f (Label x) = Label (f x)
overLabel _ DontCare = DontCare
labelHead :: FSMState [a] -> FSMState a
labelHead = overLabel head
instance (Eq st,Hashable st,Ord ot) => Reduceable (FSM st it ot) where
reduce = headFSM . reduceFSM
concatReduceFSM :: (Eq st,Hashable st,Ord ot) => FSM [st] it ot -> FSM [st] it ot
concatReduceFSM = concatFSM . reduceFSM
overFSM :: (Hashable su, Eq su) => ([st] -> su) -> FSM [st] it ot -> FSM su it ot
overFSM g (Moore ss is dt f) = Moore ss' is (\s -> overLabel g . dt (lut s)) $ f . lut
where ss' = map g ss
lut = lutss ss ss'
overFSM g (Mealy ss is dt f) = Mealy ss' is (\s -> overLabel g . dt (lut s)) $ \s -> f $ lut s
where ss' = map g ss
lut = lutss ss ss'
lutss :: (Eq a,Hashable a) => [[b]] -> [a] -> a -> [b]
lutss ss ss' = flip (HM.lookupDefault []) (HM.fromList $ zip ss' ss)
concatFSM :: (Hashable st,Eq st) => FSM [[st]] it ot -> FSM [st] it ot
concatFSM = overFSM concat
headFSM :: (Hashable st,Eq st) => FSM [st] it ot -> FSM st it ot
headFSM = overFSM head
reduceFSM :: (Hashable st,Eq st, Eq ot) => FSM st it ot -> FSM [st] it ot
reduceFSM (Moore ss is dt f) = Moore rs is (\x y -> pm $ dt (head x) y) $ f.head
where rs = calcRedStates is dt (reduce1Moore ss f)
pm = Label . flip (HM.lookupDefault []) (hashItemLists rs HM.empty) . stateLabel
reduceFSM (Mealy ss is dt f) = Mealy rs is (\x y -> pm $ dt (head x) y) (\x y -> f (head x) y)
where rs = calcRedStates is dt (reduce1Mealy ss is f)
pm = Label . flip (HM.lookupDefault []) (hashItemLists rs HM.empty) . stateLabel
mergeState :: (Eq a) => FSMState a -> FSMState a -> Maybe (FSMState a)
mergeState DontCare x = Just x
mergeState x DontCare = Just x
mergeState (Label a) (Label b) | a == b = Just (Label a)
| otherwise = Nothing
calcRedStates :: (Eq st) => [it] -> (st -> it -> FSMState st) -> [[st]] -> [[st]]
calcRedStates is dt = fixpoint (reduceInc is dt)
flatStates :: [[FSMState st]] -> [FSMState [st]]
flatStates = map (Label . map stateLabel)
reduce1Moore :: (Eq ot) => [st] -> (st -> ot) -> [[st]]
reduce1Moore ss f = singleGroupBy f ss
reduce1Mealy :: (Eq ot) => [st] -> [it] -> (st -> it -> ot) -> [[st]]
reduce1Mealy ss ins f = singleGroupBy (\x -> map (f x) ins) ss
partitionHeader :: (Eq a) => [[a]] -> FSMState a -> FSMState a
partitionHeader _ DontCare = DontCare
partitionHeader ps (Label o) | Just pi <- find (elem o) ps = Label $ head pi
| otherwise = DontCare
reduceInc :: (Eq st) => [it] -> (st -> it -> FSMState st) -> [[st]] -> [[st]]
reduceInc is dt pt = concat [ singleGroupBy (\s -> map (partitionHeader pt . dt s) is) pi | pi <- pt]
| KommuSoft/dep-software | Dep.Algorithms.Seq.hs | gpl-3.0 | 3,465 | 0 | 13 | 833 | 1,741 | 904 | 837 | 69 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- |
-- Module : Network.Google.Resource.AndroidPublisher.Edits.ExpansionFiles.Upload
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Uploads a new expansion file and attaches to the specified APK.
--
-- /See:/ <https://developers.google.com/android-publisher Google Play Android Developer API Reference> for @androidpublisher.edits.expansionfiles.upload@.
module Network.Google.Resource.AndroidPublisher.Edits.ExpansionFiles.Upload
(
-- * REST Resource
EditsExpansionFilesUploadResource
-- * Creating a Request
, editsExpansionFilesUpload
, EditsExpansionFilesUpload
-- * Request Lenses
, eXgafv
, eUploadProtocol
, ePackageName
, eAPKVersionCode
, eAccessToken
, eUploadType
, eExpansionFileType
, eEditId
, eCallback
) where
import Network.Google.AndroidPublisher.Types
import Network.Google.Prelude
-- | A resource alias for @androidpublisher.edits.expansionfiles.upload@ method which the
-- 'EditsExpansionFilesUpload' request conforms to.
type EditsExpansionFilesUploadResource =
"androidpublisher" :>
"v3" :>
"applications" :>
Capture "packageName" Text :>
"edits" :>
Capture "editId" Text :>
"apks" :>
Capture "apkVersionCode" (Textual Int32) :>
"expansionFiles" :>
Capture "expansionFileType"
EditsExpansionFilesUploadExpansionFileType
:>
QueryParam "$.xgafv" Xgafv :>
QueryParam "upload_protocol" Text :>
QueryParam "access_token" Text :>
QueryParam "uploadType" Text :>
QueryParam "callback" Text :>
QueryParam "alt" AltJSON :>
Post '[JSON] ExpansionFilesUploadResponse
:<|>
"upload" :>
"androidpublisher" :>
"v3" :>
"applications" :>
Capture "packageName" Text :>
"edits" :>
Capture "editId" Text :>
"apks" :>
Capture "apkVersionCode" (Textual Int32) :>
"expansionFiles" :>
Capture "expansionFileType"
EditsExpansionFilesUploadExpansionFileType
:>
QueryParam "$.xgafv" Xgafv :>
QueryParam "upload_protocol" Text :>
QueryParam "access_token" Text :>
QueryParam "uploadType" Text :>
QueryParam "callback" Text :>
QueryParam "alt" AltJSON :>
QueryParam "uploadType" AltMedia :>
AltMedia :>
Post '[JSON]
ExpansionFilesUploadResponse
-- | Uploads a new expansion file and attaches to the specified APK.
--
-- /See:/ 'editsExpansionFilesUpload' smart constructor.
data EditsExpansionFilesUpload =
EditsExpansionFilesUpload'
{ _eXgafv :: !(Maybe Xgafv)
, _eUploadProtocol :: !(Maybe Text)
, _ePackageName :: !Text
, _eAPKVersionCode :: !(Textual Int32)
, _eAccessToken :: !(Maybe Text)
, _eUploadType :: !(Maybe Text)
, _eExpansionFileType :: !EditsExpansionFilesUploadExpansionFileType
, _eEditId :: !Text
, _eCallback :: !(Maybe Text)
}
deriving (Eq, Show, Data, Typeable, Generic)
-- | Creates a value of 'EditsExpansionFilesUpload' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'eXgafv'
--
-- * 'eUploadProtocol'
--
-- * 'ePackageName'
--
-- * 'eAPKVersionCode'
--
-- * 'eAccessToken'
--
-- * 'eUploadType'
--
-- * 'eExpansionFileType'
--
-- * 'eEditId'
--
-- * 'eCallback'
editsExpansionFilesUpload
:: Text -- ^ 'ePackageName'
-> Int32 -- ^ 'eAPKVersionCode'
-> EditsExpansionFilesUploadExpansionFileType -- ^ 'eExpansionFileType'
-> Text -- ^ 'eEditId'
-> EditsExpansionFilesUpload
editsExpansionFilesUpload pEPackageName_ pEAPKVersionCode_ pEExpansionFileType_ pEEditId_ =
EditsExpansionFilesUpload'
{ _eXgafv = Nothing
, _eUploadProtocol = Nothing
, _ePackageName = pEPackageName_
, _eAPKVersionCode = _Coerce # pEAPKVersionCode_
, _eAccessToken = Nothing
, _eUploadType = Nothing
, _eExpansionFileType = pEExpansionFileType_
, _eEditId = pEEditId_
, _eCallback = Nothing
}
-- | V1 error format.
eXgafv :: Lens' EditsExpansionFilesUpload (Maybe Xgafv)
eXgafv = lens _eXgafv (\ s a -> s{_eXgafv = a})
-- | Upload protocol for media (e.g. \"raw\", \"multipart\").
eUploadProtocol :: Lens' EditsExpansionFilesUpload (Maybe Text)
eUploadProtocol
= lens _eUploadProtocol
(\ s a -> s{_eUploadProtocol = a})
-- | Package name of the app.
ePackageName :: Lens' EditsExpansionFilesUpload Text
ePackageName
= lens _ePackageName (\ s a -> s{_ePackageName = a})
-- | The version code of the APK whose expansion file configuration is being
-- read or modified.
eAPKVersionCode :: Lens' EditsExpansionFilesUpload Int32
eAPKVersionCode
= lens _eAPKVersionCode
(\ s a -> s{_eAPKVersionCode = a})
. _Coerce
-- | OAuth access token.
eAccessToken :: Lens' EditsExpansionFilesUpload (Maybe Text)
eAccessToken
= lens _eAccessToken (\ s a -> s{_eAccessToken = a})
-- | Legacy upload protocol for media (e.g. \"media\", \"multipart\").
eUploadType :: Lens' EditsExpansionFilesUpload (Maybe Text)
eUploadType
= lens _eUploadType (\ s a -> s{_eUploadType = a})
-- | The file type of the expansion file configuration which is being
-- updated.
eExpansionFileType :: Lens' EditsExpansionFilesUpload EditsExpansionFilesUploadExpansionFileType
eExpansionFileType
= lens _eExpansionFileType
(\ s a -> s{_eExpansionFileType = a})
-- | Identifier of the edit.
eEditId :: Lens' EditsExpansionFilesUpload Text
eEditId = lens _eEditId (\ s a -> s{_eEditId = a})
-- | JSONP
eCallback :: Lens' EditsExpansionFilesUpload (Maybe Text)
eCallback
= lens _eCallback (\ s a -> s{_eCallback = a})
instance GoogleRequest EditsExpansionFilesUpload
where
type Rs EditsExpansionFilesUpload =
ExpansionFilesUploadResponse
type Scopes EditsExpansionFilesUpload =
'["https://www.googleapis.com/auth/androidpublisher"]
requestClient EditsExpansionFilesUpload'{..}
= go _ePackageName _eEditId _eAPKVersionCode
_eExpansionFileType
_eXgafv
_eUploadProtocol
_eAccessToken
_eUploadType
_eCallback
(Just AltJSON)
androidPublisherService
where go :<|> _
= buildClient
(Proxy :: Proxy EditsExpansionFilesUploadResource)
mempty
instance GoogleRequest
(MediaUpload EditsExpansionFilesUpload)
where
type Rs (MediaUpload EditsExpansionFilesUpload) =
ExpansionFilesUploadResponse
type Scopes (MediaUpload EditsExpansionFilesUpload) =
Scopes EditsExpansionFilesUpload
requestClient
(MediaUpload EditsExpansionFilesUpload'{..} body)
= go _ePackageName _eEditId _eAPKVersionCode
_eExpansionFileType
_eXgafv
_eUploadProtocol
_eAccessToken
_eUploadType
_eCallback
(Just AltJSON)
(Just AltMedia)
body
androidPublisherService
where _ :<|> go
= buildClient
(Proxy :: Proxy EditsExpansionFilesUploadResource)
mempty
| brendanhay/gogol | gogol-android-publisher/gen/Network/Google/Resource/AndroidPublisher/Edits/ExpansionFiles/Upload.hs | mpl-2.0 | 8,728 | 0 | 43 | 2,703 | 1,252 | 696 | 556 | 190 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- |
-- Module : Network.Google.Resource.Analytics.Management.Uploads.Get
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- List uploads to which the user has access.
--
-- /See:/ <https://developers.google.com/analytics/ Google Analytics API Reference> for @analytics.management.uploads.get@.
module Network.Google.Resource.Analytics.Management.Uploads.Get
(
-- * REST Resource
ManagementUploadsGetResource
-- * Creating a Request
, managementUploadsGet
, ManagementUploadsGet
-- * Request Lenses
, mugWebPropertyId
, mugCustomDataSourceId
, mugAccountId
, mugUploadId
) where
import Network.Google.Analytics.Types
import Network.Google.Prelude
-- | A resource alias for @analytics.management.uploads.get@ method which the
-- 'ManagementUploadsGet' request conforms to.
type ManagementUploadsGetResource =
"analytics" :>
"v3" :>
"management" :>
"accounts" :>
Capture "accountId" Text :>
"webproperties" :>
Capture "webPropertyId" Text :>
"customDataSources" :>
Capture "customDataSourceId" Text :>
"uploads" :>
Capture "uploadId" Text :>
QueryParam "alt" AltJSON :> Get '[JSON] Upload
-- | List uploads to which the user has access.
--
-- /See:/ 'managementUploadsGet' smart constructor.
data ManagementUploadsGet =
ManagementUploadsGet'
{ _mugWebPropertyId :: !Text
, _mugCustomDataSourceId :: !Text
, _mugAccountId :: !Text
, _mugUploadId :: !Text
}
deriving (Eq, Show, Data, Typeable, Generic)
-- | Creates a value of 'ManagementUploadsGet' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'mugWebPropertyId'
--
-- * 'mugCustomDataSourceId'
--
-- * 'mugAccountId'
--
-- * 'mugUploadId'
managementUploadsGet
:: Text -- ^ 'mugWebPropertyId'
-> Text -- ^ 'mugCustomDataSourceId'
-> Text -- ^ 'mugAccountId'
-> Text -- ^ 'mugUploadId'
-> ManagementUploadsGet
managementUploadsGet pMugWebPropertyId_ pMugCustomDataSourceId_ pMugAccountId_ pMugUploadId_ =
ManagementUploadsGet'
{ _mugWebPropertyId = pMugWebPropertyId_
, _mugCustomDataSourceId = pMugCustomDataSourceId_
, _mugAccountId = pMugAccountId_
, _mugUploadId = pMugUploadId_
}
-- | Web property Id for the upload to retrieve.
mugWebPropertyId :: Lens' ManagementUploadsGet Text
mugWebPropertyId
= lens _mugWebPropertyId
(\ s a -> s{_mugWebPropertyId = a})
-- | Custom data source Id for upload to retrieve.
mugCustomDataSourceId :: Lens' ManagementUploadsGet Text
mugCustomDataSourceId
= lens _mugCustomDataSourceId
(\ s a -> s{_mugCustomDataSourceId = a})
-- | Account Id for the upload to retrieve.
mugAccountId :: Lens' ManagementUploadsGet Text
mugAccountId
= lens _mugAccountId (\ s a -> s{_mugAccountId = a})
-- | Upload Id to retrieve.
mugUploadId :: Lens' ManagementUploadsGet Text
mugUploadId
= lens _mugUploadId (\ s a -> s{_mugUploadId = a})
instance GoogleRequest ManagementUploadsGet where
type Rs ManagementUploadsGet = Upload
type Scopes ManagementUploadsGet =
'["https://www.googleapis.com/auth/analytics",
"https://www.googleapis.com/auth/analytics.edit",
"https://www.googleapis.com/auth/analytics.readonly"]
requestClient ManagementUploadsGet'{..}
= go _mugAccountId _mugWebPropertyId
_mugCustomDataSourceId
_mugUploadId
(Just AltJSON)
analyticsService
where go
= buildClient
(Proxy :: Proxy ManagementUploadsGetResource)
mempty
| brendanhay/gogol | gogol-analytics/gen/Network/Google/Resource/Analytics/Management/Uploads/Get.hs | mpl-2.0 | 4,492 | 0 | 19 | 1,067 | 550 | 326 | 224 | 93 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- |
-- Module : Network.Google.Resource.AndroidPublisher.InAppProducts.Batch
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- /See:/ <https://developers.google.com/android-publisher Google Play Developer API Reference> for @androidpublisher.inappproducts.batch@.
module Network.Google.Resource.AndroidPublisher.InAppProducts.Batch
(
-- * REST Resource
InAppProductsBatchResource
-- * Creating a Request
, inAppProductsBatch
, InAppProductsBatch
-- * Request Lenses
, iapbPayload
) where
import Network.Google.AndroidPublisher.Types
import Network.Google.Prelude
-- | A resource alias for @androidpublisher.inappproducts.batch@ method which the
-- 'InAppProductsBatch' request conforms to.
type InAppProductsBatchResource =
"androidpublisher" :>
"v2" :>
"applications" :>
"inappproducts" :>
"batch" :>
QueryParam "alt" AltJSON :>
ReqBody '[JSON] InAppProductsBatchRequest :>
Post '[JSON] InAppProductsBatchResponse
--
-- /See:/ 'inAppProductsBatch' smart constructor.
newtype InAppProductsBatch = InAppProductsBatch'
{ _iapbPayload :: InAppProductsBatchRequest
} deriving (Eq,Show,Data,Typeable,Generic)
-- | Creates a value of 'InAppProductsBatch' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'iapbPayload'
inAppProductsBatch
:: InAppProductsBatchRequest -- ^ 'iapbPayload'
-> InAppProductsBatch
inAppProductsBatch pIapbPayload_ =
InAppProductsBatch'
{ _iapbPayload = pIapbPayload_
}
-- | Multipart request metadata.
iapbPayload :: Lens' InAppProductsBatch InAppProductsBatchRequest
iapbPayload
= lens _iapbPayload (\ s a -> s{_iapbPayload = a})
instance GoogleRequest InAppProductsBatch where
type Rs InAppProductsBatch =
InAppProductsBatchResponse
type Scopes InAppProductsBatch =
'["https://www.googleapis.com/auth/androidpublisher"]
requestClient InAppProductsBatch'{..}
= go (Just AltJSON) _iapbPayload
androidPublisherService
where go
= buildClient
(Proxy :: Proxy InAppProductsBatchResource)
mempty
| rueshyna/gogol | gogol-android-publisher/gen/Network/Google/Resource/AndroidPublisher/InAppProducts/Batch.hs | mpl-2.0 | 2,991 | 0 | 14 | 677 | 309 | 188 | 121 | 53 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- |
-- Module : Network.Google.Resource.Storage.Buckets.List
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a list of buckets for a given project.
--
-- /See:/ <https://developers.google.com/storage/docs/json_api/ Cloud Storage JSON API Reference> for @storage.buckets.list@.
module Network.Google.Resource.Storage.Buckets.List
(
-- * REST Resource
BucketsListResource
-- * Creating a Request
, bucketsList
, BucketsList
-- * Request Lenses
, blProject
, blPrefix
, blProjection
, blPageToken
, blMaxResults
) where
import Network.Google.Prelude
import Network.Google.Storage.Types
-- | A resource alias for @storage.buckets.list@ method which the
-- 'BucketsList' request conforms to.
type BucketsListResource =
"storage" :>
"v1" :>
"b" :>
QueryParam "project" Text :>
QueryParam "prefix" Text :>
QueryParam "projection" BucketsListProjection :>
QueryParam "pageToken" Text :>
QueryParam "maxResults" (Textual Word32) :>
QueryParam "alt" AltJSON :> Get '[JSON] Buckets
-- | Retrieves a list of buckets for a given project.
--
-- /See:/ 'bucketsList' smart constructor.
data BucketsList = BucketsList'
{ _blProject :: !Text
, _blPrefix :: !(Maybe Text)
, _blProjection :: !(Maybe BucketsListProjection)
, _blPageToken :: !(Maybe Text)
, _blMaxResults :: !(Maybe (Textual Word32))
} deriving (Eq,Show,Data,Typeable,Generic)
-- | Creates a value of 'BucketsList' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'blProject'
--
-- * 'blPrefix'
--
-- * 'blProjection'
--
-- * 'blPageToken'
--
-- * 'blMaxResults'
bucketsList
:: Text -- ^ 'blProject'
-> BucketsList
bucketsList pBlProject_ =
BucketsList'
{ _blProject = pBlProject_
, _blPrefix = Nothing
, _blProjection = Nothing
, _blPageToken = Nothing
, _blMaxResults = Nothing
}
-- | A valid API project identifier.
blProject :: Lens' BucketsList Text
blProject
= lens _blProject (\ s a -> s{_blProject = a})
-- | Filter results to buckets whose names begin with this prefix.
blPrefix :: Lens' BucketsList (Maybe Text)
blPrefix = lens _blPrefix (\ s a -> s{_blPrefix = a})
-- | Set of properties to return. Defaults to noAcl.
blProjection :: Lens' BucketsList (Maybe BucketsListProjection)
blProjection
= lens _blProjection (\ s a -> s{_blProjection = a})
-- | A previously-returned page token representing part of the larger set of
-- results to view.
blPageToken :: Lens' BucketsList (Maybe Text)
blPageToken
= lens _blPageToken (\ s a -> s{_blPageToken = a})
-- | Maximum number of buckets to return.
blMaxResults :: Lens' BucketsList (Maybe Word32)
blMaxResults
= lens _blMaxResults (\ s a -> s{_blMaxResults = a})
. mapping _Coerce
instance GoogleRequest BucketsList where
type Rs BucketsList = Buckets
type Scopes BucketsList =
'["https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/cloud-platform.read-only",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/devstorage.read_write"]
requestClient BucketsList'{..}
= go (Just _blProject) _blPrefix _blProjection
_blPageToken
_blMaxResults
(Just AltJSON)
storageService
where go
= buildClient (Proxy :: Proxy BucketsListResource)
mempty
| rueshyna/gogol | gogol-storage/gen/Network/Google/Resource/Storage/Buckets/List.hs | mpl-2.0 | 4,422 | 0 | 16 | 1,062 | 660 | 385 | 275 | 93 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- |
-- Module : Network.Google.Resource.Compute.InterconnectLocations.Get
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the details for the specified interconnect location. Gets a list
-- of available interconnect locations by making a list() request.
--
-- /See:/ <https://developers.google.com/compute/docs/reference/latest/ Compute Engine API Reference> for @compute.interconnectLocations.get@.
module Network.Google.Resource.Compute.InterconnectLocations.Get
(
-- * REST Resource
InterconnectLocationsGetResource
-- * Creating a Request
, interconnectLocationsGet
, InterconnectLocationsGet
-- * Request Lenses
, ilgProject
, ilgInterconnectLocation
) where
import Network.Google.Compute.Types
import Network.Google.Prelude
-- | A resource alias for @compute.interconnectLocations.get@ method which the
-- 'InterconnectLocationsGet' request conforms to.
type InterconnectLocationsGetResource =
"compute" :>
"v1" :>
"projects" :>
Capture "project" Text :>
"global" :>
"interconnectLocations" :>
Capture "interconnectLocation" Text :>
QueryParam "alt" AltJSON :>
Get '[JSON] InterconnectLocation
-- | Returns the details for the specified interconnect location. Gets a list
-- of available interconnect locations by making a list() request.
--
-- /See:/ 'interconnectLocationsGet' smart constructor.
data InterconnectLocationsGet =
InterconnectLocationsGet'
{ _ilgProject :: !Text
, _ilgInterconnectLocation :: !Text
}
deriving (Eq, Show, Data, Typeable, Generic)
-- | Creates a value of 'InterconnectLocationsGet' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ilgProject'
--
-- * 'ilgInterconnectLocation'
interconnectLocationsGet
:: Text -- ^ 'ilgProject'
-> Text -- ^ 'ilgInterconnectLocation'
-> InterconnectLocationsGet
interconnectLocationsGet pIlgProject_ pIlgInterconnectLocation_ =
InterconnectLocationsGet'
{ _ilgProject = pIlgProject_
, _ilgInterconnectLocation = pIlgInterconnectLocation_
}
-- | Project ID for this request.
ilgProject :: Lens' InterconnectLocationsGet Text
ilgProject
= lens _ilgProject (\ s a -> s{_ilgProject = a})
-- | Name of the interconnect location to return.
ilgInterconnectLocation :: Lens' InterconnectLocationsGet Text
ilgInterconnectLocation
= lens _ilgInterconnectLocation
(\ s a -> s{_ilgInterconnectLocation = a})
instance GoogleRequest InterconnectLocationsGet where
type Rs InterconnectLocationsGet =
InterconnectLocation
type Scopes InterconnectLocationsGet =
'["https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/compute.readonly"]
requestClient InterconnectLocationsGet'{..}
= go _ilgProject _ilgInterconnectLocation
(Just AltJSON)
computeService
where go
= buildClient
(Proxy :: Proxy InterconnectLocationsGetResource)
mempty
| brendanhay/gogol | gogol-compute/gen/Network/Google/Resource/Compute/InterconnectLocations/Get.hs | mpl-2.0 | 3,923 | 0 | 15 | 854 | 393 | 237 | 156 | 70 | 1 |
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
-- Module : Gen.IO
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : provisional
-- Portability : non-portable (GHC extensions)
module Gen.IO where
import Control.Error
import Control.Monad.Except
import Data.Bifunctor (first)
import Data.ByteString (ByteString)
import Data.Text.Lazy.Builder (toLazyText)
import Filesystem.Path.CurrentOS
import Gen.Formatting
import Gen.Types
import System.IO
import qualified UnexceptionalIO as UIO
import qualified Data.Text as Text
import qualified Data.Text.Lazy as LText
import qualified Data.Text.Lazy.IO as LText
import qualified Filesystem as FS
import qualified Text.EDE as EDE
run :: ExceptT Error IO a -> IO a
run = runScript . fmapLT (Text.pack . LText.unpack)
io :: MonadIO m => IO a -> ExceptT Error m a
io = ExceptT . fmap (first (LText.pack . show)) . liftIO . UIO.run . UIO.fromIO
title :: MonadIO m => Format (ExceptT Error m ()) a -> a
title m = runFormat m (io . LText.putStrLn . toLazyText)
say :: MonadIO m => Format (ExceptT Error m ()) a -> a
say = title . (" -> " %)
done :: MonadIO m => ExceptT Error m ()
done = title ""
isFile :: MonadIO m => Path -> ExceptT Error m Bool
isFile = io . FS.isFile
readBSFile :: MonadIO m => Path -> ExceptT Error m ByteString
readBSFile f = do
p <- isFile f
if p
then say ("Reading " % path) f >> io (FS.readFile f)
else failure ("Missing " % path) f
writeLTFile :: MonadIO m => Path -> LText.Text -> ExceptT Error m ()
writeLTFile f t = do
say ("Writing " % path) f
io . FS.withFile f FS.WriteMode $ \h -> do
hSetEncoding h utf8
LText.hPutStr h t
touchFile :: MonadIO m => Path -> ExceptT Error m ()
touchFile f = do
p <- isFile f
unless p $
writeLTFile f mempty
writeOrTouch :: MonadIO m => Path -> Maybe LText.Text -> ExceptT Error m ()
writeOrTouch x = maybe (touchFile x) (writeLTFile x)
createDir :: MonadIO m => Path -> ExceptT Error m ()
createDir d = do
p <- io (FS.isDirectory d)
unless p $ do
say ("Creating " % path) d
io (FS.createTree d)
copyDir :: MonadIO m => Path -> Path -> ExceptT Error m ()
copyDir src dst = io (FS.listDirectory src >>= mapM_ copy)
where
copy f = do
let p = dst </> filename f
fprint (" -> Copying " % path % " to " % path % "\n") f (directory p)
FS.copyFile f p
readTemplate :: MonadIO m
=> Path
-> Path
-> ExceptT Error m EDE.Template
readTemplate d f =
liftIO (EDE.eitherParseFile (encodeString (d </> f)))
>>= either (throwError . LText.pack) return
| brendanhay/gogol | gen/src/Gen/IO.hs | mpl-2.0 | 2,960 | 0 | 14 | 856 | 1,010 | 513 | 497 | 68 | 2 |
{-# LANGUAGE MultiWayIf, OverloadedStrings, TupleSections #-}
module HTTP.Client
( HTTPClient
, initHTTPClient
, checkContentOk
, CookiesT
, runCookiesT
-- , withCookies
, withResponseCookies
, requestAcceptContent
, httpParse
, httpMaybe
, httpRequestJSON
) where
-- import Control.Arrow ((&&&))
import Control.Exception.Lifted (handle)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Trans.Control (MonadBaseControl)
import Control.Monad.Trans.State.Strict (StateT(..), evalStateT)
import Data.Function (on)
import Data.Monoid ((<>))
import Network.HTTP.Client.TLS (tlsManagerSettings)
import Network.HTTP.Types (hAccept, hContentType, statusIsSuccessful)
import qualified Data.Aeson as JSON
import qualified Data.Attoparsec.ByteString as P
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BSC
import qualified Network.HTTP.Client as HC
import Has
type HTTPClient = HC.Manager
initHTTPClient :: IO HTTPClient
initHTTPClient = HC.newManager tlsManagerSettings
{ HC.managerConnCount = 4
, HC.managerIdleConnectionCount = 8
}
type CookiesT m a = StateT HC.CookieJar m a
runCookiesT :: Monad m => CookiesT m a -> m a
runCookiesT f = evalStateT f mempty
{-
withCookies :: (MonadIO m, MonadHas HTTPClient c m) => (HC.Request -> HC.Manager -> IO (HC.Response a)) -> HC.Request -> CookiesT m (HC.Response a)
withCookies f r = StateT $ \c -> focusIO $ \m ->
(id &&& HC.responseCookieJar) <$> f r{ HC.cookieJar = HC.cookieJar r <> Just c } m
-}
withResponseCookies :: (MonadIO m, MonadHas HTTPClient c m) => HC.Request -> (HC.Response HC.BodyReader -> IO a) -> CookiesT m a
withResponseCookies q f = StateT $ \c -> focusIO $ \m ->
HC.withResponse q{ HC.cookieJar = HC.cookieJar q <> Just c } m $ \r -> (, HC.responseCookieJar r) <$> f r
contentTypeEq :: BS.ByteString -> BS.ByteString -> Bool
contentTypeEq = (==) `on` f where
f s
| Just i <- BSC.elemIndex ';' s = BS.take i s
| otherwise = s
checkContentOk :: BS.ByteString -> HC.Request -> HC.Response HC.BodyReader -> IO ()
checkContentOk ct _ rsp =
if | not $ statusIsSuccessful $ HC.responseStatus rsp -> fail "checkContentOk: status unsuccessful"
| not $ any (contentTypeEq ct) ht -> fail "checkContentOk: bad content type"
| otherwise -> return ()
where ht = lookup hContentType $ HC.responseHeaders rsp
requestAcceptContent :: BS.ByteString -> HC.Request -> HC.Request
requestAcceptContent ct req = req
{ HC.requestHeaders = (hAccept, ct) : HC.requestHeaders req
, HC.checkResponse = checkContentOk ct
}
httpParse :: P.Parser a -> HC.Response HC.BodyReader -> IO (P.Result a)
httpParse p r = P.parseWith (HC.responseBody r) p BS.empty
httpMaybe :: MonadBaseControl IO m => m (Maybe a) -> m (Maybe a)
httpMaybe = handle (return . fail . (show :: HC.HttpException -> String))
httpRequestJSON :: HC.Request -> HTTPClient -> IO (Maybe JSON.Value)
httpRequestJSON r m = httpMaybe $
HC.withResponse (requestAcceptContent "application/json" r) m (fmap P.maybeResult . httpParse JSON.json)
| databrary/databrary | src/HTTP/Client.hs | agpl-3.0 | 3,055 | 0 | 15 | 501 | 907 | 490 | 417 | -1 | -1 |
module Main where
import Test.Tasty
-- import Test.Tasty.QuickCheck as QC
-- import Test.Tasty.HUnit as HU
-- import Test.Tasty.Golden as TG
-- import Test.Tasty.Hspec
tests :: TestTree
tests = testGroup "cabal-new"
[ -- testCase "something" specs
]
main :: IO ()
main = defaultMain tests
| erochest/cabal-new | specs/Specs.hs | apache-2.0 | 305 | 0 | 6 | 60 | 49 | 29 | 20 | 7 | 1 |
-- Defines a list of tests that test the "show" aspects of expressions
-- that is, how they are rendered in to strings by the "show" function
module UnitTests.Show
where
import Test.HUnit (Test(TestCase, TestLabel))
import CAS
import UnitTests.Base
tests = [
TestLabel "Rendering plain symbols" $
TestCase $ do
aE "test1" "x" $ show x
aE "test2" "y" $ show y
aE "test3" "z" $ show z
,
TestLabel "Rendering pre-ordered addition of symbols and constants" $
TestCase $ do
aE "test1" "(x + y)" $ show (x + y)
aE "test2" "(y + z)" $ show (y + z)
aE "test3" "(x + z)" $ show (x + z)
aE "test4" "(x + 2)" $ show (x + 2)
aE "test5" "(y + 3)" $ show (y + 3)
,
TestLabel "Rendering pre-ordered addition of more than two symbols and constants" $
TestCase $ do
aE "test1" "(x + y + z)" $ show (x + y + z)
aE "test2" "(x + y + 3)" $ show (x + y + 3)
,
TestLabel "Rendering subtraction of symbols and constants" $
TestCase $ do
aE "test1" "(x - y)" $ show (x - y)
aE "test2" "(x - 3)" $ show (x - 3)
aE "test3" "(x + y - z)" $ show (x + y - z)
aE "test4" "(x - y + z)" $ show (x - y + z)
,
TestLabel "Rendering addition and subtraction where the first symbol is negative" $
TestCase $ do
aE "test1" "(-x + y)" $ show (-x + y)
aE "test2" "(-x - y)" $ show (-x - y)
,
TestLabel "Rendering pre-ordered constants, symbols and sums being multiplied" $
TestCase $ do
aE "test1" "x y" $ show (x * y)
aE "test2" "2 z" $ show (2 * z)
aE "test3" "-3 x" $ show (-3 * x)
aE "test4" "2 (x + y)" $ show (2 * (x + y))
aE "test5" "2 (x + y) z" $ show (2 * (x + y) * z)
,
TestLabel "Rendering pre-ordered sum of products" $
TestCase $ do
aE "test1" "(2 x + y)" $ show (2 * x + y)
aE "test2" "(-3 x + z)" $ show (-3 * x + z)
aE "test3" "(2 x y + 3 z)" $ show (2 * x * y + 3 * z)
,
TestLabel "Rendering (pre-ordered) products of exponents" $
TestCase $ do
aE "test1" "x^2" $ show (x^2)
aE "test2" "x^3" $ show (x^3)
aE "test3" "x^2 y" $ show (x^2 * y)
aE "test4" "x y^2" $ show (x * y^2)
aE "test5" "x (y + z)" $ show (x * (y + z))
aE "test6" "(x + y)^2" $ show ((x + y)^2)
,
TestLabel "Rendering divided terms" $
TestCase $ do
aE "test1" "1 / x" $ show (1 / x)
aE "test2" "x / y" $ show (x / y)
aE "test3" "1 / x^2" $ show (1 / x^2)
aE "test4" "x / (y z)" $ show (x / (y*z))
aE "test5" "x / (y + z)" $ show (x / (y + z))
aE "test6" "x / 2" $ show (x / 2)
aE "test7" "(x + y) / 2" $ show ((x + y) / 2)
]
| abid-mujtaba/haskell-cas | test/UnitTests/Show.hs | apache-2.0 | 3,493 | 0 | 15 | 1,671 | 1,065 | 504 | 561 | 60 | 1 |
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd">
<helpset version="2.0" xml:lang="ru-RU">
<title>Getting started Guide</title>
<maps>
<homeID>top</homeID>
<mapref location="map.jhm"/>
</maps>
<view>
<name>TOC</name>
<label>Contents</label>
<type>org.zaproxy.zap.extension.help.ZapTocView</type>
<data>toc.xml</data>
</view>
<view>
<name>Index</name>
<label>Индекс</label>
<type>javax.help.IndexView</type>
<data>index.xml</data>
</view>
<view>
<name>Search</name>
<label>Поиск</label>
<type>javax.help.SearchView</type>
<data engine="com.sun.java.help.search.DefaultSearchEngine">
JavaHelpSearch
</data>
</view>
<view>
<name>Favorites</name>
<label>Favorites</label>
<type>javax.help.FavoritesView</type>
</view>
</helpset> | secdec/zap-extensions | addOns/gettingStarted/src/main/javahelp/org/zaproxy/zap/extension/gettingStarted/resources/help_ru_RU/helpset_ru_RU.hs | apache-2.0 | 977 | 82 | 52 | 157 | 412 | 216 | 196 | -1 | -1 |
{-
Copyright 2018 The CodeWorld Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-}
{- |
This module encapsulates the logics behind the prediction code in the
multi-player setup. It is the “trivially correct” version.
-}
{-# LANGUAGE RecordWildCards, ViewPatterns #-}
module CodeWorld.Prediction.Trivial
( Timestamp
, AnimationRate
, StepFun
, Future
, initFuture
, currentTimePasses
, currentState
, addEvent
, eqFuture
, printInternalState
) where
import Data.Bifunctor (second)
import qualified Data.IntMap as IM
import Data.List (foldl', intercalate)
import qualified Data.MultiMap as M
import Text.Printf
type PlayerId = Int
type Timestamp = Double -- in seconds, relative to some arbitrary starting point
type AnimationRate = Double -- in seconds, e.g. 0.1
-- All we do with events is to apply them to the state. So let's just store the
-- function that does that.
type Event s = s -> s
-- A state and an event only make sense together with a time.
type TState s = (Timestamp, s)
type TEvent s = (Timestamp, Event s)
type StepFun s = Double -> s -> s
type EventQueue s = M.MultiMap (Timestamp, PlayerId) (Event s)
-- | Invariants about the time stamps in this data type:
-- * committed <= pending <= current < future
-- * The time is advanced with strictly ascending timestamps
-- * For each player, events come in with strictly ascending timestamps
-- * For each player, all events in pending or future are before the
-- corresponding lastEvents entry.
data Future s = Future
{ initial :: s
, events :: EventQueue s
}
initFuture :: s -> Int -> Future s
initFuture s _numPlayers = Future {initial = s, events = M.empty}
-- Time handling.
--
-- Move state forward in fixed animation rate steps, and get
-- the timestamp as close to the given target as possible (but possibly stop short)
timePassesBigStep ::
StepFun s -> AnimationRate -> Timestamp -> TState s -> TState s
timePassesBigStep step rate target (now, s)
| now + rate <= target =
timePassesBigStep step rate target (stepBy step rate (now, s))
| otherwise = (now, s)
-- Move state forward in fixed animation rate steps, and get
-- the timestamp as close to the given target as possible, and then do a final small step
timePasses :: StepFun s -> AnimationRate -> Timestamp -> TState s -> TState s
timePasses step rate target =
stepTo step target . timePassesBigStep step rate target
stepBy :: StepFun s -> Double -> TState s -> TState s
stepBy step diff (now, s) = (now + diff, step diff s)
stepTo :: StepFun s -> Timestamp -> TState s -> TState s
stepTo step target (now, s) = (target, step (target - now) s)
handleNextEvent ::
StepFun s -> AnimationRate -> TEvent s -> TState s -> TState s
handleNextEvent step rate (target, event) =
second event . timePasses step rate target
handleNextEvents ::
StepFun s -> AnimationRate -> EventQueue s -> TState s -> TState s
handleNextEvents step rate eq ts =
foldl' (flip (handleNextEvent step rate)) ts $
map (\((t, _p), h) -> (t, h)) $ M.toList eq
-- | This should be called shortly following 'currentTimePasses'
currentState :: StepFun s -> AnimationRate -> Timestamp -> Future s -> s
currentState step rate target f =
snd $
timePasses step rate target $
handleNextEvents step rate to_apply (0, initial f)
where
(to_apply, _) = M.spanAntitone (\(t, p) -> t <= target) (events f)
-- | This should be called regularly, to keep the current state up to date,
-- and to incorporate future events in it.
currentTimePasses ::
StepFun s -> AnimationRate -> Timestamp -> Future s -> Future s
currentTimePasses step rate target = id
-- | Take a new event into account, local or remote.
-- Invariant:
-- * The timestamp of the event is larger than the timestamp
-- of any event added for this player (which is the timestamp for the player
-- in `lastEvents`)
addEvent ::
StepFun s
-> AnimationRate
-> PlayerId
-> Timestamp
-> Maybe (Event s)
-> Future s
-> Future s-- A future event.
addEvent step rate player now mbEvent f =
f {events = maybe id (M.insertR (now, player)) mbEvent $ events f}
-- | Advances the current time (by big steps)
advanceCurrentTime ::
StepFun s -> AnimationRate -> Timestamp -> Future s -> Future s
advanceCurrentTime step rate target = id
eqFuture :: Eq s => Future s -> Future s -> Bool
eqFuture f1 f2 = M.keys (events f1) == M.keys (events f2)
printInternalState :: (s -> String) -> Future s -> IO ()
printInternalState showState f = do
printf " Event keys: %s\n" (show (M.keys (events f)))
| tgdavies/codeworld | codeworld-prediction/src/CodeWorld/Prediction/Trivial.hs | apache-2.0 | 5,164 | 0 | 13 | 1,097 | 1,167 | 624 | 543 | 79 | 1 |
{-# OPTIONS -fglasgow-exts #-}
-----------------------------------------------------------------------------
{-| Module : QTextEdit_h.hs
Copyright : (c) David Harley 2010
Project : qtHaskell
Version : 1.1.4
Modified : 2010-09-02 17:02:15
Warning : this file is machine generated - do not modify.
--}
-----------------------------------------------------------------------------
module Qtc.Gui.QTextEdit_h where
import Foreign.C.Types
import Qtc.Enums.Base
import Qtc.Enums.Gui.QPaintDevice
import Qtc.Enums.Core.Qt
import Qtc.Classes.Base
import Qtc.Classes.Qccs_h
import Qtc.Classes.Core_h
import Qtc.ClassTypes.Core
import Qth.ClassTypes.Core
import Qtc.Classes.Gui_h
import Qtc.ClassTypes.Gui
import Foreign.Marshal.Array
instance QunSetUserMethod (QTextEdit ()) where
unSetUserMethod qobj evid
= withBoolResult $
withObjectPtr qobj $ \cobj_qobj ->
qtc_QTextEdit_unSetUserMethod cobj_qobj (toCInt 0) (toCInt evid)
foreign import ccall "qtc_QTextEdit_unSetUserMethod" qtc_QTextEdit_unSetUserMethod :: Ptr (TQTextEdit a) -> CInt -> CInt -> IO (CBool)
instance QunSetUserMethod (QTextEditSc a) where
unSetUserMethod qobj evid
= withBoolResult $
withObjectPtr qobj $ \cobj_qobj ->
qtc_QTextEdit_unSetUserMethod cobj_qobj (toCInt 0) (toCInt evid)
instance QunSetUserMethodVariant (QTextEdit ()) where
unSetUserMethodVariant qobj evid
= withBoolResult $
withObjectPtr qobj $ \cobj_qobj ->
qtc_QTextEdit_unSetUserMethod cobj_qobj (toCInt 1) (toCInt evid)
instance QunSetUserMethodVariant (QTextEditSc a) where
unSetUserMethodVariant qobj evid
= withBoolResult $
withObjectPtr qobj $ \cobj_qobj ->
qtc_QTextEdit_unSetUserMethod cobj_qobj (toCInt 1) (toCInt evid)
instance QunSetUserMethodVariantList (QTextEdit ()) where
unSetUserMethodVariantList qobj evid
= withBoolResult $
withObjectPtr qobj $ \cobj_qobj ->
qtc_QTextEdit_unSetUserMethod cobj_qobj (toCInt 2) (toCInt evid)
instance QunSetUserMethodVariantList (QTextEditSc a) where
unSetUserMethodVariantList qobj evid
= withBoolResult $
withObjectPtr qobj $ \cobj_qobj ->
qtc_QTextEdit_unSetUserMethod cobj_qobj (toCInt 2) (toCInt evid)
instance QsetUserMethod (QTextEdit ()) (QTextEdit x0 -> IO ()) where
setUserMethod _eobj _eid _handler
= do
funptr <- wrapSetUserMethod_QTextEdit setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetUserMethod_QTextEdit_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
qtc_QTextEdit_setUserMethod cobj_eobj (toCInt _eid) (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return ()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO ()
setHandlerWrapper x0
= do
x0obj <- objectFromPtr_nf x0
if (objectIsNull x0obj)
then return ()
else _handler x0obj
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setUserMethod" qtc_QTextEdit_setUserMethod :: Ptr (TQTextEdit a) -> CInt -> Ptr (Ptr (TQTextEdit x0) -> IO ()) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetUserMethod_QTextEdit :: (Ptr (TQTextEdit x0) -> IO ()) -> IO (FunPtr (Ptr (TQTextEdit x0) -> IO ()))
foreign import ccall "wrapper" wrapSetUserMethod_QTextEdit_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetUserMethod (QTextEditSc a) (QTextEdit x0 -> IO ()) where
setUserMethod _eobj _eid _handler
= do
funptr <- wrapSetUserMethod_QTextEdit setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetUserMethod_QTextEdit_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
qtc_QTextEdit_setUserMethod cobj_eobj (toCInt _eid) (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return ()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO ()
setHandlerWrapper x0
= do
x0obj <- objectFromPtr_nf x0
if (objectIsNull x0obj)
then return ()
else _handler x0obj
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QsetUserMethod (QTextEdit ()) (QTextEdit x0 -> QVariant () -> IO (QVariant ())) where
setUserMethod _eobj _eid _handler
= do
funptr <- wrapSetUserMethodVariant_QTextEdit setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetUserMethodVariant_QTextEdit_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
qtc_QTextEdit_setUserMethodVariant cobj_eobj (toCInt _eid) (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return ()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQVariant ()) -> IO (Ptr (TQVariant ()))
setHandlerWrapper x0 x1
= do
x0obj <- objectFromPtr_nf x0
x1obj <- objectFromPtr_nf x1
rv <- if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj x1obj
withObjectPtr rv $ \cobj_rv -> return cobj_rv
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setUserMethodVariant" qtc_QTextEdit_setUserMethodVariant :: Ptr (TQTextEdit a) -> CInt -> Ptr (Ptr (TQTextEdit x0) -> Ptr (TQVariant ()) -> IO (Ptr (TQVariant ()))) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetUserMethodVariant_QTextEdit :: (Ptr (TQTextEdit x0) -> Ptr (TQVariant ()) -> IO (Ptr (TQVariant ()))) -> IO (FunPtr (Ptr (TQTextEdit x0) -> Ptr (TQVariant ()) -> IO (Ptr (TQVariant ()))))
foreign import ccall "wrapper" wrapSetUserMethodVariant_QTextEdit_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetUserMethod (QTextEditSc a) (QTextEdit x0 -> QVariant () -> IO (QVariant ())) where
setUserMethod _eobj _eid _handler
= do
funptr <- wrapSetUserMethodVariant_QTextEdit setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetUserMethodVariant_QTextEdit_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
qtc_QTextEdit_setUserMethodVariant cobj_eobj (toCInt _eid) (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return ()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQVariant ()) -> IO (Ptr (TQVariant ()))
setHandlerWrapper x0 x1
= do
x0obj <- objectFromPtr_nf x0
x1obj <- objectFromPtr_nf x1
rv <- if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj x1obj
withObjectPtr rv $ \cobj_rv -> return cobj_rv
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QunSetHandler (QTextEdit ()) where
unSetHandler qobj evid
= withBoolResult $
withObjectPtr qobj $ \cobj_qobj ->
withCWString evid $ \cstr_evid ->
qtc_QTextEdit_unSetHandler cobj_qobj cstr_evid
foreign import ccall "qtc_QTextEdit_unSetHandler" qtc_QTextEdit_unSetHandler :: Ptr (TQTextEdit a) -> CWString -> IO (CBool)
instance QunSetHandler (QTextEditSc a) where
unSetHandler qobj evid
= withBoolResult $
withObjectPtr qobj $ \cobj_qobj ->
withCWString evid $ \cstr_evid ->
qtc_QTextEdit_unSetHandler cobj_qobj cstr_evid
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> QObject t1 -> IO (Bool)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit1 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit1_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler1 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO (CBool)
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
x1obj <- qObjectFromPtr x1
let rv =
if (objectIsNull x0obj)
then return False
else _handler x0obj x1obj
rvf <- rv
return (toCBool rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler1" qtc_QTextEdit_setHandler1 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO (CBool)) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit1 :: (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO (CBool)) -> IO (FunPtr (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO (CBool)))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit1_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> QObject t1 -> IO (Bool)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit1 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit1_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler1 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO (CBool)
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
x1obj <- qObjectFromPtr x1
let rv =
if (objectIsNull x0obj)
then return False
else _handler x0obj x1obj
rvf <- rv
return (toCBool rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QcanInsertFromMimeData_h (QTextEdit ()) ((QMimeData t1)) where
canInsertFromMimeData_h x0 (x1)
= withBoolResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_canInsertFromMimeData cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_canInsertFromMimeData" qtc_QTextEdit_canInsertFromMimeData :: Ptr (TQTextEdit a) -> Ptr (TQMimeData t1) -> IO CBool
instance QcanInsertFromMimeData_h (QTextEditSc a) ((QMimeData t1)) where
canInsertFromMimeData_h x0 (x1)
= withBoolResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_canInsertFromMimeData cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> QEvent t1 -> IO ()) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit2 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit2_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler2 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO ()
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
x1obj <- objectFromPtr_nf x1
if (objectIsNull x0obj)
then return ()
else _handler x0obj x1obj
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler2" qtc_QTextEdit_setHandler2 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO ()) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit2 :: (Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO ()) -> IO (FunPtr (Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO ()))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit2_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> QEvent t1 -> IO ()) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit2 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit2_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler2 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO ()
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
x1obj <- objectFromPtr_nf x1
if (objectIsNull x0obj)
then return ()
else _handler x0obj x1obj
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QchangeEvent_h (QTextEdit ()) ((QEvent t1)) where
changeEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_changeEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_changeEvent" qtc_QTextEdit_changeEvent :: Ptr (TQTextEdit a) -> Ptr (TQEvent t1) -> IO ()
instance QchangeEvent_h (QTextEditSc a) ((QEvent t1)) where
changeEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_changeEvent cobj_x0 cobj_x1
instance QcontextMenuEvent_h (QTextEdit ()) ((QContextMenuEvent t1)) where
contextMenuEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_contextMenuEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_contextMenuEvent" qtc_QTextEdit_contextMenuEvent :: Ptr (TQTextEdit a) -> Ptr (TQContextMenuEvent t1) -> IO ()
instance QcontextMenuEvent_h (QTextEditSc a) ((QContextMenuEvent t1)) where
contextMenuEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_contextMenuEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> IO (QObject t0)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit3 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit3_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler3 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO (Ptr (TQObject t0))
setHandlerWrapper x0
= do x0obj <- qTextEditFromPtr x0
let rv =
if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj
rvf <- rv
withObjectPtr rvf $ \cobj_rvf -> return (cobj_rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler3" qtc_QTextEdit_setHandler3 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> IO (Ptr (TQObject t0))) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit3 :: (Ptr (TQTextEdit x0) -> IO (Ptr (TQObject t0))) -> IO (FunPtr (Ptr (TQTextEdit x0) -> IO (Ptr (TQObject t0))))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit3_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> IO (QObject t0)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit3 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit3_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler3 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO (Ptr (TQObject t0))
setHandlerWrapper x0
= do x0obj <- qTextEditFromPtr x0
let rv =
if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj
rvf <- rv
withObjectPtr rvf $ \cobj_rvf -> return (cobj_rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QcreateMimeDataFromSelection_h (QTextEdit ()) (()) where
createMimeDataFromSelection_h x0 ()
= withQMimeDataResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_createMimeDataFromSelection cobj_x0
foreign import ccall "qtc_QTextEdit_createMimeDataFromSelection" qtc_QTextEdit_createMimeDataFromSelection :: Ptr (TQTextEdit a) -> IO (Ptr (TQMimeData ()))
instance QcreateMimeDataFromSelection_h (QTextEditSc a) (()) where
createMimeDataFromSelection_h x0 ()
= withQMimeDataResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_createMimeDataFromSelection cobj_x0
instance QdragEnterEvent_h (QTextEdit ()) ((QDragEnterEvent t1)) where
dragEnterEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_dragEnterEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_dragEnterEvent" qtc_QTextEdit_dragEnterEvent :: Ptr (TQTextEdit a) -> Ptr (TQDragEnterEvent t1) -> IO ()
instance QdragEnterEvent_h (QTextEditSc a) ((QDragEnterEvent t1)) where
dragEnterEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_dragEnterEvent cobj_x0 cobj_x1
instance QdragLeaveEvent_h (QTextEdit ()) ((QDragLeaveEvent t1)) where
dragLeaveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_dragLeaveEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_dragLeaveEvent" qtc_QTextEdit_dragLeaveEvent :: Ptr (TQTextEdit a) -> Ptr (TQDragLeaveEvent t1) -> IO ()
instance QdragLeaveEvent_h (QTextEditSc a) ((QDragLeaveEvent t1)) where
dragLeaveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_dragLeaveEvent cobj_x0 cobj_x1
instance QdragMoveEvent_h (QTextEdit ()) ((QDragMoveEvent t1)) where
dragMoveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_dragMoveEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_dragMoveEvent" qtc_QTextEdit_dragMoveEvent :: Ptr (TQTextEdit a) -> Ptr (TQDragMoveEvent t1) -> IO ()
instance QdragMoveEvent_h (QTextEditSc a) ((QDragMoveEvent t1)) where
dragMoveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_dragMoveEvent cobj_x0 cobj_x1
instance QdropEvent_h (QTextEdit ()) ((QDropEvent t1)) where
dropEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_dropEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_dropEvent" qtc_QTextEdit_dropEvent :: Ptr (TQTextEdit a) -> Ptr (TQDropEvent t1) -> IO ()
instance QdropEvent_h (QTextEditSc a) ((QDropEvent t1)) where
dropEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_dropEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> QEvent t1 -> IO (Bool)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit4 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit4_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler4 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO (CBool)
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
x1obj <- objectFromPtr_nf x1
let rv =
if (objectIsNull x0obj)
then return False
else _handler x0obj x1obj
rvf <- rv
return (toCBool rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler4" qtc_QTextEdit_setHandler4 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO (CBool)) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit4 :: (Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO (CBool)) -> IO (FunPtr (Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO (CBool)))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit4_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> QEvent t1 -> IO (Bool)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit4 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit4_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler4 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQEvent t1) -> IO (CBool)
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
x1obj <- objectFromPtr_nf x1
let rv =
if (objectIsNull x0obj)
then return False
else _handler x0obj x1obj
rvf <- rv
return (toCBool rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance Qevent_h (QTextEdit ()) ((QEvent t1)) where
event_h x0 (x1)
= withBoolResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_event cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_event" qtc_QTextEdit_event :: Ptr (TQTextEdit a) -> Ptr (TQEvent t1) -> IO CBool
instance Qevent_h (QTextEditSc a) ((QEvent t1)) where
event_h x0 (x1)
= withBoolResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_event cobj_x0 cobj_x1
instance QfocusInEvent_h (QTextEdit ()) ((QFocusEvent t1)) where
focusInEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_focusInEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_focusInEvent" qtc_QTextEdit_focusInEvent :: Ptr (TQTextEdit a) -> Ptr (TQFocusEvent t1) -> IO ()
instance QfocusInEvent_h (QTextEditSc a) ((QFocusEvent t1)) where
focusInEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_focusInEvent cobj_x0 cobj_x1
instance QfocusOutEvent_h (QTextEdit ()) ((QFocusEvent t1)) where
focusOutEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_focusOutEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_focusOutEvent" qtc_QTextEdit_focusOutEvent :: Ptr (TQTextEdit a) -> Ptr (TQFocusEvent t1) -> IO ()
instance QfocusOutEvent_h (QTextEditSc a) ((QFocusEvent t1)) where
focusOutEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_focusOutEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> QObject t1 -> IO ()) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit5 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit5_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler5 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO ()
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
x1obj <- qObjectFromPtr x1
if (objectIsNull x0obj)
then return ()
else _handler x0obj x1obj
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler5" qtc_QTextEdit_setHandler5 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO ()) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit5 :: (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO ()) -> IO (FunPtr (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO ()))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit5_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> QObject t1 -> IO ()) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit5 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit5_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler5 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> IO ()
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
x1obj <- qObjectFromPtr x1
if (objectIsNull x0obj)
then return ()
else _handler x0obj x1obj
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QinsertFromMimeData_h (QTextEdit ()) ((QMimeData t1)) where
insertFromMimeData_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_insertFromMimeData cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_insertFromMimeData" qtc_QTextEdit_insertFromMimeData :: Ptr (TQTextEdit a) -> Ptr (TQMimeData t1) -> IO ()
instance QinsertFromMimeData_h (QTextEditSc a) ((QMimeData t1)) where
insertFromMimeData_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_insertFromMimeData cobj_x0 cobj_x1
instance QkeyPressEvent_h (QTextEdit ()) ((QKeyEvent t1)) where
keyPressEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_keyPressEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_keyPressEvent" qtc_QTextEdit_keyPressEvent :: Ptr (TQTextEdit a) -> Ptr (TQKeyEvent t1) -> IO ()
instance QkeyPressEvent_h (QTextEditSc a) ((QKeyEvent t1)) where
keyPressEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_keyPressEvent cobj_x0 cobj_x1
instance QkeyReleaseEvent_h (QTextEdit ()) ((QKeyEvent t1)) where
keyReleaseEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_keyReleaseEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_keyReleaseEvent" qtc_QTextEdit_keyReleaseEvent :: Ptr (TQTextEdit a) -> Ptr (TQKeyEvent t1) -> IO ()
instance QkeyReleaseEvent_h (QTextEditSc a) ((QKeyEvent t1)) where
keyReleaseEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_keyReleaseEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> Int -> QUrl t2 -> IO (QVariant t0)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit6 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit6_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler6 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> CInt -> Ptr (TQUrl t2) -> IO (Ptr (TQVariant t0))
setHandlerWrapper x0 x1 x2
= do x0obj <- qTextEditFromPtr x0
let x1int = fromCInt x1
x2obj <- objectFromPtr_nf x2
let rv =
if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj x1int x2obj
rvf <- rv
withObjectPtr rvf $ \cobj_rvf -> return (cobj_rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler6" qtc_QTextEdit_setHandler6 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> CInt -> Ptr (TQUrl t2) -> IO (Ptr (TQVariant t0))) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit6 :: (Ptr (TQTextEdit x0) -> CInt -> Ptr (TQUrl t2) -> IO (Ptr (TQVariant t0))) -> IO (FunPtr (Ptr (TQTextEdit x0) -> CInt -> Ptr (TQUrl t2) -> IO (Ptr (TQVariant t0))))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit6_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> Int -> QUrl t2 -> IO (QVariant t0)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit6 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit6_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler6 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> CInt -> Ptr (TQUrl t2) -> IO (Ptr (TQVariant t0))
setHandlerWrapper x0 x1 x2
= do x0obj <- qTextEditFromPtr x0
let x1int = fromCInt x1
x2obj <- objectFromPtr_nf x2
let rv =
if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj x1int x2obj
rvf <- rv
withObjectPtr rvf $ \cobj_rvf -> return (cobj_rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QloadResource_h (QTextEdit ()) ((Int, QUrl t2)) where
loadResource_h x0 (x1, x2)
= withQVariantResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x2 $ \cobj_x2 ->
qtc_QTextEdit_loadResource cobj_x0 (toCInt x1) cobj_x2
foreign import ccall "qtc_QTextEdit_loadResource" qtc_QTextEdit_loadResource :: Ptr (TQTextEdit a) -> CInt -> Ptr (TQUrl t2) -> IO (Ptr (TQVariant ()))
instance QloadResource_h (QTextEditSc a) ((Int, QUrl t2)) where
loadResource_h x0 (x1, x2)
= withQVariantResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x2 $ \cobj_x2 ->
qtc_QTextEdit_loadResource cobj_x0 (toCInt x1) cobj_x2
instance QmouseDoubleClickEvent_h (QTextEdit ()) ((QMouseEvent t1)) where
mouseDoubleClickEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_mouseDoubleClickEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_mouseDoubleClickEvent" qtc_QTextEdit_mouseDoubleClickEvent :: Ptr (TQTextEdit a) -> Ptr (TQMouseEvent t1) -> IO ()
instance QmouseDoubleClickEvent_h (QTextEditSc a) ((QMouseEvent t1)) where
mouseDoubleClickEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_mouseDoubleClickEvent cobj_x0 cobj_x1
instance QmouseMoveEvent_h (QTextEdit ()) ((QMouseEvent t1)) where
mouseMoveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_mouseMoveEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_mouseMoveEvent" qtc_QTextEdit_mouseMoveEvent :: Ptr (TQTextEdit a) -> Ptr (TQMouseEvent t1) -> IO ()
instance QmouseMoveEvent_h (QTextEditSc a) ((QMouseEvent t1)) where
mouseMoveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_mouseMoveEvent cobj_x0 cobj_x1
instance QmousePressEvent_h (QTextEdit ()) ((QMouseEvent t1)) where
mousePressEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_mousePressEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_mousePressEvent" qtc_QTextEdit_mousePressEvent :: Ptr (TQTextEdit a) -> Ptr (TQMouseEvent t1) -> IO ()
instance QmousePressEvent_h (QTextEditSc a) ((QMouseEvent t1)) where
mousePressEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_mousePressEvent cobj_x0 cobj_x1
instance QmouseReleaseEvent_h (QTextEdit ()) ((QMouseEvent t1)) where
mouseReleaseEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_mouseReleaseEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_mouseReleaseEvent" qtc_QTextEdit_mouseReleaseEvent :: Ptr (TQTextEdit a) -> Ptr (TQMouseEvent t1) -> IO ()
instance QmouseReleaseEvent_h (QTextEditSc a) ((QMouseEvent t1)) where
mouseReleaseEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_mouseReleaseEvent cobj_x0 cobj_x1
instance QpaintEvent_h (QTextEdit ()) ((QPaintEvent t1)) where
paintEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_paintEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_paintEvent" qtc_QTextEdit_paintEvent :: Ptr (TQTextEdit a) -> Ptr (TQPaintEvent t1) -> IO ()
instance QpaintEvent_h (QTextEditSc a) ((QPaintEvent t1)) where
paintEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_paintEvent cobj_x0 cobj_x1
instance QresizeEvent_h (QTextEdit ()) ((QResizeEvent t1)) where
resizeEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_resizeEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_resizeEvent" qtc_QTextEdit_resizeEvent :: Ptr (TQTextEdit a) -> Ptr (TQResizeEvent t1) -> IO ()
instance QresizeEvent_h (QTextEditSc a) ((QResizeEvent t1)) where
resizeEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_resizeEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> Int -> Int -> IO ()) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit7 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit7_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler7 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> CInt -> CInt -> IO ()
setHandlerWrapper x0 x1 x2
= do x0obj <- qTextEditFromPtr x0
let x1int = fromCInt x1
let x2int = fromCInt x2
if (objectIsNull x0obj)
then return ()
else _handler x0obj x1int x2int
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler7" qtc_QTextEdit_setHandler7 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> CInt -> CInt -> IO ()) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit7 :: (Ptr (TQTextEdit x0) -> CInt -> CInt -> IO ()) -> IO (FunPtr (Ptr (TQTextEdit x0) -> CInt -> CInt -> IO ()))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit7_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> Int -> Int -> IO ()) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit7 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit7_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler7 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> CInt -> CInt -> IO ()
setHandlerWrapper x0 x1 x2
= do x0obj <- qTextEditFromPtr x0
let x1int = fromCInt x1
let x2int = fromCInt x2
if (objectIsNull x0obj)
then return ()
else _handler x0obj x1int x2int
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QscrollContentsBy_h (QTextEdit ()) ((Int, Int)) where
scrollContentsBy_h x0 (x1, x2)
= withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_scrollContentsBy cobj_x0 (toCInt x1) (toCInt x2)
foreign import ccall "qtc_QTextEdit_scrollContentsBy" qtc_QTextEdit_scrollContentsBy :: Ptr (TQTextEdit a) -> CInt -> CInt -> IO ()
instance QscrollContentsBy_h (QTextEditSc a) ((Int, Int)) where
scrollContentsBy_h x0 (x1, x2)
= withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_scrollContentsBy cobj_x0 (toCInt x1) (toCInt x2)
instance QshowEvent_h (QTextEdit ()) ((QShowEvent t1)) where
showEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_showEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_showEvent" qtc_QTextEdit_showEvent :: Ptr (TQTextEdit a) -> Ptr (TQShowEvent t1) -> IO ()
instance QshowEvent_h (QTextEditSc a) ((QShowEvent t1)) where
showEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_showEvent cobj_x0 cobj_x1
instance QwheelEvent_h (QTextEdit ()) ((QWheelEvent t1)) where
wheelEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_wheelEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_wheelEvent" qtc_QTextEdit_wheelEvent :: Ptr (TQTextEdit a) -> Ptr (TQWheelEvent t1) -> IO ()
instance QwheelEvent_h (QTextEditSc a) ((QWheelEvent t1)) where
wheelEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_wheelEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> IO (QSize t0)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit8 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit8_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler8 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO (Ptr (TQSize t0))
setHandlerWrapper x0
= do x0obj <- qTextEditFromPtr x0
let rv =
if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj
rvf <- rv
withObjectPtr rvf $ \cobj_rvf -> return (cobj_rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler8" qtc_QTextEdit_setHandler8 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> IO (Ptr (TQSize t0))) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit8 :: (Ptr (TQTextEdit x0) -> IO (Ptr (TQSize t0))) -> IO (FunPtr (Ptr (TQTextEdit x0) -> IO (Ptr (TQSize t0))))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit8_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> IO (QSize t0)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit8 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit8_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler8 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO (Ptr (TQSize t0))
setHandlerWrapper x0
= do x0obj <- qTextEditFromPtr x0
let rv =
if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj
rvf <- rv
withObjectPtr rvf $ \cobj_rvf -> return (cobj_rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QqminimumSizeHint_h (QTextEdit ()) (()) where
qminimumSizeHint_h x0 ()
= withQSizeResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_minimumSizeHint cobj_x0
foreign import ccall "qtc_QTextEdit_minimumSizeHint" qtc_QTextEdit_minimumSizeHint :: Ptr (TQTextEdit a) -> IO (Ptr (TQSize ()))
instance QqminimumSizeHint_h (QTextEditSc a) (()) where
qminimumSizeHint_h x0 ()
= withQSizeResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_minimumSizeHint cobj_x0
instance QminimumSizeHint_h (QTextEdit ()) (()) where
minimumSizeHint_h x0 ()
= withSizeResult $ \csize_ret_w csize_ret_h ->
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_minimumSizeHint_qth cobj_x0 csize_ret_w csize_ret_h
foreign import ccall "qtc_QTextEdit_minimumSizeHint_qth" qtc_QTextEdit_minimumSizeHint_qth :: Ptr (TQTextEdit a) -> Ptr CInt -> Ptr CInt -> IO ()
instance QminimumSizeHint_h (QTextEditSc a) (()) where
minimumSizeHint_h x0 ()
= withSizeResult $ \csize_ret_w csize_ret_h ->
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_minimumSizeHint_qth cobj_x0 csize_ret_w csize_ret_h
instance QqsizeHint_h (QTextEdit ()) (()) where
qsizeHint_h x0 ()
= withQSizeResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_sizeHint cobj_x0
foreign import ccall "qtc_QTextEdit_sizeHint" qtc_QTextEdit_sizeHint :: Ptr (TQTextEdit a) -> IO (Ptr (TQSize ()))
instance QqsizeHint_h (QTextEditSc a) (()) where
qsizeHint_h x0 ()
= withQSizeResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_sizeHint cobj_x0
instance QsizeHint_h (QTextEdit ()) (()) where
sizeHint_h x0 ()
= withSizeResult $ \csize_ret_w csize_ret_h ->
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_sizeHint_qth cobj_x0 csize_ret_w csize_ret_h
foreign import ccall "qtc_QTextEdit_sizeHint_qth" qtc_QTextEdit_sizeHint_qth :: Ptr (TQTextEdit a) -> Ptr CInt -> Ptr CInt -> IO ()
instance QsizeHint_h (QTextEditSc a) (()) where
sizeHint_h x0 ()
= withSizeResult $ \csize_ret_w csize_ret_h ->
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_sizeHint_qth cobj_x0 csize_ret_w csize_ret_h
instance QviewportEvent_h (QTextEdit ()) ((QEvent t1)) where
viewportEvent_h x0 (x1)
= withBoolResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_viewportEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_viewportEvent" qtc_QTextEdit_viewportEvent :: Ptr (TQTextEdit a) -> Ptr (TQEvent t1) -> IO CBool
instance QviewportEvent_h (QTextEditSc a) ((QEvent t1)) where
viewportEvent_h x0 (x1)
= withBoolResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_viewportEvent cobj_x0 cobj_x1
instance QactionEvent_h (QTextEdit ()) ((QActionEvent t1)) where
actionEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_actionEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_actionEvent" qtc_QTextEdit_actionEvent :: Ptr (TQTextEdit a) -> Ptr (TQActionEvent t1) -> IO ()
instance QactionEvent_h (QTextEditSc a) ((QActionEvent t1)) where
actionEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_actionEvent cobj_x0 cobj_x1
instance QcloseEvent_h (QTextEdit ()) ((QCloseEvent t1)) where
closeEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_closeEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_closeEvent" qtc_QTextEdit_closeEvent :: Ptr (TQTextEdit a) -> Ptr (TQCloseEvent t1) -> IO ()
instance QcloseEvent_h (QTextEditSc a) ((QCloseEvent t1)) where
closeEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_closeEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> IO (Int)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit9 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit9_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler9 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO (CInt)
setHandlerWrapper x0
= do x0obj <- qTextEditFromPtr x0
let rv =
if (objectIsNull x0obj)
then return 0
else _handler x0obj
rvf <- rv
return (toCInt rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler9" qtc_QTextEdit_setHandler9 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> IO (CInt)) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit9 :: (Ptr (TQTextEdit x0) -> IO (CInt)) -> IO (FunPtr (Ptr (TQTextEdit x0) -> IO (CInt)))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit9_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> IO (Int)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit9 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit9_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler9 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO (CInt)
setHandlerWrapper x0
= do x0obj <- qTextEditFromPtr x0
let rv =
if (objectIsNull x0obj)
then return 0
else _handler x0obj
rvf <- rv
return (toCInt rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QdevType_h (QTextEdit ()) (()) where
devType_h x0 ()
= withIntResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_devType cobj_x0
foreign import ccall "qtc_QTextEdit_devType" qtc_QTextEdit_devType :: Ptr (TQTextEdit a) -> IO CInt
instance QdevType_h (QTextEditSc a) (()) where
devType_h x0 ()
= withIntResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_devType cobj_x0
instance QenterEvent_h (QTextEdit ()) ((QEvent t1)) where
enterEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_enterEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_enterEvent" qtc_QTextEdit_enterEvent :: Ptr (TQTextEdit a) -> Ptr (TQEvent t1) -> IO ()
instance QenterEvent_h (QTextEditSc a) ((QEvent t1)) where
enterEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_enterEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> Int -> IO (Int)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit10 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit10_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler10 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> CInt -> IO (CInt)
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
let x1int = fromCInt x1
let rv =
if (objectIsNull x0obj)
then return 0
else _handler x0obj x1int
rvf <- rv
return (toCInt rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler10" qtc_QTextEdit_setHandler10 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> CInt -> IO (CInt)) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit10 :: (Ptr (TQTextEdit x0) -> CInt -> IO (CInt)) -> IO (FunPtr (Ptr (TQTextEdit x0) -> CInt -> IO (CInt)))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit10_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> Int -> IO (Int)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit10 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit10_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler10 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> CInt -> IO (CInt)
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
let x1int = fromCInt x1
let rv =
if (objectIsNull x0obj)
then return 0
else _handler x0obj x1int
rvf <- rv
return (toCInt rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QheightForWidth_h (QTextEdit ()) ((Int)) where
heightForWidth_h x0 (x1)
= withIntResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_heightForWidth cobj_x0 (toCInt x1)
foreign import ccall "qtc_QTextEdit_heightForWidth" qtc_QTextEdit_heightForWidth :: Ptr (TQTextEdit a) -> CInt -> IO CInt
instance QheightForWidth_h (QTextEditSc a) ((Int)) where
heightForWidth_h x0 (x1)
= withIntResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_heightForWidth cobj_x0 (toCInt x1)
instance QhideEvent_h (QTextEdit ()) ((QHideEvent t1)) where
hideEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_hideEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_hideEvent" qtc_QTextEdit_hideEvent :: Ptr (TQTextEdit a) -> Ptr (TQHideEvent t1) -> IO ()
instance QhideEvent_h (QTextEditSc a) ((QHideEvent t1)) where
hideEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_hideEvent cobj_x0 cobj_x1
instance QleaveEvent_h (QTextEdit ()) ((QEvent t1)) where
leaveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_leaveEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_leaveEvent" qtc_QTextEdit_leaveEvent :: Ptr (TQTextEdit a) -> Ptr (TQEvent t1) -> IO ()
instance QleaveEvent_h (QTextEditSc a) ((QEvent t1)) where
leaveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_leaveEvent cobj_x0 cobj_x1
instance QmoveEvent_h (QTextEdit ()) ((QMoveEvent t1)) where
moveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_moveEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_moveEvent" qtc_QTextEdit_moveEvent :: Ptr (TQTextEdit a) -> Ptr (TQMoveEvent t1) -> IO ()
instance QmoveEvent_h (QTextEditSc a) ((QMoveEvent t1)) where
moveEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_moveEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> IO (QPaintEngine t0)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit11 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit11_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler11 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO (Ptr (TQPaintEngine t0))
setHandlerWrapper x0
= do x0obj <- qTextEditFromPtr x0
let rv =
if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj
rvf <- rv
withObjectPtr rvf $ \cobj_rvf -> return (cobj_rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler11" qtc_QTextEdit_setHandler11 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> IO (Ptr (TQPaintEngine t0))) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit11 :: (Ptr (TQTextEdit x0) -> IO (Ptr (TQPaintEngine t0))) -> IO (FunPtr (Ptr (TQTextEdit x0) -> IO (Ptr (TQPaintEngine t0))))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit11_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> IO (QPaintEngine t0)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit11 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit11_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler11 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> IO (Ptr (TQPaintEngine t0))
setHandlerWrapper x0
= do x0obj <- qTextEditFromPtr x0
let rv =
if (objectIsNull x0obj)
then return $ objectCast x0obj
else _handler x0obj
rvf <- rv
withObjectPtr rvf $ \cobj_rvf -> return (cobj_rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QpaintEngine_h (QTextEdit ()) (()) where
paintEngine_h x0 ()
= withObjectRefResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_paintEngine cobj_x0
foreign import ccall "qtc_QTextEdit_paintEngine" qtc_QTextEdit_paintEngine :: Ptr (TQTextEdit a) -> IO (Ptr (TQPaintEngine ()))
instance QpaintEngine_h (QTextEditSc a) (()) where
paintEngine_h x0 ()
= withObjectRefResult $
withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_paintEngine cobj_x0
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> Bool -> IO ()) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit12 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit12_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler12 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> CBool -> IO ()
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
let x1bool = fromCBool x1
if (objectIsNull x0obj)
then return ()
else _handler x0obj x1bool
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler12" qtc_QTextEdit_setHandler12 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> CBool -> IO ()) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit12 :: (Ptr (TQTextEdit x0) -> CBool -> IO ()) -> IO (FunPtr (Ptr (TQTextEdit x0) -> CBool -> IO ()))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit12_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> Bool -> IO ()) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit12 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit12_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler12 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> CBool -> IO ()
setHandlerWrapper x0 x1
= do x0obj <- qTextEditFromPtr x0
let x1bool = fromCBool x1
if (objectIsNull x0obj)
then return ()
else _handler x0obj x1bool
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QsetVisible_h (QTextEdit ()) ((Bool)) where
setVisible_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_setVisible cobj_x0 (toCBool x1)
foreign import ccall "qtc_QTextEdit_setVisible" qtc_QTextEdit_setVisible :: Ptr (TQTextEdit a) -> CBool -> IO ()
instance QsetVisible_h (QTextEditSc a) ((Bool)) where
setVisible_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
qtc_QTextEdit_setVisible cobj_x0 (toCBool x1)
instance QtabletEvent_h (QTextEdit ()) ((QTabletEvent t1)) where
tabletEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_tabletEvent cobj_x0 cobj_x1
foreign import ccall "qtc_QTextEdit_tabletEvent" qtc_QTextEdit_tabletEvent :: Ptr (TQTextEdit a) -> Ptr (TQTabletEvent t1) -> IO ()
instance QtabletEvent_h (QTextEditSc a) ((QTabletEvent t1)) where
tabletEvent_h x0 (x1)
= withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
qtc_QTextEdit_tabletEvent cobj_x0 cobj_x1
instance QsetHandler (QTextEdit ()) (QTextEdit x0 -> QObject t1 -> QEvent t2 -> IO (Bool)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit13 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit13_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler13 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> Ptr (TQEvent t2) -> IO (CBool)
setHandlerWrapper x0 x1 x2
= do x0obj <- qTextEditFromPtr x0
x1obj <- qObjectFromPtr x1
x2obj <- objectFromPtr_nf x2
let rv =
if (objectIsNull x0obj)
then return False
else _handler x0obj x1obj x2obj
rvf <- rv
return (toCBool rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
foreign import ccall "qtc_QTextEdit_setHandler13" qtc_QTextEdit_setHandler13 :: Ptr (TQTextEdit a) -> CWString -> Ptr (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> Ptr (TQEvent t2) -> IO (CBool)) -> Ptr () -> Ptr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO ()
foreign import ccall "wrapper" wrapSetHandler_QTextEdit13 :: (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> Ptr (TQEvent t2) -> IO (CBool)) -> IO (FunPtr (Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> Ptr (TQEvent t2) -> IO (CBool)))
foreign import ccall "wrapper" wrapSetHandler_QTextEdit13_d :: (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()) -> IO (FunPtr (Ptr fun -> Ptr state -> Ptr fun_d -> IO ()))
instance QsetHandler (QTextEditSc a) (QTextEdit x0 -> QObject t1 -> QEvent t2 -> IO (Bool)) where
setHandler _eobj _eid _handler
= do
funptr <- wrapSetHandler_QTextEdit13 setHandlerWrapper
stptr <- newStablePtr (Wrap _handler)
funptr_d <- wrapSetHandler_QTextEdit13_d setHandlerWrapper_d
withObjectPtr _eobj $ \cobj_eobj ->
withCWString _eid $ \cstr_eid ->
qtc_QTextEdit_setHandler13 cobj_eobj cstr_eid (toCFunPtr funptr) (castStablePtrToPtr stptr) (toCFunPtr funptr_d)
return()
where
setHandlerWrapper :: Ptr (TQTextEdit x0) -> Ptr (TQObject t1) -> Ptr (TQEvent t2) -> IO (CBool)
setHandlerWrapper x0 x1 x2
= do x0obj <- qTextEditFromPtr x0
x1obj <- qObjectFromPtr x1
x2obj <- objectFromPtr_nf x2
let rv =
if (objectIsNull x0obj)
then return False
else _handler x0obj x1obj x2obj
rvf <- rv
return (toCBool rvf)
setHandlerWrapper_d :: Ptr fun -> Ptr () -> Ptr fun_d -> IO ()
setHandlerWrapper_d funptr stptr funptr_d
= do when (stptr/=ptrNull)
(freeStablePtr (castPtrToStablePtr stptr))
when (funptr/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr))
when (funptr_d/=ptrNull)
(freeHaskellFunPtr (castPtrToFunPtr funptr_d))
return ()
instance QeventFilter_h (QTextEdit ()) ((QObject t1, QEvent t2)) where
eventFilter_h x0 (x1, x2)
= withBoolResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
withObjectPtr x2 $ \cobj_x2 ->
qtc_QTextEdit_eventFilter cobj_x0 cobj_x1 cobj_x2
foreign import ccall "qtc_QTextEdit_eventFilter" qtc_QTextEdit_eventFilter :: Ptr (TQTextEdit a) -> Ptr (TQObject t1) -> Ptr (TQEvent t2) -> IO CBool
instance QeventFilter_h (QTextEditSc a) ((QObject t1, QEvent t2)) where
eventFilter_h x0 (x1, x2)
= withBoolResult $
withObjectPtr x0 $ \cobj_x0 ->
withObjectPtr x1 $ \cobj_x1 ->
withObjectPtr x2 $ \cobj_x2 ->
qtc_QTextEdit_eventFilter cobj_x0 cobj_x1 cobj_x2
| keera-studios/hsQt | Qtc/Gui/QTextEdit_h.hs | bsd-2-clause | 72,016 | 0 | 18 | 15,932 | 24,169 | 11,620 | 12,549 | -1 | -1 |
module GTKInitialization
( initUI
, buildUI
, setupUI
, startUI
) where
import BattleContext
import GTKContext
import GTKMainWindow
import GTKButtonPanel
import GTKOverlay
import GTKUnit
import qualified Data.Text as DT
import Data.IORef
import Control.Monad.Trans
import Control.Monad.Trans.Reader
import qualified GI.Gtk as Gtk
-- import System.IO.Unsafe
-- import Data.IORef
-- import qualified Data.Text as DT
-- import System.FilePath
-- import Data.Maybe
-- import Control.Monad
-- import Data.GI.Base
-- import qualified GI.Gtk as Gtk
-- import qualified GI.GdkPixbuf as GP
-- -- cairo/gi-cairo stuff
-- import qualified GI.Cairo as GI.Cairo
-- import Graphics.Rendering.Cairo
-- import Graphics.Rendering.Cairo.Internal (Render(runRender))
-- import Graphics.Rendering.Cairo.Types (Cairo(Cairo))
-- import Foreign.Ptr (castPtr)
-- import Control.Monad.Trans.Reader
-- | Early initialization of GTK
initUI :: IO ()
initUI = Gtk.init Nothing
-- | Build GTK ui (both builder and manual widgets) and return its program context
buildUI :: BattleContext -> FilePath -> IO GTKContext
buildUI bctx datadir = do
let f = (uctxDataDir uctx) ++ "/ui-main.glade"
builder <- Gtk.builderNewFromFile (DT.pack f)
-- fetch and construct gtk units
let blueforce = bctxBlueForce bctx
let redforce = bctxRedForce bctx
let iconsdir = datadir ++ "/Icons"
bluegus <- liftIO $ constructForceUnitWidgets iconsdir blueforce
redgus <- liftIO $ constructForceUnitWidgets iconsdir redforce
-- mutable battle context
bctxref <- newIORef bctx
-- gtk units are stored in a mutable list to modify them on the fly
gunitsref <- newIORef $ bluegus ++ redgus
-- attach click events in the gtk context to all units' event boxes
-- _ <- liftIO $ Gtk.onWidgetButtonPressEvent evbox (runReaderT btnOrbatClicked gtkctx)
return $ GTKContext
{ gctxBattleContext = bctxref
, gctxDataDir = datadir
, gctxBuilder = builder
, gctxUnitWidgets = gunitsref
}
-- | Set up signal handlers, widgets, etc in GTK program context
setupUI :: ReaderT GTKContext IO ()
setupUI = do
setupMainWindow
setupButtons
setupOverlay
return ()
-- | Run the GTK program
startUI :: ReaderT GTKContext IO ()
startUI = do
liftIO $ Gtk.main
| nbrk/ld | executable/GTK.hs | bsd-2-clause | 2,269 | 0 | 12 | 407 | 371 | 205 | 166 | 43 | 1 |
module TestImport
( module TestImport
, module X
) where
import Test.Hspec as X
import Data.Text as X (Text)
import Database.Persist.Sqlite as X
import Control.Monad.IO.Class as X (liftIO, MonadIO)
import Control.Monad as X (void, liftM)
import Control.Monad.Reader as X (ReaderT)
import Control.Monad.Logger
import Control.Monad.Trans.Resource (ResourceT, MonadBaseControl, runResourceT)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Database.OrgMode as Db
import qualified Database.OrgMode.Internal.Types as Db
-------------------------------------------------------------------------------
setupDb :: (MonadBaseControl IO m, MonadIO m) => ReaderT SqlBackend m ()
setupDb = void $ runMigrationSilent Db.migrateAll
runDb :: forall a. SqlPersistT (NoLoggingT (ResourceT IO)) a -> IO a
runDb a = liftIO $ runSqlite ":memory:" $ setupDb >> a
runDb' :: forall a. SqlPersistT (LoggingT (ResourceT IO)) a -> IO a
runDb' a = liftIO $ runSqlite' ":memory:" $ setupDb >> a
runSqlite' :: forall (m :: * -> *) a.
(MonadIO m, MonadBaseControl IO m)
=> Text
-> SqlPersistT (LoggingT (ResourceT m)) a
-> m a
runSqlite' connstr = runResourceT
. runStderrLoggingT
. withSqliteConn connstr
. runSqlConn
{-|
Imports the given example file to the database
-}
importExample :: (MonadIO m)
=> FilePath
-> ReaderT SqlBackend m (Key Db.Document)
importExample fname = do
contents <- liftIO (getExample fname)
parseImport (T.pack fname) allowedTags contents
where
allowedTags = ["TODO", "DONE"]
{-|
Helper for reading a org-mode example file from the `examples` directory in
test.
-}
getExample :: FilePath -> IO Text
getExample fname = T.readFile $ "test/examples/" ++ fname
{-|
Helper for parsing org-mode document contents and then importing the result
into the database. Does nothing on parsing failure, instead lets the database
test constraints handle the failure (since nothing will be inserted into the
database on parse failure).
-}
parseImport :: (MonadIO m)
=> Text -- ^ Name of the document
-> [Text] -- ^ Keywords to allow
-> Text -- ^ org-mode document contents
-> ReaderT SqlBackend m (Key Db.Document)
parseImport docName keywords contents
= getId `liftM` Db.textImportDocument docName keywords contents
where
getId (Right docId) = docId
getId (Left err) = error err
| rzetterberg/orgmode-sql | test/TestImport.hs | bsd-3-clause | 2,708 | 0 | 13 | 744 | 622 | 347 | 275 | -1 | -1 |
import qualified Wigner.Transformations as T
import qualified Wigner.Symbols as S
import qualified Wigner.DefineExpression as D
import qualified Wigner.OperatorAlgebra as O
import Wigner.Texable
import Wigner.Expression
import qualified Data.Map as M
import qualified Data.List as L
index :: Integer -> Index
index i = S.index (fromInteger i :: Int)
a i = D.operatorIx S.a [index i]
b i = D.operatorIx S.b [index i]
s_rho = S.symbol "\\rho"
rho = D.operator s_rho
kappa i = D.constantIx (S.symbol "\\kappa") [index i]
g i j = D.constantIx (S.symbol "g") (L.sort [index i, index j])
gamma1 i = D.constantIx (S.symbol "\\gamma") [index i]
gamma2 i j = D.constantIx (S.symbol "\\gamma") (L.sort [index i, index j])
gamma3 i j k = D.constantIx (S.symbol "\\gamma") (L.sort [index i, index j, index k])
commutator x y = x * y - y * x
lossTerm x = 2 * x * rho * dagger x - dagger x * x * rho - rho * dagger x * x
hamiltonian =
sum (map
(\i -> kappa i * (dagger (a i) * b i + dagger (b i) * a i))
[1, 2])
+ sum (map
(\(i, j) -> g i j * (
dagger (a i) * dagger (a j) * a j * a i +
dagger (b i) * dagger (b j) * b j * b i
) / 2)
[(1,1), (1,2), (2,1), (2,2)])
loss_terms =
gamma1 1 * lossTerm (a 1) +
gamma1 1 * lossTerm (b 1) +
gamma2 1 2 * lossTerm (a 1 * a 2) +
gamma2 1 2 * lossTerm (b 1 * b 2) +
gamma2 2 2 * lossTerm (a 2 * a 2) +
gamma2 2 2 * lossTerm (b 2 * b 2)
--gamma3 1 1 1 * lossTerm (a 1 * a 1 * a 1) +
--gamma3 1 1 1 * lossTerm (b 1 * b 1 * b 1)
master_eqn = -D.i * commutator hamiltonian rho + loss_terms
fpe = T.wignerTransformation S.default_map s_rho master_eqn
main = do
putStrLn $ T.showTexByDifferentials (T.truncateDifferentials 2 fpe)
| fjarri/wigner | examples/master_equation.hs | bsd-3-clause | 1,759 | 9 | 22 | 451 | 915 | 450 | 465 | 42 | 1 |
-- | https://github.com/eugenkiss/7guis/wiki#the-seven-tasks
module LGtk.Demos.SevenGuis.Timer (timer) where
import Control.Monad
import Control.Lens
import LGtk
import Numeric
timer :: Widget
timer = do
d <- newRef 10.0
e <- liftM (lensMap _2) $ extendRef d (lens fst $ \(_, t) d -> (d, min t d) ) (0, 0)
let ratio = liftM2 (/) (readRef e) (readRef d) <&> min 1 . max 0
_ <- onChange ratio $ const $ do
t <- readerToCreator $ readRef e
duration <- readerToCreator $ readRef d
when (t < duration) $ asyncWrite 20000 $ writeRef e $ min duration $ t + 0.02
vertically
[ horizontally
[ label (return "Elapsed Time: ")
, progress ratio
]
, horizontally
[ vertically
[ label $ liftM (\v -> showFFloat (Just 2) v $ "s") $ readRef e
, label $ return "Duration: "
]
, hscale 0.0 60.0 10.0 d
]
, button (return "Reset") $ return $ Just $ writeRef e 0
]
| divipp/lgtk | lgtkdemo/LGtk/Demos/SevenGuis/Timer.hs | bsd-3-clause | 1,044 | 0 | 21 | 358 | 382 | 190 | 192 | -1 | -1 |
-- | Functions to create a Fragment for (parts of) an abstract syntax tree.
module Language.Python.TypeInference.CFG.ToFragment (
convertModule,
runConversion,
ConversionState
) where
import Control.Monad.State
import Data.Map (Map)
import Data.Maybe
import Data.Set (Set)
import Language.Python.Common.SrcLocation
import Language.Python.TypeInference.CFG.CFG
import Language.Python.TypeInference.CFG.Fragment
import Language.Python.TypeInference.Common
import Language.Python.TypeInference.Error
import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Language.Python.Common.AST as AST
-- | Create a fragment for a module.
convertModule :: String -> AST.ModuleSpan
-> StateT ConversionState TypeInferenceMonad (Fragment, Set Identifier)
convertModule moduleName (AST.Module stmts) =
do bound <- lift $ namesBound stmts
moduleNames <- lift $ moduleNamesBound stmts
let bindings = [ (n, Name (ModuleScope moduleName) n)
| n <- Set.toList bound ]
identifiers = map snd bindings
env = Map.fromList bindings
fragment <- withStateT (\cs -> cs { csEnvironment = env,
csCurrentModule = moduleName,
csOtherModules = moduleNames } )
(convertAll stmts)
return (fragment, Set.fromList identifiers)
-- | Create a fragment for a sequence of statements.
convertAll :: [AST.Statement SrcSpan] -> Conversion
convertAll stmts = do fs <- mapM convert stmts
return $ mconcat fs
-- | The environment indicates which name binding a name refers to.
type Environment = Map String Identifier
-- | State maintained while converting from AST to Fragment.
data ConversionState =
ConversionState {
csNextLabel :: Int,
csNextIdentifier :: Int,
csNextFunctionId :: FunctionId,
csNextClassId :: ClassId,
csNextWithId :: Int,
csNextForLoopId :: Int,
csEnvironment :: Environment,
csCurrentModule :: String,
csOtherModules :: Set String,
csExternalModules :: Set String
}
-- | Given the module name and top-level environment, create an initial state.
initialState :: ConversionState
initialState = ConversionState 1 1 1 1 1 1 Map.empty "none" Set.empty Set.empty
-- | Type of a computation that converts from AST to Fragment.
type Conversion = StateT ConversionState TypeInferenceMonad Fragment
-- | Given the module name and top-level environment, run conversion.
runConversion :: Set String
-> Int
-> StateT ConversionState TypeInferenceMonad a
-> TypeInferenceMonad a
runConversion externalModules nextClassId c =
evalStateT c (initialState { csNextClassId = nextClassId
, csExternalModules = externalModules })
-- | Get a new, unique label.
newLabel :: StateT ConversionState TypeInferenceMonad Int
newLabel = do l <- gets csNextLabel
modify $ \s -> s { csNextLabel = l + 1 }
return l
-- | Get a new, unique identifier.
newIdentifier :: StateT ConversionState TypeInferenceMonad Identifier
newIdentifier = do i <- gets csNextIdentifier
modify $ \s -> s { csNextIdentifier = i + 1 }
return $ Generated i
-- | Get a new, unique function id.
newFunctionId :: StateT ConversionState TypeInferenceMonad FunctionId
newFunctionId = do l <- gets csNextFunctionId
modify $ \s -> s { csNextFunctionId = l + 1 }
return l
-- | Get a new, unique class id.
newClassId :: StateT ConversionState TypeInferenceMonad ClassId
newClassId = do l <- gets csNextClassId
modify $ \s -> s { csNextClassId = l + 1 }
return l
-- | Get a new, unique @with@ id.
newWithId :: StateT ConversionState TypeInferenceMonad Int
newWithId = do l <- gets csNextWithId
modify $ \s -> s { csNextWithId = l + 1 }
return l
-- | Get a new, unique @for@ loop id.
newForLoopId :: StateT ConversionState TypeInferenceMonad Int
newForLoopId = do l <- gets csNextForLoopId
modify $ \s -> s { csNextForLoopId = l + 1 }
return l
-- | Look up the given name in the current environment and return the
-- identifier it revers to.
getI :: String -> StateT ConversionState TypeInferenceMonad Identifier
getI name =
do env <- gets csEnvironment
return $ Map.findWithDefault (Name Global name) name env
mkIdentifier :: String -> String
-> StateT ConversionState TypeInferenceMonad Identifier
mkIdentifier moduleName identifierName =
do externalModules <- gets csExternalModules
let scope = if moduleName `Set.member` externalModules
then ExternalScope
else ModuleScope
return $ Name (scope moduleName) identifierName
-- | Execute an action on a state modified by adding a list of bindings to the
-- environment.
withBindings :: [(String, Identifier)]
-> StateT ConversionState TypeInferenceMonad a
-> StateT ConversionState TypeInferenceMonad a
withBindings list m =
do let setEnv env = modify $ \s -> s { csEnvironment = env }
env <- gets csEnvironment
setEnv $ Map.fromList list `Map.union` env
result <- m
setEnv env
return result
-- | Create a new fragment containing one program point.
newFragment :: ProgramPoint -> SrcSpan
-> StateT ConversionState TypeInferenceMonad (Label, Fragment)
newFragment pp srcSpan =
do l <- newLabel
pos <- lift $ toPosition srcSpan
let f = fragment (Map.singleton l (pp, pos))
Set.empty
(Set.singleton l)
(Set.singleton l)
return (l, f)
-- | Like 'newFragment', but don't return the label.
newFragment' :: ProgramPoint -> SrcSpan -> Conversion
newFragment' p s = do (_, f) <- newFragment p s
return f
-- | Create Fragment for a statement.
convert :: AST.Statement SrcSpan -> Conversion
-- Import statements.
convert (AST.Import items s) =
do imports <- mapM imported items
fs <- mapM (importNodes s) imports
return $ mconcat fs
convert (AST.FromImport m i s) =
do imports <- fromImported m i
importNodes s imports
-- While loop.
convert (AST.While cond body els _) =
do (fCondBefore, e) <- toExpression cond
fCondActual <- newFragment' (LoopCondition e) (AST.annot cond)
let fCond = fCondBefore `mappend` fCondActual
fBody <- convertAll body
fEls <- convertAll els
let fs = [fCond, fBody] ++ if nullF fEls then [] else [fEls]
nodes = Map.unions (map getNodes fs)
edges = Set.unions (map getEdges fs)
`Set.union` (fCond --> fBody)
`Set.union` (fBody --> fCond)
`Set.union` (fCond --> fEls)
`Set.union` continueEdges fBody fCond
initial = frInitial fCond
final = getBreak fBody
`Set.union` if nullF fEls
then getFinal fCond
`Set.union` getContinue fBody
else getFinal fEls
break = if nullF fEls then Set.empty else getBreak fEls
continu = if nullF fEls then Set.empty else getContinue fEls
ret = Set.unions $ map getReturn fs
imports = Map.unions $ map getImports fs
ft = Map.unions $ map getFunctionTable fs
return $ Fragment nodes edges initial final break continu ret imports ft
-- For loop.
convert (AST.For targets generator body els _) =
do forLoopId <- newForLoopId
let newBindings = [(n, Name (ForLoopScope forLoopId) n)
| n <- targetNames targets]
newIdentifiers = map snd newBindings
lookupName name = withBindings newBindings (getI name)
(fGenBefore, e) <- toExpression generator
i <- newIdentifier
let srcSpan = AST.annot generator
fGen <- newFragment' (Assignment [TargetIdentifier i] e) srcSpan
let fg = fGenBefore `mappend` fGen
targetList <- mapM (toTarget lookupName) targets
let (fts, ts) = unzip targetList
(lAssign, fAssign) <- newFragment (ForAssign (TargetList ts) i) srcSpan
fBody <- withBindings newBindings (convertAll body)
(sn, sx) <- scopeFragments newIdentifiers srcSpan
let fBefore = mconcat (fts ++ [sn])
fEls <- convertAll els
let fs = [fg, fBefore, fAssign, sx, fBody]
++ if nullF fEls then [] else [fEls]
nodes = Map.unions (map getNodes fs)
edges = Set.unions (map getEdges fs)
`Set.union` (fg --> fBefore)
`Set.union` (fBefore --> fAssign)
`Set.union` (fAssign --> fBody)
`Set.union` (fBody --> fAssign)
`Set.union` (fAssign --> sx)
`Set.union` (sx --> fEls)
`Set.union` continueEdges fBody fAssign
`Set.union`
Set.fromList
[(b, i) | b <- Set.toList (getBreak fBody),
i <- Set.toList (getInitial sx)]
initial = frInitial fg
final = getFinal (if nullF fEls then sx else fEls)
break = if nullF fEls then Set.empty else getBreak fEls
continu = if nullF fEls then Set.empty else getContinue fEls
ret = Set.unions $ map getReturn fs
imports = Map.unions $ map getImports fs
ft = Map.unions $ map getFunctionTable fs
return $ Fragment nodes edges initial final break continu ret imports ft
-- Function definition.
convert (AST.Fun (AST.Ident name _) params _ body s) =
do functionId <- newFunctionId
identifier <- getI name
list <- mapM (toParameter (FunctionScope functionId)) params
let (pfs, ps) = unzip (concat list)
fd <- newFragment' (Def identifier functionId) s
let fd' = mconcat $ pfs ++ [fd]
(ln, fn) <- newFragment (FunctionEntry ps) s
(lx, fx) <- newFragment (FunctionExit ps) s
bound <- lift $ namesBound body
nonlocal <- lift $ declaredNonlocal body
global <- lift $ declaredGlobal body
ps <- lift $ mapM paramName params
moduleName <- gets csCurrentModule
let paramNames = concat ps
newNames = (Set.fromList paramNames `Set.union` bound)
Set.\\ (nonlocal `Set.union` global)
moduleScope = ModuleScope moduleName
newBindings = [ (n, Name (FunctionScope functionId) n)
| n <- Set.toList newNames]
newIdentifiers = map snd newBindings
globalBindings = [(n, Name moduleScope n) | n <- Set.toList global]
fBody <- withBindings (newBindings ++ globalBindings) (convertAll body)
(sn, sx) <- scopeFragments newIdentifiers s
let fs = [fd', fn, fx, fBody, sn, sx]
nodes = Map.unions (map getNodes fs)
edges = getEdges fd'
`Set.union` getEdges fBody
`Set.union` (sn --> fn)
`Set.union` (fn --> fBody)
`Set.union` returnEdges fBody fx
`Set.union` (fx --> sx)
initial = frInitial fd'
final = getFinal fd'
break = Set.empty
continu = Set.empty
ret = Set.empty
imports = Map.unions $ map getImports fs
ft = Map.fromList [ (functionId, (a, b))
| a <- Set.toList (getInitial sn),
b <- Set.toList (getInitial sx) ]
`Map.union`
Map.unions (map getFunctionTable fs)
return $ Fragment nodes edges initial final break continu ret imports ft
-- Class definition.
convert (AST.Class (AST.Ident name _) args body s) =
do list <- mapM toArgument args
let (fs, as) = unzip list
identifier <- getI name
classId <- newClassId
(le, fe) <- newFragment (ClassEntry identifier classId as) s
(lx, fx) <- newFragment (ClassExit identifier classId as) s
bound <- lift $ namesBound body
nonlocal <- lift $ declaredNonlocal body
global <- lift $ declaredGlobal body
moduleName <- gets csCurrentModule
let newNames = bound Set.\\ (nonlocal `Set.union` global)
moduleScope = ModuleScope moduleName
newBindings = [ (n, Name (ClassScope classId) n)
| n <- Set.toList newNames]
newIdentifiers = map snd newBindings
globalBindings = [(n, Name moduleScope n) | n <- Set.toList global]
fb <- withBindings (newBindings ++ globalBindings) (convertAll body)
(sn, sx) <- scopeFragments newIdentifiers s
return $ mconcat (fs ++ [sn, fe, fb, fx, sx])
-- Conditional (if-elif-else).
convert (AST.Conditional ifs els _) =
do list <- mapM convertPair ifs
fEls <- if null els then return EmptyFragment else convertAll els
let (cs, bs) = unzip list
lastCond = last cs
fs = cs ++ bs ++ if null els then [] else [fEls]
nodes = Map.unions (map getNodes fs)
edgesL = map getEdges fs
++ [c --> b | (c, b) <- list]
++ [a --> b | (a, b) <- zip cs (tail cs)]
++ if null els then [] else [lastCond --> fEls]
edges = Set.unions edgesL
initial = frInitial (head cs)
finalL = (if null els then getFinal lastCond else getFinal fEls)
: map getFinal bs
final = Set.unions finalL
break = Set.unions $ map getBreak fs
continu = Set.unions $ map getContinue fs
ret = Set.unions $ map getReturn fs
imports = Map.unions $ map getImports fs
ft = Map.unions (map getFunctionTable fs)
return $ Fragment nodes edges initial final break continu ret imports ft
where convertPair (cond, body) =
do (fCondBefore, e) <- toExpression cond
fCond <- newFragment' (Condition e) (AST.annot cond)
fBody <- convertAll body
return (fCondBefore `mappend` fCond, fBody)
-- Assignment statement (= operator).
convert (AST.Assign lhs rhs s) =
do list <- mapM (toTarget getI) lhs
let (fs, ts) = unzip list
(f2, e) <- toExpression rhs
f3 <- newFragment' (Assignment ts e) s
return $ mconcat (fs ++ [f2, f3])
-- Augmented assignment statement (+=, -=, etc).
convert (AST.AugmentedAssign lhs op rhs s) =
do (f1, t) <- toAugTarget lhs
let o = toAssignmentOperator op
(f2, e) <- toExpression rhs
f3 <- newFragment' (AugmentedAssignment t o e) s
return $ f1 `mappend` f2 `mappend` f3
-- Decorated function or class definition. The decorator is ignored.
convert (AST.Decorated _ stmt _) = convert stmt
-- Return statement.
convert (AST.Return Nothing s) =
do (l, f) <- newFragment (Return Nothing) s
return $ f { frReturn = Set.singleton l,
frFinal = Set.empty }
convert (AST.Return (Just expr) s) =
do (fe, e) <- toExpression expr
(l, fr) <- newFragment (Return $ Just e) s
let f = fe `mappend` fr
return $ f { frReturn = Set.singleton l,
frFinal = Set.empty }
-- Try-catch-finally: We ignore exception handling, so the CFG for a try
-- statement is just the body, else and finally parts concatenated.
convert (AST.Try body _ els finally _) =
do fs <- mapM convertAll [body, els, finally]
return $ mconcat fs
-- Raise statement. Ignored since we don't support exception handling.
convert (AST.Raise _ _) = return EmptyFragment
-- With statement.
convert (AST.With ctx body s) =
do withId <- newWithId
let targets = mapMaybe snd ctx
newBindings = [(n, Name (WithScope withId) n)
| n <- targetNames targets]
newIdentifiers = map snd newBindings
lookupName name = withBindings newBindings (getI name)
list <- mapM (toTarget lookupName) targets
let (fs, ts) = unzip list
(lw, fw) <- newFragment (With ts) s
fBody <- withBindings newBindings (convertAll body)
(sn, sx) <- scopeFragments newIdentifiers s
return $ mconcat (fs ++ [sn, fw, fBody, sx])
-- Pass statement.
convert (AST.Pass s) = newFragment' Pass s
-- Break and continue.
convert (AST.Break s) = do (l, f) <- newFragment Break s
return $ f { frBreak = Set.singleton l,
frFinal = Set.empty }
convert (AST.Continue s) = do (l, f) <- newFragment Continue s
return $ f { frContinue = Set.singleton l,
frFinal = Set.empty }
-- Delete statement.
convert (AST.Delete lhs s) =
do list <- mapM (toTarget getI) lhs
let (fs, ts) = unzip list
f <- newFragment' (Del ts) s
return $ mconcat (fs ++ [f])
-- Statement containing only an expression.
convert (AST.StmtExpr e s) =
do (f, e) <- toExpression e
f' <- newFragment' (Expression e) s
return $ f `mappend` f'
-- Global and nonlocal statements.
convert (AST.Global _ _) = return EmptyFragment
convert (AST.NonLocal _ _) = return EmptyFragment
-- Assertion.
convert (AST.Assert _ s) = newFragment' Assert s
-- Statements that should not occur.
convert (AST.Print _ _ _ _) =
throwError $ CFGError "print statement does not exist in Python 3"
convert (AST.Exec _ _ _) =
throwError $ CFGError "exec statement does not exist in Python 3"
-- | Create 'ImportCall' and 'ImportReturn' nodes.
importNodes :: SrcSpan -> ImportedNames -> Conversion
importNodes s importedNames =
do (lc, fc) <- newFragment ImportCall s
(lr, fr) <- newFragment (ImportReturn importedNames) s
let fromModule = case importedNames of ModuleImport n _ _ -> n
FromImport n _ _ -> n
imports = Map.singleton lc (lr, fromModule)
f = fc `mappend` fr
return $ f { frImports = imports }
-- | Get the names imported by an 'ImportItem'.
imported :: AST.ImportItem SrcSpan
-> StateT ConversionState TypeInferenceMonad ImportedNames
imported (AST.ImportItem dotted as _) =
do currentModule <- gets csCurrentModule
return $ ModuleImport (dottedName dotted)
currentModule
(fmap (\(AST.Ident name _) -> name) as)
-- | Get the names imported by an 'ImportRelative'.
fromImported :: AST.ImportRelative SrcSpan -> AST.FromItems SrcSpan
-> StateT ConversionState TypeInferenceMonad ImportedNames
fromImported (AST.ImportRelative _ name _) (AST.ImportEverything _) =
do currentModule <- gets csCurrentModule
let m = maybeDottedName name
return $ FromImport m currentModule [] -- not really supported
fromImported (AST.ImportRelative _ name _) (AST.FromItems items _) =
do currentModule <- gets csCurrentModule
let m = maybeDottedName name
names = [ (n, fmap (\(AST.Ident name _) -> name) as)
| AST.FromItem (AST.Ident n _) as _ <- items ]
return $ FromImport m currentModule names
maybeDottedName :: Maybe (AST.DottedName SrcSpan) -> String
maybeDottedName Nothing = "__init__"
maybeDottedName (Just x) = dottedName x
-- | Turn a dotted name into a regular module name.
dottedName :: AST.DottedName SrcSpan -> String
dottedName [] = ""
dottedName xs = let AST.Ident name _ = last xs in name
-- | Connect @continue@ statements in the first fragment to the second fragment.
continueEdges :: Fragment -> Fragment -> Set Edge
continueEdges body loop =
Set.fromList [(c, i) | c <- Set.toList (getContinue body),
i <- Set.toList (getInitial loop)]
-- | Connect @return@ statements in the first fragment to the second fragment.
returnEdges :: Fragment -> Fragment -> Set Edge
returnEdges body fx =
Set.fromList [(rf, i) | rf <- Set.toList (getReturn body `Set.union`
getFinal body),
i <- Set.toList (getInitial fx) ]
-- | Find module names bound by @import@ statements.
moduleNamesBound :: AST.Suite SrcSpan -> TypeInferenceMonad (Set String)
moduleNamesBound stmts = collectInScope stmts find
where find (AST.Import items _) =
return $ Set.fromList $ importedModuleNames items
find _ = return Set.empty
-- | Extract the names imported into the environment by an @import ... from
-- ...@ statement.
importedModuleNames :: [AST.ImportItem SrcSpan] -> [String]
importedModuleNames items =
let getName (AST.ImportItem n Nothing _) = dottedName n
getName (AST.ImportItem _ (Just (AST.Ident n _)) _) = n
in map getName items
-- | Find names bound in the suite.
namesBound :: AST.Suite SrcSpan -> TypeInferenceMonad (Set String)
namesBound stmts = collectInScope stmts find
where find (AST.Import items _) =
return $ Set.fromList $ importedModuleNames items
find (AST.FromImport _ (AST.ImportEverything _) _) =
return Set.empty -- not really supported
find (AST.FromImport _ (AST.FromItems items _) _) =
let getName (AST.FromItem (AST.Ident n _) Nothing _) = n
getName (AST.FromItem _ (Just (AST.Ident n _)) _) = n
in return $ Set.fromList $ map getName items
find (AST.Assign lhs _ _) =
return $ Set.fromList (targetNames lhs)
find (AST.AugmentedAssign (AST.Var (AST.Ident name _) _) _ _ _) =
return $ Set.singleton name
find (AST.Delete exprs _) =
let f (AST.Var (AST.Ident name _) _) = Set.singleton name
f _ = Set.empty
in return $ Set.unions (map f exprs)
find (AST.Fun (AST.Ident name _) _ _ _ _) =
return $ Set.singleton name
find (AST.Class (AST.Ident name _) _ _ _) =
return $ Set.singleton name
find (AST.For targets _ body els _) =
do boundInside <- collectInScope (body ++ els) find
let boundByLoop = Set.fromList (targetNames targets)
return $ boundInside Set.\\ boundByLoop
find (AST.With ctx body _) =
do boundInside <- collectInScope body find
let boundByWith = Set.fromList (targetNames (mapMaybe snd ctx))
return $ boundInside Set.\\ boundByWith
find _ = return Set.empty
-- | Find names declared @nonlocal@ in the suite.
declaredNonlocal :: AST.Suite SrcSpan -> TypeInferenceMonad (Set String)
declaredNonlocal stmts = collectInScope stmts find
where find (AST.NonLocal ns _) =
return $ Set.fromList [n | AST.Ident n _ <- ns]
find (AST.For _ _ body els _) = collectInScope (body ++ els) find
find (AST.With _ body _) = collectInScope body find
find _ = return Set.empty
-- | Find names declared @global@ in the suite.
declaredGlobal :: AST.Suite SrcSpan -> TypeInferenceMonad (Set String)
declaredGlobal stmts = collectInScope stmts find
where find (AST.Global ns _) =
return $ Set.fromList [n | AST.Ident n _ <- ns]
find (AST.For _ _ body els _) = collectInScope (body ++ els) find
find (AST.With _ body _) = collectInScope body find
find _ = return Set.empty
-- | Apply a function to all simple statements, and @for@ and @with@
-- statements, in one scope and collect the results.
collectInScope :: Ord a => AST.Suite SrcSpan
-> (AST.Statement SrcSpan -> TypeInferenceMonad (Set a))
-> TypeInferenceMonad (Set a)
collectInScope stmts f =
do results <- mapM f' stmts
return $ Set.unions results
where f' (AST.While _ body els _) =
do list <- mapM f' (body ++ els)
return $ Set.unions list
f' (AST.Conditional guards els _) =
do list <- mapM f' (concatMap snd guards ++ els)
return $ Set.unions list
f' (AST.Try body _ els finally _) =
do list <- mapM f' (body ++ els ++ finally)
return $ Set.unions list
f' stmt = f stmt
-- | Assuming the given list is the target of an assignment, return the names
-- it binds.
targetNames :: [AST.Expr SrcSpan] -> [String]
targetNames targets =
concatMap f targets
where f (AST.Var (AST.Ident n _) _) = [n]
f (AST.Tuple exprs _) = concatMap f exprs
f (AST.List exprs _) = concatMap f exprs
f (AST.Paren expr _) = f expr
f _ = []
-- | Assuming the given expression is the target of an assignment, convert it
-- to the Target type.
toTarget :: (String -> StateT ConversionState TypeInferenceMonad Identifier)
-> AST.Expr SrcSpan
-> StateT ConversionState TypeInferenceMonad (Fragment, Target)
toTarget lookupName (AST.Var (AST.Ident name _) _) =
do identifier <- lookupName name
return (EmptyFragment, TargetIdentifier identifier)
toTarget _ (AST.BinaryOp (AST.Dot _) e (AST.Var (AST.Ident name _) _) _) =
do (f, e) <- toExpression e
return (f, TargetAttributeRef $ AttributeRef e name)
toTarget _ (AST.Subscript x e _) =
do (xf, xe) <- toExpression x
(ef, _) <- toExpression e
return (xf `mappend` ef, TargetSubscription $ Subscription xe)
toTarget _ (AST.SlicedExpr x s _) =
do (xf, xe) <- toExpression x
sf <- mapM fragmentForSlice s
return (mconcat (xf : sf), TargetSlicing $ Slicing xe)
toTarget lookupName (AST.Tuple es _) =
do list <- mapM (toTarget lookupName) es
let (fs, ts) = unzip list
return (mconcat fs, TargetList ts)
toTarget lookupName (AST.List es _) =
do list <- mapM (toTarget lookupName) es
let (fs, ts) = unzip list
return (mconcat fs, TargetList ts)
toTarget lookupName (AST.Starred e _) =
do (f, t) <- toTarget lookupName e
return (f, StarTarget t)
toTarget lookupName (AST.Paren e _) = toTarget lookupName e
toTarget _ e =
throwError $ CFGError $ "invalid expression in target: " ++ show e
-- | Assuming the given expression is the target of an augmented assignment,
-- convert it to the AugTarget type.
toAugTarget :: AST.Expr SrcSpan
-> StateT ConversionState TypeInferenceMonad (Fragment, AugTarget)
toAugTarget (AST.Var (AST.Ident name _) _) =
do identifier <- getI name
return (EmptyFragment, AugTargetIdentifier identifier)
toAugTarget (AST.BinaryOp (AST.Dot _) e (AST.Var (AST.Ident name _) _) _) =
do (f, e) <- toExpression e
return (f, AugTargetAttributeRef $ AttributeRef e name)
toAugTarget (AST.Subscript x e _) =
do (xf, xe) <- toExpression x
(ef, _) <- toExpression e
return (xf `mappend` ef, AugTargetSubscription $ Subscription xe)
toAugTarget (AST.SlicedExpr x s _) =
do (xf, xe) <- toExpression x
sf <- mapM fragmentForSlice s
return (mconcat (xf : sf), AugTargetSlicing $ Slicing xe)
toAugTarget (AST.Paren e _) = toAugTarget e
toAugTarget e =
throwError $ CFGError $ msg ++ show e
where msg = "invalid expression in target for augmented assignment: "
-- | Convert parameters.
toParameter :: Scope
-> AST.Parameter SrcSpan
-> StateT ConversionState TypeInferenceMonad [(Fragment, Parameter)]
toParameter scope (AST.Param (AST.Ident name _) _ Nothing _) =
returnP $ Parameter (Name scope name) Nothing
toParameter scope (AST.Param (AST.Ident name _) _ (Just d) srcSpan) =
do (f, e) <- toExpression d
i <- newIdentifier
fAssign <- newFragment' (Assignment [TargetIdentifier i] e) srcSpan
return [ (f `mappend` fAssign,
Parameter (Name scope name) (Just $ Identifier i)) ]
toParameter scope (AST.VarArgsPos (AST.Ident name _) _ _) =
returnP $ StarParameter (Name scope name)
toParameter scope (AST.VarArgsKeyword (AST.Ident name _) _ _) =
returnP $ StarStarParameter (Name scope name)
toParameter scope (AST.EndPositional _) = return []
toParameter scope (AST.UnPackTuple _ _ _) =
throwError $ CFGError "tuple unpack parameters don't exist in Python 3"
-- | Return the name the parameter, if any.
paramName :: AST.Parameter SrcSpan -> TypeInferenceMonad [String]
paramName (AST.Param (AST.Ident name _) _ _ _) = return [name]
paramName (AST.VarArgsPos (AST.Ident name _) _ _) = return [name]
paramName (AST.VarArgsKeyword (AST.Ident name _) _ _) = return [name]
paramName (AST.EndPositional _) = return []
paramName (AST.UnPackTuple _ _ _) =
throwError $ CFGError "tuple unpack parameters don't exist in Python 3"
-- | Convert expression.
toExpression :: AST.Expr SrcSpan
-> StateT ConversionState TypeInferenceMonad (Fragment, Expression)
-- Parenthesized expression.
toExpression (AST.Paren e _) = toExpression e
-- Variable.
toExpression (AST.Var (AST.Ident name _) _) =
do identifier <- getI name
returnExpression $ Identifier identifier
-- Literal constants.
toExpression (AST.Int val _ _) = returnLiteral $ IntegerLiteral val
toExpression (AST.Float val _ _) = returnLiteral $ FloatLiteral val
toExpression (AST.Imaginary val _ _) = returnLiteral $ ImagLiteral val
toExpression (AST.Bool val _) = returnLiteral $ BoolLiteral val
toExpression (AST.None _) = returnLiteral NoneLiteral
toExpression (AST.ByteStrings l _) = returnLiteral $ ByteStringLiteral $
concat l
toExpression (AST.Strings l _) = returnLiteral $ StringLiteral (concat l)
-- Function call.
toExpression (AST.Call e args s) =
do (f1, e1) <- toExpression e
list <- mapM toArgument args
let (fs, as) = unzip list
f2 = mconcat (f1 : fs)
i <- newIdentifier
lc <- newLabel
lr <- newLabel
pos <- lift $ toPosition s
let f3 = fragment (Map.fromList [(lc, (FunctionCall e1 as lr, pos)),
(lr, (FunctionReturn e1 i lc, pos))])
Set.empty
(Set.singleton lc)
(Set.singleton lr)
return (f2 `mappend` f3, Identifier i)
-- Subscription and slicing.
toExpression (AST.Subscript x e _) =
do (xf, xe) <- toExpression x
(ef, _) <- toExpression e
return (xf `mappend` ef, SubscriptionExpression $ Subscription xe)
toExpression (AST.SlicedExpr x s _) =
do (xf, xe) <- toExpression x
sf <- mapM fragmentForSlice s
return (mconcat (xf : sf), SlicingExpression $ Slicing xe)
-- Conditional expression ('left if cond else right')
toExpression (AST.CondExpr left cond right _) =
do (fcBefore, ec) <- toExpression cond
(flBefore, el) <- toExpression left
(frBefore, er) <- toExpression right
i <- newIdentifier
fc <- newFragment' (Condition ec) (AST.annot cond)
fl <- newFragment' (Assignment [TargetIdentifier i] el) (AST.annot left)
fr <- newFragment' (Assignment [TargetIdentifier i] er) (AST.annot right)
let c = fcBefore `mappend` fc
l = flBefore `mappend` fl
r = frBefore `mappend` fr
nodes = Map.unions $ map getNodes [c, l, r]
edges = Set.unions $ [c --> r, c --> l] ++ map getEdges [c, l, r]
final = getFinal l `Set.union` getFinal r
return (fragment nodes edges (frInitial c) final, Identifier i)
-- Binary operation.
toExpression (AST.BinaryOp (AST.Dot _)
(AST.Var (AST.Ident a _) _)
(AST.Var (AST.Ident b _) _) _) =
do otherModules <- gets csOtherModules
if a `Set.member` otherModules
then do identifier <- mkIdentifier a b
returnExpression $ Identifier identifier
else do identifier <- getI a
returnExpression $
AttributeReference $
AttributeRef (Identifier identifier) b
toExpression (AST.BinaryOp (AST.Dot _) a b _) =
do (f, e) <- toExpression a
case b of
AST.Var (AST.Ident name _) _ ->
return (f, AttributeReference (AttributeRef e name))
_ ->
throwError $ CFGError "invalid attribute reference"
toExpression (AST.BinaryOp op a b _) =
do (f, e) <- toExpression a
o <- lift $ toBinaryOperator op
(f', e') <- toExpression b
return (f `mappend` f', BinaryOperation e o e')
-- Unary operation.
toExpression (AST.UnaryOp op expr _) =
do o <- lift $ toUnaryOperator op
(f, e) <- toExpression expr
return (f, UnaryOperation o e)
-- Lambda expression (anonymous function).
toExpression (AST.Lambda params body s) =
do functionId <- newFunctionId
i <- newIdentifier
(ld, fd) <- newFragment (Def i functionId) s
list <- mapM (toParameter (FunctionScope functionId)) params
let (pfs, ps) = unzip (concat list)
(ln, fn) <- newFragment (FunctionEntry ps) s
(lx, fx) <- newFragment (FunctionExit ps) s
paramNames <- lift $ mapM paramName params
let newBindings = [(n, Name (FunctionScope functionId) n)
| n <- concat paramNames]
(fbBefore, be) <- withBindings newBindings (toExpression body)
(lb, fb) <- newFragment (Return $ Just be) s
let fBody = fbBefore `mappend` fb
let fs = pfs ++ [fd, fn, fx, fBody]
nodes = Map.unions (map getNodes fs)
edges = Set.singleton (lb, lx)
`Set.union` getEdges fBody
`Set.union` (fn --> fBody)
initial = Set.singleton ld
final = Set.singleton ld
break = Set.empty
continu = Set.empty
ret = Set.empty
imports = Map.empty
ft = Map.insert functionId (ln, lx) (getFunctionTable fBody)
return (Fragment nodes edges initial final break continu ret imports ft,
Identifier i)
-- | Tuples, lists, sets and dictionaries.
toExpression (AST.Tuple es _) =
do list <- mapM toExpression es
let (fs, exprs) = unzip list
return (mconcat fs, TupleExpression exprs)
toExpression (AST.List es _) =
do list <- mapM toExpression es
let (fs, exprs) = unzip list
return (mconcat fs, ListExpression exprs)
toExpression (AST.Set es _) =
do list <- mapM toExpression es
let (fs, exprs) = unzip list
return (mconcat fs, SetExpression exprs)
toExpression (AST.Dictionary es _) =
let pairToE (a, b) = do (f1, e1) <- toExpression a
(f2, e2) <- toExpression b
return (f1 `mappend` f2, (e1, e2))
in do list <- mapM pairToE es
let (fs, exprs) = unzip list
return (mconcat fs, DictionaryExpression exprs)
-- List, set and dictionary comprehensions.
toExpression (AST.ListComp comprehension s) =
convertCompr comprehension toExpression ListComprehension
toExpression (AST.SetComp comprehension _) =
convertCompr comprehension toExpression SetComprehension
toExpression (AST.DictComp comprehension _) =
convertCompr comprehension f DictComprehension
where f (a, b) = do (fa, ea) <- toExpression a
(fb, eb) <- toExpression b
return (fb `mappend` fb, (ea, eb))
-- Generator expression and yield statement -- not really supported.
toExpression (AST.Generator _ _) = returnExpression Generator
toExpression (AST.Yield Nothing _) = returnExpression $ Yield Nothing
toExpression (AST.Yield (Just e) _) =
do (f, exp) <- toExpression e
return (f, Yield $ Just exp)
-- Expressions that should not occur here.
toExpression (AST.Starred _ _) =
throwError $ CFGError "starred expression outside of assignment"
toExpression (AST.LongInt _ _ _) =
throwError $ CFGError "long ints don't exist in Python 3"
toExpression (AST.Ellipsis _) =
throwError $ CFGError "ellipsis in expression"
toExpression (AST.StringConversion _ _) =
throwError $ CFGError "backquotes don't exist in Python 3"
-- | Convert comprehension.
convertCompr :: AST.Comprehension a SrcSpan
-> (a -> StateT ConversionState TypeInferenceMonad (Fragment, b))
-> (Identifier -> b -> ProgramPoint)
-> StateT ConversionState TypeInferenceMonad (Fragment, Expression)
convertCompr (AST.Comprehension comprehensionExpr compFor s)
convertComprehensionExpr
pp =
do forLoopId <- newForLoopId
let newBindings = [(n, Name (ForLoopScope forLoopId) n)
| n <- compForNames compFor]
newIdentifiers = map snd newBindings
i <- newIdentifier
(eBefore, e) <- withBindings newBindings $
convertComprehensionExpr comprehensionExpr
fc <- newFragment' (pp i e) s
f <- withBindings newBindings $ compForToFragment compFor
(eBefore `mappend` fc)
(sn, sx) <- scopeFragments newIdentifiers s
return (sn `mappend` f `mappend` sx, Identifier i)
-- | Create fragment for the @for ... in ...@ part of a comprehension.
compForToFragment :: AST.CompFor SrcSpan -> Fragment -> Conversion
compForToFragment (AST.CompFor targets generator next s) inner =
do (gBefore, g) <- toExpression generator
i <- newIdentifier
gAssign <- newFragment' (Assignment [TargetIdentifier i] g) s
let g = gBefore `mappend` gAssign
targetList <- mapM (toTarget getI) targets
let (fts, ts) = unzip targetList
tBefore = mconcat fts
ft <- newFragment' (ForAssign (TargetList ts) i) s
inner' <- compIterToFragment next inner
let ft' = tBefore `mappend` ft
fs = [g, ft', inner']
nodes = Map.unions (map getNodes fs)
edges = Set.unions (map getEdges fs)
`Set.union` (g --> ft')
`Set.union` (ft' --> inner')
`Set.union` (inner' --> ft')
initial = frInitial $ if nullF g then ft' else g
final = frFinal ft'
return $ fragment nodes edges initial final
-- | Create fragment for the @if ...@ part of a comprehension.
compIfToFragment :: AST.CompIf SrcSpan -> Fragment -> Conversion
compIfToFragment (AST.CompIf cond next s) inner =
do (fcBefore, ec) <- toExpression cond
fc <- newFragment' (Condition ec) (AST.annot cond)
inner' <- compIterToFragment next inner
return $ fcBefore `mappend` fc `mappend` inner'
-- | Create fragment for part of a comprehension.
compIterToFragment :: Maybe (AST.CompIter SrcSpan) -> Fragment -> Conversion
compIterToFragment Nothing inner = return inner
compIterToFragment (Just (AST.IterFor f _)) inner = compForToFragment f inner
compIterToFragment (Just (AST.IterIf i _)) inner = compIfToFragment i inner
-- | Find names bound in a list comprehension.
compForNames :: AST.CompFor SrcSpan -> [String]
compForNames (AST.CompFor targets _ next _) = targetNames targets
++ compIterNames next
-- | Find names bound in a list comprehension.
compIfNames :: AST.CompIf SrcSpan -> [String]
compIfNames (AST.CompIf _ next _) = compIterNames next
-- | Find names bound in a list comprehension.
compIterNames :: Maybe (AST.CompIter SrcSpan) -> [String]
compIterNames (Just (AST.IterFor f _)) = compForNames f
compIterNames (Just (AST.IterIf f _)) = compIfNames f
compIterNames Nothing = []
-- | Convert funcation call argument.
toArgument :: AST.Argument SrcSpan
-> StateT ConversionState TypeInferenceMonad (Fragment, Argument)
toArgument (AST.ArgExpr expr _) =
do (f, e) <- toExpression expr
return (f, PositionalArgument e)
toArgument (AST.ArgKeyword (AST.Ident k _) expr _) =
do (f, e) <- toExpression expr
return (f, KeywordArgument k e)
toArgument (AST.ArgVarArgsPos expr _) =
do (f, e) <- toExpression expr
return (f, StarArgument e)
toArgument (AST.ArgVarArgsKeyword expr _) =
do (f, e) <- toExpression expr
return (f, StarStarArgument e)
-- | Convert a slice expression.
fragmentForSlice :: AST.Slice SrcSpan -> Conversion
fragmentForSlice (AST.SliceProper l u s _) =
do f1 <- f l
f2 <- f u
f3 <- case s of Nothing -> return EmptyFragment
Just e -> f e
return $ f1 `mappend` f2 `mappend` f3
where f Nothing = return EmptyFragment
f (Just e) = do (f, _) <- toExpression e
return f
fragmentForSlice (AST.SliceExpr e _) = do (f, _) <- toExpression e
return f
fragmentForSlice (AST.SliceEllipsis _) = return EmptyFragment
returnLiteral l = return (EmptyFragment, Literal l)
returnExpression e = return (EmptyFragment, e)
returnP p = return [(EmptyFragment, p)]
-- | Convert a unary operator.
toUnaryOperator :: AST.Op SrcSpan -> TypeInferenceMonad UnaryOperator
toUnaryOperator (AST.Not _) = return BooleanNot
toUnaryOperator (AST.Minus _) = return UnaryMinus
toUnaryOperator (AST.Plus _) = return UnaryPlus
toUnaryOperator (AST.Invert _) = return Invert
toUnaryOperator op =
throwError $ CFGError ("not a unary operator: " ++ show op)
-- | Convert a binary operator.
toBinaryOperator :: AST.Op SrcSpan -> TypeInferenceMonad BinaryOperator
toBinaryOperator (AST.And _) = return BooleanAnd
toBinaryOperator (AST.Or _) = return BooleanOr
toBinaryOperator (AST.Exponent _) = return Exponent
toBinaryOperator (AST.LessThan _) = return Lt
toBinaryOperator (AST.GreaterThan _) = return Gt
toBinaryOperator (AST.Equality _) = return Eq
toBinaryOperator (AST.GreaterThanEquals _) = return GEq
toBinaryOperator (AST.LessThanEquals _) = return LEq
toBinaryOperator (AST.NotEquals _) = return NEq
toBinaryOperator (AST.In _) = return In
toBinaryOperator (AST.Is _) = return Is
toBinaryOperator (AST.IsNot _) = return IsNot
toBinaryOperator (AST.NotIn _) = return NotIn
toBinaryOperator (AST.BinaryOr _) = return BitwiseOr
toBinaryOperator (AST.Xor _) = return BitwiseXor
toBinaryOperator (AST.BinaryAnd _) = return BitwiseAnd
toBinaryOperator (AST.ShiftLeft _) = return LeftShift
toBinaryOperator (AST.ShiftRight _) = return RightShift
toBinaryOperator (AST.Multiply _) = return Times
toBinaryOperator (AST.Plus _) = return Plus
toBinaryOperator (AST.Minus _) = return Minus
toBinaryOperator (AST.Divide _) = return Div
toBinaryOperator (AST.FloorDivide _) = return DivDiv
toBinaryOperator (AST.Modulo _) = return Modulo
toBinaryOperator (AST.NotEqualsV2 _) =
throwError $ CFGError "<> operator doesn't exist in Python 3"
toBinaryOperator op =
throwError $ CFGError ("not a binary operator: " ++ show op)
-- | Convert an assigment operator.
toAssignmentOperator :: AST.AssignOp SrcSpan -> AssignmentOperator
toAssignmentOperator (AST.PlusAssign _) = PlusGets
toAssignmentOperator (AST.MinusAssign _) = MinusGets
toAssignmentOperator (AST.MultAssign _) = TimesGets
toAssignmentOperator (AST.DivAssign _) = DivGets
toAssignmentOperator (AST.ModAssign _) = ModGets
toAssignmentOperator (AST.PowAssign _) = ExpGets
toAssignmentOperator (AST.BinAndAssign _) = AndGets
toAssignmentOperator (AST.BinOrAssign _) = OrGets
toAssignmentOperator (AST.BinXorAssign _) = XorGets
toAssignmentOperator (AST.LeftShiftAssign _) = LeftShiftGets
toAssignmentOperator (AST.RightShiftAssign _) = RightShiftGets
toAssignmentOperator (AST.FloorDivAssign _) = DivDivGets
-- | Convert a source code position.
toPosition :: SrcSpan -> TypeInferenceMonad Position
toPosition (SpanCoLinear filename row _ _) = return $ Position filename row
toPosition (SpanMultiLine filename row _ _ _) = return $ Position filename row
toPosition (SpanPoint filename row _) = return $ Position filename row
toPosition SpanEmpty =
throwError $ CFGError "missing source location information"
-- | Create ScopeEntry and ScopeExit fragments.
scopeFragments :: [Identifier] -> SrcSpan
-> StateT ConversionState TypeInferenceMonad (Fragment, Fragment)
scopeFragments newIdentifiers srcSpan =
do sn <- newFragment' (ScopeEntry newIdentifiers) srcSpan
sx <- newFragment' (ScopeExit newIdentifiers) srcSpan
return (sn, sx)
| lfritz/python-type-inference | python-type-inference/src/Language/Python/TypeInference/CFG/ToFragment.hs | bsd-3-clause | 45,554 | 0 | 20 | 13,402 | 14,325 | 7,148 | 7,177 | 839 | 13 |
-----------------------------------------------------------------------------
-- |
-- Module : Text.Show.Functions
-- Copyright : (c) The University of Glasgow 2001
-- License : BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer : [email protected]
-- Stability : provisional
-- Portability : portable
--
-- Optional instance of 'Text.Show.Show' for functions:
--
-- > instance Show (a -> b) where
-- > showsPrec _ _ = showString \"\<function\>\"
--
-----------------------------------------------------------------------------
module Text.Show.Functions () where
import Prelude
instance Show (a -> b) where
showsPrec _ _ = showString "<function>"
| OS2World/DEV-UTIL-HUGS | libraries/Text/Show/Functions.hs | bsd-3-clause | 694 | 0 | 7 | 110 | 57 | 39 | 18 | 4 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.