packages feed

uhc-light-1.1.8.7: src/UHC/Light/Compiler/EHC/BuildFunction.hs

{-# LANGUAGE GADTs #-}

module UHC.Light.Compiler.EHC.BuildFunction
( BFun (..) )
where
import UHC.Light.Compiler.EHC.Common
import UHC.Light.Compiler.EHC.CompileUnit
import Control.Applicative

{-# LINE 29 "src/ehc/EHC/BuildFunction.chs" #-}
-- | Representation of build functions (embedded comment screws up haddock, hence see source code directly)
data BFun res where
  --- | Obtain FPath of an (imported module)
  FPathOfImported
    :: HsName				--- ^ module name
    -> BFun FPath

  --- | Extract imported modules from a module
  ImportsOf
    :: HsName				--- ^ module name
    -> BFun [HsName]

  --- | Extract compileunit from a module
  EcuOf
    :: HsName				--- ^ module name
    -> BFun EHCompileUnit

  --- | Applicative: pure
  Pure
    :: res
    -> BFun res

  --- | Applicative: <*>
  App
    :: BFun (res1 -> res2)
    -> BFun res1
    -> BFun res2

instance Functor BFun where
  fmap f (Pure  x) = Pure (f x)
  fmap f (App g x) = App (fmap (f .) g) x
  fmap _ _         = panic "BuildFuncion.Functor.BFun"

instance Applicative BFun where
  pure  = Pure
  (<*>) = App