niv-0.2.0: Easy dependency management for Nix projects

Safe HaskellNone
LanguageHaskell2010

Niv.Update

Synopsis

Documentation

data Update b c where Source #

Constructors

Id :: Update a a 
Compose :: Compose b c -> Update b c 
Arr :: (b -> c) -> Update b c 
First :: Update b c -> Update (b, d) (c, d) 
Zero :: Update b c 
Plus :: Update b c -> Update b c -> Update b c 
Check :: (a -> Bool) -> Update (Box a) () 
Load :: Text -> Update () (Box Value) 
UseOrSet :: Text -> Update (Box Value) (Box Value) 
Update :: Text -> Update (Box Value) (Box Value) 
Run :: (a -> IO b) -> Update (Box a) (Box b) 
Template :: Update (Box Text) (Box Text) 
Instances
Arrow Update Source # 
Instance details

Defined in Niv.Update

Methods

arr :: (b -> c) -> Update b c #

first :: Update b c -> Update (b, d) (c, d) #

second :: Update b c -> Update (d, b) (d, c) #

(***) :: Update b c -> Update b' c' -> Update (b, b') (c, c') #

(&&&) :: Update b c -> Update b c' -> Update b (c, c') #

ArrowZero Update Source # 
Instance details

Defined in Niv.Update

Methods

zeroArrow :: Update b c #

ArrowPlus Update Source # 
Instance details

Defined in Niv.Update

Methods

(<+>) :: Update b c -> Update b c -> Update b c #

Category Update Source # 
Instance details

Defined in Niv.Update

Methods

id :: Update a a #

(.) :: Update b c -> Update a b -> Update a c #

Show (Update b c) Source # 
Instance details

Defined in Niv.Update

Methods

showsPrec :: Int -> Update b c -> ShowS #

show :: Update b c -> String #

showList :: [Update b c] -> ShowS #

data Compose a c Source #

Constructors

Compose' (Update b c) (Update a b) 

runUpdate :: Attrs -> Update () a -> IO (Attrs, a) Source #

Run an Update and return the new attributes and result.

execUpdate :: Attrs -> Update () a -> IO a Source #

type JSON a = (ToJSON a, FromJSON a) Source #

data UpdateRes a b Source #

Constructors

UpdateReady (UpdateReady b) 
UpdateNeedMore (a -> IO (UpdateReady b)) 
Instances
Functor (UpdateRes a) Source # 
Instance details

Defined in Niv.Update

Methods

fmap :: (a0 -> b) -> UpdateRes a a0 -> UpdateRes a b #

(<$) :: a0 -> UpdateRes a b -> UpdateRes a a0 #

data UpdateReady b Source #

Instances
Functor UpdateReady Source # 
Instance details

Defined in Niv.Update

Methods

fmap :: (a -> b) -> UpdateReady a -> UpdateReady b #

(<$) :: a -> UpdateReady b -> UpdateReady a #

runBox :: Box a -> IO a Source #

data Box a Source #

Constructors

Box 

Fields

  • boxNew :: Bool

    Whether the value is new or was retrieved (or derived) from old attributes

  • boxOp :: IO a
     
Instances
Functor Box Source # 
Instance details

Defined in Niv.Update

Methods

fmap :: (a -> b) -> Box a -> Box b #

(<$) :: a -> Box b -> Box a #

Applicative Box Source # 
Instance details

Defined in Niv.Update

Methods

pure :: a -> Box a #

(<*>) :: Box (a -> b) -> Box a -> Box b #

liftA2 :: (a -> b -> c) -> Box a -> Box b -> Box c #

(*>) :: Box a -> Box b -> Box b #

(<*) :: Box a -> Box b -> Box a #

IsString (Box Text) Source # 
Instance details

Defined in Niv.Update

Methods

fromString :: String -> Box Text #

Semigroup a => Semigroup (Box a) Source # 
Instance details

Defined in Niv.Update

Methods

(<>) :: Box a -> Box a -> Box a #

sconcat :: NonEmpty (Box a) -> Box a #

stimes :: Integral b => b -> Box a -> Box a #

data Freedom Source #

Constructors

Locked 
Free 
Instances
Eq Freedom Source # 
Instance details

Defined in Niv.Update

Methods

(==) :: Freedom -> Freedom -> Bool #

(/=) :: Freedom -> Freedom -> Bool #

Show Freedom Source # 
Instance details

Defined in Niv.Update

runUpdate' :: BoxedAttrs -> Update a b -> IO (UpdateRes a b) Source #

Runs an update, trying to evaluate the Boxes as little as possible. This is a hairy piece of code, apologies ¯_(ツ)_/¯ In most cases I just picked the first implementation that compiled

renderTemplate :: (Text -> Maybe (Box Text)) -> Text -> Maybe (Box Text) Source #

Renders the template. Returns Nothing if some of the attributes are missing. renderTemplate ("foo" -> "bar") "foo" -> pure (Just "bar") renderTemplate ("foo" -> "bar") "baz" -> pure Nothing

check :: (a -> Bool) -> Update (Box a) () Source #

load :: FromJSON a => Text -> Update () (Box a) Source #

useOrSet :: JSON a => Text -> Update (Box a) (Box a) Source #

update :: JSON a => Text -> Update (Box a) (Box a) Source #

run :: (a -> IO b) -> Update (Box a) (Box b) Source #

run' :: (a -> IO b) -> Update (Box a) (Box b) Source #

Like run but forces evaluation

dirty :: Update (Box a) (Box a) Source #