开发者

Haskell - Assigning a value to user defined types

开发者 https://www.devze.com 2023-03-12 14:08 出处:网络
Que开发者_StackOverflow中文版stion I have defined a user defined type as type asd = [(Char,Int)]

Que开发者_StackOverflow中文版stion

I have defined a user defined type as

type asd = [(Char,Int)]

How can i assigin a value to a type asd such as asd= [("Hello",1)] (Not in run time) to keep hard code a value in source code

is this possible ? , becouse there is no variable concept in functional programming


You are defining a constant. An example would be:

-- A type of lists of pairs
type ASD = [(String,Int)]

-- A value of type ASD
asd :: ASD
asd = [("Hello", 1)]

That is, you just declare what the value of asd is.

0

精彩评论

暂无评论...
验证码 换一张
取 消