Remove the type-checking knot.
[ghc.git] / testsuite / tests / polykinds / T13393.hs
1 {-# LANGUAGE DataKinds #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE FlexibleInstances #-}
4 {-# LANGUAGE FunctionalDependencies #-}
5 {-# LANGUAGE KindSignatures #-}
6 {-# LANGUAGE MultiParamTypeClasses #-}
7 {-# LANGUAGE PolyKinds #-}
8 {-# LANGUAGE RankNTypes #-}
9 module T13393 ( ) where
10
11 import Control.Monad.Trans.RWS.Strict (RWST)
12 import Data.Functor.Identity (Identity)
13 import Data.Kind (Type)
14 import Data.Word (Word16)
15
16 data Rate
17 data Audio (sampleRate :: Rate) (channelLayout :: Type) (encoding :: Type)
18 data EncodeResult = MkEncodeResult
19 { encodeResultLeftOverInput :: !(Maybe [Word16])
20 }
21 data EncodeFailure
22 data AacEncErrorCode
23 data Aac (aot :: AacCodec)
24 data AacCodec
25 newtype AacEncSt (rate :: Rate) channels (codec :: AacCodec) = MkAacEncSt
26 { _leftOvers :: Maybe [Word16]
27 }
28
29 -- makeLenses ''AacEncSt
30
31 type Iso s t a b = forall p f. (Functor f) => (a -> f b) -> s -> (f t)
32 instance (Monad m, Monoid w) => MonadState s (RWST r w s m) where
33
34 iso :: (s -> a) -> (b -> t) -> Iso s t a b
35 iso sa bt x = fmap bt . x . sa
36 {-# INLINE iso #-}
37
38 leftOvers ::
39 forall rate_a750
40 channels_a753
41 codec_a757
42 rate_aaYK
43 channels_aaYL
44 codec_aaYM.
45 Iso (AacEncSt rate_a750 channels_a753 codec_a757) (AacEncSt rate_aaYK channels_aaYL codec_aaYM) (Maybe [Word16]) (Maybe [Word16])
46 leftOvers = (iso (\ (MkAacEncSt x_aaYN) -> x_aaYN)) MkAacEncSt
47 {-# INLINE leftOvers #-}
48
49 type ASetter s t a b = (a -> Identity b) -> s -> Identity t
50 class Monad m => MonadState s m | m -> s where
51
52 (.=) :: MonadState s m => ASetter s s a b -> b -> m ()
53 l .= b = undefined
54 {-# INLINE (.=) #-}
55
56 type AacEncT rate channels codec m a = RWST Int () (AacEncSt rate channels codec) m a
57
58 encodeLinearToAac
59 :: AacEncT rate channels codec IO (Either EncodeFailure (Maybe (Audio rate channels (Aac codec))))
60 encodeLinearToAac = do
61 mapM putBackLeftOverInputAndReturnOutput undefined
62 undefined
63 where
64 putBackLeftOverInputAndReturnOutput (MkEncodeResult x) = do
65 leftOvers .= x
66 undefined