Skip to content

Instantly share code, notes, and snippets.

@cartazio
Created April 6, 2017 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cartazio/8f9f33e58ac92f3fbf0e45b1cbb42dc5 to your computer and use it in GitHub Desktop.
Save cartazio/8f9f33e58ac92f3fbf0e45b1cbb42dc5 to your computer and use it in GitHub Desktop.
how to do splices
$ ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Prelude> :set -XQuasiQuotes
Prelude> :set -XTemplateHaskellQuotes
Prelude> [t| forall x . (x -> x) -> x |]
<interactive>:3:14: error:
Illegal symbol '.' in type
Perhaps you intended to use RankNTypes or a similar language
extension to enable explicit-forall syntax: forall <tvs>. <type>
Prelude> [t| forall x . (x -> x) -> x |]
Prelude> :set -XR
-XRank2Types -XRankNTypes -XRebindableSyntax -XRecordWildCards -XRecursiveDo -XRelaxedLayout -XRoleAnnotations
Prelude> :set -XRank
-XRank2Types -XRankNTypes
Prelude> :set -XRankNTypes
Prelude> [t| forall x . (x -> x) -> x |]
<interactive>:5:1: error:
• No instance for (Show Language.Haskell.TH.Lib.TypeQ)
arising from a use of ‘print’
• In a stmt of an interactive GHCi command: print it
Prelude> [t| forall x . (x -> x) -> x |]
Prelude> import Language.Haskell.TH.Syntax
Prelude Language.Haskell.TH.Syntax> runQ $ t| forall x . (x -> x) -> x |]
<interactive>:7:31: error: parse error on input ‘->’
Prelude Language.Haskell.TH.Syntax> runQ $ t| forall x . ((x -> x) -> x) |]
<interactive>:8:38: error: parse error on input ‘|]’
Prelude Language.Haskell.TH.Syntax> runQ $ [t| forall x . ((x -> x) -> x) |]
ForallT [PlainTV x_0] [] (AppT (AppT ArrowT (AppT (AppT ArrowT (VarT x_0)) (VarT x_0))) (VarT x_0))
Prelude Language.Haskell.TH.Syntax>