#REDIRECT [[Haskell_(programming_language)#Related_languages]] {{R from related topic}}
'''Cayenne''' is a [[functional programming]] language with [[dependent type]]s.
The basic types are functions, products, and sums. Functions and products use dependent types to gain additional power.
There are very few building blocks in the language, but much [[syntactic sugar]] to make it more readable. The syntax is largely borrowed from [[Haskell (programming language)|Haskell]].
There is no special module system, because with dependent types records (products) are powerful enough to define modules.
The main aim with '''Cayenne''' is not to use the types to express specifications (although this can be done), but rather to use the [[type system]] to give type to more functions. An example of a function that can be given a type in '''Cayenne''' is <code>printf</code>.
<source lang="haskell">
PrintfType :: String -> #
PrintfType (Nil) = String
PrintfType ('%':('d':cs)) = Int -> PrintfType cs
PrintfType ('%':('s':cs)) = String -> PrintfType cs
PrintfType ('%':( _ :cs)) = PrintfType cs
PrintfType ( _ :cs) = PrintfType cs
aux :: (fmt::String) -> String -> PrintfType fmt
aux (Nil) out = out
aux ('%':('d':cs)) out = \ (i::Int) -> aux cs (out ++ show i)
aux ('%':('s':cs)) out = \ (s::String) -> aux cs (out ++ s)
aux ('%':( c :cs)) out = aux cs (out ++ c : Nil)
aux (c:cs) out = aux cs (out ++ c : Nil)
printf :: (fmt::String) -> PrintfType fmt
printf fmt = aux fmt Nil
</source>
The '''Cayenne''' implementation is written in Haskell, and it also translates to Haskell.
== External links ==
* [http://www.kframework.org/images/5/5e/Cayenne.pdf A description].
{{logic-stub}}
{{prog-lang-stub}}
[[Category:Functional languages]]
[[Category:Dependently typed languages]]
[[Category:Articles with example code]]
[[Category:Discontinued programming languages]]
[[Category:Programming languages created in the 1990s]]
|