Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding type family

I have the following code:

{-# LANGUAGE TypeFamilies #-}
type family Times (a :: Nat) (b :: Nat) :: Nat where 
   Times Z n = Z
   Times (S m) n = Plus n (Times m n)

I know that type families allow you to write functions on the type level. However, for the code above, I know that (a :: Nat) (b :: Nat) are the types of the two parameters that are passed to the function Times.

However I don't understand what the final :: Nat after (a :: Nat) (b :: Nat) means. Any insights are appreciated.

like image 276
ceno980 Avatar asked Aug 02 '19 01:08

ceno980


People also ask

What is a type family meaning?

Type families are ranges of typeface designs. Each family is a variation of a basic style of alphabet. There are hundreds or maybe even thousands of typeface families.

What are the 5 font families?

In CSS (and in typography in general) there are five basic types, or families, of fonts: serif, sans serif, cursive, fantasy, and monospace.


1 Answers

The final :: Nat indicates that the type-level function returns a Nat.

like image 186
Daniel Wagner Avatar answered Oct 05 '22 17:10

Daniel Wagner