Can I define a type synonym inside the "let" block?

Advertisements

I want to get something like this. It’s possible?

something :: String
something = 
  let
    type FirstName = String
    type LastName = String
    
    fullName :: FirstName -> LastName -> String
    fullName = a ++ " " ++ b
  in
    fullName "Haskell" "Curry"

I’ve been trying to find language extensions that do this, but to no avail.

>Solution :

Direct answer is no, type definitions are possible only on module level.

Something similar is possible:

let
  fullName ::
    (firstName ~ String, lastName ~ String) =>
    firstName -> lastName -> String
  fullName = a ++ " " ++ b
in
  _

Leave a Reply Cancel reply