modelling data Flashcards

1
Q

homogenious

A

same data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

heterogenious

A

different data types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

type keyword

A

allows you to create a type alias

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is an advantage of creating a type alias

A

means you dont have to write out the type multiple times

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

type alias as transparent

A

can pass values with the same structure instead of the alias
can change the internal values as much as you want

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

newtype keyword

A

like type but defines a new type rather than an alias

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is a positive and negative of the newtype keyword

A

allows you to maintain data constraints
cant be used interchangeably by the types its made up of

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

why do we use the deriving keyword

A

when defining new types we want to avoid making the type an instance of the type class we want to use it with (e.g. deriving(show))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

data keyword

A

defines a new data type
allows you to do things that have been build into other languages separately

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

data + enumeration

A

separates the different values with a |

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

enumeration

A

a list of all possible values a type can have

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

type constructors

A

allows you to make a value of a new type/datatype
becomes another function and can be used like one anywhere

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

value constructor

A

a function that produces a value of the type from arguments inputted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

smart construction

A

functions that take the necessary data to create a value of a type and returns the value if the constraints are valid

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how do we stop smart construction from crashing if the constraints arent valid

A

using maybe or either

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

parametised types

A

a generic type; uses a type variable e.g. a

17
Q

what is a benefit of parametised types

A

allows us to write flexible and reusable data types