Changeset 15 for sizechecking_branches/LL.hs
- Timestamp:
- Nov 16, 2012, 4:26:26 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sizechecking_branches/LL.hs
r10 r15 1 {-# Language GADTs, 2 FlexibleInstances, 3 FlexibleContexts, 4 ScopedTypeVariables, 5 TypeFamilies, 1 {-# Language GADTs, 2 FlexibleInstances, 3 FlexibleContexts, 4 ScopedTypeVariables, 5 TypeFamilies, 6 6 NoMonomorphismRestriction, 7 7 OverlappingInstances #-} 8 module LL where 8 9 9 10 import Data.Char … … 14 15 deriving Show 15 16 16 type family Arr (repr :: * -> *) (a :: *) (b :: *) :: *17 17 18 18 class Lambda l where 19 type Arr l (a :: *) (b :: *) :: * 19 20 labs :: (l a -> l b) -> l (Arr l a b) 20 21 app :: l (Arr l a b) -> l a -> l b … … 49 50 50 51 newtype LPrint a = LPrint { unPrint :: Int -> Int -> ShowS } 51 type instance Arr LPrint a b = a -> b52 52 53 53 instance Lambda LPrint where 54 type Arr LPrint a b = a -> b 54 55 lit x = LPrint $ \_ -> return $ shows x 55 56 op m opc n = LPrint $ \p -> do … … 75 76 {- Evaluating -} 76 77 newtype R a = R { unR :: a } 77 type instance Arr R a b = R a -> R b78 78 79 79 instance Lambda R where 80 type Arr R a b = R a -> R b 80 81 labs = R 81 82 app = unR … … 94 95 eval = unR 95 96 96 z = labs ( \s -> s + 1) `app` ( 1 + lit2)97 z = labs (\s -> s + lit 1) `app` (lit 1 + 2)
Note: See TracChangeset
for help on using the changeset viewer.