You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Page 29 defines a data type to be used as a data kind:
dataUserType=User
| Admin
Then suggests to refine some User data type:
dataUser=User{ ... }
Unfortunately, the two cannot coexist as is, since they use the same data constructor name User. Seasoned Haskellers will not be too bothered by this, but someone a little new can be surprised by the duplicate identifier error.
(Mediocre) suggestions for fixes:
renaming User into something else in UserType... nothing great comes to mind, the somewhat verbose NormalUser? :\
explicitly mentioning that UserType should live in its own module and used qualified as UserType.User?
Not sure, it's a very minor issue! :-)
The text was updated successfully, but these errors were encountered:
Regarding the same code snippet... could you please give an example of how to use doSensitiveThings in connection with the userAdminToken. It is not clear to me how can you possibly turn Maybe (Proxy 'Admin) into a type error?
This is obviously wrong example...
{-# LANGUAGE DataKinds #-}
importData.ProxydataUserType=NonAdmin | AdmindataUser=User{userAdminToken::Maybe (Proxy 'Admin) }doSensitiveThings::Proxy 'Admin ->IO()
doSensitiveThings _proxy =print"This is admin."-- ??
main =do-- Is there any other way to create users?let adminUser =User (JustProxy) -- ??
nonAdminUser =UserNothing-- ??-- How to use 'doSensitiveThings' properly ??
doSensitiveThings undefined
There should probably be data User t = ... instead of data User = .... But I am obviously missing something important about Proxy. I would appreciate a working example.
Page 29 defines a data type to be used as a data kind:
Then suggests to refine some
User
data type:Unfortunately, the two cannot coexist as is, since they use the same data constructor name
User
. Seasoned Haskellers will not be too bothered by this, but someone a little new can be surprised by the duplicate identifier error.(Mediocre) suggestions for fixes:
User
into something else inUserType
... nothing great comes to mind, the somewhat verboseNormalUser
? :\UserType
should live in its own module and used qualified asUserType.User
?Not sure, it's a very minor issue! :-)
The text was updated successfully, but these errors were encountered: