Last active
February 22, 2020 03:48
-
-
Save greatBigDot/68e7a32e4802a7359450077bf03cbe88 to your computer and use it in GitHub Desktop.
Natural numbers and vectors and such
This file contains hidden or 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
| {-# LANGUAGE UnicodeSyntax, NoStarIsType, LambdaCase #-} | |
| {-# LANGUAGE GADTs, DataKinds, PolyKinds, PatternSynonyms, ViewPatterns, TypeApplications #-} | |
| module Utils where | |
| import Data.Kind | |
| -- The usual definitions of Nat and Vec: | |
| data Nat = Z | S Nat | |
| data Vec :: Nat -> Type -> Type where | |
| VNil :: Vec 'Z a | |
| (:>) :: a -> Vec n a -> Vec ('S n) a | |
| instance Functor (Vec n) where | |
| fmap _ VNil = VNil | |
| fmap f (x:>xs) = f x :> fmap f xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment