David
David

Reputation: 646

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.

Upvotes: 5

Views: 753

Answers (1)

hugomg
hugomg

Reputation: 69934

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 ++ "?"

Upvotes: 4

Related Questions