What are these square brackets in Haskell?

I read the code below in Indexed Monad

{-# LANGUAGE QuasiQuotes #-} import Control.Monad.Indexed.State import Control.Monad.Indexed import Language.Haskell.IndexedDo hoge :: IxState Int [Int] () hoge = [ido|do imodify (*10) imodify show imodify reverse imodify (++"123") imodify $ map fromEnum |] 

What is the syntax of these characters [|....|] ?

Is it some kind of syntactic sugar?

+6
source share
1 answer

This is a quasiquotation syntax. See also the wiki page. Text between [ido| and |] is passed verbatim to the ido quasiquator, which uses it to generate some Haskell code at compile time.

+8
source

Source: https://habr.com/ru/post/944302/


All Articles