secret
Last active

  • Download Gist
error-7.4.2.txt
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63
[1 of 1] Compiling Main ( from.hs, interpreted )
 
from.hs:36:8:
No instances for (Typeable c, Typeable b)
arising from a use of `arr'
In the expression: arr
When checking that `arr' (needed by a syntactic construct)
has the required type: forall b c. (b -> c) -> R b c
arising from a proc expression at from.hs:(36,8)-(43,30)
In the expression:
proc n -> case n of {
0 -> returnA -< 0
1 -> returnA -< 1
n'
-> do { l <- ...;
.... } }
 
from.hs:36:8:
No instances for (Typeable c, Typeable b, Typeable a)
arising from a use of `>>>'
In the expression: (>>>)
When checking that `(>>>)' (needed by a syntactic construct)
has the required type: forall a b c. R a b -> R b c -> R a c
arising from a proc expression at from.hs:(36,8)-(43,30)
In the expression:
proc n -> case n of {
0 -> returnA -< 0
1 -> returnA -< 1
n'
-> do { l <- ...;
.... } }
 
from.hs:36:8:
No instances for (Typeable d, Typeable c, Typeable b)
arising from a use of `first'
In the expression: first
When checking that `first' (needed by a syntactic construct)
has the required type: forall b c d. R b c -> R (b, d) (c, d)
arising from a proc expression at from.hs:(36,8)-(43,30)
In the expression:
proc n -> case n of {
0 -> returnA -< 0
1 -> returnA -< 1
n'
-> do { l <- ...;
.... } }
 
from.hs:36:8:
No instances for (Typeable d, Typeable c, Typeable b)
arising from a use of `|||'
In the expression: (|||)
When checking that `(|||)' (needed by a syntactic construct)
has the required type: forall b d c.
R b d -> R c d -> R (Either b c) d
arising from a proc expression at from.hs:(36,8)-(43,30)
In the expression:
proc n -> case n of {
0 -> returnA -< 0
1 -> returnA -< 1
n'
-> do { l <- ...;
.... } }
Failed, modules loaded: none.
error-7.6.2.txt
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
[1 of 1] Compiling Main ( from.hs, interpreted )
 
from.hs:36:8:
No instance for (Typeable c) arising from a use of `arr'
Possible fix:
add (Typeable c) to the context of
a type expected by the context: (b -> c) -> R b c
In the expression: arr
When checking that `arr' (needed by a syntactic construct)
has the required type: forall b1 c1. (b1 -> c1) -> R b1 c1
arising from a proc expression at from.hs:(36,8)-(43,30)
In the expression:
proc n -> case n of {
0 -> returnA -< 0
1 -> returnA -< 1
n'
-> do { l <- ...;
.... } }
 
from.hs:36:8:
No instance for (Typeable c) arising from a use of `>>>'
Possible fix:
add (Typeable c) to the context of
a type expected by the context: R a b -> R b c -> R a c
In the expression: (>>>)
When checking that `(>>>)' (needed by a syntactic construct)
has the required type: forall a1 b1 c1.
R a1 b1 -> R b1 c1 -> R a1 c1
arising from a proc expression at from.hs:(36,8)-(43,30)
In the expression:
proc n -> case n of {
0 -> returnA -< 0
1 -> returnA -< 1
n'
-> do { l <- ...;
.... } }
 
from.hs:36:8:
No instance for (Typeable d) arising from a use of `first'
Possible fix:
add (Typeable d) to the context of
a type expected by the context: R b c -> R (b, d) (c, d)
In the expression: first
When checking that `first' (needed by a syntactic construct)
has the required type: forall b1 c1 d1.
R b1 c1 -> R (b1, d1) (c1, d1)
arising from a proc expression at from.hs:(36,8)-(43,30)
In the expression:
proc n -> case n of {
0 -> returnA -< 0
1 -> returnA -< 1
n'
-> do { l <- ...;
.... } }
 
from.hs:36:8:
No instance for (Typeable d) arising from a use of `|||'
Possible fix:
add (Typeable d) to the context of
a type expected by the context: R b d -> R c d -> R (Either b c) d
In the expression: (|||)
When checking that `(|||)' (needed by a syntactic construct)
has the required type: forall b1 d1 c1.
R b1 d1 -> R c1 d1 -> R (Either b1 c1) d1
arising from a proc expression at from.hs:(36,8)-(43,30)
In the expression:
proc n -> case n of {
0 -> returnA -< 0
1 -> returnA -< 1
n'
-> do { l <- ...;
.... } }
Failed, modules loaded: none.
from.hs
Haskell
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE RankNTypes #-}
module Main where
 
import Data.Typeable
 
import Prelude (Int, Bool, Either(..), fromInteger, (==), (-), (+), flip)
 
 
 
data R a b where
Id :: (Typeable a, Typeable b)
=> R a b
Comp :: (Typeable a, Typeable b, Typeable c)
=> R b c -> R a b -> R a c
Arr :: (Typeable a, Typeable b)
=> (a -> b) -> R a b
Split :: (Typeable b, Typeable b', Typeable c, Typeable c')
=> R b c -> R b' c' -> R (b,b') (c,c')
Cache :: Typeable a
=> (a -> a -> Bool) -> R a a
-- ArrowChoice
Choice :: (Typeable b, Typeable b', Typeable c, Typeable c')
=> R b c -> R b' c' -> R (Either b b') (Either c c')
-- ArrowLoop
Loop :: (Typeable b, Typeable c, Typeable d)
=> R (b, d) (c, d) -> R b c
-- ArrowApply
Apply :: (Typeable b, Typeable c)
=> R (R b c, b) c
fib :: R Int Int
fib = proc n ->
case n of
0 -> returnA -< 0
1 -> returnA -< 1
n' ->
do l <- fib -< (n'-2)
r <- fib -< (n'-1)
returnA -< (l+r)
-- Arrow stuff
arr :: (Typeable a, Typeable b) => (a -> b) -> R a b
arr = Arr
 
first :: (Typeable b, Typeable c, Typeable d)
=> R b c -> R (b, d) (c, d)
first = (*** id)
 
second :: (Typeable b, Typeable c, Typeable d)
=> R b c -> R (d, b) (d, c)
second = (id ***)
 
(***) :: (Typeable b, Typeable b', Typeable c, Typeable c')
=> R b c -> R b' c' -> R (b,b') (c,c')
(***) = Split
 
 
left :: (Typeable b, Typeable c, Typeable d)
=> R b c -> R (Either b d) (Either c d)
left = (+++ id)
 
right :: (Typeable b, Typeable c, Typeable d)
=> R b c -> R (Either d b) (Either d c)
right = (id +++)
 
(+++) :: (Typeable b, Typeable b', Typeable c, Typeable c')
=> R b c -> R b' c' -> R (Either b b') (Either c c')
(+++) = Choice
 
(>>>) :: (Typeable a, Typeable b, Typeable c)
=> R a b -> R b c -> R a c
(>>>) = flip Comp
 
id :: Typeable a => R a a
id = Id
 
returnA :: Typeable a => R a a
returnA = Id
 
(|||) :: (Typeable b, Typeable c, Typeable d)
=> R b d -> R c d -> R (Either b c) d
f ||| g = f +++ g >>> arr untag
where
untag (Left x) = x
untag (Right y) = y

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.