summaryrefslogtreecommitdiff
path: root/testsuite/tests/rep-poly/PandocArrowCmd.hs
blob: 3b868c3d17a8d458cf0de4107e6acc5b50a0b86c (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

{-

this test file was extracted from Text.Pandoc.Readers.Odt.ContentReader,
which caused a panic in GHC.Tc.Class.Instance.hasFixedRuntimeRep:

error: panic! (the 'impossible' happened)

  hasFixedRuntimeRep: not of form 'TYPE rep'
  ty = c_anCXp[tau:0]
  ki = k_anCXl[tau:0]
  frrOrig = The arrow command `returnA -< anchorElem_anC3K'
            does not have a fixed runtime representation.

-}

{-# LANGUAGE Arrows #-}
{-# OPTIONS_GHC -Wno-missing-methods #-}

module PandocArrowCmd where

import Control.Arrow
import Control.Category

maybeAddAnchorFrom :: OdtReader i p
                   -> OdtReaderSafe i i
maybeAddAnchorFrom anchorReader =
  keepingTheValue_etc_etc
  >>>
  proc (inlines, fAnchorElem) -> do
  case fAnchorElem of
    Right anchorElem -> returnA -< anchorElem
    Left _           -> returnA -< inlines

-----

keepingTheValue_etc_etc :: OdtReader i (b, Either a b)
keepingTheValue_etc_etc = undefined

data OdtState
type OdtReader      a b = ArrowState OdtState a b
type OdtReaderSafe  a b = ArrowState OdtState a (Either () b)

newtype ArrowState state a b = ArrowState
  { runArrowState :: (state, a) -> (state, b) }

instance Category    (ArrowState s) where {}
instance Arrow       (ArrowState s) where {}
instance ArrowChoice (ArrowState s) where {}