Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell type synonym

Tags:

haskell

yesod

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.

like image 478
David Avatar asked Oct 08 '22 07:10

David


1 Answers

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 ++ "?"
like image 168
hugomg Avatar answered Oct 13 '22 12:10

hugomg