Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I found a bug in the code that set the active screen from your mouse location. I'm not sure it ever worked... Also, I broke up the Standard.hs file into smaller files.
- Loading branch information
Jack Garner
committed
Aug 11, 2020
1 parent
3741b35
commit acf15f1
Showing
11 changed files
with
193 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Standard.Beam where | ||
|
||
import Data.Functor.Foldable.TH | ||
import BasePrelude | ||
|
||
-- |You can think of a beam as the opposite of a list. instead of having | ||
-- 0 or more elements and a guaranteed empty case, Beam has 0 or more | ||
-- empty cases and a guaranteed element wrapped inside. | ||
-- | ||
-- You might be thinking, "This looks completely useluss!" and if we think of | ||
-- it as a normal container (like array, tree, list, etc.) then you would | ||
-- probably be right. If you think of Beam not as a container but as control | ||
-- flow, you get some cool results though. For an example, look at onInput . | ||
-- Instead of doing it recursively, you can use a hylomorphism to abstract away | ||
-- the recursion. At this point though, you need to pick a data type for F wich | ||
-- will wrap the intermediate result. What do you pick? Well Beam makes a | ||
-- great choice. For each recursive call, you just return Continue. Once you | ||
-- reach the leaf, you return End. Then, you can use a simple catamorphism to | ||
-- extract the value from the beam. | ||
data Beam a = End a | Continue (Beam a) | ||
deriving (Eq, Show, Functor) | ||
|
||
makeBaseFunctor ''Beam | ||
|
||
getEnd :: BeamF a a -> a | ||
getEnd (EndF a) = a | ||
getEnd (ContinueF a) = a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Standard.RectA where | ||
|
||
import Data.Bifunctor.TH | ||
import BasePrelude | ||
|
||
-- |A rectangle with any kind of dimension you could every want. The A stands | ||
-- for abstract. You probably want one of the type synonyms below. | ||
data RectA a b = Rect { x :: a | ||
, y :: a | ||
, w :: b | ||
, h :: b | ||
} | ||
deriving (Show, Eq) | ||
deriveBifunctor ''RectA | ||
|
||
-- |A rectangle over Doubles. This is usually what people think of | ||
-- when you say rectangle. | ||
type Rect = RectA Double Double | ||
|
||
-- |A rectangle according to X11. | ||
type XRect = RectA Int32 Word32 | ||
|
||
-- TODO There must be some way to get the Compiler to make this one... | ||
instance (Num n, Num m) => Semigroup (RectA n m) where | ||
Rect a1 a2 a3 a4 <> Rect b1 b2 b3 b4 = Rect (a1 + b1) (a2 + b2) (a3 + b3) (a4 + b4) | ||
|
||
-- And this one as well... | ||
instance (Num n, Num m) => Monoid (RectA n m) where | ||
mempty = Rect 0 0 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Standard.Stream where | ||
|
||
import BasePrelude | ||
|
||
-- |This stream lets me return an infinite list of values where each value | ||
-- comes from some monadic computation. To understand why I need this, consider | ||
-- implementing filterStream on something of type [m a] where filterStream | ||
-- remains lazy. | ||
data Stream m a = Stream a (m (Stream m a)) | ||
|
||
filterStream :: Monad m => (a -> Bool) -> Stream m a -> m (Stream m a) | ||
filterStream p (Stream a m) | ||
| p a = return $ Stream a (filterStream p =<< m) | ||
| otherwise = filterStream p =<< m | ||
|
||
repeatStream :: Functor m => m a -> m (Stream m a) | ||
repeatStream m = fmap (\a -> Stream a $ repeatStream m) m | ||
|
||
overStream :: Monad m => (a -> m b) -> Stream m a -> m c | ||
overStream f (Stream a m) = f a >> m >>= overStream f |
Oops, something went wrong.