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

Time:11-04

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.

CodePudding user response:

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 = a    " "    b
in
  _
  • Related