haskell - Understanding type -
a few questions haskell programming language:
what's difference between these 2 code statements? i'm convinced should same:
type t = [char] type currentvalue = char
my concern that, in second one, there no brackets.
anyway, declarations, aren't they?
what
maybe string
?for instance:
type p = (char, maybe string)
is function has 2 arguments?
what
maybe char
?for instance :
type d = ((maybe char) , char)
it's function taking 3 arguments, right?
what's difference between these 2 code statements?
type t = [char] type currentvalue = char
the first line declares type alias
t
[char]
list of characters. second line declares type aliascurrentvalue
char
, single character.what
maybe string
?it application of type constructor
maybe
typestring
(which alias[char]
). similar how brackets turn type list of type, exceptmaybe
makes things optional.for instance:
type p = (char, maybe string)
is function has 2 arguments ?
no, that's tuple type of 2 elements. first element
char
, secondmaybe string
.what
maybe char
?for instance :
type d = ((maybe char) , char)
it's function having 3 arguments. right?
this again tuple type. type of first element
maybe char
, secondchar
. inner parenthesis redundant, it's sametype d = (maybe char, char)
.
Comments
Post a Comment