summaryrefslogtreecommitdiff
path: root/testsuite/tests/profiling/should_compile/T14931_Bug.hs
blob: 4e6f2136a8c4dda9fc41c7d2dea26ab37eab28f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
module T14931_Bug where

import Prelude (Int, IO, Bool(..), Num(..), Monad(..), not, print)
import qualified Language.Haskell.TH.Syntax as TH
import T14931_State

wat :: IO ()
wat = print $(let playGame []     = do
                      (_, score) <- get
                      return score
                  playGame (x:xs) = do
                      (on, score) <- get
                      case x of
                           'a' | on -> put (on, score + 1)
                           'b' | on -> put (on, score - 1)
                           'c'      -> put (not on, score)
                           _        -> put (on, score)
                      playGame xs

                  startState :: (Bool, Int)
                  startState = (False, 0)
              in TH.lift (evalState (playGame "abcaaacbbcabbab") startState) )