Skip to content

Instantly share code, notes, and snippets.

{
module Lexer98 ( scanTokens ) where
import Data.Text (Text)
import qualified Data.Text as Text
}
%wrapper "basic"
@dmjio
dmjio / SplitOn.hs
Last active December 4, 2020 07:06
import qualified Data.ByteString as B
import Data.ByteString (ByteString)
splitOn' :: ByteString -> ByteString -> [ByteString]
splitOn' del bs | B.null bs = []
splitOn' del bs =
case B.breakSubstring del bs of
(ls, rest) ->
if B.null rest
# run these two lines first
echo 'nix' | sudo tee -a /etc/synthetic.conf # or edit this file and just add nix
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B
[ 0 -ne "$?" ] && echo "Restarting APFS failed, please reboot your computer"
# reboot if it tells you to reboot
# then run this
sudo diskutil apfs addVolume disk1 APFSX Nix -mountpoint /nix # make sure disk1 is correct
sudo diskutil enableOwnership /nix
sudo chown -R $(whoami) /nix
sudo chflags hidden /nix # if you don't want to see Nix volume in finder
newtype DL a = DL { unDL :: [a] -> [a] }
instance Show a => Show (DL a) where
show = show . toList
instance Semigroup (DL a) where
perms [] = []
perms [x] = [pure x]
perms k@(z:zs) = do
(ls,rs) <-
splitAt
<$> [ 0 .. length zs ]
<*> perms zs
pure (ls ++ [z] ++ rs)
==================== Output Cmm ====================
2020-06-27 01:29:07.434663996 UTC
[Test.test_entry() { // [R2]
{ info_tbls: [(cA7,
label: Test.test_info
rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} }
srt: Just GHC.Num.$fNumInt_closure)]
stack_info: arg_space: 8
@dmjio
dmjio / Foo.hs
Created May 10, 2020 02:57 — forked from Lysxia/Foo.hs
{-# LANGUAGE
DeriveGeneric,
FlexibleInstances,
FlexibleContexts,
AllowAmbiguousTypes,
ScopedTypeVariables,
TypeApplications,
TypeFamilies,
TypeOperators,
PartialTypeSignatures,
This file has been truncated, but you can view the full file.
{
"id": "0x7fb639848808",
"kind": "TranslationUnitDecl",
"loc": {},
"range": {
"begin": {},
"end": {}
},
"inner": [
{

Raison D'être - miso

Miso was written for those who want the simplicity of an Elm interface without sacrificing typeclasses and allowing type-sharing between server and client.

Type sharing

A lot of web dev becomes boilerplate -- serializing and transferring state is a large part of the work of web dev. Type sharing ensures correct-by-construction serialization between server / client amidst any changes to your business logic data types, allows you to focus on your apps core offerings as opposed to minutia.

Rich ecosystem

The Haskell ecosystem has many great libraries that compile w/o any problems on the frontend.

@dmjio
dmjio / Main.hs
Last active January 7, 2023 17:21
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
module Main where