#REDIRECT [[Lennart Augustsson]]
'''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.
{{Rcat shell|
There are very few building blocks in the language, but a lot of [[syntactic sugar]] to make it more readable. The syntax is largely borrowed from [[Haskell (programming language)|Haskell]].
{{R to related topic}}
}}
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>.
<pre>
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
printf' :: (fmt::String) -> String -> PrintfType fmt
printf' (Nil) out = out
printf' ('%':('d':cs)) out = \ (i::Int) -> printf' cs (out ++ show i)
printf' ('%':('s':cs)) out = \ (s::String) -> printf' cs (out ++ s)
printf' ('%':( c :cs)) out = printf' cs (out ++ c : Nil)
printf' (c:cs) out = printf' cs (out ++ c : Nil)
printf :: (fmt::String) -> PrintfType fmt
printf fmt = printf' fmt Nil
</pre>
The '''Cayenne''' implementation is written in [[Haskell (programming language)|Haskell]], and it also translates to Haskell.
{{logic-stub}}
{{prog-lang-stub}}
[[Category:Functional languages]]
[[Category:Dependently typed formal languages]]
[[Category:Articles with example code]]
[[Category:Discontinued programming languages]]
[[Category:Programming languages created in the 1990s]]
|