Skip to content

Instantly share code, notes, and snippets.

View Huxpro's full-sized avatar
🤔
Still making sense of JavaScript

Xuan Huang (黄玄) Huxpro

🤔
Still making sense of JavaScript
View GitHub Profile
@Huxpro
Huxpro / A-Pen-by-Huxism.markdown
Created March 12, 2014 03:09
A Pen by Huxism.
module Query = [%graphql
{|
query {
someFieldWithInterfaceType {
id
...on ImplA {
a_only
}
...on ImplB {
b_only
(* SIMPLE FUNCTIONS OVER INTEGERS *)
let multiple_of n d =
n mod d = 0;;
let integer_square_root n =
int_of_float (sqrt (float n));;
(* PRIME NUMBERS *)
let rec gcd n m =
match (n, m) with
module type Set = sig
type 'a t
val empty : 'a t
val isEmpty : 'a t -> bool
end
module ListSet : Set = struct
type 'a t = 'a list
let empty = []
let isEmpty l = l == []

Hi folks, I just wanna share my story on my first day trying Cabal/Stack.

So I was learning Haskell for half a semester but only live within ghci and runhaskell. But today I was thinking of playing with /write-you-a-haskell/chapter4/untyped so I pulled it down.

I was first trying to follow the README.md which asked me to do cabal run. It failed and gave me errors on the ambiguous usage of <>, I realized cabal is using my global GHC version and it might be some breaking changes there. (since it's Haskell)

I heard stack can solve this problem by having multiple GHC so I changed to looking into that. So I run stack build, see the new GHC being downloaded, but failed. The resolver of the project is 7.8.4 and the problem is ar permission errors on OS X 10.11 El Capitan with GHC 7.8.4 . I tried several workarounds posted in the issue page but none of them works.

Aft

{-# LANGUAGE
GADTs,
ExistentialQuantification
#-}
import Control.Monad
import Data.IORef
import Data.Sequence
import Data.Foldable
@Huxpro
Huxpro / TextInput.dart
Created April 8, 2020 00:16
A Flutter TextField that maintain selection state like TextInput in React Native
import 'package:flutter/material.dart';
/// A TextField that maintain selection state like React Native
class TextInput extends StatefulWidget {
TextInput({@required this.decoration, @required this.text, @required this.onChanged});
final String text;
final InputDecoration decoration;
final Function onChanged;
@Huxpro
Huxpro / An-Anonymous-Pen.markdown
Created March 12, 2014 03:08
A Pen by Captain Anonymous.
@Huxpro
Huxpro / EmulateESNextClass.js
Last active September 22, 2020 09:27
Emulate ES Next Class
// 试了两种方式模拟:
class Super {
constructor() {
this.x = "super"
}
};
// 这样的话也是 own property
new Super().hasOwnProperty('x') // true
/**
class Super {
x = "super"
}
*/
class Super {
constructor() {