a10
authorMart Lubbers <mart@martlubbers.net>
Fri, 30 Nov 2018 10:52:51 +0000 (11:52 +0100)
committerMart Lubbers <mart@martlubbers.net>
Fri, 30 Nov 2018 10:52:51 +0000 (11:52 +0100)
afp/a10/a10.icl
funcdeps/test.icl

index 9f4a7a5..838f340 100644 (file)
@@ -7,6 +7,7 @@ import Control.Applicative
 import Control.Monad
 import Data.Maybe
 import Data.Error
+import Text => qualified join
 
 :: BM a b = {t :: a->b, f :: b->a, t2 :: A.c t:(t c a)->t c b, f2 :: A.c t:(t b c)->t a c}
 bm = {t = id, f = id, t2 = id, f2 = id}
@@ -77,7 +78,35 @@ eval (WhileContainerBelow _ action) s
                = eval (action :. whileContainerBelow action) s
        = pure s
 
-Start = loadShip
+//print :: (Action i f) [String] -> [String]
+//print (MoveToShip _ _) s = ["Move to ship":s]
+//print (MoveToQuay _ _) s = ["Move to quay":s]
+//print (MoveUp _ _)     s = ["Move up":s]
+//print (MoveDown _ _)   s = ["Move down":s]
+//print (Lock _ _)       s = ["Lock":s]
+//print (Unlock _ _)     s = ["Unlock":s]
+//print (Wait _)         s = ["Wait":s]
+//print (a :. b)         s = print a ["\n":print b s]
+//print (WhileContainerBelow _ a) s
+//     = ["While container below (":indent ["\n":print a [")":s]]]
+//where
+//     indent s = map (\s->if (s.[0] == '\n') (s +++ "\t") s)
+//
+
+print :: (Action i f) String [String] -> [String]
+print (MoveToShip _ _) i s = [i,"Move to ship":s]
+print (MoveToQuay _ _) i s = [i,"Move to quay":s]
+print (MoveUp _ _)     i s = [i,"Move up":s]
+print (MoveDown _ _)   i s = [i,"Move down":s]
+print (Lock _ _)       i s = [i,"Lock":s]
+print (Unlock _ _)     i s = [i,"Unlock":s]
+print (Wait _)         i s = [i,"Wait":s]
+print (a :. b)         i s = print a i ["\n":print b i s]
+print (WhileContainerBelow _ a) i s
+       = [i,"While container below (\n":print a ("\t"+++i) ["\n",i,")":s]]
+
+Start = print loadShip "" []
+
 p1 = moveToShip :. moveDown
 
 //p2 = moveToShip :. wait :. lock // the required type error
@@ -93,5 +122,5 @@ loadShip =
                wait:.
                unlock:.
                moveUp:.
-               moveToQuay 
-       )
+               moveToQuay
+       ) :. wait
index 5a03545..3f9bb21 100644 (file)
@@ -1,18 +1,9 @@
 module test
 
-import StdMisc
+import StdEnv
 
-:: Zero = Zero
-:: Succ a = Succ
+class fmap t :: (a -> b) (t a) -> t b
 
-:: Ar3 a b c :== (a -> b -> c)
+instance fmap ((,)a) where fmap f (a, b) = (a, f b)
 
-class C m :: (m b)
-
-instance C ((->) a) where C = \x->undef
-
-Start :: (a -> b -> c)
-Start = t
-
-t :: (Ar3 a b c)
-t = C
+Start = fmap inc (42, 37)