2{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE LambdaCase #-}
7{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE NoMonomorphismRestriction #-}
9{-# LANGUAGE PolyKinds #-}
10{-# LANGUAGE RankNTypes #-}
11{-# LANGUAGE RecursiveDo #-}
12{-# LANGUAGE ScopedTypeVariables #-}
13{-# LANGUAGE StandaloneDeriving #-}
14{-# LANGUAGE TypeFamilies #-}
15{-# LANGUAGE TypeOperators #-}
16{-# LANGUAGE UndecidableInstances #-}
17#ifdef USE_REFLEX_OPTIMIZER
18{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
24-- This module contains various functions for working with 'Dynamic' values.
25-- 'Dynamic' and its primitives have been moved to the 'Reflex' class.
28 Dynamic -- Abstract so we can preserve the law that the current value is always equal to the most recent update
41 , attachPromptlyDynWith
42 , attachPromptlyDynWithMaybe
59 , distributeMapOverDynPure
60 , distributeDMapOverDynPure
61 , distributeListOverDynPure
66 -- Things that probably aren't very useful:
70 , RebuildSortedHList (..)
74 , distributeFHListOverDynPure
79import Data.Functor.Compose
80import Data.Functor.Misc
84import Control.Monad.Fix
85import Control.Monad.Identity
87import Data.Dependent.Map (DMap)
88import qualified Data.Dependent.Map as DMap
89import Data.Dependent.Sum (DSum (..))
90import Data.GADT.Compare ((:~:) (..), GCompare (..), GEq (..), GOrdering (..))
93import Data.Monoid ((<>))
98-- | Map a sampling function over a 'Dynamic'.
99mapDynM :: forall t m a b. (Reflex t, MonadHold t m) => (forall m'. MonadSample t m' => a -> m' b) -> Dynamic t a -> m (Dynamic t b)
100mapDynM f d = buildDynamic (f =<< sample (current d)) $ pushAlways f (updated d)
102-- | Flipped version of 'mapDynM'
103forDynM :: forall t m a b. (Reflex t, MonadHold t m) => Dynamic t a -> (forall m'. MonadSample t m' => a -> m' b) -> m (Dynamic t b)
104forDynM d f = mapDynM f d
106-- | Create a new 'Dynamic' that only signals changes if the values actually
108holdUniqDyn :: (Reflex t, MonadHold t m, MonadFix m, Eq a) => Dynamic t a -> m (Dynamic t a)
109holdUniqDyn = holdUniqDynBy (==)
111-- | Create a new 'Dynamic' that changes only when the underlying 'Dynamic'
112-- changes and the given function returns 'False' when given both the old and
114holdUniqDynBy :: (Reflex t, MonadHold t m, MonadFix m) => (a -> a -> Bool) -> Dynamic t a -> m (Dynamic t a)
115holdUniqDynBy eq = scanDynMaybe id (\new old -> if new `eq` old then Nothing else Just new)
117-- | @/Dynamic Maybe/@ that can only update from @/Nothing/@ to @/Just/@ or @/Just/@ to @/Just/@ (i.e., cannot revert to @/Nothing/@)
118improvingMaybe :: (Reflex t, MonadHold t m, MonadFix m) => Dynamic t (Maybe a) -> m (Dynamic t (Maybe a))
119improvingMaybe = scanDynMaybe id (\new _ -> if isJust new then Just new else Nothing)
121-- | Create a 'Dynamic' that accumulates values from another 'Dynamic'. This
122-- function does not force its input 'Dynamic' until the output 'Dynamic' is
124scanDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b) -> (a -> b -> b) -> Dynamic t a -> m (Dynamic t b)
125scanDyn z f = scanDynMaybe z (\a b -> Just $ f a b)
127-- | Like 'scanDyn', but the the accumulator function may decline to update the
128-- result 'Dynamic''s value.
129scanDynMaybe :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b) -> (a -> b -> Maybe b) -> Dynamic t a -> m (Dynamic t b)
130scanDynMaybe z f d = do
131 rec d' <- buildDynamic (z <$> sample (current d)) $ flip push (updated d) $ \a -> do
132 b <- sample $ current d'
136-- | Create a 'Dynamic' using the initial value and change it each time the
137-- 'Event' occurs using a folding function on the previous value and the value
139foldDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> b) -> b -> Event t a -> m (Dynamic t b)
140foldDyn = accumDyn . flip
142-- | Like 'foldDyn', but the combining function is a 'PushM' action, so it
143-- can 'sample' existing 'Behaviors' and 'hold' new ones.
144foldDynM :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t b) -> b -> Event t a -> m (Dynamic t b)
145foldDynM = accumMDyn . flip
147-- | Create a 'Dynamic' using the provided initial value and change it each time
148-- the provided 'Event' occurs, using a function to combine the old value with
149-- the 'Event''s value. If the function returns 'Nothing', the value is not
150-- changed; this is distinct from returning 'Just' the old value, since the
151-- 'Dynamic''s 'updated' 'Event' will fire in the 'Just' case, and will not fire
152-- in the 'Nothing' case.
153foldDynMaybe :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> Maybe b) -> b -> Event t a -> m (Dynamic t b)
154foldDynMaybe = accumMaybeDyn . flip
156-- | Like 'foldDynMaybe', but the combining function is a 'PushM' action, so it
157-- can 'sample' existing 'Behaviors' and 'hold' new ones.
158foldDynMaybeM :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe b)) -> b -> Event t a -> m (Dynamic t b)
159foldDynMaybeM = accumMaybeMDyn . flip
161-- | Create a new 'Dynamic' that counts the occurrences of the 'Event'.
162count :: (Reflex t, MonadHold t m, MonadFix m, Num b) => Event t a -> m (Dynamic t b)
163count e = holdDyn 0 =<< zipListWithEvent const (iterate (+1) 1) e
165-- | Create a new 'Dynamic' using the initial value that flips its
166-- value every time the 'Event' occurs.
167toggle :: (Reflex t, MonadHold t m, MonadFix m) => Bool -> Event t a -> m (Dynamic t Bool)
168toggle = foldDyn (const not)
170-- | Switches to the new 'Event' whenever it receives one. Only the old event is
171-- considered the moment a new one is switched in; the output event will fire at
172-- that moment if only if the old event does.
174-- Prefer this to 'switchPromptlyDyn' where possible. The lack of doing double
175-- work when the outer and (new) inner fires means this imposes fewer "timing
176-- requirements" and thus is far more easy to use without introducing fresh
177-- failure cases. 'switchDyn' is also more performant.
178switchDyn :: forall t a. Reflex t => Dynamic t (Event t a) -> Event t a
179switchDyn d = switch (current d)
181-- | Switches to the new 'Event' whenever it receives one. Switching occurs
182-- __before__ the inner 'Event' fires - so if the 'Dynamic' changes and both the
183-- old and new inner Events fire simultaneously, the output will fire with the
184-- value of the __new__ 'Event'.
186-- Prefer 'switchDyn' to this where possible. The timing requirements that
187-- switching before imposes are likely to bring down your app unless you are
188-- very careful. 'switchDyn' is also more performant.
189switchPromptlyDyn :: forall t a. Reflex t => Dynamic t (Event t a) -> Event t a
190switchPromptlyDyn de =
191 let eLag = switch $ current de
192 eCoincidences = coincidence $ updated de
193 in leftmost [eCoincidences, eLag]
195-- | Split a 'Dynamic' pair into a pair of 'Dynamic's
196splitDynPure :: Reflex t => Dynamic t (a, b) -> (Dynamic t a, Dynamic t b)
197splitDynPure d = (fmap fst d, fmap snd d)
199-- | Convert a 'Map' with 'Dynamic' elements into a 'Dynamic' of a 'Map' with
200-- non-'Dynamic' elements.
201distributeMapOverDynPure :: (Reflex t, Ord k) => Map k (Dynamic t v) -> Dynamic t (Map k v)
202distributeMapOverDynPure = fmap dmapToMap . distributeDMapOverDynPure . mapWithFunctorToDMap
204-- | Convert a list with 'Dynamic' elements into a 'Dynamic' of a list with
205-- non-'Dynamic' elements, preserving the order of the elements.
206distributeListOverDynPure :: Reflex t => [Dynamic t v] -> Dynamic t [v]
207distributeListOverDynPure =
208 fmap (map fromDSum . DMap.toAscList) .
209 distributeDMapOverDynPure .
210 DMap.fromDistinctAscList .
213 toDSum :: Int -> Dynamic t a -> DSum (Const2 Int a) (Dynamic t)
214 toDSum k v = Const2 k :=> v
215 fromDSum :: DSum (Const2 Int a) Identity -> a
216 fromDSum (Const2 _ :=> Identity v) = v
218--TODO: Generalize this to functors other than Maps
219-- | Combine a 'Dynamic' of a 'Map' of 'Dynamic's into a 'Dynamic'
220-- with the current values of the 'Dynamic's in a map.
221joinDynThroughMap :: forall t k a. (Reflex t, Ord k) => Dynamic t (Map k (Dynamic t a)) -> Dynamic t (Map k a)
222joinDynThroughMap = join . fmap distributeMapOverDynPure
224-- | Print the value of the 'Dynamic' when it is first read and on each
225-- subsequent change that is observed (as 'traceEvent'), prefixed with the
226-- provided string. This should /only/ be used for debugging.
228-- Note: Just like Debug.Trace.trace, the value will only be shown if something
229-- else in the system is depending on it.
230traceDyn :: (Reflex t, Show a) => String -> Dynamic t a -> Dynamic t a
231traceDyn s = traceDynWith $ \x -> s <> ": " <> show x
233-- | Print the result of applying the provided function to the value
234-- of the 'Dynamic' when it is first read and on each subsequent change
235-- that is observed (as 'traceEvent'). This should /only/ be used for
238-- Note: Just like Debug.Trace.trace, the value will only be shown if something
239-- else in the system is depending on it.
240traceDynWith :: Reflex t => (a -> String) -> Dynamic t a -> Dynamic t a
242 let e' = traceEventWith f $ updated d
244 x <- sample $ current d
245 trace (f x) $ return x
246 in unsafeBuildDynamic getV0 e'
248-- | Replace the value of the 'Event' with the current value of the 'Dynamic'
249-- each time the 'Event' occurs.
251-- Note: @/tagPromptlyDyn d e/@ differs from @/tag (current d) e/@ in the case that @/e/@ is firing
252-- at the same time that @/d/@ is changing. With @/tagPromptlyDyn d e/@, the __new__ value of @/d/@
253-- will replace the value of @/e/@, whereas with @/tag (current d) e/@, the __old__ value
254-- will be used, since the 'Behavior' won't be updated until the end of the frame.
255-- Additionally, this means that the output 'Event' may not be used to directly change
256-- the input 'Dynamic', because that would mean its value depends on itself. __When creating__
257-- __cyclic data flows, generally @/tag (current d) e/@ is preferred.__
258tagPromptlyDyn :: Reflex t => Dynamic t a -> Event t b -> Event t a
259tagPromptlyDyn = attachPromptlyDynWith const
261-- | Attach the current value of the 'Dynamic' to the value of the
262-- 'Event' each time it occurs.
264-- Note: @/attachPromptlyDyn d/@ is not the same as @/attach (current d)/@. See 'tagPromptlyDyn' for details.
265attachPromptlyDyn :: Reflex t => Dynamic t a -> Event t b -> Event t (a, b)
266attachPromptlyDyn = attachPromptlyDynWith (,)
268-- | Combine the current value of the 'Dynamic' with the value of the
269-- 'Event' each time it occurs.
271-- Note: @/attachPromptlyDynWith f d/@ is not the same as @/attachWith f (current d)/@. See 'tagPromptlyDyn' for details.
272attachPromptlyDynWith :: Reflex t => (a -> b -> c) -> Dynamic t a -> Event t b -> Event t c
273attachPromptlyDynWith f = attachPromptlyDynWithMaybe $ \a b -> Just $ f a b
275-- | Create a new 'Event' by combining the value at each occurrence with the
276-- current value of the 'Dynamic' value and possibly filtering if the combining
277-- function returns 'Nothing'.
279-- Note: @/attachPromptlyDynWithMaybe f d/@ is not the same as @/attachWithMaybe f (current d)/@. See 'tagPromptlyDyn' for details.
280attachPromptlyDynWithMaybe :: Reflex t => (a -> b -> Maybe c) -> Dynamic t a -> Event t b -> Event t c
281attachPromptlyDynWithMaybe f d e =
282 let e' = attach (current d) e
283 in fforMaybe (align e' $ updated d) $ \case
284 This (a, b) -> f a b -- Only the tagging event is firing, so use that
285 These (_, b) a -> f a b -- Both events are firing, so use the newer value
286 That _ -> Nothing -- The tagging event isn't firing, so don't fire
288-- | Factor a @/Dynamic t (Maybe a)/@ into a @/Dynamic t (Maybe (Dynamic t a))/@,
289-- such that the outer 'Dynamic' is updated only when the "Maybe"'s constructor
290-- chages from 'Nothing' to 'Just' or vice-versa. Whenever the constructor
291-- becomes 'Just', an inner 'Dynamic' will be provided, whose value will track
292-- the 'a' inside the 'Just'; when the constructor becomes 'Nothing', the
293-- existing inner 'Dynamic' will become constant, and will not change when the
294-- outer constructor changes back to 'Nothing'.
295maybeDyn :: forall t a m. (Reflex t, MonadFix m, MonadHold t m) => Dynamic t (Maybe a) -> m (Dynamic t (Maybe (Dynamic t a)))
296maybeDyn = fmap (fmap unpack) . eitherDyn . fmap pack
304eitherDyn :: forall t a b m. (Reflex t, MonadFix m, MonadHold t m) => Dynamic t (Either a b) -> m (Dynamic t (Either (Dynamic t a) (Dynamic t b)))
305eitherDyn = fmap (fmap unpack) . factorDyn . fmap eitherToDSum
306 where unpack :: DSum (EitherTag a b) (Compose (Dynamic t) Identity) -> Either (Dynamic t a) (Dynamic t b)
308 LeftTag :=> Compose a -> Left $ coerceDynamic a
309 RightTag :=> Compose b -> Right $ coerceDynamic b
311factorDyn :: forall t m k v. (Reflex t, MonadHold t m, GEq k)
312 => Dynamic t (DSum k v) -> m (Dynamic t (DSum k (Compose (Dynamic t) v)))
313factorDyn d = buildDynamic (sample (current d) >>= holdKey) update where
314 update :: Event t (DSum k (Compose (Dynamic t) v))
315 update = flip push (updated d) $ \(newKey :=> newVal) -> do
316 (oldKey :=> _) <- sample (current d)
317 case newKey `geq` oldKey of
318 Just Refl -> return Nothing
319 Nothing -> Just <$> holdKey (newKey :=> newVal)
321 holdKey (k :=> v) = do
322 inner' <- filterEventKey k (updated d)
323 inner <- holdDyn v inner'
324 return $ k :=> Compose inner
325--------------------------------------------------------------------------------
327--------------------------------------------------------------------------------
329-- | Represents a time changing value together with an 'EventSelector' that can
330-- efficiently detect when the underlying 'Dynamic' has a particular value.
331-- This is useful for representing data like the current selection of a long
336-- > demuxed (demux d) k === fmap (== k) d
338-- However, when getDemuxed is used multiple times, the complexity is only
339-- /O(log(n))/, rather than /O(n)/ for fmap.
340data Demux t k = Demux { demuxValue :: Behavior t k
341 , demuxSelector :: EventSelector t (Const2 k Bool)
344-- | Demultiplex an input value to a 'Demux' with many outputs. At any given
345-- time, whichever output is indicated by the given 'Dynamic' will be 'True'.
346demux :: (Reflex t, Ord k) => Dynamic t k -> Demux t k
347demux k = Demux (current k)
348 (fan $ attachWith (\k0 k1 -> if k0 == k1
350 else DMap.fromList [Const2 k0 :=> Identity False,
351 Const2 k1 :=> Identity True])
352 (current k) (updated k))
354-- | Select a particular output of the 'Demux'; this is equivalent to (but much
355-- faster than) mapping over the original 'Dynamic' and checking whether it is
356-- equal to the given key.
357demuxed :: (Reflex t, Eq k) => Demux t k -> k -> Dynamic t Bool
359 let e = select (demuxSelector d) (Const2 k)
360 in unsafeBuildDynamic (fmap (==k) $ sample $ demuxValue d) e
362--------------------------------------------------------------------------------
364--------------------------------------------------------------------------------
366--TODO: This whole section is badly in need of cleanup
368-- | A heterogeneous list whose type and length are fixed statically. This is
369-- reproduced from the 'HList' package due to integration issues, and because
370-- very little other functionality from that library is needed.
371data HList (l::[*]) where
373 HCons :: e -> HList l -> HList (e ': l)
377type family HRevApp (l1 :: [k]) (l2 :: [k]) :: [k]
378type instance HRevApp '[] l = l
379type instance HRevApp (e ': l) l' = HRevApp l (e ': l')
381hRevApp :: HList l1 -> HList l2 -> HList (HRevApp l1 l2)
383hRevApp (HCons x l) l' = hRevApp l (HCons x l')
385hReverse :: HList l -> HList (HRevApp l '[])
386hReverse l = hRevApp l HNil
388hBuild :: (HBuild' '[] r) => r
391class HBuild' l r where
392 hBuild' :: HList l -> r
394instance (l' ~ HRevApp l '[])
395 => HBuild' l (HList l') where
398instance HBuild' (a ': l) r
399 => HBuild' l (a->r) where
400 hBuild' l x = hBuild' (HCons x l)
402-- | Like 'HList', but with a functor wrapping each element.
404 FHNil :: FHList f '[]
405 FHCons :: f e -> FHList f l -> FHList f (e ': l)
407instance GEq (HListPtr l) where
408 HHeadPtr `geq` HHeadPtr = Just Refl
409 HHeadPtr `geq` HTailPtr _ = Nothing
410 HTailPtr _ `geq` HHeadPtr = Nothing
411 HTailPtr a `geq` HTailPtr b = a `geq` b
413instance GCompare (HListPtr l) where -- Warning: This ordering can't change, dmapTo*HList will break
414 HHeadPtr `gcompare` HHeadPtr = GEQ
415 HHeadPtr `gcompare` HTailPtr _ = GLT
416 HTailPtr _ `gcompare` HHeadPtr = GGT
417 HTailPtr a `gcompare` HTailPtr b = a `gcompare` b
419-- | A typed index into a typed heterogeneous list.
420data HListPtr l a where
421 HHeadPtr :: HListPtr (h ': t) h
422 HTailPtr :: HListPtr t a -> HListPtr (h ': t) a
424deriving instance Eq (HListPtr l a)
425deriving instance Ord (HListPtr l a)
427fhlistToDMap :: forall (f :: * -> *) l. FHList f l -> DMap (HListPtr l) f
428fhlistToDMap = DMap.fromList . go
429 where go :: forall l'. FHList f l' -> [DSum (HListPtr l') f]
432 FHCons h t -> (HHeadPtr :=> h) : map (\(p :=> v) -> HTailPtr p :=> v) (go t)
434-- | This class allows 'HList's and 'FHlist's to be built from regular lists;
435-- they must be contiguous and sorted.
436class RebuildSortedHList l where
437 rebuildSortedFHList :: [DSum (HListPtr l) f] -> FHList f l
438 rebuildSortedHList :: [DSum (HListPtr l) Identity] -> HList l
440instance RebuildSortedHList '[] where
441 rebuildSortedFHList l = case l of
443 _ : _ -> error "rebuildSortedFHList{'[]}: empty list expected"
444 rebuildSortedHList l = case l of
446 _ : _ -> error "rebuildSortedHList{'[]}: empty list expected"
448instance RebuildSortedHList t => RebuildSortedHList (h ': t) where
449 rebuildSortedFHList l = case l of
450 ((HHeadPtr :=> h) : t) -> FHCons h . rebuildSortedFHList . map (\(HTailPtr p :=> v) -> p :=> v) $ t
451 _ -> error "rebuildSortedFHList{h':t}: non-empty list with HHeadPtr expected"
452 rebuildSortedHList l = case l of
453 ((HHeadPtr :=> Identity h) : t) -> HCons h . rebuildSortedHList . map (\(HTailPtr p :=> v) -> p :=> v) $ t
454 _ -> error "rebuildSortedHList{h':t}: non-empty list with HHeadPtr expected"
456dmapToHList :: forall l. RebuildSortedHList l => DMap (HListPtr l) Identity -> HList l
457dmapToHList = rebuildSortedHList . DMap.toList
459-- | Collect a hetereogeneous list whose elements are all 'Dynamic's into a
460-- single 'Dynamic' whose value represents the current values of all of the
462distributeFHListOverDynPure :: (Reflex t, RebuildSortedHList l) => FHList (Dynamic t) l -> Dynamic t (HList l)
463distributeFHListOverDynPure l = fmap dmapToHList $ distributeDMapOverDynPure $ fhlistToDMap l
465-- | Indicates that all elements in a type-level list are applications of the
467class AllAreFunctors (f :: a -> *) (l :: [a]) where
468 type FunctorList f l :: [*]
469 toFHList :: HList (FunctorList f l) -> FHList f l
470 fromFHList :: FHList f l -> HList (FunctorList f l)
472instance AllAreFunctors f '[] where
473 type FunctorList f '[] = '[]
474 toFHList l = case l of
476#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 800
477 _ -> error "toFHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
479 fromFHList FHNil = HNil
481instance AllAreFunctors f t => AllAreFunctors f (h ': t) where
482 type FunctorList f (h ': t) = f h ': FunctorList f t
483 toFHList l = case l of
484 a `HCons` b -> a `FHCons` toFHList b
485#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 800
486 _ -> error "toFHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
488 fromFHList (a `FHCons` b) = a `HCons` fromFHList b
490-- | Convert a datastructure whose constituent parts are all 'Dynamic's into a
491-- single 'Dynamic' whose value represents all the current values of the input's
492-- constituent 'Dynamic's.
493collectDynPure :: ( RebuildSortedHList (HListElems b)
494 , IsHList a, IsHList b
495 , AllAreFunctors (Dynamic t) (HListElems b)
497 , HListElems a ~ FunctorList (Dynamic t) (HListElems b)
498 ) => a -> Dynamic t b
499collectDynPure ds = fmap fromHList $ distributeFHListOverDynPure $ toFHList $ toHList ds
501-- | Poor man's 'Generic's for product types only.
503 type HListElems a :: [*]
504 toHList :: a -> HList (HListElems a)
505 fromHList :: HList (HListElems a) -> a
507instance IsHList (a, b) where
508 type HListElems (a, b) = [a, b]
509 toHList (a, b) = hBuild a b
510 fromHList l = case l of
511 a `HCons` b `HCons` HNil -> (a, b)
512#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 800
513 _ -> error "fromHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
516instance IsHList (a, b, c, d) where
517 type HListElems (a, b, c, d) = [a, b, c, d]
518 toHList (a, b, c, d) = hBuild a b c d
519 fromHList l = case l of
520 a `HCons` b `HCons` c `HCons` d `HCons` HNil -> (a, b, c, d)
521#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 800
522 _ -> error "fromHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
525instance IsHList (a, b, c, d, e, f) where
526 type HListElems (a, b, c, d, e, f) = [a, b, c, d, e, f]
527 toHList (a, b, c, d, e, f) = hBuild a b c d e f
528 fromHList l = case l of
529 a `HCons` b `HCons` c `HCons` d `HCons` e `HCons` f `HCons` HNil -> (a, b, c, d, e, f)
530#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 800
531 _ -> error "fromHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
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