1-- | A module containing a box datatype representing a compiled item. This
2-- item can be of any type, given that a few restrictions hold (e.g. we want
3-- a 'Typeable' instance to perform type-safe casts).
5{-# LANGUAGE ExistentialQuantification #-}
6module Hakyll.Core.CompiledItem
12import Data.Binary (Binary)
13import Data.Typeable (Typeable, cast)
14import Data.Maybe (fromMaybe)
16import Hakyll.Core.Writable
18-- | Box type for a compiled item
20data CompiledItem = forall a. (Binary a, Typeable a, Writable a)
23instance Writable CompiledItem where
24 write p (CompiledItem x) = write p x
26-- | Box a value into a 'CompiledItem'
28compiledItem :: (Binary a, Typeable a, Writable a)
31compiledItem = CompiledItem
33-- | Unbox a value from a 'CompiledItem'
35unCompiledItem :: (Binary a, Typeable a, Writable a)
38unCompiledItem (CompiledItem x) = fromMaybe error' $ cast x
40 error' = error "Hakyll.Core.CompiledItem.unCompiledItem: Unsupported type"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list