From 4ef19aa35a6d63a8d9f7b6a7a11ac82c2a525783 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 31 Aug 2019 13:17:27 -0400 Subject: Add entities, and allow walking around Add support for entities via a port of the EntityMap type, and implement command support starting at basic hjkl. --- src/Xanthous/Orphans.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Xanthous/Orphans.hs (limited to 'src/Xanthous/Orphans.hs') diff --git a/src/Xanthous/Orphans.hs b/src/Xanthous/Orphans.hs new file mode 100644 index 000000000000..232eabf4efb1 --- /dev/null +++ b/src/Xanthous/Orphans.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE UndecidableInstances, PatternSynonyms #-} +{-# OPTIONS_GHC -Wno-orphans #-} +-- | + +module Xanthous.Orphans () where + +import Xanthous.Prelude + +instance forall s a. + ( Cons s s a a + , MonoFoldable s + ) => Cons (NonNull s) (NonNull s) a a where + _Cons = prism hither yon + where + hither :: (a, NonNull s) -> NonNull s + hither (a, ns) = + let s = toNullable ns + in impureNonNull $ a <| s + + yon :: NonNull s -> Either (NonNull s) (a, NonNull s) + yon ns = case ns ^? _Cons of + Nothing -> Left ns + Just (a, ns') -> Right (a, ns') -- cgit 1.4.1