X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=test.icl;h=822f41d96f79c20b12a4020c848454a937724434;hb=0140429ff1785b6ff033813fe4d4c7cdb018e5a9;hp=2350a9a721c08da33bea0b08cc4bd588bcfd0bab;hpb=8ff537028a2955ede52506d13628c2d3faede6ed;p=clean-tests.git diff --git a/test.icl b/test.icl index 2350a9a..822f41d 100644 --- a/test.icl +++ b/test.icl @@ -1,52 +1,38 @@ module test -import StdEnv, StdGeneric -import Data.Array - -Start :: [{!Int}] -Start = - [ appendArr {!1,2,3} {!4,5,6,7} - , appendArr {!} {!} - , appendArr {!} {!1,2,3} - , appendArr {!1,2,3} {!} - ] -/* -derive bimap Box - -:: Box b a =: Box b - -unBox (Box b) :== b -box b :== Box b - -generic gPotentialInf a :: [String] -> Box Bool a - -gPotentialInf{|World|} _ = box False -gPotentialInf{|File|} _ = box False -gPotentialInf{|Bool|} _ = box False -gPotentialInf{|Char|} _ = box False -gPotentialInf{|Real|} _ = box False -gPotentialInf{|Int|} _ = box False -gPotentialInf{|Dynamic|} _ = box False -gPotentialInf{|(->)|} _ _ _ = box False -gPotentialInf{|{}|} a m = box (unBox (a m)) -gPotentialInf{|{!}|} a m = box (unBox (a m)) -gPotentialInf{|{#}|} a m = box (unBox (a m)) -gPotentialInf{|UNIT|} _ = box False -gPotentialInf{|EITHER|} l r m = box (unBox (l m) || unBox (r m)) -gPotentialInf{|PAIR|} l r m = box (unBox (l m) || unBox (r m)) -gPotentialInf{|CONS|} x m = box (unBox (x m)) -gPotentialInf{|FIELD|} x m = box (unBox (x m)) -gPotentialInf{|RECORD of {grd_name}|} x m - | isMember grd_name m = box True - = box (unBox (x [grd_name:m])) -gPotentialInf{|OBJECT of {gtd_name}|} x m - | isMember gtd_name m = box True - = box (unBox (x [gtd_name:m])) - -//derive gPotentialInf Int,Bool,Char,Real,String,File,World,Dynamic -derive gPotentialInf (),(,),(,,),(,,,),(,,,,),(,,,,,),(,,,,,,),(,,,,,,,),(,,,,,,,,),(,,,,,,,,,),(,,,,,,,,,,),(,,,,,,,,,,,),(,,,,,,,,,,,,),(,,,,,,,,,,,,,),(,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,),(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) -derive gPotentialInf {},{#},{!},[],[! ],[ !],[!!],[#],[#!] - -Start :: Box Bool *File -Start = gPotentialInf{|*|} [] -*/ +import StdEnv +import Data.Maybe +import Data.Functor +import Control.Monad +import Control.Applicative + +class expr v where + lit :: i -> v i | toString i + (+.) infixl 6 :: (v i) (v i) -> v i | + i + +instance + (v a) | expr v & + a where + + l r = l +. r + +eval :: (Maybe a) -> Maybe a +eval x = x +instance expr Maybe where + lit i = Just i + +. x y = (+) <$> x <*> y + +:: Print a =: Print String +print :: (Print a) -> String +print (Print a) = a +instance expr Print where + lit i = Print (toString i) + +. (Print l) (Print r) = Print (l +++ "+" +++ r) + +printEval :: (A.v: v a | expr v) -> (Maybe a, String) +//printEval f = (f, let (Print p) = f in p) +printEval f = (eval f, print f) + +//Mag niet +//Start :: (Maybe Int, String) +//Start = printEval (lit 4 + lit 38) + +//Mag wel +Start = let (Print f) = lit 4 + lit 38 in f