1{-# LANGUAGE DeriveFunctor #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5{-# LANGUAGE LambdaCase #-}
6{-# LANGUAGE OverloadedStrings #-}
8import qualified Data.AppendMap as Map
15newtype MyQuery = MyQuery SelectedCount
16 deriving (Show, Read, Eq, Ord, Monoid, Semigroup, Additive, Group)
18instance Query MyQuery where
19 type QueryResult MyQuery = ()
22instance (Ord k, Query a, Eq (QueryResult a)) => Query (Selector k a) where
23 type QueryResult (Selector k a) = Selector k (QueryResult a)
26newtype Selector k a = Selector { unSelector :: Map.AppendMap k a }
27 deriving (Show, Read, Eq, Ord, Functor)
29instance (Ord k, Eq a, Monoid a) => Semigroup (Selector k a) where
30 (Selector a) <> (Selector b) = Selector $ fmapMaybe id $ f a b
37 in if z == mempty then Nothing else Just z
39instance (Ord k, Eq a, Monoid a) => Monoid (Selector k a) where
40 mempty = Selector Map.empty
43instance (Eq a, Ord k, Group a) => Group (Selector k a) where
44 negateG = fmap negateG
46instance (Eq a, Ord k, Group a) => Additive (Selector k a)
51 n <- count =<< button "Increment"
53 queryDyn $ zipDynWith (\x y -> Selector (Map.singleton (x :: Int) y)) n $ pure $ MyQuery $ SelectedCount 1
56 replace <- button "Replace"
57 widgetHold w $ w <$ replace
58 (_, q) <- runQueryT outer $ pure mempty
59 display $ incrementalToDynamic q
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