content: -- {-# LANGUAGE #-}
  {-# OPTIONS_GHC -Wall #-}
  
  -- {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- TEMP
  -- {-# OPTIONS_GHC -fno-warn-unused-binds   #-} -- TEMP
  
  ----------------------------------------------------------------------
  -- |
  -- Module      :  LambdaCCC.MkStringExpr
  -- Copyright   :  (c) 2013 Tabula, Inc.
  -- LICENSE     :  BSD3
  -- 
  -- Maintainer  :  conal@tabula.com
  -- Stability   :  experimental
  -- 
  -- Tweaked mkStringExpr from coreSyn/MkCore in GHC API. The standard version
  -- treats empty and single-character strings specially, which makes for less
  -- uniform-looking Core.
  ----------------------------------------------------------------------
  
  module LambdaCCC.MkStringExpr (mkStringExpr) where
  
  import Control.Monad (liftM)
  import Data.Char (ord)
  
  import GhcPlugins hiding (mkStringExpr)
  import PrelNames (unpackCStringName,unpackCStringUtf8Name)
  
  -- | Create a 'CoreExpr' that evaluates to the given string
  mkStringExpr :: MonadThings m => String -> m CoreExpr
  mkStringExpr str = liftM mk (lookupId unpackName)
   where
     mk unpackId = App (Var unpackId) (Lit (mkMachString str))
     unpackName | all safeChar str = unpackCStringName
                | otherwise        = unpackCStringUtf8Name
     safeChar c = ord c >= 1 && ord c <= 0x7F
  