1{-# LANGUAGE OverloadedStrings #-}23-- | This module implements a 'Formatter' for Scheme variable definition.4--5-- For example:6--7-- > (define x 42)8module SchemeDoc.Format.Variable (Variable (..), mkVariable) where910import qualified Data.Text as T11import SchemeDoc.Format.Types12import SchemeDoc.Format.Util13import SchemeDoc.Types1415-- | A R7RS Scheme variable definition.16data Variable = Variable17 { name :: T.Text18 -- ^ Identifier, i.e. variable name.19 , value :: Sexp20 -- ^ Value assigned to the variable name.21 }22 deriving (Eq, Show)2324instance Formatable Variable where25 fmt (Variable internalId _) desc =26 mkDeclaration internalId desc $ \n ->27 do28 component "constant " n29 fromMkd desc30 htmlSexp (Id n)3132-- | Parses a Scheme definition.33--34-- > <definition> → (define <identifier> <expression>)35mkVariable :: Sexp -> Maybe Variable36mkVariable (List [Id "define", Id n, expr]) =37 Just $ Variable n expr38mkVariable _ = Nothing