Search code examples
haskellyesod

Haskell type synonym


I'm trying to understand what the following type synonym from Yesod is doing.

type HtmlUrlI18n msg url = Translate msg -> Render url -> Html

I could not find an example in learn you some haskell or the haskell wikibook of a type synonym with -> present. Any links or explanations are much appreciated. Thanks.


Solution

  • Its just a synonym for a (long to write down) function type. For example, the following should be valid Haskell

    --Example of a function type synonym
    type StrFn = String -> String
    
    foo :: StrFn
    foo s = s ++ "!"
    
    --Example of a function type synonym with type parameters
    type Fn a = a -> a
    
    bar :: Fn String
    bar s = s ++ "?"