Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
-- Sequential conjunction of constraints<br />
(&>) :: Success -> Success -> Success<br />
c1 &> c2 | c1 = c2<br />
-- Maybe type<br />
data Maybe a = Nothing | Just a<br />
maybe :: b -> (a -> b) -> Maybe a -> b<br />
maybe n _ Nothing = n<br />
maybe _ f (Just x) = f x<br />
-- Either type<br />
data Either a b = Left a | Right b<br />
either :: (a -> c) -> (b -> c) -> Either a b -> c<br />
either f _ (Left x) = f x<br />
either _ g (Right x) = g x<br />
-- Monadic IO<br />
data IO a -- conceptually: World -> (a,World)<br />
(>>=) :: IO a -> (a -> IO b) -> IO b<br />
return :: a -> IO a<br />
(>>) :: IO a -> IO b -> IO b<br />
a >> b = a >>= (\_ -> b)<br />
done :: IO ()<br />
done = return ()<br />
putChar :: Char -> IO ()<br />
getChar :: IO Char<br />
readFile :: String -> IO String<br />
writeFile :: String -> String -> IO ()<br />
appendFile :: String -> String -> IO ()<br />
putStr :: String -> IO ()<br />
55