Skip to content

Instantly share code, notes, and snippets.

@mankyKitty
mankyKitty / DMapssssss.hs
Last active June 5, 2018 03:51
Messing with Dependent Map for type safe narrow scope HTML attribute maps
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
--
{-# LANGUAGE DefaultSignatures #-}
@mankyKitty
mankyKitty / Errors.hs
Created May 24, 2018 03:42
Musings about errors
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ConstraintKinds #-}
module Errors where
import Control.Lens (makeClassyPrisms, ( # ))
@mankyKitty
mankyKitty / MultiStepPropTesting.hs
Last active May 1, 2018 23:19
Property based testing & multistep test cases.
module Main where
import Test.Tasty (TestTree, defaultMain, testGroup)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.HUnit (assertBool, assertFailure,
testCaseSteps)
import Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
elAttrStylez
:: MonadWidget t m
=> Text
-> m a
-> Map Text Text
-> m a
elAttrStylez e =
flip (RD.elAttr e)
clayDiv
(*
**
** A template for single-file ATS programs
**
*)
(* ****** ****** *)
//
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
@mankyKitty
mankyKitty / Rurder.hs
Last active January 22, 2018 04:19
Something something - to add type signatures or not to add type signatures...
newtype AppM a = AppM (Env -> IO a)
instance Functor AppM where
fmap = error "fmap for AppM not implemented"
instance Applicative AppM where
pure = error "pure for AppM not implemented"
(<*>) = error "ap for AppM not implemented"
instance Monad AppM where
instance (Monad m) => Monad (ReaderT r m) where
return = lift . return
(>>=) :: ReaderT r m a -> (a -> ReaderT r m b) -> ReaderT r m b
(ReaderT rma) >>= k = ReaderT $ \ r -> do
a <- rma r
let ReaderT rmb = k a -- rmb :: r -> m b
rmb r :: m b -- rmb r :: m b
ask :: Monad m => (ReaderT r m) r == (r -> m r)
@mankyKitty
mankyKitty / day1.dats
Last active December 22, 2017 00:58
Day1 AoC Attempt using ATS2 <3
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
// 1122 produces a sum of 3 (1 + 2) because the first digit (1) matches the second digit and the third digit (2) matches the fourth digit.
// 1111 produces 4 because each digit (all 1) matches the next.
// 1234 produces 0 because no digit matches the next.
// 91212129 produces 9 because the only digit that matches the next one is the last digit, 9.
fn fold_stylez { n: int } ( last: int, xs: list(int, n) ): int =
let
@mankyKitty
mankyKitty / sif_I_didnt_give_myself_enough_to_do.txt
Created May 31, 2017 23:43
[Documentation Ideas] - Haskell Runtime Guides/How-Tos/Nice-to-Knows
- Memory Usage & You
-- Don't just blame laziness
-- Space leaks and how to find them
-- Understanding memory usage graphs (*.hp output)
-- let / where (accidental sharing is a thing, I don't fully understand it yet)
-- Also, saying "Space leaks" doesn't constitute a talking point
- Debugging
-- How the F... (Starting out)
-- DWARF integration (ghci, gdb, lldb)
@mankyKitty
mankyKitty / Sand.hs
Created October 4, 2016 11:15
Need coffee....
module Sand
( Base (..)
, Time
)
where
data Base
= Sec
| Nano
| Pico