Search code examples
haskellsml

Convert a MOSCOW ML type to HASKELL


I'm trying to convert a SML type to a Haskell type.

type Identifier = string

type 'a Environment = (Identifier * 'a) list

Solution

  • I guess the same code in Haskell could be

    type Identifier = String
    
    type Environment a = [(Identifier, a)]
    

    Still, I would recommend to use newtypes to increase type safety, like in

    newtype Identifier = Identifier String
    
    newtype Environment a = Environment [(Identifier, a)]